Skip to content

Commit bc6f81f

Browse files
committed
Lint: Fix Layout/LineLength
1 parent f88a249 commit bc6f81f

File tree

6 files changed

+134
-15
lines changed

6 files changed

+134
-15
lines changed

.rubocop_todo.yml

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

lib/money/currency.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,22 @@ def hash
354354
# @example
355355
# Money::Currency.new(:usd) #=> #<Currency id: usd ...>
356356
def inspect
357-
"#<#{self.class.name} id: #{id}, priority: #{priority}, symbol_first: #{symbol_first}, thousands_separator: #{thousands_separator}, html_entity: #{html_entity}, decimal_mark: #{decimal_mark}, name: #{name}, symbol: #{symbol}, subunit_to_unit: #{subunit_to_unit}, exponent: #{exponent}, iso_code: #{iso_code}, iso_numeric: #{iso_numeric}, subunit: #{subunit}, smallest_denomination: #{smallest_denomination}, format: #{format}>"
357+
"#<#{self.class.name} " \
358+
"id: #{id}, " \
359+
"priority: #{priority}, " \
360+
"symbol_first: #{symbol_first}, " \
361+
"thousands_separator: #{thousands_separator}, " \
362+
"html_entity: #{html_entity}, " \
363+
"decimal_mark: #{decimal_mark}, " \
364+
"name: #{name}, " \
365+
"symbol: #{symbol}, " \
366+
"subunit_to_unit: #{subunit_to_unit}, " \
367+
"exponent: #{exponent}, " \
368+
"iso_code: #{iso_code}, " \
369+
"iso_numeric: #{iso_numeric}, " \
370+
"subunit: #{subunit}, " \
371+
"smallest_denomination: #{smallest_denomination}, " \
372+
"format: #{format}>"
358373
end
359374

360375
# Returns a string representation corresponding to the upcase +id+

lib/money/money/formatter.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ class Formatter
117117
#
118118
# @example
119119
# Money.ca_dollar(570).format(html_wrap: true, with_currency: true)
120-
# #=> "<span class=\"money-currency-symbol\">$</span><span class=\"money-whole\">5</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">70</span> <span class=\"money-currency\">CAD</span>"
120+
# #=> "<span class=\"money-currency-symbol\">$</span>" \
121+
# "<span class=\"money-whole\">5</span>" \
122+
# "<span class=\"money-decimal-mark\">.</span>" \
123+
# "<span class=\"money-decimal\">70</span> " \
124+
# "<span class=\"money-currency\">CAD</span>"
121125
#
122126
# @option rules [Boolean] :sign_before_symbol (false) Whether the sign should be
123127
# before the currency symbol.

spec/currency_spec.rb

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,41 @@ def to_s
392392

393393
describe "#inspect" do
394394
it "works as documented" do
395-
expect(described_class.new(:usd).inspect).to eq "#<Money::Currency id: usd, priority: 1, symbol_first: true, thousands_separator: ,, html_entity: $, decimal_mark: ., name: United States Dollar, symbol: $, subunit_to_unit: 100, exponent: 2, iso_code: USD, iso_numeric: 840, subunit: Cent, smallest_denomination: 1, format: >"
396-
expect(described_class.new(:aed).inspect).to eq "#<Money::Currency id: aed, priority: 100, symbol_first: false, thousands_separator: ,, html_entity: , decimal_mark: ., name: United Arab Emirates Dirham, symbol: د.إ, subunit_to_unit: 100, exponent: 2, iso_code: AED, iso_numeric: 784, subunit: Fils, smallest_denomination: 25, format: %n %u>"
395+
expect(described_class.new(:usd).inspect).to eq(
396+
"#<Money::Currency " \
397+
"id: usd, priority: 1, " \
398+
"symbol_first: true, " \
399+
"thousands_separator: ,, " \
400+
"html_entity: $, " \
401+
"decimal_mark: ., " \
402+
"name: United States Dollar, " \
403+
"symbol: $, " \
404+
"subunit_to_unit: 100, " \
405+
"exponent: 2, " \
406+
"iso_code: USD, " \
407+
"iso_numeric: 840, " \
408+
"subunit: Cent, " \
409+
"smallest_denomination: 1, " \
410+
"format: >",
411+
)
412+
expect(described_class.new(:aed).inspect).to eq(
413+
"#<Money::Currency " \
414+
"id: aed, " \
415+
"priority: 100, " \
416+
"symbol_first: false, " \
417+
"thousands_separator: ,, " \
418+
"html_entity: , " \
419+
"decimal_mark: ., " \
420+
"name: United Arab Emirates Dirham, " \
421+
"symbol: د.إ, " \
422+
"subunit_to_unit: 100, " \
423+
"exponent: 2, " \
424+
"iso_code: AED, " \
425+
"iso_numeric: 784, " \
426+
"subunit: Fils, " \
427+
"smallest_denomination: 25, " \
428+
"format: %n %u>",
429+
)
397430
end
398431
end
399432

