biggs 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/README.md +5 -5
- data/lib/biggs/extractor.rb +3 -1
- data/lib/biggs/formatter.rb +1 -1
- data/lib/biggs/version.rb +1 -1
- data/spec/unit/concern_spec.rb +5 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72743e6a2efe86f4e3954f6783380627afa89d944c0f23eb8f5e05ae271c24aa
|
4
|
+
data.tar.gz: eadb5928335ad7a9dfe362fcfa3bf7bc6b156ad0a0051c046c680c39188cd020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5deb05a75009544a7439169f7fb12bacff1ec3643b51b9715f44eb0866961dee09138ceb87702c8d1977b4643f41531be85646fd0bd91b551030b5855ff0c8a2
|
7
|
+
data.tar.gz: 17bc4a86075d4c56b3128d0a1d209f06446ca9437095cdb921393179d6335a3559b30524ee4d11e9ba8da747900859e95370748cc8c627d88d1e81ddc1f2ced3
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
### dev
|
2
2
|
|
3
|
+
### 0.6.0 / 2022-04-08
|
4
|
+
|
5
|
+
* Remove not only trailing but also leading newline from formatted address
|
6
|
+
* Biggs::Concern Allow passing false as field to add blank string
|
7
|
+
|
3
8
|
### 0.5.1 / 2022-04-08
|
4
9
|
|
5
10
|
* Biggs::Extractor: small refactorings + don't delete options
|
data/README.md
CHANGED
@@ -37,9 +37,9 @@ With the data from the above example this would return:
|
|
37
37
|
Musterallee 12
|
38
38
|
12345 Ausgedacht"
|
39
39
|
|
40
|
-
### Usage with
|
40
|
+
### Usage with Class
|
41
41
|
|
42
|
-
Address
|
42
|
+
class Address
|
43
43
|
include Biggs
|
44
44
|
|
45
45
|
biggs :postal_address
|
@@ -49,7 +49,7 @@ This adds the method postal_address to your Address-model, and assumes the prese
|
|
49
49
|
|
50
50
|
You can customize the method-names biggs will use by passing in a hash of options:
|
51
51
|
|
52
|
-
Address
|
52
|
+
class Address
|
53
53
|
include Biggs
|
54
54
|
|
55
55
|
biggs :postal_address,
|
@@ -62,7 +62,7 @@ You can pass in a symbol to let biggs call a different method on your Address-mo
|
|
62
62
|
|
63
63
|
You can even pass in a array of symbols:
|
64
64
|
|
65
|
-
Address
|
65
|
+
class Address
|
66
66
|
include Biggs
|
67
67
|
|
68
68
|
biggs :postal_address,
|
@@ -73,7 +73,7 @@ This will call the methods company_name and person_name on your address-instance
|
|
73
73
|
|
74
74
|
To access the formatted address string, simply call the provided method on an address instance:
|
75
75
|
|
76
|
-
Address.
|
76
|
+
Address.new.postal_address
|
77
77
|
|
78
78
|
If you pass in a ISO alpha 2 code as :country that is not supported by biggs, it will choose the US-format for addresses with an state specified, and the french/german format for addresses without an state.
|
79
79
|
|
data/lib/biggs/extractor.rb
CHANGED
@@ -2,7 +2,7 @@ module Biggs
|
|
2
2
|
class Extractor
|
3
3
|
def initialize(options)
|
4
4
|
@value_methods = Biggs::Formatter::FIELDS.reduce({}) do |methods, field|
|
5
|
-
methods[field] = options[field] if options[field]
|
5
|
+
methods[field] = options[field] if options[field] || options[field] == false
|
6
6
|
methods
|
7
7
|
end
|
8
8
|
end
|
@@ -15,6 +15,8 @@ module Biggs
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def get_value(instance, field)
|
18
|
+
return if @value_methods[field] == false
|
19
|
+
|
18
20
|
key = @value_methods[field] || field
|
19
21
|
|
20
22
|
case key
|
data/lib/biggs/formatter.rb
CHANGED
@@ -19,7 +19,7 @@ module Biggs
|
|
19
19
|
format_string.gsub!(/\{\{#{key}\}\}/, (values[key] || "").to_s)
|
20
20
|
end
|
21
21
|
format_string.gsub!(/\{\{country\}\}/, country_name)
|
22
|
-
format_string.
|
22
|
+
format_string.strip
|
23
23
|
end
|
24
24
|
|
25
25
|
attr_accessor :blank_country_on, :default_country_without_state, :default_country_with_state
|
data/lib/biggs/version.rb
CHANGED
data/spec/unit/concern_spec.rb
CHANGED
@@ -75,14 +75,11 @@ end
|
|
75
75
|
class FooBarMultiple < BaseClass
|
76
76
|
biggs :postal_address_one
|
77
77
|
biggs :postal_address_two,
|
78
|
-
country:
|
79
|
-
|
80
|
-
def alt_country
|
81
|
-
"Alt country"
|
82
|
-
end
|
78
|
+
country: false,
|
79
|
+
recipient: false
|
83
80
|
end
|
84
81
|
|
85
|
-
describe "
|
82
|
+
describe "Extended Class" do
|
86
83
|
|
87
84
|
it "should include Biggs::Concern" do
|
88
85
|
FooBar.included_modules.should be_include(Biggs::Concern)
|
@@ -97,7 +94,7 @@ describe "ActiveRecord Class" do
|
|
97
94
|
end
|
98
95
|
end
|
99
96
|
|
100
|
-
describe "
|
97
|
+
describe "Extended Class Instance" do
|
101
98
|
|
102
99
|
describe "Empty" do
|
103
100
|
it "should not have postal_address method" do
|
@@ -156,7 +153,7 @@ describe "ActiveRecord Instance" do
|
|
156
153
|
end
|
157
154
|
|
158
155
|
it "should return postal_address with alt country on postal_address_two" do
|
159
|
-
FooBarMultiple.new.postal_address_two.should eql("
|
156
|
+
FooBarMultiple.new.postal_address_two.should eql("STREET\nCITY STATE ZIP")
|
160
157
|
end
|
161
158
|
end
|
162
159
|
|