us_geo 1.0.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +82 -0
  3. data/MIT_LICENSE.txt +21 -0
  4. data/README.md +77 -60
  5. data/UPDATING_TO_VERSION_2.md +172 -0
  6. data/VERSION +1 -0
  7. data/db/migrate/20190221054200_create_regions.rb +4 -2
  8. data/db/migrate/20190221054300_create_divisions.rb +4 -2
  9. data/db/migrate/20190221054400_create_states.rb +4 -2
  10. data/db/migrate/20190221054500_create_combined_statistical_areas.rb +4 -2
  11. data/db/migrate/20190221054600_create_core_based_statistical_areas.rb +4 -2
  12. data/db/migrate/20190221054650_create_metropolitan_divisions.rb +4 -2
  13. data/db/migrate/20190221054700_create_counties.rb +4 -3
  14. data/db/migrate/20190221054800_create_zctas.rb +4 -2
  15. data/db/migrate/20190221054900_create_zcta_counties.rb +4 -2
  16. data/db/migrate/20190221055000_create_urban_areas.rb +4 -2
  17. data/db/migrate/20190221055100_create_urban_area_counties.rb +4 -4
  18. data/db/migrate/20190221055200_create_zcta_urban_areas.rb +4 -4
  19. data/db/migrate/20190221060000_create_places.rb +4 -2
  20. data/db/migrate/20190221061000_create_place_counties.rb +4 -2
  21. data/db/migrate/20190221062000_create_zcta_places.rb +4 -4
  22. data/db/migrate/20190221063000_create_county_subdivisions.rb +4 -2
  23. data/db/migrate/20220722000000_allow_null_zcta_counties_demographics.rb +23 -0
  24. data/db/migrate/20220722000200_allow_null_zcta_places_demographics.rb +23 -0
  25. data/db/migrate/20230414000000_add_zcta_primary_place.rb +13 -0
  26. data/db/migrate/20230414000200_add_demographics_to_regions.rb +28 -0
  27. data/db/migrate/20230414000300_add_demographics_to_divisions.rb +28 -0
  28. data/db/migrate/20230414000400_add_demographics_to_states.rb +28 -0
  29. data/db/migrate/20230414000700_add_short_name_to_core_based_statistical_areas.rb +22 -0
  30. data/db/migrate/20230414000750_add_short_name_to_combined_statistical_areas.rb +22 -0
  31. data/db/migrate/20230414000800_create_zcta_mappings.rb +18 -0
  32. data/db/migrate/20230417000100_create_zcta_county_subdivisions.rb +22 -0
  33. data/db/migrate/20230417000200_add_unique_name_index_to_county_subdivisions.rb +26 -0
  34. data/db/migrate/20230417000250_add_zcta_primary_county_subdivision.rb +13 -0
  35. data/db/migrate/20230417000300_create_urban_area_county_subdivisions.rb +23 -0
  36. data/db/migrate/20230417000400_allow_null_urban_area_counties_demographics.rb +23 -0
  37. data/db/migrate/20230417000500_allow_null_zcta_urban_areas_demographics.rb +23 -0
  38. data/db/migrate/20230417000600_add_additional_time_zone_name_to_counties.rb +13 -0
  39. data/db/schema.rb +303 -0
  40. data/explorer_app/.gitattributes +7 -0
  41. data/explorer_app/.gitignore +34 -0
  42. data/explorer_app/Gemfile +38 -0
  43. data/explorer_app/Rakefile +6 -0
  44. data/explorer_app/app/assets/images/.keep +0 -0
  45. data/explorer_app/app/assets/stylesheets/application.css +1 -0
  46. data/explorer_app/app/controllers/application_controller.rb +64 -0
  47. data/explorer_app/app/controllers/combined_statistical_areas_controller.rb +12 -0
  48. data/explorer_app/app/controllers/concerns/.keep +0 -0
  49. data/explorer_app/app/controllers/core_based_statistical_areas_controller.rb +36 -0
  50. data/explorer_app/app/controllers/counties_controller.rb +22 -0
  51. data/explorer_app/app/controllers/county_subdivisions_controller.rb +23 -0
  52. data/explorer_app/app/controllers/divisions_controller.rb +27 -0
  53. data/explorer_app/app/controllers/home_controller.rb +6 -0
  54. data/explorer_app/app/controllers/metropolitan_divisions_controller.rb +27 -0
  55. data/explorer_app/app/controllers/places_controller.rb +23 -0
  56. data/explorer_app/app/controllers/regions_controller.rb +13 -0
  57. data/explorer_app/app/controllers/states_controller.rb +25 -0
  58. data/explorer_app/app/controllers/urban_areas_controller.rb +24 -0
  59. data/explorer_app/app/controllers/zctas_controller.rb +23 -0
  60. data/explorer_app/app/helpers/application_helper.rb +137 -0
  61. data/explorer_app/app/models/application_record.rb +3 -0
  62. data/explorer_app/app/models/concerns/.keep +0 -0
  63. data/explorer_app/app/views/combined_statistical_areas/_table.html.erb +18 -0
  64. data/explorer_app/app/views/combined_statistical_areas/index.html.erb +7 -0
  65. data/explorer_app/app/views/combined_statistical_areas/show.html.erb +52 -0
  66. data/explorer_app/app/views/core_based_statistical_areas/_table.html.erb +32 -0
  67. data/explorer_app/app/views/core_based_statistical_areas/index.html.erb +19 -0
  68. data/explorer_app/app/views/core_based_statistical_areas/show.html.erb +60 -0
  69. data/explorer_app/app/views/counties/_table.html.erb +64 -0
  70. data/explorer_app/app/views/counties/show.html.erb +96 -0
  71. data/explorer_app/app/views/county_subdivisions/_table.html.erb +48 -0
  72. data/explorer_app/app/views/county_subdivisions/show.html.erb +84 -0
  73. data/explorer_app/app/views/divisions/_table.html.erb +24 -0
  74. data/explorer_app/app/views/divisions/index.html.erb +3 -0
  75. data/explorer_app/app/views/divisions/show.html.erb +3 -0
  76. data/explorer_app/app/views/home/index.html.erb +23 -0
  77. data/explorer_app/app/views/layouts/application.html.erb +34 -0
  78. data/explorer_app/app/views/metropolitan_divisions/_table.html.erb +42 -0
  79. data/explorer_app/app/views/metropolitan_divisions/index.html.erb +8 -0
  80. data/explorer_app/app/views/metropolitan_divisions/show.html.erb +46 -0
  81. data/explorer_app/app/views/places/_table.html.erb +47 -0
  82. data/explorer_app/app/views/places/show.html.erb +92 -0
  83. data/explorer_app/app/views/regions/_table.html.erb +18 -0
  84. data/explorer_app/app/views/regions/index.html.erb +7 -0
  85. data/explorer_app/app/views/regions/show.html.erb +3 -0
  86. data/explorer_app/app/views/shared/_breadcrumbs.html.erb +13 -0
  87. data/explorer_app/app/views/shared/_demographics_cells.html.erb +5 -0
  88. data/explorer_app/app/views/shared/_demographics_headers.html.erb +5 -0
  89. data/explorer_app/app/views/states/_table.html.erb +31 -0
  90. data/explorer_app/app/views/states/index.html.erb +7 -0
  91. data/explorer_app/app/views/states/show.html.erb +54 -0
  92. data/explorer_app/app/views/urban_areas/_table.html.erb +45 -0
  93. data/explorer_app/app/views/urban_areas/index.html.erb +19 -0
  94. data/explorer_app/app/views/urban_areas/show.html.erb +68 -0
  95. data/explorer_app/app/views/zctas/_table.html.erb +60 -0
  96. data/explorer_app/app/views/zctas/show.html.erb +104 -0
  97. data/explorer_app/bin/bundle +109 -0
  98. data/explorer_app/bin/rails +4 -0
  99. data/explorer_app/bin/rake +4 -0
  100. data/explorer_app/bin/setup +33 -0
  101. data/explorer_app/config/application.rb +37 -0
  102. data/explorer_app/config/boot.rb +3 -0
  103. data/explorer_app/config/database.yml +13 -0
  104. data/explorer_app/config/environment.rb +5 -0
  105. data/explorer_app/config/environments/development.rb +59 -0
  106. data/explorer_app/config/initializers/filter_parameter_logging.rb +8 -0
  107. data/explorer_app/config/locales/en.yml +2 -0
  108. data/explorer_app/config/puma.rb +43 -0
  109. data/explorer_app/config/routes.rb +56 -0
  110. data/explorer_app/config.ru +6 -0
  111. data/explorer_app/db/seeds.rb +7 -0
  112. data/explorer_app/lib/assets/.keep +0 -0
  113. data/explorer_app/lib/tasks/.keep +0 -0
  114. data/explorer_app/log/.keep +0 -0
  115. data/explorer_app/public/404.html +67 -0
  116. data/explorer_app/public/422.html +67 -0
  117. data/explorer_app/public/500.html +66 -0
  118. data/explorer_app/public/apple-touch-icon-precomposed.png +0 -0
  119. data/explorer_app/public/apple-touch-icon.png +0 -0
  120. data/explorer_app/public/favicon.ico +0 -0
  121. data/explorer_app/public/robots.txt +1 -0
  122. data/explorer_app/tmp/.keep +0 -0
  123. data/explorer_app/tmp/pids/.keep +0 -0
  124. data/lib/tasks/us_geo/us_geo.rake +44 -3
  125. data/lib/us_geo/area.rb +44 -0
  126. data/lib/us_geo/base_record.rb +22 -16
  127. data/lib/us_geo/combined_statistical_area.rb +18 -8
  128. data/lib/us_geo/core_based_statistical_area.rb +24 -12
  129. data/lib/us_geo/county.rb +67 -16
  130. data/lib/us_geo/county_subdivision.rb +43 -7
  131. data/lib/us_geo/division.rb +17 -7
  132. data/lib/us_geo/metropolitan_area.rb +1 -5
  133. data/lib/us_geo/metropolitan_division.rb +17 -9
  134. data/lib/us_geo/micropolitan_area.rb +1 -5
  135. data/lib/us_geo/place.rb +61 -11
  136. data/lib/us_geo/place_county.rb +1 -4
  137. data/lib/us_geo/population.rb +26 -0
  138. data/lib/us_geo/region.rb +18 -8
  139. data/lib/us_geo/state.rb +32 -11
  140. data/lib/us_geo/urban_area.rb +46 -16
  141. data/lib/us_geo/urban_area_county.rb +4 -21
  142. data/lib/us_geo/urban_area_county_subdivision.rb +51 -0
  143. data/lib/us_geo/urban_cluster.rb +1 -5
  144. data/lib/us_geo/urbanized_area.rb +1 -5
  145. data/lib/us_geo/version.rb +1 -1
  146. data/lib/us_geo/zcta.rb +90 -13
  147. data/lib/us_geo/zcta_county.rb +5 -22
  148. data/lib/us_geo/zcta_county_subdivision.rb +51 -0
  149. data/lib/us_geo/zcta_mapping.rb +35 -0
  150. data/lib/us_geo/zcta_place.rb +5 -12
  151. data/lib/us_geo/zcta_urban_area.rb +3 -20
  152. data/lib/us_geo.rb +34 -31
  153. data/us_geo.gemspec +36 -0
  154. metadata +125 -129
  155. data/Gemfile +0 -5
  156. data/Gemfile.lock +0 -75
  157. data/Rakefile +0 -18
  158. data/db/migrate/20190221054490_create_designated_market_areas.rb +0 -16
  159. data/lib/us_geo/demographics.rb +0 -25
  160. data/lib/us_geo/designated_market_area.rb +0 -30
  161. data/spec/spec_helper.rb +0 -22
  162. data/spec/us_geo/base_record_spec.rb +0 -67
  163. data/spec/us_geo/combined_statistical_area_spec.rb +0 -33
  164. data/spec/us_geo/core_based_statistical_area_spec.rb +0 -56
  165. data/spec/us_geo/county_spec.rb +0 -131
  166. data/spec/us_geo/county_subdivision_spec.rb +0 -37
  167. data/spec/us_geo/demographics_spec.rb +0 -19
  168. data/spec/us_geo/designated_market_area_spec.rb +0 -29
  169. data/spec/us_geo/division_spec.rb +0 -37
  170. data/spec/us_geo/metropolitan_division_spec.rb +0 -41
  171. data/spec/us_geo/place_county_spec.rb +0 -39
  172. data/spec/us_geo/place_spec.rb +0 -71
  173. data/spec/us_geo/region_spec.rb +0 -36
  174. data/spec/us_geo/state_spec.rb +0 -70
  175. data/spec/us_geo/urban_area_county_spec.rb +0 -82
  176. data/spec/us_geo/urban_area_spec.rb +0 -98
  177. data/spec/us_geo/zcta_county_spec.rb +0 -82
  178. data/spec/us_geo/zcta_place_spec.rb +0 -82
  179. data/spec/us_geo/zcta_spec.rb +0 -99
  180. data/spec/us_geo/zcta_urban_area_spec.rb +0 -82