spec/money/allocation_spec.rb

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,76 @@
140140
context "with an allocation seen in the wild" do
141141
it "allocates the full amount" do
142142
amount = 700273
143-
allocations = [1.1818583143661, 1.1818583143661, 1.1818583143661, 1.1818583143661, 1.1818583143661, 1.1818583143661, 1.1818583143661, 1.170126087450276, 1.0, 1.0, 1.0, 1.0]
143+
allocations = [
144+
1.1818583143661,
145+
1.1818583143661,
146+
1.1818583143661,
147+
1.1818583143661,
148+
1.1818583143661,
149+
1.1818583143661,
150+
1.1818583143661,
151+
1.170126087450276,
152+
1.0,
153+
1.0,
154+
1.0,
155+
1.0,
156+
]
144157

145158
result = described_class.generate(amount, allocations)
146159
expect(result.reduce(&:+)).to eq(amount)
147-
expect(result).to eq([61566, 61565, 61565, 61565, 61565, 61565, 61565, 60953, 52091, 52091, 52091, 52091])
160+
expect(result).to eq(
161+
[
162+
61566,
163+
61565,
164+
61565,
165+
61565,
166+
61565,
167+
61565,
168+
61565,
169+
60953,
170+
52091,
171+
52091,
172+
52091,
173+
52091,
174+
],
175+
)
148176
end
149177

150178
it "allocates the full -amount" do
151179
amount = -700273
152-
allocations = [1.1818583143661, 1.1818583143661, 1.1818583143661, 1.1818583143661, 1.1818583143661, 1.1818583143661, 1.1818583143661, 1.170126087450276, 1.0, 1.0, 1.0, 1.0]
180+
allocations = [
181+
1.1818583143661,
182+
1.1818583143661,
183+
1.1818583143661,
184+
1.1818583143661,
185+
1.1818583143661,
186+
1.1818583143661,
187+
1.1818583143661,
188+
1.170126087450276,
189+
1.0,
190+
1.0,
191+
1.0,
192+
1.0,
193+
]
153194

154195
result = described_class.generate(amount, allocations)
155196
expect(result.reduce(&:+)).to eq(amount)
156-
expect(result).to eq([-61566, -61565, -61565, -61565, -61565, -61565, -61565, -60953, -52091, -52091, -52091, -52091])
197+
expect(result).to eq(
198+
[
199+
-61566,
200+
-61565,
201+
-61565,
202+
-61565,
203+
-61565,
204+
-61565,
205+
-61565,
206+
-60953,
207+
-52091,
208+
-52091,
209+
-52091,
210+
-52091,
211+
],
212+
)
157213
end
158214

159215
context "when specified precision" do

spec/money/formatting_spec.rb

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,19 @@
417417
end
418418

419419
specify "(south_asian_number_formatting: true) works as documented" do
420-
expect(Money.new(10000000, "INR").format(south_asian_number_formatting: true, symbol: false)).to eq "1,00,000.00"
421-
expect(Money.new(1000000000, "INDIAN_BAR").format(south_asian_number_formatting: true, symbol: false)).to eq "1,00,000.0000"
422-
expect(Money.new(10000000).format(south_asian_number_formatting: true)).to eq "$1,00,000.00"
420+
expect(Money.new(10000000, "INR").format(south_asian_number_formatting: true, symbol: false))
421+
.to eq "1,00,000.00"
422+
expect(Money.new(1000000000, "INDIAN_BAR").format(south_asian_number_formatting: true, symbol: false))
423+
.to eq "1,00,000.0000"
424+
expect(Money.new(10000000).format(south_asian_number_formatting: true))
425+
.to eq "$1,00,000.00"
423426
end
424427

425428
specify "(south_asian_number_formatting: true and no_cents_if_whole => true) works as documented" do
426-
expect(Money.new(10000000, "INR").format(south_asian_number_formatting: true, symbol: false, no_cents_if_whole: true)).to eq "1,00,000"
427-
expect(Money.new(1000000000, "INDIAN_BAR").format(south_asian_number_formatting: true, symbol: false, no_cents_if_whole: true)).to eq "1,00,000"
429+
expect(Money.new(10000000, "INR").format(south_asian_number_formatting: true, symbol: false, no_cents_if_whole: true))
430+
.to eq "1,00,000"
431+
expect(Money.new(1000000000, "INDIAN_BAR").format(south_asian_number_formatting: true, symbol: false, no_cents_if_whole: true))
432+
.to eq "1,00,000"
428433
end
429434
end
430435

@@ -488,7 +493,13 @@
488493

489494
specify "(html_wrap: true, with_currency: true)" do
490495
string = Money.ca_dollar(570).format(html_wrap: true, with_currency: true)
491-
expect(string).to eq "<span class=\"money-currency-symbol\">$</span><span class=\"money-whole\">5</span><span class=\"money-decimal-mark\">.</span><span class=\"money-decimal\">70</span> <span class=\"money-currency\">CAD</span>"
496+
expect(string).to eq(
497+
"<span class=\"money-currency-symbol\">$</span>" \
498+
"<span class=\"money-whole\">5</span>" \
499+
"<span class=\"money-decimal-mark\">.</span>" \
500+
"<span class=\"money-decimal\">70</span> " \
501+
"<span class=\"money-currency\">CAD</span>",
502+
)
492503
end
493504

494505
specify "should fallback to symbol if entity is not available" do

0 commit comments

Comments
 (0)