formatting 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -5
- data/lib/formatting/currency.rb +0 -2
- data/lib/formatting/number.rb +0 -2
- data/lib/formatting/version.rb +1 -1
- data/lib/formatting.rb +0 -6
- data/spec/currency_spec.rb +0 -5
- data/spec/number_spec.rb +0 -5
- data/spec/spec_helper.rb +0 -4
- metadata +1 -3
- data/spec/formatting_spec.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35af947641623b8cf80b8323106412901717087e
|
4
|
+
data.tar.gz: 41ff76fcf71cac124cd77f1b58d0c70a21fdf0a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c49acfa52b48b08f6309e3e5eb2db8d55705c7c67b2aabc8ca9245084ecaadf3b55e5b641c3b983cc4b1fe7b665e3abb7fc16467c4bb9b336e468f04e48dd18
|
7
|
+
data.tar.gz: 9a223c7ed6d58d67f74eb0a5cfb0898b0f68980ff1f31f2e59888b0c454cadaea6052a72b1ccd4481922fd6e8cebb2182090b777fdbdf6dfe01a3921eb597d8d
|
data/README.md
CHANGED
@@ -67,11 +67,6 @@ Formatting.format_currency(company, item.price) # => "1,234.00 SEK"
|
|
67
67
|
Formatting.format_currency(company, 4567) # => "4,567.00 SEK"
|
68
68
|
|
69
69
|
Formatting.format_currency(company, 4567, currency: false) # => "4,567.00"
|
70
|
-
|
71
|
-
Formatting.defaults[:currency] = "SEK"
|
72
|
-
item = Item.new(price: 1234) # Does not respond to "currency"
|
73
|
-
Formatting.format_currency(item, :price) # => "1,234.00 SEK"
|
74
|
-
|
75
70
|
```
|
76
71
|
|
77
72
|
#### Options
|
data/lib/formatting/currency.rb
CHANGED
@@ -9,8 +9,6 @@ module Formatting
|
|
9
9
|
raise NotARecordError, "Expected an object that could tell us its currency; got #{record.inspect}"
|
10
10
|
end
|
11
11
|
|
12
|
-
opts = Formatting.defaults.merge(opts)
|
13
|
-
|
14
12
|
format_string = opts.fetch(:format, "<amount> <currency>")
|
15
13
|
skip_currency = opts.fetch(:skip_currency, false)
|
16
14
|
|
data/lib/formatting/number.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
module Formatting
|
2
2
|
module Number
|
3
3
|
def format_number(number, opts = {})
|
4
|
-
opts = Formatting.defaults.merge(opts)
|
5
|
-
|
6
4
|
thousands_separator = opts.fetch(:thousands_separator) { default_thousands_separator }
|
7
5
|
decimal_separator = opts.fetch(:decimal_separator) { default_decimal_separator }
|
8
6
|
round = opts.fetch(:round, 2)
|
data/lib/formatting/version.rb
CHANGED
data/lib/formatting.rb
CHANGED
data/spec/currency_spec.rb
CHANGED
@@ -39,11 +39,6 @@ describe Formatting do
|
|
39
39
|
it "passes on number formatting options" do
|
40
40
|
expect_formatted(item, 1.567, round: 2).to include "1.57"
|
41
41
|
end
|
42
|
-
|
43
|
-
it "applies default options" do
|
44
|
-
Formatting.defaults = { currency: "FOO" }
|
45
|
-
expect_formatted(item, 1).to eq space_to_nbsp("1.00 FOO")
|
46
|
-
end
|
47
42
|
end
|
48
43
|
|
49
44
|
context "currency option" do
|
data/spec/number_spec.rb
CHANGED
@@ -14,11 +14,6 @@ describe Formatting do
|
|
14
14
|
expect_formatted(1234567.89).to eq space_to_nbsp("1 234 567.89")
|
15
15
|
end
|
16
16
|
|
17
|
-
it "applies default options" do
|
18
|
-
Formatting.defaults = { round: 3 }
|
19
|
-
expect_formatted(12.3456789).to eq "12.346"
|
20
|
-
end
|
21
|
-
|
22
17
|
context "thousands separator" do
|
23
18
|
context "with I18n" do
|
24
19
|
let(:i18n) { stub_const("I18n", double) }
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Nyh
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- lib/formatting/number.rb
|
71
71
|
- lib/formatting/version.rb
|
72
72
|
- spec/currency_spec.rb
|
73
|
-
- spec/formatting_spec.rb
|
74
73
|
- spec/number_spec.rb
|
75
74
|
- spec/spec_helper.rb
|
76
75
|
homepage: ''
|
@@ -99,7 +98,6 @@ specification_version: 4
|
|
99
98
|
summary: Rails-less formatting for your unit-testable code.
|
100
99
|
test_files:
|
101
100
|
- spec/currency_spec.rb
|
102
|
-
- spec/formatting_spec.rb
|
103
101
|
- spec/number_spec.rb
|
104
102
|
- spec/spec_helper.rb
|
105
103
|
has_rdoc:
|
data/spec/formatting_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Formatting do
|
4
|
-
describe "defaults" do
|
5
|
-
it "starts out as an empty hash" do
|
6
|
-
expect(Formatting.defaults).to eq({})
|
7
|
-
end
|
8
|
-
|
9
|
-
it "can get and set them" do
|
10
|
-
Formatting.defaults = { hello: "world" }
|
11
|
-
expect(Formatting.defaults).to eq({ hello: "world" })
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|