address_concern 2.0.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -30,12 +30,8 @@ CreateAddresses.up
30
30
 
31
31
  require 'rspec'
32
32
 
33
- require 'active_record_ignored_attributes/matchers'
34
-
35
-
36
33
  RSpec.configure do |config|
37
- config.include AttributeNormalizer::RSpecMatcher #, :type => :models
38
- config.expect_with(:rspec) { |c| c.syntax = :should }
34
+ #config.include AttributeNormalizer::RSpecMatcher #, :type => :models
39
35
  config.example_status_persistence_file_path = "tmp/rspec_status.txt"
40
36
  end
41
37
 
@@ -1,3 +1,4 @@
1
1
  class Address < ApplicationRecord
2
- include AddressConcern::Address
2
+ #normalize_attributes :name
3
+ acts_as_address
3
4
  end
@@ -0,0 +1,11 @@
1
+ class AddressCustomAttrNames < ApplicationRecord
2
+ self.table_name = 'addresses'
3
+
4
+ acts_as_address(
5
+ country: {
6
+ name_attribute: 'country',
7
+ code_attribute: 'country_code',
8
+ carmen_code: 'code', # same as 'alpha_2_code'
9
+ }
10
+ )
11
+ end
@@ -0,0 +1,12 @@
1
+ class AddressWithCodeOnly < ApplicationRecord
2
+ self.table_name = 'address_with_code_or_name_only'
3
+
4
+ acts_as_address(
5
+ state: {
6
+ code_attribute: 'state',
7
+ },
8
+ country: {
9
+ code_attribute: 'country'
10
+ },
11
+ )
12
+ end
@@ -0,0 +1,5 @@
1
+ class AddressWithNameOnly < ApplicationRecord
2
+ self.table_name = 'address_with_code_or_name_only'
3
+
4
+ acts_as_address
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddressWithSeparateAddressColumns < ApplicationRecord
2
+ self.table_name = 'address_with_separate_address_columns'
3
+
4
+ acts_as_address
5
+ end
@@ -1,3 +1,8 @@
1
1
  class User < ApplicationRecord
2
- has_addresses :types => [:physical, :shipping, :billing]
2
+ # Could also do:
3
+ # has_addresses [:physical, :shipping, :billing]
4
+ has_addresses
5
+ has_address :physical
6
+ has_address :shipping
7
+ has_address :billing
3
8
  end
@@ -1,4 +1,26 @@
1
1
  ActiveRecord::Schema.define do
2
+ # In order to avoid duplication, and to ensure that the template migration is valid, the schema for :addresses table can be found in lib/generators/address_concern/templates/migration.rb
3
+
4
+ create_table :address_with_code_or_name_only do |t|
5
+ t.text :address
6
+ t.string :city
7
+ t.string :state
8
+ t.string :postal_code
9
+ t.string :country
10
+ t.timestamps
11
+ end
12
+
13
+ create_table :address_with_separate_address_columns do |t|
14
+ t.string :address_1
15
+ t.string :address_2
16
+ t.string :address_3
17
+ t.string :city
18
+ t.string :state
19
+ t.string :postal_code
20
+ t.string :country
21
+ t.timestamps
22
+ end
23
+
2
24
  create_table :users, :force => true do |t|
3
25
  t.string :name
4
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: address_concern
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Campbell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-03-23 00:00:00.000000000 Z
12
+ date: 2022-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -25,20 +25,6 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
- - !ruby/object:Gem::Dependency
29
- name: cucumber
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: rails
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -96,7 +82,7 @@ dependencies:
96
82
  - !ruby/object:Gem::Version
97
83
  version: 1.1.1
98
84
  - !ruby/object:Gem::Dependency
99
- name: attribute_normalizer
85
+ name: zeitwerk
100
86
  requirement: !ruby/object:Gem::Requirement
101
87
  requirements:
102
88
  - - ">="
@@ -116,21 +102,7 @@ dependencies:
116
102
  - - ">="
117
103
  - !ruby/object:Gem::Version
118
104
  version: '0'
119
- type: :runtime
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: facets
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: '0'
133
- type: :runtime
105
+ type: :development
134
106
  prerelease: false
135
107
  version_requirements: !ruby/object:Gem::Requirement
136
108
  requirements:
@@ -185,20 +157,31 @@ files:
185
157
  - VERSION
186
158
  - address_concern.gemspec
187
159
  - bin/console
160
+ - config/address_concern.rb
188
161
  - config/locale/overlay/en/id.yml
189
162
  - lib/address_concern.rb
190
163
  - lib/address_concern/address.rb
191
164
  - lib/address_concern/address_associations.rb
192
165
  - lib/address_concern/attribute_normalizer.rb
166
+ - lib/address_concern/attributes_slice.rb
167
+ - lib/address_concern/engine.rb
168
+ - lib/address_concern/inspect_base.rb
193
169
  - lib/address_concern/version.rb
170
+ - lib/core_extensions/hash/reorder.rb
171
+ - lib/core_extensions/string/cleanlines.rb
194
172
  - lib/generators/address_concern/install_generator.rb
195
173
  - lib/generators/address_concern/templates/configurable.yml
196
174
  - lib/generators/address_concern/templates/migration.rb
175
+ - spec/models/acts_as_address_spec.rb
197
176
  - spec/models/address_spec.rb
198
177
  - spec/spec_helper.rb
199
178
  - spec/support/database.mysql2.yml
200
179
  - spec/support/database.sqlite3.yml
201
180
  - spec/support/models/address.rb
181
+ - spec/support/models/address_custom_attr_names.rb
182
+ - spec/support/models/address_with_code_only.rb
183
+ - spec/support/models/address_with_name_only.rb
184
+ - spec/support/models/address_with_separate_address_columns.rb
202
185
  - spec/support/models/application_record.rb
203
186
  - spec/support/models/child.rb
204
187
  - spec/support/models/company.rb
@@ -225,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
208
  - !ruby/object:Gem::Version
226
209
  version: '0'
227
210
  requirements: []
228
- rubygems_version: 3.1.6
211
+ rubygems_version: 3.3.3
229
212
  signing_key:
230
213
  specification_version: 4
231
214
  summary: A reusable Address model for your Rails apps