us_geo 2.1.0 → 2.1.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: 68802aa8e92d01352ec2107646d28307fcc14fb2c4fe2a103654d40b1ec1328c
4
- data.tar.gz: 50f856f724b528654ef89a561aa0e7bf0cd9ac4f17a3a270ac92d6a41bc23927
3
+ metadata.gz: c76c059a8661033a5ac658fc7cb9aa3f3a10f478adb44c1c1c4681374dba1b78
4
+ data.tar.gz: fe0d4bc194e683493ed4bc7be6cb0f886b2223c7ae20e9b9c71595300cf4e5ee
5
5
  SHA512:
6
- metadata.gz: 4d721fcf6721324a42d7271bec405b6f0656631a3662482ddfcd9b000747040efbd7f6b6c46395607b0d752df96870328e2bf6d803b15048b55d768274e00f5b
7
- data.tar.gz: 6aacb9847c137272d88fc212fa1ee4deb9c118d577d3bcd75f373c87d3d4c7b03b2e02a6d3bee3d125cdb3e1c35e6b78cac906fb44b095ec74786be8abb49649
6
+ metadata.gz: a11dc0cebe135efdec9b1d6a94ebfc87786311ef2266cd987778121de1b18ead07d099914342ba027d0002ff574d4d9f7c39f226c412a3c02c97dc51f9f05fc6
7
+ data.tar.gz: d23e1c89a23594ee86284f3597a22e0f26f69621b827dc411abad38088aa8faf1b0dace47d619950bc0e5714f75df80034aeb27cec58a41f8960821f14455926
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 2.1.1
8
+
9
+ ### Fixed
10
+
11
+ - Made `belongs_to` associations on models optional so that you don't need to import the full data set in order to have valid records.
12
+
7
13
  ## 2.1.0
8
14
 
9
15
  ### Changed
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.1.1
data/lib/us_geo/county.rb CHANGED
@@ -12,7 +12,7 @@ module USGeo
12
12
 
13
13
  belongs_to :core_based_statistical_area, foreign_key: :cbsa_geoid, optional: true, inverse_of: :counties
14
14
  belongs_to :metropolitan_division, foreign_key: :metropolitan_division_geoid, optional: true, inverse_of: :counties
15
- belongs_to :state, foreign_key: :state_code, inverse_of: :counties
15
+ belongs_to :state, foreign_key: :state_code, optional: true, inverse_of: :counties
16
16
 
17
17
  has_many :subdivisions, -> { not_removed }, foreign_key: :county_geoid, inverse_of: :county, class_name: "USGeo::CountySubdivision"
18
18
 
@@ -8,7 +8,7 @@ module USGeo
8
8
 
9
9
  self.primary_key = "geoid"
10
10
 
11
- belongs_to :county, foreign_key: :county_geoid, inverse_of: :subdivisions
11
+ belongs_to :county, foreign_key: :county_geoid, optional: true, inverse_of: :subdivisions
12
12
 
13
13
  has_many :zcta_county_subdivisions, -> { not_removed }, foreign_key: :county_subdivision_geoid, inverse_of: :county_subdivision, dependent: :destroy
14
14
  has_many :zctas, -> { not_removed }, through: :zcta_county_subdivisions
@@ -6,7 +6,7 @@ module USGeo
6
6
  include Population
7
7
  include Area
8
8
 
9
- belongs_to :region, inverse_of: :divisions
9
+ belongs_to :region, optional: true, inverse_of: :divisions
10
10
  has_many :states, -> { not_removed }, inverse_of: :division
11
11
 
12
12
  validates :name, presence: true, length: {maximum: 30}, uniqueness: true
data/lib/us_geo/place.rb CHANGED
@@ -26,7 +26,7 @@ module USGeo
26
26
 
27
27
  # !@method primary_county
28
28
  # @return [County] County that contains most of the place.
29
- belongs_to :primary_county, foreign_key: :primary_county_geoid, class_name: "USGeo::County"
29
+ belongs_to :primary_county, foreign_key: :primary_county_geoid, optional: true, class_name: "USGeo::County"
30
30
 
31
31
  # !@method urban_area
32
32
  # @return [UrbanArea] Urban area that the place is a part of.
@@ -34,7 +34,7 @@ module USGeo
34
34
 
35
35
  # !@method state
36
36
  # @return [State] State that the place is in.
37
- belongs_to :state, foreign_key: :state_code, inverse_of: :places
37
+ belongs_to :state, foreign_key: :state_code, optional: true, inverse_of: :places
38
38
 
39
39
  validates :geoid, length: {is: 7}
