Skip to content

Commit a46aa81

Browse files
authored
Merge branch 'main' into lint-rspec
2 parents a774f24 + 27850e2 commit a46aa81

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
@@ -99,6 +99,30 @@ Style/SymbolArray:
9999
# Prefer [:a, :b] to %i[a b]
100100
EnforcedStyle: brackets
101101

102+
Style/TrailingCommaInArguments:
103+
# Prefer trailing commas in multiline arguments:
104+
# call(
105+
# a: 1,
106+
# b: 2,
107+
# )
108+
EnforcedStyleForMultiline: diff_comma
109+
110+
Style/TrailingCommaInArrayLiteral:
111+
# Prefer trailing commas in arrays:
112+
# [
113+
# 1,
114+
# 2,
115+
# ]
116+
EnforcedStyleForMultiline: diff_comma
117+
118+
Style/TrailingCommaInHashLiteral:
119+
# Prefer trailing commas in multiline hashes:
120+
# {
121+
# a: 1,
122+
# b: 2,
123+
# }
124+
EnforcedStyleForMultiline: diff_comma
125+
102126
Style/YodaCondition:
103127
# Sometimes in specs it makes more sense to write
104128
# 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
@@ -636,7 +636,7 @@ def dup_with(options = {})
636636
self.class.new(
637637
options[:fractional] || fractional,
638638
options[:currency] || currency,
639-
bank: options[:bank] || bank
639+
bank: options[:bank] || bank,
640640
)
641641
end
642642

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)
@@ -163,7 +163,7 @@ def to_s
163163
iso_code: "XXX",
164164
name: "Golden Doubloon",
165165
symbol: "%",
166-
subunit_to_unit: 100
166+
subunit_to_unit: 100,
167167
)
168168
new_currency = described_class.find("XXX")
169169
expect(new_currency).not_to be_nil
@@ -190,12 +190,12 @@ def to_s
190190
iso_code: "XXX",
191191
name: "Golden Doubloon",
192192
symbol: "%",
193-
subunit_to_unit: 100
193+
subunit_to_unit: 100,
194194
)
195195
described_class.inherit(
196196
"XXX",
197197
iso_code: "YYY",
198-
symbol: "@"
198+
symbol: "@",
199199
)
200200
new_currency = described_class.find("YYY")
201201
expect(new_currency).not_to be_nil
@@ -484,7 +484,7 @@ def to_s
484484
:subunit => cad.subunit,
485485
:subunit_to_unit => cad.subunit_to_unit,
486486
:thousands_separator => cad.thousands_separator,
487-
:decimal_mark => modified_mark
487+
:decimal_mark => modified_mark,
488488
)
489489
end
490490

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)