@@ -0,0 +1,68 @@
1
+ <%= breadcrumbs @urban_area.name, active: @urban_area %>
2
+
3
+ <h1><%= @urban_area.name %></h1>
4
+
5
+ <table class="table table-striped">
6
+ <tbody>
7
+ <tr>
8
+ <th>GEOID</th>
9
+ <td><%= @urban_area.geoid %></td>
10
+ </tr>
11
+ <tr>
12
+ <th>Short Name</th>
13
+ <td><%= @urban_area.short_name %></td>
14
+ </tr>
15
+ <tr>
16
+ <th>Type</th>
17
+ <td><%= @urban_area.urbanized? ? "Urbanized Area" : "Urban Cluster" %></td>
18
+ </tr>
19
+ <tr>
20
+ <th>Primary County</th>
21
+ <td><%= link_to @urban_area.primary_county.full_name, county_path(@urban_area.primary_county) %></td>
22
+ </tr>
23
+ <tr>
24
+ <th>Population</th>
25
+ <td><%= formatted_number(@urban_area.population) %></td>
26
+ </tr>
27
+ <tr>
28
+ <th>Housing Units</th>
29
+ <td><%= formatted_number(@urban_area.housing_units) %></td>
30
+ </tr>
31
+ <tr>
32
+ <th>Land Area (mi<sup>2</sup>)</th>
33
+ <td><%= formatted_number(@urban_area.land_area, round: 0) %></td>
34
+ </tr>
35
+ <tr>
36
+ <th>Water Area (mi<sup>2</sup>)</th>
37
+ <td><%= formatted_number(@urban_area.water_area, round: 0) %></td>
38
+ </tr>
39
+ <tr>
40
+ <th>Coordinates</th>
41
+ <td><%= google_maps_link(@urban_area) %></td>
42
+ </tr>
43
+ </tbody>
44
+ </table>
45
+
46
+ <br>
47
+
48
+ <h2><%= pluralize(@urban_area.counties.count, "County") %></h2>
49
+
50
+ <%= render "counties/table", counties: @urban_area.counties, urban_area: @urban_area %>
51
+
52
+ <br>
53
+
54
+ <h2><%= pluralize(@urban_area.county_subdivisions.count, "County Subdivision") %></h2>
55
+
56
+ <%= render "county_subdivisions/table", county_subdivisions: @urban_area.county_subdivisions, urban_area: @urban_area %>
57
+
58
+ <br>
59
+
60
+ <h2><%= pluralize(@urban_area.places.count, "Place") %></h2>
61
+
62
+ <%= render "places/table", places: @urban_area.places, urban_area: @urban_area %>
63
+
64
+ <br>
65
+
66
+ <h2><%= pluralize(@urban_area.zctas.count, "ZIP Code Tabulation Area") %></h2>
67
+
68
+ <%= render "zctas/table", zctas: @urban_area.zctas, urban_area: @urban_area %>
@@ -0,0 +1,60 @@
1
+ <%
2
+ urban_area ||= nil
3
+ county ||= nil
4
+ county_subdivision ||= nil
5
+ place ||= nil
6
+ overlap = (urban_area || county || county_subdivision || place)
7
+ %>
8
+
9
+ <table class="table table-striped sortable">
10
+ <thead>
11
+ <tr>
12
+ <th>ZIP Code</th>
13
+ <th>Primary County</th>
14
+ <th>Primary Place</th>
15
+
16
+ <%= demographics_headers %>
17
+
18
+ <% if overlap %>
19
+ <th class="text-end">Overlap</th>
20
+ <% end %>
21
+ </th>
22
+ </thead>
23
+ <tbody>
24
+ <% zctas.each do |zcta| %>
25
+ <tr>
26
+ <td><%= link_to zcta.zipcode, zcta_path(zcta, breadcrumb_params) %></td>
27
+ <td>
28
+ <% if zcta.primary_county %>
29
+ <%= link_to zcta.primary_county.full_name, county_path(zcta.primary_county, breadcrumb_params) %>
30
+ <% else %>
31
+ -
32
+ <% end %>
33
+ </td>
34
+ <td>
35
+ <% if zcta.primary_place %>
36
+ <%= link_to zcta.primary_place.full_name, place_path(zcta.primary_place, breadcrumb_params) %>
37
+ <% else %>
38
+ -
39
+ <% end %>
40
+ </td>
41
+
42
+ <%= demographics_cells(zcta, round_area: 1) %>
43
+
44
+ <% if overlap %>
45
+ <td class="text-end">
46
+ <% if county %>
47
+ <%= overlap_percentage(county, zcta, :zcta_counties) %>
48
+ <% elsif county_subdivision %>
49
+ <%= overlap_percentage(county_subdivision, zcta, :zcta_county_subdivisions) %>
50
+ <% elsif place %>
51
+ <%= overlap_percentage(place, zcta, :zcta_places) %>
52
+ <% elsif urban_area %>
53
+ <%= overlap_percentage(urban_area, zcta, :zcta_urban_areas) %>
54
+ <% end %>
55
+ </td>
56
+ <% end %>
57
+ </tr>
58
+ <% end %>
59
+ </tbody>
60
+ </table>
@@ -0,0 +1,104 @@
1
+ <%= breadcrumbs @zcta.zipcode, active: @zcta %>
2
+
3
+ <h1>ZIP Code <%= @zcta.zipcode %></h1>
4
+
5
+ <table class="table table-striped">
6
+ <tbody>
7
+ <tr>
8
+ <th>Primary County</th>
9
+ <td>
10
+ <% if @zcta.primary_county %>
11
+ <%= link_to @zcta.primary_county.full_name, county_path(@zcta.primary_county, breadcrumb_params) %>
12
+ <% else %>
13
+ -
14
+ <% end %>
15
+ </td>
16
+ </tr>
17
+ <tr>
18
+ <th>Primary Place</th>
19
+ <td>
20
+ <% if @zcta.primary_place %>
21
+ <%= link_to @zcta.primary_place.full_name, place_path(@zcta.primary_place, breadcrumb_params) %>
22
+ <% else %>
23
+ -
24
+ <% end %>
25
+ </td>
26
+ </tr>
27
+ <% if @zcta.combined_statistical_area %>
28
+ <tr>
29
+ <th>Combined Statistical Area</th>
30
+ <td><%= link_to @zcta.combined_statistical_area.name, combined_statistical_area_path(@zcta.combined_statistical_area, breadcrumb_params) %></td>
31
+ </tr>
32
+ <% end %>
33
+ <% if @zcta.core_based_statistical_area %>
34
+ <tr>
35
+ <th>Core Based Statistical Area</th>
36
+ <td><%= link_to @zcta.core_based_statistical_area.name, core_based_statistical_area_path(@zcta.core_based_statistical_area, breadcrumb_params) %></td>
37
+ </tr>
38
+ <% end %>
39
+ <% if @zcta.metropolitan_division %>
40
+ <tr>
41
+ <th>Metropolitan Division</th>
42
+ <td><%= link_to @zcta.metropolitan_division.name, metropolitan_division_path(@zcta.metropolitan_division, breadcrumb_params) %></td>
43
+ </tr>
44
+ <% end %>
45
+ <% if @zcta.primary_urban_area %>
46
+ <tr>
47
+ <th>Primary Urban Area</th>
48
+ <td><%= link_to @zcta.primary_urban_area.name, urban_area_path(@zcta.primary_urban_area, breadcrumb_params) %></td>
49
+ </tr>
50
+ <% end %>
51
+ <tr>
52
+ <th>Population</th>
53
+ <td><%= formatted_number(@zcta.population) %></td>
54
+ </tr>
55
+ <tr>
56
+ <th>Population Density</th>
57
+ <td><%= population_density(@zcta) %></td>
58
+ </tr>
59
+ <tr>
60
+ <th>Housing Units</th>
61
+ <td><%= formatted_number(@zcta.housing_units) %></td>
62
+ </tr>
63
+ <tr>
64
+ <th>Land Area (mi<sup>2</sup>)</th>
65
+ <td><%= formatted_number(@zcta.land_area, round: 0) %></td>
66
+ </tr>
67
+ <tr>
68
+ <th>Water Area (mi<sup>2</sup>)</th>
69
+ <td><%= formatted_number(@zcta.water_area, round: 0) %></td>
70
+ </tr>
71
+ <tr>
72
+ <th>Coordinates</th>
73
+ <td><%= google_maps_link(@zcta) %></td>
74
+ </tr>
75
+ </tbody>
76
+ </table>
77
+
78
+ <% if @zcta.urban_areas.size > 1 %>
79
+ <br>
80
+
81
+ <h2><%= pluralize(@zcta.urban_areas.count, "Urban Area") %></h2>
82
+
83
+ <%= render "urban_areas/table", urban_areas: @zcta.urban_areas, zcta: @zcta %>
84
+ <% end %>
85
+
86
+ <% if @zcta.counties.size > 1 %>
87
+ <br>
88
+
89
+ <h2><%= pluralize(@zcta.counties.count, "County") %></h2>
90
+
91
+ <%= render "counties/table", counties: @zcta.counties, zcta: @zcta %>
92
+ <% end %>
93
+
94
+ <br>
95
+
96
+ <h2><%= pluralize(@zcta.county_subdivisions.count, "County Subdivision") %></h2>
97
+
98
+ <%= render "county_subdivisions/table", county_subdivisions: @zcta.county_subdivisions, zcta: @zcta %>
99
+
100
+ <br>
101
+
102
+ <h2><%= pluralize(@zcta.places.count, "Place") %></h2>
103
+
104
+ <%= render "places/table", places: @zcta.places, zcta: @zcta %>
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/o
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../Gemfile", __dir__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/o
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_requirement
64
+ @bundler_requirement ||=
65
+ env_var_version ||
66
+ cli_arg_version ||
67
+ bundler_requirement_for(lockfile_version)
68
+ end
69
+
70
+ def bundler_requirement_for(version)
71
+ return "#{Gem::Requirement.default}.a" unless version
72
+
73
+ bundler_gem_version = Gem::Version.new(version)
74
+
75
+ bundler_gem_version.approximate_recommendation
76
+ end
77
+
78
+ def load_bundler!
79
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
80
+
81
+ activate_bundler
82
+ end
83
+
84
+ def activate_bundler
85
+ gem_error = activation_error_handling do
86
+ gem "bundler", bundler_requirement
87
+ end
88
+ return if gem_error.nil?
89
+ require_error = activation_error_handling do
90
+ require "bundler/version"
91
+ end
92
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
93
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
94
+ exit 42
95
+ end
96
+
97
+ def activation_error_handling
98
+ yield
99
+ nil
100
+ rescue StandardError, LoadError => e
101
+ e
102
+ end
103
+ end
104
+
105
+ m.load_bundler!
106
+
107
+ if m.invoked_as_script?
108
+ load Gem.bin_path("bundler", "bundle")
109
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "rake"
4
+ Rake.application.run
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path("..", __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts "== Installing dependencies =="
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?("config/database.yml")
22
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! "bin/rails db:prepare"
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! "bin/rails log:clear tmp:clear"
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! "bin/rails restart"
33
+ end
@@ -0,0 +1,37 @@
1
+ require_relative "boot"
2
+
3
+ require "rails"
4
+ # Pick the frameworks you want:
5
+ require "active_model/railtie"
6
+ # require "active_job/railtie"
7
+ require "active_record/railtie"
8
+ # require "active_storage/engine"
9
+ require "action_controller/railtie"
10
+ # require "action_mailer/railtie"
11
+ # require "action_mailbox/engine"
12
+ # require "action_text/engine"
13
+ require "action_view/railtie"
14
+ # require "action_cable/engine"
15
+ # require "rails/test_unit/railtie"
16
+
17
+ # Require the gems listed in Gemfile, including any gems
18
+ # you've limited to :test, :development, or :production.
19
+ Bundler.require(*Rails.groups)
20
+
21
+ module ExploreApp
22
+ class Application < Rails::Application
23
+ # Initialize configuration defaults for originally generated Rails version.
24
+ config.load_defaults 7.0
25
+
26
+ # Configuration for the application, engines, and railties goes here.
27
+ #
28
+ # These settings can be overridden in specific environments using the files
29
+ # in config/environments, which are processed later.
30
+ #
31
+ # config.time_zone = "Central Time (US & Canada)"
32
+ # config.eager_load_paths << Rails.root.join("extras")
33
+
34
+ # Don't generate system test files.
35
+ config.generators.system_tests = nil
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
@@ -0,0 +1,13 @@
1
+ # SQLite. Versions 3.8.0 and up are supported.
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem "sqlite3"
6
+ #
7
+ default: &default
8
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
9
+ timeout: 5000
10
+
11
+ development:
12
+ <<: *default
13
+ url: <%= ENV.fetch("DATABASE_URL", "sqlite3:db/development.sqlite3").inspect %>
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative "application"
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,59 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # In the development environment your application's code is reloaded any time
7
+ # it changes. This slows down response time but is perfect for development
8
+ # since you don't have to restart the web server when you make code changes.
9
+ config.cache_classes = false
10
+
11
+ # Do not eager load code on boot.
12
+ config.eager_load = false
13
+
14
+ # Show full error reports.
15
+ config.consider_all_requests_local = true
16
+
17
+ # Enable server timing
18
+ config.server_timing = true
19
+
20
+ # Enable/disable caching. By default caching is disabled.
21
+ # Run rails dev:cache to toggle caching.
22
+ if Rails.root.join("tmp/caching-dev.txt").exist?
23
+ config.action_controller.perform_caching = true
24
+ config.action_controller.enable_fragment_cache_logging = true
25
+
26
+ config.cache_store = :memory_store
27
+ config.public_file_server.headers = {
28
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
29
+ }
30
+ else
31
+ config.action_controller.perform_caching = false
32
+
33
+ config.cache_store = :null_store
34
+ end
35
+
36
+ # Print deprecation notices to the Rails logger.
37
+ config.active_support.deprecation = :log
38
+
39
+ # Raise exceptions for disallowed deprecations.
40
+ config.active_support.disallowed_deprecation = :raise
41
+
42
+ # Tell Active Support which deprecation messages to disallow.
43
+ config.active_support.disallowed_deprecation_warnings = []
44
+
45
+ # Raise an error on page load if there are pending migrations.
46
+ config.active_record.migration_error = :page_load
47
+
48
+ # Highlight code that triggered database queries in logs.
49
+ config.active_record.verbose_query_logs = true
50
+
51
+ # Raises error for missing translations.
52
+ # config.i18n.raise_on_missing_translations = true
53
+
54
+ # Annotate rendered view with file names.
55
+ # config.action_view.annotate_rendered_view_with_filenames = true
56
+
57
+ # Uncomment if you wish to allow Action Cable access from any origin.
58
+ # config.action_cable.disable_request_forgery_protection = true
59
+ end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4
+ # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5
+ # notations and behaviors.
6
+ Rails.application.config.filter_parameters += [
7
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
8
+ ]
@@ -0,0 +1,2 @@
1
+ en:
2
+ hello: "Hello world"
@@ -0,0 +1,43 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9
+ threads min_threads_count, max_threads_count
10
+
11
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
12
+ # terminating a worker in development environments.
13
+ #
14
+ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15
+
16
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17
+ #
18
+ port ENV.fetch("PORT") { 3000 }
19
+
20
+ # Specifies the `environment` that Puma will run in.
21
+ #
22
+ environment ENV.fetch("RAILS_ENV") { "development" }
23
+
24
+ # Specifies the `pidfile` that Puma will use.
25
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26
+
27
+ # Specifies the number of `workers` to boot in clustered mode.
28
+ # Workers are forked web server processes. If using threads and workers together
29
+ # the concurrency of the application would be max `threads` * `workers`.
30
+ # Workers do not work on JRuby or Windows (both of which do not support
31
+ # processes).
32
+ #
33
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34
+
35
+ # Use the `preload_app!` method when specifying a `workers` number.
36
+ # This directive tells Puma to first boot the application and load code
37
+ # before forking the application. This takes advantage of Copy On Write
38
+ # process behavior so workers use less memory.
39
+ #
40
+ # preload_app!
41
+
42
+ # Allow puma to be restarted by `bin/rails restart` command.
43
+ plugin :tmp_restart
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ root "home#index"
5
+
6
+ controller :regions do
7
+ get "regions", action: :index, as: :regions
8
+ get "regions/:id", action: :show, as: :region
9
+ end
10
+
11
+ controller :divisions do
12
+ get "divisions", action: :index, as: :divisions
13
+ get "divisions/:id", action: :show, as: :division
14
+ end
15
+
16
+ controller :states do
17
+ get "states", action: :index, as: :states
18
+ get "states/:id", action: :show, as: :state
19
+ end
20
+
21
+ controller :combined_statistical_areas do
22
+ get "csas", action: :index, as: :combined_statistical_areas
23
+ get "csas/:id", action: :show, as: :combined_statistical_area
24
+ end
25
+
26
+ controller :core_based_statistical_areas do
27
+ get "core_based_statistical_areas", action: :index, as: :core_based_statistical_areas
28
+ get "core_based_statistical_areas/:id", action: :show, as: :core_based_statistical_area
29
+ end
30
+
31
+ controller :metropolitan_divisions do
32
+ get "metropolitan_divisions", action: :index, as: :metropolitan_divisions
33
+ get "metropolitan_divisions/:id", action: :show, as: :metropolitan_division
34
+ end
35
+
36
+ controller :urban_areas do
37
+ get "urban_areas", action: :index, as: :urban_areas
38
+ get "urban_areas/:id", action: :show, as: :urban_area
39
+ end
40
+
41
+ controller :counties do
42
+ get "counties/:id", action: :show, as: :county
43
+ end
44
+
45
+ controller :county_subdivisions do
46
+ get "county_subdivisions/:id", action: :show, as: :county_subdivision
47
+ end
48
+
49
+ controller :places do
50
+ get "places/:id", action: :show, as: :place
51
+ end
52
+
53
+ controller :zctas do
54
+ get "zctas/:id", action: :show, as: :zcta
55
+ end
56
+ end
@@ -0,0 +1,6 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
6
+ Rails.application.load_server
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
7
+ # Character.create(name: "Luke", movie: movies.first)
File without changes
File without changes
File without changes