Skip to content

Commit a64cee7

Browse files
Convert source code to "new" hash format
1 parent a984037 commit a64cee7

File tree

12 files changed

+35
-35
lines changed

12 files changed

+35
-35
lines changed

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bundler::GemHelper.install_tasks
44
require 'rake/testtask'
55

66
desc 'Default: run unit tests.'
7-
task :default => :test
7+
task default: :test
88

99
desc 'Run tests.'
1010
Rake::TestTask.new(:test) do |t|

lib/i18n_alchemy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def localized(attributes = nil)
2020

2121
included do
2222
class_attribute :localized_methods,
23-
:instance_reader => false, :instance_writer => false
23+
instance_reader: false, instance_writer: false
2424
self.localized_methods = {}
2525
end
2626

lib/i18n_alchemy/date_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def extract_date(parsed_date)
2828
end
2929

3030
def i18n_format
31-
I18n.t(:default, :scope => [i18n_scope, :formats])
31+
I18n.t(:default, scope: [i18n_scope, :formats])
3232
end
3333

3434
def i18n_scope

lib/i18n_alchemy/numeric_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def separator
3434
end
3535

3636
def translate(key)
37-
I18n.t(key, :scope => :"number.format")
37+
I18n.t(key, scope: :"number.format")
3838
end
3939

4040
def valid_for_localization?(value)

test/action_view_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ class ActionViewTest < I18n::Alchemy::TestCase
55
def setup
66
@template = ActionView::Base.respond_to?(:empty) ? ActionView::Base.empty : ActionView::Base.new
77
@product = Product.new(
8-
:name => "Potato",
9-
:quantity => 10,
10-
:price => 1.99,
11-
:released_at => Date.new(2011, 2, 28),
12-
:last_sale_at => Time.mktime(2011, 2, 28, 13, 25, 30)
8+
name: "Potato",
9+
quantity: 10,
10+
price: 1.99,
11+
released_at: Date.new(2011, 2, 28),
12+
last_sale_at: Time.mktime(2011, 2, 28, 13, 25, 30)
1313
)
1414
@localized = @product.localized
1515

@@ -48,7 +48,7 @@ def assert_same_text_input(attribute, value)
4848
assert_includes [
4949
text_input_sorted_attributes(attribute, value),
5050
text_input_unsorted_attributes(attribute, value)
51-
], @template.text_field(:product, attribute, :object => @localized)
51+
], @template.text_field(:product, attribute, object: @localized)
5252
end
5353

5454
def text_input_sorted_attributes(attribute_name, value)

test/custom_parsers/my_custom_date_parser.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module MyCustomDateParser
33
extend self
44

55
def localize(value)
6-
I18n.localize value, :format => :custom
6+
I18n.localize value, format: :custom
77
end
88

99
protected
1010

1111
def i18n_format
12-
I18n.t(:custom, :scope => [:date, :formats])
12+
I18n.t(:custom, scope: [:date, :formats])
1313
end
1414
end

test/db/test_schema.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ActiveRecord::Base.establish_connection(
2-
:adapter => "sqlite3",
3-
:database => ":memory:"
2+
adapter: "sqlite3",
3+
database: ":memory:"
44
)
55

66
ActiveRecord::Schema.define do

test/i18n_alchemy/proxy/attributes_parsing_test.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class ProxyAttributesParsingTest < I18n::Alchemy::ProxyTestCase
44
# Attributes
55
def test_initializes_proxy_with_attributes
66
@localized = @product.localized(
7-
:name => "Banana", :price => "0,99", :released_at => "28/02/2011")
7+
name: "Banana", price: "0,99", released_at: "28/02/2011")
88

99
assert_equal 0.99, @product.price
1010
assert_equal "0,99", @localized.price
@@ -14,7 +14,7 @@ def test_initializes_proxy_with_attributes
1414
end
1515

1616
def test_assign_attributes
17-
@localized.assign_attributes(:price => '1,99')
17+
@localized.assign_attributes(price: '1,99')
1818
assert_equal "1,99", @localized.price
1919
end
2020

@@ -31,7 +31,7 @@ def test_assign_attributes_does_not_change_given_attributes_hash
3131
end
3232

3333
def test_attributes_assignment
34-
@localized.attributes = { :price => '1,99' }
34+
@localized.attributes = { price: '1,99' }
3535
assert_equal "1,99", @localized.price
3636
end
3737

@@ -42,7 +42,7 @@ def test_attributes_assignment_does_not_change_given_attributes_hash
4242
end
4343

4444
def test_update
45-
@localized.update(:price => '2,88')
45+
@localized.update(price: '2,88')
4646
assert_equal '2,88', @localized.price
4747
assert_equal 2.88, @product.reload.price
4848
end
@@ -54,13 +54,13 @@ def test_update_does_not_change_given_attributes_hash
5454
end
5555

