us_geo 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/VERSION +1 -1
- data/db/migrate/20251029215800_add_locale_name_to_zctas.rb +6 -0
- data/explorer_app/Gemfile +3 -3
- data/explorer_app/app/helpers/application_helper.rb +1 -1
- data/lib/tasks/us_geo/us_geo.rake +13 -9
- data/lib/us_geo/base_record.rb +11 -3
- data/lib/us_geo/zcta.rb +0 -1
- data/us_geo.gemspec +7 -0
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dceb63343a54560e873aa526e7be7e3990936674596c7983eb579a9921bea7bf
|
|
4
|
+
data.tar.gz: d2ccf2fd72f5363d77c29e6f39f288f2b9d9b569ea75dddd1ae5030615381994
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df0c5cf5216e6eb926d6ffda006c003d7661790c4c3c10ee41c00a63342bc6ce2fb3e15fe081f5465c144c1fd06d28131d55af7b8273e1d89ec09d5f5cd5c4a9
|
|
7
|
+
data.tar.gz: 24e36f6a2af2c4b73853d8ab17a557c16faa04e8bf6e058f166defe1ac5dbfdd90cfe2ff7d8b828b9d8e8f34cbcfe51a3123d16e3004ba36239048bba45e012e
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ 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.2.0
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Added places with `U6` FIPS classification. This adds more places in rural areas where not all settlements were previously included in the data set because they were not classified as places by the Census Bureau. These are places that are not incorporated and do not have many businesses or services, but are still recognized places where people live. These places do not have any demographic data associated with them since they are not included in the Census population estimates.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Updated data set with 2023 population estimates from the Census Bureau.
|
|
16
|
+
|
|
7
17
|
## 2.1.1
|
|
8
18
|
|
|
9
19
|
### Fixed
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.2.0
|
data/explorer_app/Gemfile
CHANGED
|
@@ -4,13 +4,13 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
|
4
4
|
gemspec path: "../"
|
|
5
5
|
|
|
6
6
|
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
|
|
7
|
-
gem "rails", "~>
|
|
7
|
+
gem "rails", "~> 8.1.2", ">= 8.1.2"
|
|
8
8
|
|
|
9
9
|
# Use sqlite3 as the database for Active Record
|
|
10
|
-
gem "sqlite3", "~>
|
|
10
|
+
gem "sqlite3", "~> 2.9"
|
|
11
11
|
|
|
12
12
|
# Use the Puma web server [https://github.com/puma/puma]
|
|
13
|
-
gem "puma", "~>
|
|
13
|
+
gem "puma", "~> 7.1"
|
|
14
14
|
|
|
15
15
|
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
|
|
16
16
|
# gem "kredis"
|
|
@@ -42,7 +42,7 @@ module ApplicationHelper
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def overlap_percentage(entity, other_entity, association)
|
|
45
|
-
return nil unless entity && other_entity && entity.total_area > 0
|
|
45
|
+
return nil unless entity && other_entity && entity.total_area.to_f > 0
|
|
46
46
|
|
|
47
47
|
belongs_to = other_entity.class.base_class.to_s.demodulize.underscore
|
|
48
48
|
overlap = entity.send(association).detect { |r| r.send(belongs_to) == other_entity }
|
|
@@ -24,24 +24,28 @@ namespace :us_geo do
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
klasses.each do |name, klass|
|
|
27
|
-
desc
|
|
27
|
+
desc <<~DOC
|
|
28
|
+
Import data for #{klass}. Set US_GEO_BASE_DATA_URI to override the data source location.
|
|
29
|
+
DOC
|
|
28
30
|
task name => :environment do
|
|
29
31
|
t = Time.now
|
|
30
32
|
|
|
31
|
-
klass.load!
|
|
32
|
-
puts "Loaded #{
|
|
33
|
+
imported_count, removed_count = klass.load!
|
|
34
|
+
puts "Loaded #{imported_count} rows into #{klass.table_name} in #{(Time.now - t).round(1)}s"
|
|
33
35
|
|
|
34
|
-
removed_count = klass.removed.count
|
|
35
36
|
if removed_count > 0
|
|
36
37
|
puts " #{removed_count} previously imported records in #{klass.table_name} no longer exist in the current data source"
|
|
37
38
|
end
|
|
38
39
|
end
|
|
40
|
+
end
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
desc <<~DOC
|
|
43
|
+
Import data for all USGeo models". Set US_GEO_BASE_DATA_URI to override the data source location.
|
|
44
|
+
The default data location is https://raw.githubusercontent.com/bdurand/us_geo/master/data/2020_dist
|
|
45
|
+
DOC
|
|
46
|
+
task all: :environment do
|
|
47
|
+
klasses.each_key do |name|
|
|
48
|
+
Rake::Task["us_geo:import:#{name}"].invoke
|
|
45
49
|
end
|
|
46
50
|
end
|
|
47
51
|
|
data/lib/us_geo/base_record.rb
CHANGED
|
@@ -37,11 +37,19 @@ module USGeo
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# Mark the status of any records not updated in the block as being no longer imported.
|
|
40
|
+
#
|
|
41
|
+
# @return [Array<Integer>] Count of the number of records imported and the number of records removed
|
|
40
42
|
def import!(&block)
|
|
41
43
|
start_time = Time.at(Time.now.to_i.floor)
|
|
44
|
+
|
|
42
45
|
yield
|
|
43
|
-
|
|
44
|
-
where("updated_at
|
|
46
|
+
|
|
47
|
+
imported_count = where("updated_at >= ?", start_time).count
|
|
48
|
+
raise LoadError.new("No data found") if imported_count == 0
|
|
49
|
+
|
|
50
|
+
removed_count = where("updated_at < ?", start_time).imported.update_all(status: STATUS_REMOVED)
|
|
51
|
+
|
|
52
|
+
[imported_count, removed_count]
|
|
45
53
|
end
|
|
46
54
|
|
|
47
55
|
def data_uri(path)
|
|
@@ -60,7 +68,7 @@ module USGeo
|
|
|
60
68
|
require "csv"
|
|
61
69
|
|
|
62
70
|
file = if location.include?(":")
|
|
63
|
-
URI.parse(location).open(read_timeout:
|
|
71
|
+
URI.parse(location).open(read_timeout: 10, open_timeout: 5)
|
|
64
72
|
else
|
|
65
73
|
File.open(location)
|
|
66
74
|
end
|
data/lib/us_geo/zcta.rb
CHANGED
|
@@ -22,7 +22,6 @@ module USGeo
|
|
|
22
22
|
# This scope will search for ZCTA's via the ZCTAMappings table. This is useful
|
|
23
23
|
# when you have a retired ZIP code and want to find the current ZCTA for that ZIP code.
|
|
24
24
|
#
|
|
25
|
-
# @param zipcode [String] ZIP code to search for.
|
|
26
25
|
# @return [ActiveRecord::Relation] ZCTA's matching the given ZIP code.
|
|
27
26
|
scope :for_zipcode, ->(zipcode) { left_outer_joins(:zcta_mappings).where(ZctaMapping.table_name => {zipcode: zipcode}).or(left_outer_joins(:zcta_mappings).where(zipcode: zipcode)).distinct }
|
|
28
27
|
|
data/us_geo.gemspec
CHANGED
|
@@ -8,10 +8,17 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.homepage = "https://github.com/bdurand/us_geo"
|
|
9
9
|
spec.license = "MIT"
|
|
10
10
|
|
|
11
|
+
spec.metadata = {
|
|
12
|
+
"homepage_uri" => spec.homepage,
|
|
13
|
+
"source_code_uri" => spec.homepage,
|
|
14
|
+
"changelog_uri" => "#{spec.homepage}/blob/main/CHANGELOG.md"
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
# Specify which files should be added to the gem when it is released.
|
|
12
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
13
19
|
ignore_files = %w[
|
|
14
20
|
.
|
|
21
|
+
AGENTS.md
|
|
15
22
|
Appraisals
|
|
16
23
|
Gemfile
|
|
17
24
|
Gemfile.lock
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: us_geo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian Durand
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
@@ -52,7 +51,6 @@ dependencies:
|
|
|
52
51
|
- - ">="
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
53
|
version: '0'
|
|
55
|
-
description:
|
|
56
54
|
email:
|
|
57
55
|
- bbdurand@gmail.com
|
|
58
56
|
executables: []
|
|
@@ -98,6 +96,7 @@ files:
|
|
|
98
96
|
- db/migrate/20230417000600_add_additional_time_zone_name_to_counties.rb
|
|
99
97
|
- db/migrate/20230426000100_add_index_on_zctas_geoids.rb
|
|
100
98
|
- db/migrate/20230620000100_fix_short_names.rb
|
|
99
|
+
- db/migrate/20251029215800_add_locale_name_to_zctas.rb
|
|
101
100
|
- db/schema.rb
|
|
102
101
|
- explorer_app/.gitattributes
|
|
103
102
|
- explorer_app/.gitignore
|
|
@@ -217,8 +216,10 @@ files:
|
|
|
217
216
|
homepage: https://github.com/bdurand/us_geo
|
|
218
217
|
licenses:
|
|
219
218
|
- MIT
|
|
220
|
-
metadata:
|
|
221
|
-
|
|
219
|
+
metadata:
|
|
220
|
+
homepage_uri: https://github.com/bdurand/us_geo
|
|
221
|
+
source_code_uri: https://github.com/bdurand/us_geo
|
|
222
|
+
changelog_uri: https://github.com/bdurand/us_geo/blob/main/CHANGELOG.md
|
|
222
223
|
rdoc_options: []
|
|
223
224
|
require_paths:
|
|
224
225
|
- lib
|
|
@@ -233,8 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
233
234
|
- !ruby/object:Gem::Version
|
|
234
235
|
version: '0'
|
|
235
236
|
requirements: []
|
|
236
|
-
rubygems_version:
|
|
237
|
-
signing_key:
|
|
237
|
+
rubygems_version: 4.0.3
|
|
238
238
|
specification_version: 4
|
|
239
239
|
summary: Collection of geographic data for the United States for use with ActiveRecord
|
|
240
240
|
test_files: []
|