bullet_train 1.3.20 → 1.3.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/address.rb +24 -0
- data/app/models/addresses/continent.rb +22 -0
- data/app/models/addresses/country.rb +22 -0
- data/app/models/addresses/region.rb +22 -0
- data/app/models/addresses/subcontinent.rb +22 -0
- data/app/models/concerns/addresses/base.rb +18 -0
- data/app/models/concerns/addresses/continents/base.rb +7 -0
- data/app/models/concerns/addresses/countries/base.rb +9 -0
- data/app/models/concerns/addresses/regions/base.rb +13 -0
- data/app/models/concerns/addresses/subcontinents/base.rb +7 -0
- data/app/models/concerns/records/base.rb +9 -0
- data/config/addresses/countries.json +10975 -0
- data/config/addresses/states.json +43841 -0
- data/config/locales/en/addresses.en.yml +51 -0
- data/lib/bullet_train/version.rb +1 -1
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 347c8bc91b3b401f88551f4e20464258313548a54bbcfc8568088cfb3eea401b
|
4
|
+
data.tar.gz: f12fd053f264a5cd60c9789195cd0ced4b171febfa96bfbdd2bf3b020fec6241
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e86a8f1861ee560b385397be2034e0933bbf020f24a1a909eec9a25e239291915aacebc74a8dddfc3172dd4d1e48f2526169101df369d321108e3e50dcc987bf
|
7
|
+
data.tar.gz: 21433ad6bccf6e919838e239141b3aa27840c8c04cfe9bcf6ce9b3fc804c1168599fea7f6e6dbe1bc0d11059c6ee596e3e5bd49731411880967499b06157592a
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Address < ApplicationRecord
|
2
|
+
extend ActiveHash::Associations::ActiveRecordExtensions
|
3
|
+
|
4
|
+
include Addresses::Base
|
5
|
+
# 🚅 add concerns above.
|
6
|
+
|
7
|
+
# 🚅 add belongs_to associations above.
|
8
|
+
|
9
|
+
# 🚅 add has_many associations above.
|
10
|
+
|
11
|
+
# 🚅 add oauth providers above.
|
12
|
+
|
13
|
+
# 🚅 add has_one associations above.
|
14
|
+
|
15
|
+
# 🚅 add scopes above.
|
16
|
+
|
17
|
+
# 🚅 add validations above.
|
18
|
+
|
19
|
+
# 🚅 add callbacks above.
|
20
|
+
|
21
|
+
# 🚅 add delegations above.
|
22
|
+
|
23
|
+
# 🚅 add methods above.
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Addresses::Continent < ApplicationHash
|
2
|
+
include Addresses::Continents::Base
|
3
|
+
# 🚅 add concerns above.
|
4
|
+
|
5
|
+
# 🚅 add belongs_to associations above.
|
6
|
+
|
7
|
+
# 🚅 add has_many associations above.
|
8
|
+
|
9
|
+
# 🚅 add oauth providers above.
|
10
|
+
|
11
|
+
# 🚅 add has_one associations above.
|
12
|
+
|
13
|
+
# 🚅 add scopes above.
|
14
|
+
|
15
|
+
# 🚅 add validations above.
|
16
|
+
|
17
|
+
# 🚅 add callbacks above.
|
18
|
+
|
19
|
+
# 🚅 add delegations above.
|
20
|
+
|
21
|
+
# 🚅 add methods above.
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Addresses::Country < ApplicationHash
|
2
|
+
include Addresses::Countries::Base
|
3
|
+
# 🚅 add concerns above.
|
4
|
+
|
5
|
+
# 🚅 add belongs_to associations above.
|
6
|
+
|
7
|
+
# 🚅 add has_many associations above.
|
8
|
+
|
9
|
+
# 🚅 add oauth providers above.
|
10
|
+
|
11
|
+
# 🚅 add has_one associations above.
|
12
|
+
|
13
|
+
# 🚅 add scopes above.
|
14
|
+
|
15
|
+
# 🚅 add validations above.
|
16
|
+
|
17
|
+
# 🚅 add callbacks above.
|
18
|
+
|
19
|
+
# 🚅 add delegations above.
|
20
|
+
|
21
|
+
# 🚅 add methods above.
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Addresses::Region < ApplicationHash
|
2
|
+
include Addresses::Regions::Base
|
3
|
+
# 🚅 add concerns above.
|
4
|
+
|
5
|
+
# 🚅 add belongs_to associations above.
|
6
|
+
|
7
|
+
# 🚅 add has_many associations above.
|
8
|
+
|
9
|
+
# 🚅 add oauth providers above.
|
10
|
+
|
11
|
+
# 🚅 add has_one associations above.
|
12
|
+
|
13
|
+
# 🚅 add scopes above.
|
14
|
+
|
15
|
+
# 🚅 add validations above.
|
16
|
+
|
17
|
+
# 🚅 add callbacks above.
|
18
|
+
|
19
|
+
# 🚅 add delegations above.
|
20
|
+
|
21
|
+
# 🚅 add methods above.
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Addresses::Subcontinent < ApplicationHash
|
2
|
+
include Addresses::Subcontinents::Base
|
3
|
+
# 🚅 add concerns above.
|
4
|
+
|
5
|
+
# 🚅 add belongs_to associations above.
|
6
|
+
|
7
|
+
# 🚅 add has_many associations above.
|
8
|
+
|
9
|
+
# 🚅 add oauth providers above.
|
10
|
+
|
11
|
+
# 🚅 add has_one associations above.
|
12
|
+
|
13
|
+
# 🚅 add scopes above.
|
14
|
+
|
15
|
+
# 🚅 add validations above.
|
16
|
+
|
17
|
+
# 🚅 add callbacks above.
|
18
|
+
|
19
|
+
# 🚅 add delegations above.
|
20
|
+
|
21
|
+
# 🚅 add methods above.
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Addresses::Base
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
belongs_to :addressable, polymorphic: true
|
6
|
+
belongs_to :country, class_name: "Addresses::Country"
|
7
|
+
belongs_to :region, class_name: "Addresses::Region"
|
8
|
+
|
9
|
+
def valid_address?
|
10
|
+
address_one? && city? && region_id? && country_id? && postal_code?
|
11
|
+
end
|
12
|
+
|
13
|
+
def all_blank?(attributes = {})
|
14
|
+
return super(attributes) unless attributes.empty?
|
15
|
+
!(address_one? || address_two? || city? || region_id? || country_id? || postal_code?)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
module Addresses::Continents::Base
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
self.data = JSON.parse(File.read(File.expand_path("../../../../../config/addresses/countries.json", File.dirname(__FILE__)))).map { |row| {id: row["region"], name: row["region"]} }.select { |row| row[:name].present? }.uniq
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Addresses::Countries::Base
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
self.data = JSON.parse(File.read(File.expand_path("../../../../../config/addresses/countries.json", File.dirname(__FILE__))))
|
6
|
+
|
7
|
+
has_many :regions, class_name: "Addresses::Region"
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Addresses::Regions::Base
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
self.data = JSON.parse(File.read(File.expand_path("../../../../../config/addresses/states.json", File.dirname(__FILE__))))
|
6
|
+
|
7
|
+
belongs_to :country, class_name: "Addresses::Country"
|
8
|
+
|
9
|
+
def modified_state_code
|
10
|
+
state_code.scan(/\D/).empty? ? name : state_code
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
module Addresses::Subcontinents::Base
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
self.data = JSON.parse(File.read(File.expand_path("../../../../../config/addresses/countries.json", File.dirname(__FILE__)))).map { |row| {id: row["subregion"], name: row["subregion"]} }.select { |row| row[:name].present? }.uniq
|
6
|
+
end
|
7
|
+
end
|
@@ -78,5 +78,14 @@ module Records::Base
|
|
78
78
|
Rake::Task.task_defined?("db:seed") && Rake::Task["db:seed"].already_invoked
|
79
79
|
end
|
80
80
|
|
81
|
+
def all_blank?(attributes = {})
|
82
|
+
attributes = self.attributes if attributes.empty?
|
83
|
+
attributes.all? do |key, value|
|
84
|
+
key == "_destroy" || value.blank? ||
|
85
|
+
value.is_a?(Hash) && all_blank?(value) ||
|
86
|
+
value.is_a?(Array) && value.all? { |val| all_blank?(val) }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
81
90
|
ActiveSupport.run_load_hooks :bullet_train_records_base, self
|
82
91
|
end
|