5656
def test_update_attributes
57-
@localized.update_attributes(:price => '2,88')
57+
@localized.update_attributes(price: '2,88')
5858
assert_equal '2,88', @localized.price
5959
assert_equal 2.88, @product.reload.price
6060
end
6161

6262
def test_update!
63-
@localized.update!(:price => '2,88')
63+
@localized.update!(price: '2,88')
6464
assert_equal '2,88', @localized.price
6565
assert_equal 2.88, @product.reload.price
6666
end
@@ -72,7 +72,7 @@ def test_update_bang_does_not_change_given_attributes_hash
7272
end
7373

7474
def test_update_attributes!
75-
@localized.update_attributes!(:price => '2,88')
75+
@localized.update_attributes!(price: '2,88')
7676
assert_equal '2,88', @localized.price
7777
assert_equal 2.88, @product.reload.price
7878
end
@@ -85,40 +85,40 @@ def test_update_attribute
8585

8686
# Nested Attributes
8787
def test_should_assign_for_nested_attributes_for_collection_association
88-
@supplier_localized.assign_attributes(:products_attributes => [{:price => '1,99'}, {:price => '2,93'}])
88+
@supplier_localized.assign_attributes(products_attributes: [{ price: '1,99' }, { price: '2,93' }])
8989
assert_equal 2, @supplier_localized.products.size
9090
assert_equal '1,99', @supplier_localized.products.first.localized.price
9191
assert_equal '2,93', @supplier_localized.products.last.localized.price
9292
end
9393

9494
def test_should_assign_for_nested_attributes_passing_a_hash_for_collection_with_unique_keys
95-
@supplier_localized.assign_attributes(:products_attributes => {"0" => {:price => '2,93', "_destroy"=>"false"}, "1" => {:price => '2,85', "_destroy" => "false"}})
95+
@supplier_localized.assign_attributes(products_attributes: { '0' => { price: '2,93', _destroy: 'false' }, '1' => { price: '2,85', _destroy: 'false' }})
9696
prices = @supplier.products.map { |p| p.localized.price }.sort
9797
assert_equal ['2,85', '2,93'], prices
9898
end
9999

100100
def test_should_assign_for_nested_attributes_for_one_to_one_association
101-
@supplier_localized.assign_attributes(:account_attributes => {:account_number => 10, :total_money => '100,87'})
101+
@supplier_localized.assign_attributes(account_attributes: { account_number: 10, total_money: '100,87' })
102102
account = @supplier_localized.account
103103
assert_equal '10', account.account_number.to_s
104104
assert_equal '100,87', account.localized.total_money
105105
end
106106

107107
def test_update_for_nested_attributes
108-
@supplier_localized.update(:account_attributes => {:total_money => '99,87'})
108+
@supplier_localized.update(account_attributes: { total_money: '99,87' })
109109
assert_equal '99,87', @supplier_localized.account.localized.total_money
110110
end
111111

112112
def test_attributes_assignment_for_nested
113-
@supplier_localized.attributes = {:account_attributes => {:total_money => '88,12'}}
113+
@supplier_localized.attributes = { account_attributes: { total_money: '88,12' }}
114114
assert_equal '88,12', @supplier_localized.account.localized.total_money
115115
end
116116

117117
private
118118

119119
def assert_attributes_hash_is_unchanged
120-
attributes = { :quantity => 1 }
120+
attributes = { quantity: 1 }
121121
yield attributes
122-
assert_equal({ :quantity => 1 }, attributes)
122+
assert_equal({ quantity: 1 }, attributes)
123123
end
124124
end

test/i18n_alchemy/proxy_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class ProxyTest < I18n::Alchemy::ProxyTestCase
44
def test_delegates_orm_methods_to_target_object
55
assert @product.new_record?
6-
assert @localized.save!(:name => "foo", :price => 1.99)
6+
assert @localized.save!(name: "foo", price: 1.99)
77
assert !@product.new_record?
88
end
99

test/models/product.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class Product < ActiveRecord::Base
22
include I18n::Alchemy
3-
localize :total, :using => :number
4-
localize :estimated_delivery_at, :using => :date
5-
localize :estimated_last_comission_payment_at, :using => :timestamp
6-
localize :released_month, :using => MyCustomDateParser
3+
localize :total, using: :number
4+
localize :estimated_delivery_at, using: :date
5+
localize :estimated_last_comission_payment_at, using: :timestamp
6+
localize :released_month, using: MyCustomDateParser
77

88
belongs_to :supplier
99

0 commit comments

Comments
 (0)