Skip to content

Commit f732e76

Browse files
authored
Merge branch 'main' into lint-Style/TrivialAccessors
2 parents acde7a9 + 27850e2 commit f732e76

File tree

14 files changed

+70
-78
lines changed

14 files changed

+70
-78
lines changed

.rubocop.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,30 @@ Style/SymbolArray:
9191
# Prefer [:a, :b] to %i[a b]
9292
EnforcedStyle: brackets
9393

94+
Style/TrailingCommaInArguments:
95+
# Prefer trailing commas in multiline arguments:
96+
# call(
97+
# a: 1,
98+
# b: 2,
99+
# )
100+
EnforcedStyleForMultiline: diff_comma
101+
102+
Style/TrailingCommaInArrayLiteral:
103+
# Prefer trailing commas in arrays:
104+
# [
105+
# 1,
106+
# 2,
107+
# ]
108+
EnforcedStyleForMultiline: diff_comma
109+
110+
Style/TrailingCommaInHashLiteral:
111+
# Prefer trailing commas in multiline hashes:
112+
# {
113+
# a: 1,
114+
# b: 2,
115+
# }
116+
EnforcedStyleForMultiline: diff_comma
117+
94118
Style/YodaCondition:
95119
# Sometimes in specs it makes more sense to write
96120
# 2 >= Money.new(2, 'USD')

.rubocop_todo.yml

Lines changed: 1 addition & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/money/bank/variable_exchange.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def exchange_with(from, to_currency, &block)
118118
from.dup_with(
119119
fractional: exchange(fractional, rate, &block),
120120
currency: to_currency,
121-
bank: self
121+
bank: self,
122122
)
123123
else
124124
raise UnknownRate, "No conversion rate known for '#{from.currency.iso_code}' -> '#{to_currency}'"

lib/money/currency.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,12 @@ def inherit(parent_iso_code, curr)
196196
# @return [Boolean] true if the currency previously existed, false
197197
# if it didn't.
198198
def unregister(curr)
199-
if curr.is_a?(Hash)
200-
key = curr.fetch(:iso_code).downcase.to_sym
201-
else
202-
key = curr.downcase.to_sym
203-
end
199+
key =
200+
if curr.is_a?(Hash)
201+
curr.fetch(:iso_code).downcase.to_sym
202+
else
203+
curr.downcase.to_sym
204+
end
204205
existed = @table.delete(key)
205206
@stringified_keys = nil if existed
206207
existed ? true : false

lib/money/money.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ def dup_with(options = {})
628628
self.class.new(
629629
options[:fractional] || fractional,
630630
options[:currency] || currency,
631-
bank: options[:bank] || bank
631+
bank: options[:bank] || bank,
632632
)
633633
end
634634

lib/money/money/allocation.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ class Allocation
2222
# @return [Array<Numeric>] An array containing the allocated amounts.
2323
# @raise [ArgumentError] If parts is empty or not provided.
2424
def self.generate(amount, parts, decimal_cutoff = true)
25-
parts = if parts.is_a?(Numeric)
26-
Array.new(parts, 1)
27-
elsif parts.all?(&:zero?)
28-
Array.new(parts.count, 1)
29-
else
30-
parts.dup
31-
end
25+
parts =
26+
if parts.is_a?(Numeric)
27+
Array.new(parts, 1)
28+
elsif parts.all?(&:zero?)
29+
Array.new(parts.count, 1)
30+
else
31+
parts.dup
32+
end
3233

3334
raise ArgumentError, 'need at least one part' if parts.empty?
3435

lib/money/money/formatter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Money
66
class Formatter
77
DEFAULTS = {
88
thousands_separator: '',
9-
decimal_mark: '.'
9+
decimal_mark: '.',
1010
}.freeze
1111

1212
# Creates a formatted price string according to several rules.
@@ -230,7 +230,7 @@ def format_number
230230
[
231231
html_wrap(whole_part, "whole"),
232232
html_wrap(decimal_mark, "decimal-mark"),
233-
html_wrap(decimal_part, "decimal")
233+
html_wrap(decimal_part, "decimal"),
234234
].join
235235
end
236236
else

lib/money/money/locale_backend.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Money
88
module LocaleBackend
99
BACKENDS = {
1010
i18n: Money::LocaleBackend::I18n,
11-
currency: Money::LocaleBackend::Currency
11+
currency: Money::LocaleBackend::Currency,
1212
}.freeze
1313

1414
def self.find(name)

spec/currency_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def to_s
8585
subunit: "Centimes",
8686
subunit_to_unit: 100,
8787
decimal_mark: ",",
88-
thousands_separator: " "
88+
thousands_separator: " ",
8989
)
9090

9191
expect(described_class.find_by_iso_numeric(250)).to eq described_class.new(:frf)
@@ -100,7 +100,7 @@ def to_s
100100
name: "French Francs",
101101
symbol: "FR",
102102
subunit: "Centimes",
103-
subunit_to_unit: 100
103+
subunit_to_unit: 100,
104104
)
105105

106106
expect(described_class.find_by_iso_numeric(250)).to eq described_class.new(:frf)
@@ -160,7 +160,7 @@ def to_s
160160
iso_code: "XXX",
161161
name: "Golden Doubloon",
162162
symbol: "%",
163-
subunit_to_unit: 100
163+
subunit_to_unit: 100,
164164
)
165165
new_currency = described_class.find("XXX")
166166
expect(new_currency).not_to be_nil
@@ -187,12 +187,12 @@ def to_s
187187
iso_code: "XXX",
188188
name: "Golden Doubloon",
189189
symbol: "%",
190-
subunit_to_unit: 100
190+
subunit_to_unit: 100,
191191
)
192192
described_class.inherit(
193193
"XXX",
194194
iso_code: "YYY",
195-
symbol: "@"
195+
symbol: "@",
196196
)
197197
new_currency = described_class.find("YYY")
198198
expect(new_currency).not_to be_nil
@@ -481,7 +481,7 @@ def to_s
481481
:subunit => cad.subunit,
482482
:subunit_to_unit => cad.subunit_to_unit,
483483
:thousands_separator => cad.thousands_separator,
484-
:decimal_mark => modified_mark
484+
:decimal_mark => modified_mark,
485485
)
486486
end
487487

spec/locale_backend/i18n_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
before do
2121
I18n.locale = :de
2222
I18n.backend.store_translations(:de, number: {
23-
currency: { format: { delimiter: '.', separator: ',', unit: '$', format: '%u%n' } }
23+
currency: { format: { delimiter: '.', separator: ',', unit: '$', format: '%u%n' } },
2424
})
2525
end
2626

0 commit comments

Comments
 (0)