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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b305ad58e72593f21215121377ae70f2d17bd29a2d61f3265230f44c9e0c3092
4
- data.tar.gz: 34566de6851e95ebc713110a6822498fa9da24c5fed7e158a7f53676ce11ce51
3
+ metadata.gz: 72743e6a2efe86f4e3954f6783380627afa89d944c0f23eb8f5e05ae271c24aa
4
+ data.tar.gz: eadb5928335ad7a9dfe362fcfa3bf7bc6b156ad0a0051c046c680c39188cd020
5
5
  SHA512:
6
- metadata.gz: 34c29129d47a847e79e81793724f57a06ad89955004f240f154c491cb5bb7a35c68d49d7af52e9c66c609fae7335c5b2d7733f515287d7f7f68145e86665c845
7
- data.tar.gz: 577f6f7d55229a2f5c3e6a9b0b4d5dd5badb488551da4ec6eadf8189ac6dd1ab4ab9ef56e176c2308fd9dd7eff29db9a8698157279a1cb4976e814bb7053e4f8
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 Rails and ActiveRecord
40
+ ### Usage with Class
41
41
 
42
- Address < ActiveRecord::Base
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 < ActiveRecord::Base
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 < ActiveRecord::Base
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.find(1).postal_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
 
@@ -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
@@ -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.gsub(/\n$/, "")
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
@@ -1,3 +1,3 @@
1
1
  module Biggs
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -75,14 +75,11 @@ end
75
75
  class FooBarMultiple < BaseClass
76
76
  biggs :postal_address_one
77
77
  biggs :postal_address_two,
78
- country: :alt_country
79
-
80
- def alt_country
81
- "Alt country"
82
- end
78
+ country: false,
79
+ recipient: false
83
80
  end
84
81
 
85
- describe "ActiveRecord Class" do
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 "ActiveRecord Instance" do
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("RECIPIENT\nSTREET\nCITY STATE ZIP\nalt country")
156
+ FooBarMultiple.new.postal_address_two.should eql("STREET\nCITY STATE ZIP")
160
157
  end
161
158
  end
162
159
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biggs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Munz