effective_addresses 1.9.10 → 1.10.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e257e305f2f6447f8a91e137a65dd35255c5b65d3825c1ff802989bd57032cdd
|
4
|
+
data.tar.gz: e0db38e0fe6c6d71e45df54fb12d84aeb89ecc1bcbee1617f2d85abb0b17c626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fa4f895765b5982ae7b87498ba7f0ee02b89fcabb0f88c82856569bd6dcff1acbf2e6a52054ade228bb7cdaf822381a4890d882dddd8ecda949172ccaf0ddaf
|
7
|
+
data.tar.gz: b851883afa543835fb6055155729acd5f6d3a7720580df4fb7ccd8fadbe10cca3bc3c4dc3d4af4370528d259fa7f17711c57cc39a1a262ce83e84b8bf7f8fb87
|
@@ -7,6 +7,7 @@ module EffectiveAddressesHelper
|
|
7
7
|
required = (form.object._validators[method.to_sym].any? { |v| v.kind_of?(ActiveRecord::Validations::PresenceValidator) && (v.options[:if].blank? || (v.options[:if].respond_to?(:call) ? f.object.instance_exec(&v.options[:if]) : v.options[:if])) } rescue true)
|
8
8
|
|
9
9
|
address = form.object.send(method) || form.object.addresses.build(category: method.to_s.gsub('_address', ''))
|
10
|
+
|
10
11
|
effective_address_pre_select(address) if address.new_record?
|
11
12
|
|
12
13
|
opts = { required: required, field_order: [:full_name, :address1, :address2, :city, :country_code, :state_code, :postal_code] }.merge(options).merge({:f => form, :address => address, :method => method})
|
@@ -24,16 +25,23 @@ module EffectiveAddressesHelper
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def effective_address_pre_select(address)
|
27
|
-
if EffectiveAddresses.pre_selected_country.present?
|
28
|
-
address.country
|
29
|
-
|
30
|
-
|
28
|
+
if address.country.blank? && EffectiveAddresses.pre_selected_country.present?
|
29
|
+
address.country = EffectiveAddresses.pre_selected_country
|
30
|
+
end
|
31
|
+
|
32
|
+
if address.state.blank? && EffectiveAddresses.pre_selected_state.present?
|
33
|
+
address.state = EffectiveAddresses.pre_selected_state
|
34
|
+
end
|
35
|
+
|
36
|
+
if defined?(Geocoder) && request.try(:location).present?
|
31
37
|
location = request.location
|
32
38
|
address.country = location.country_code
|
33
39
|
address.state = location.state_code
|
34
40
|
address.postal_code = location.postal_code
|
35
41
|
address.city = location.city
|
36
42
|
end
|
43
|
+
|
44
|
+
address
|
37
45
|
end
|
38
46
|
|
39
47
|
def effective_address_regions_collection(regions = nil, resource: nil)
|
@@ -6,7 +6,7 @@ module Effective
|
|
6
6
|
attr_accessor :shipping_address_same_as_billing
|
7
7
|
|
8
8
|
POSTAL_CODE_CA = /\A[A-Z]{1}\d{1}[A-Z]{1}\ \d{1}[A-Z]{1}\d{1}\z/ # Matches 'T5Z 2B1'
|
9
|
-
POSTAL_CODE_US = /\A\d{5}
|
9
|
+
POSTAL_CODE_US = /\A\d{5}(-\d{4})?\z/ # matches 5 digits plus optional hyphen and 4 digits
|
10
10
|
|
11
11
|
belongs_to :addressable, polymorphic: true, touch: true
|
12
12
|
|
@@ -93,6 +93,7 @@ module Effective
|
|
93
93
|
code = code.insert(3, ' ') if code.length == 6
|
94
94
|
elsif country_code == 'US'
|
95
95
|
code = code.gsub(/[^0-9]/, '')
|
96
|
+
code = code.insert(5, '-') if code.length == 9
|
96
97
|
end
|
97
98
|
end
|
98
99
|
|
@@ -7,7 +7,7 @@ module EffectiveAddresses
|
|
7
7
|
|
8
8
|
# Include acts_as_addressable concern and allow any ActiveRecord object to call it
|
9
9
|
initializer 'effective_addresses.active_record' do |app|
|
10
|
-
|
10
|
+
app.config.to_prepare do
|
11
11
|
ActiveRecord::Base.extend(ActsAsAddressable::Base)
|
12
12
|
end
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_addresses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|