40
40
  validates :state_code, length: {is: 2}
data/lib/us_geo/state.rb CHANGED
@@ -13,8 +13,8 @@ module USGeo
13
13
  self.primary_key = "code"
14
14
  self.inheritance_column = :_type_disabled
15
15
 
16
- belongs_to :region, optional: -> { territory? }, inverse_of: :states
17
- belongs_to :division, optional: -> { territory? }, inverse_of: :states
16
+ belongs_to :region, optional: true, inverse_of: :states
17
+ belongs_to :division, optional: true, inverse_of: :states
18
18
 
19
19
  has_many :counties, -> { not_removed }, foreign_key: :state_code, inverse_of: :state
20
20
  has_many :places, -> { not_removed }, foreign_key: :state_code, inverse_of: :state
@@ -19,7 +19,7 @@ module USGeo
19
19
 
20
20
  # !@method primary_county
21
21
  # @return [USGeo::County] Primary county that contains most of the urban area.
22
- belongs_to :primary_county, foreign_key: :primary_county_geoid, class_name: "USGeo::County"
22
+ belongs_to :primary_county, foreign_key: :primary_county_geoid, optional: true, class_name: "USGeo::County"
23
23
 
24
24
  # !@method urban_area_county_subdivisions
25
25
  # @return [ActiveRecord::Relation<USGeo::UrbanAreaCountySubdivision>] County subdivision to urban area mapping.
data/lib/us_geo/zcta.rb CHANGED
@@ -36,7 +36,7 @@ module USGeo
36
36
 
37
37
  # @!method primary_county
38
38
  # @return [USGeo::County] County that contains most of the ZCTA's land area.
39
- belongs_to :primary_county, foreign_key: :primary_county_geoid, class_name: "USGeo::County"
39
+ belongs_to :primary_county, foreign_key: :primary_county_geoid, optional: true, class_name: "USGeo::County"
40
40
 
41
41
  # @!method zcta_urban_areas
42
42
  # @return [ActiveRecord::Relation] ZCTA to urban area mappings.
@@ -48,7 +48,7 @@ module USGeo
48
48
 
49
49
  # @!method primary_urban_area
50
50
  # @return [USGeo::UrbanArea] Urban area that contains most of the ZCTA's land area.
51
- belongs_to :primary_urban_area, foreign_key: :primary_urban_area_geoid, class_name: "USGeo::UrbanArea"
51
+ belongs_to :primary_urban_area, foreign_key: :primary_urban_area_geoid, optional: true, class_name: "USGeo::UrbanArea"
52
52
 
53
53
  # @!method zcta_county_subdivisions
54
54
  # @return [ActiveRecord::Relation] ZCTA to county subdivision mappings.
@@ -60,7 +60,7 @@ module USGeo
60
60
 
61
61
  # @!method primary_county_subdivision
62
62
  # @return [USGeo::CountySubdivision] County subdivision that contains most of the ZCTA's land area.
63
- belongs_to :primary_county_subdivision, foreign_key: :primary_county_subdivision_geoid, class_name: "USGeo::CountySubdivision"
63
+ belongs_to :primary_county_subdivision, foreign_key: :primary_county_subdivision_geoid, optional: true, class_name: "USGeo::CountySubdivision"
64
64
 
65
65
  # @!method zcta_places
66
66
  # @return [ActiveRecord::Relation] ZCTA to place mappings.
@@ -72,7 +72,7 @@ module USGeo
72
72
 
73
73
  # @!method primary_place
74
74
  # @return [USGeo::Place] Place that contains most of the ZCTA's land area.
75
- belongs_to :primary_place, foreign_key: :primary_place_geoid, class_name: "USGeo::Place"
75
+ belongs_to :primary_place, foreign_key: :primary_place_geoid, optional: true, class_name: "USGeo::Place"
76
76
 
77
77
  # @!method zcta_mappings
78
78
  # @return [ActiveRecord::Relation] 2010 ZCTA to current ZCTA mappings.
data/us_geo.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
 
31
31
  spec.add_dependency "activerecord", ">= 5.2"
32
+ spec.add_dependency "csv"
32
33
 
33
34
  spec.add_development_dependency "bundler"
34
35
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: us_geo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-30 00:00:00.000000000 Z
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: csv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -219,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
233
  - !ruby/object:Gem::Version
220
234
  version: '0'
221
235
  requirements: []
222
- rubygems_version: 3.4.12
236
+ rubygems_version: 3.4.10
223
237
  signing_key:
224
238
  specification_version: 4
225
239
  summary: Collection of geographic data for the United States for use with ActiveRecord