Skip to content

Commit 7fa8ce7

Browse files
authored
Merge branch 'main' into lint-fix-RSpec/InstanceVariable
2 parents 915d55e + 5ba273d commit 7fa8ce7

File tree

10 files changed

+27
-54
lines changed

10 files changed

+27
-54
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/money/currency.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,9 @@ def stringify_keys
278278
:disambiguate_symbol, :html_entity, :subunit, :subunit_to_unit, :decimal_mark,
279279
:thousands_separator, :symbol_first, :smallest_denomination, :format
280280

281-
alias_method :separator, :decimal_mark
282-
alias_method :delimiter, :thousands_separator
283-
alias_method :eql?, :==
281+
alias separator decimal_mark
282+
alias delimiter thousands_separator
283+
alias eql? ==
284284

285285
# Create a new +Currency+ object.
286286
#

lib/money/money.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class << self
168168
# @attr_writer rounding_mode Use this to specify the rounding mode
169169
attr_writer :rounding_mode
170170

171-
alias_method :from_cents, :new
171+
alias from_cents new
172172
end
173173

174174
# @!attribute default_currency
@@ -578,7 +578,8 @@ def allocate(parts)
578578
amounts = Money::Allocation.generate(fractional, parts, !Money.default_infinite_precision)
579579
amounts.map { |amount| dup_with(fractional: amount) }
580580
end
581-
alias_method :split, :allocate
581+
582+
alias split allocate
582583

583584
# Round the monetary amount to smallest unit of coinage.
584585
#

lib/money/money/constructors.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module Constructors
1313
def empty(currency = default_currency)
1414
new(0, currency)
1515
end
16-
alias_method :zero, :empty
16+
17+
alias zero empty
1718

1819
# Creates a new Money object of the given value, using the Canadian
1920
# dollar currency.
@@ -29,7 +30,8 @@ def empty(currency = default_currency)
2930
def ca_dollar(cents)
3031
new(cents, "CAD")
3132
end
32-
alias_method :cad, :ca_dollar
33+
34+
alias cad ca_dollar
3335

3436
# Creates a new Money object of the given value, using the American dollar
3537
# currency.
@@ -45,7 +47,8 @@ def ca_dollar(cents)
4547
def us_dollar(cents)
4648
new(cents, "USD")
4749
end
48-
alias_method :usd, :us_dollar
50+
51+
alias usd us_dollar
4952

5053
# Creates a new Money object of the given value, using the Euro currency.
5154
#
@@ -60,7 +63,8 @@ def us_dollar(cents)
6063
def euro(cents)
6164
new(cents, "EUR")
6265
end
63-
alias_method :eur, :euro
66+
67+
alias eur euro
6468

6569
# Creates a new Money object of the given value, in British pounds.
6670
#
@@ -75,6 +79,7 @@ def euro(cents)
7579
def pound_sterling(pence)
7680
new(pence, "GBP")
7781
end
78-
alias_method :gbp, :pound_sterling
82+
83+
alias gbp pound_sterling
7984
end
8085
end

lib/money/money/formatter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ def decimal_mark
209209
lookup :decimal_mark
210210
end
211211

212-
alias_method :delimiter, :thousands_separator
213-
alias_method :separator, :decimal_mark
212+
alias delimiter thousands_separator
213+
alias separator decimal_mark
214214

215215
private
216216

spec/bank/base_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
describe "#initialize" do
1414
it "accepts a block and stores @rounding_method" do
15-
proc = Proc.new { |n| n.ceil }
15+
proc = proc(&:ceil)
1616
bank = described_class.new(&proc)
1717
expect(bank.rounding_method).to eq proc
1818
end

spec/bank/variable_exchange_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
# end
6868

6969
it "accepts a custom truncation method" do
70-
proc = Proc.new { |n| n.ceil }
70+
proc = proc(&:ceil)
7171
expect(bank.exchange_with(Money.new(10, 'USD'), 'EUR', &proc)).to eq Money.new(14, 'EUR')
7272
end
7373

@@ -89,7 +89,7 @@
8989

9090
context "with &block" do
9191
let(:bank) do
92-
proc = Proc.new { |n| n.ceil }
92+
proc = proc(&:ceil)
9393
described_class.new(&proc).tap do |bank|
9494
bank.add_rate('USD', 'EUR', 1.33)
9595
end
@@ -101,7 +101,7 @@
101101
end
102102

103103
it "accepts a custom truncation method" do
104-
proc = Proc.new { |n| n.ceil + 1 }
104+
proc = proc { |n| n.ceil + 1 }
105105
expect(bank.exchange_with(Money.new(10, 'USD'), 'EUR', &proc)).to eq Money.new(15, 'EUR')
106106
end
107107
end

spec/currency_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def to_s
447447

448448
it "doesn't create new symbols indefinitely" do
449449
expect { described_class.new("bogus") }.to raise_error(described_class::UnknownCurrency)
450-
expect(Symbol.all_symbols.map { |s| s.to_s }).not_to include("bogus")
450+
expect(Symbol.all_symbols.map(&:to_s)).not_to include("bogus")
451451
end
452452
end
453453

spec/money/formatting_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
end
151151

152152
it "respects the thousands_separator and decimal_mark defaults" do
153-
one_thousand = Proc.new do |currency|
153+
one_thousand = proc do |currency|
154154
Money.new(1000_00, currency).format
155155
end
156156

@@ -293,7 +293,7 @@
293293
end
294294

295295
specify "(symbol: true) returns symbol based on the given currency code" do
296-
one = Proc.new do |currency|
296+
one = proc do |currency|
297297
Money.new(100, currency).format(symbol: true)
298298
end
299299

spec/money_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@
11031103
end
11041104

11051105
it "accepts a lambda" do
1106-
Money.default_currency = lambda { :eur }
1106+
Money.default_currency = -> { :eur }
11071107
expect(Money.default_currency).to eq Money::Currency.new(:eur)
11081108
end
11091109

@@ -1130,7 +1130,7 @@
11301130
end
11311131

11321132
it 'accepts a lambda' do
1133-
Money.default_bank = lambda { Money::Bank::SingleCurrency.instance }
1133+
Money.default_bank = -> { Money::Bank::SingleCurrency.instance }
11341134
expect(Money.default_bank).to be_instance_of(Money::Bank::SingleCurrency)
11351135
end
11361136
end

0 commit comments

Comments
 (0)