state_geo_tools 0.2.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a797992d9fd66ce615c2ae196fe5ebea5f7f0b3e5d7ecc0d11ae9fd476cf8dc
4
- data.tar.gz: c58596ab153652945353cbec8ecbea833f37a6732514329ae40523fb0f29ed93
3
+ metadata.gz: b480633985bd7d4cb27c5bf388af65131e508dbd0b86f22f39d4cfd7fd3a4a84
4
+ data.tar.gz: 7a6ee02e1318c8219eca2ea4b72950dd481934f2d8ab94c79a8d8ee897611005
5
5
  SHA512:
6
- metadata.gz: 579fd09dde7ce7b541483c92bb47fbdd8215b010e63a09d336db937a3cb36b7c23c641d1b0ac7ecc6adcbe44bcb00e9437de4098354aeceee70c62394d484ef1
7
- data.tar.gz: 6a047446835b663b9b6671d2b20903932aa9acc5f9b1386e2a26d6e020e59f0da10dcdcbcc3b0ebd8b303b4ce5295ae475cebad6d977d7910e55b614cb08416a
6
+ metadata.gz: 5a3d61d315892d88cd6f2ae41eca289f93ff58d1946f05232d5c09e95333bbfda369b70eb7fd7b300f1382073d9ea6555cf2c55dec459003ccba0948384afd74
7
+ data.tar.gz: 97dc80c94ce6cef26ba58c56a51fc4d5fe338d6dba9272cba8d2587c06a16735e1e744b1eeff525096bc47207141b0c08a0d4859840e971188201be69eddd8a9
@@ -1,2 +1,2 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4.1
2
+ TargetRubyVersion: 2.6.3
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.6.3
@@ -4,4 +4,3 @@ rvm:
4
4
  - 2.4
5
5
  - 2.5
6
6
  - 2.6
7
- before_install: gem install bundler -v 1.17.2
data/README.md CHANGED
@@ -64,30 +64,6 @@ the top of a list. Pass `topload: [elements]` to `states`, `territories`,
64
64
  => ["MI", "DC", "TX", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "UT", "VT", "VA", "WA", "WV", "WI", "AL", "WY", "AK", "AZ"]
65
65
  ```
66
66
 
67
- ### Count instances of states in a string
68
-
69
- There is a convenience method provided to scan a string for state or territory
70
- names and return a count.
71
-
72
- Coming eventually: Handling all the aliases for Washington, DC.
73
-
74
- ```rb
75
- > require 'state_geo_tools'
76
- > StateGeoTools.count_states_in('Pantera were from Texas, I saw them in Indiana')
77
- => {"Texas"=>1, "Indiana"=>1}
78
-
79
- > StateGeoTools.count_territories_in('The Simpsons are going to Guam!')
80
- => {"Guam"=>1}
81
-
82
- # There's some special handling for Washington/Washington DC and Virginia/West
83
- # Virginia. It doesn't work flawlessly yet, so heads up!
84
- > StateGeoTools.count_states_in('Virginia and West Virginia are for lovers')
85
- => {"West Virginia"=>1, "Virginia"=>1}
86
-
87
- > StateGeoTools.count_states_in('Washington and Washington, DC are on opposite sides of the country')
88
- => {"Washington"=>1}
89
- ```
90
-
91
67
  ## Development
92
68
 
93
69
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
@@ -3,7 +3,6 @@
3
3
  require 'state_geo_tools/version'
4
4
  require 'state_geo_tools/state_constants'
5
5
  require 'state_geo_tools/territory_constants'
6
- require 'state_geo_tools/counters'
7
6
  require 'state_geo_tools/toploader'
8
7
 
9
8
  # Because I got sick of copying and pasting arrays of states everywhere, this
@@ -15,7 +14,6 @@ require 'state_geo_tools/toploader'
15
14
  #
16
15
  # See the README for examples.
17
16
  module StateGeoTools
18
- extend StateGeoTools::Counters
19
17
  extend StateGeoTools::Toploader
20
18
 
21
19
  # Return an array of states and the District of Columbia.
@@ -14,7 +14,7 @@ module StateGeoTools
14
14
  { name: 'Connecticut', code: 'CT' },
15
15
  { name: 'Delaware', code: 'DE' },
16
16
  # Statehood for DC: An opinion I am expressing in code by including DC
17
- { name: 'District of Columbia', code: 'DC', also_known_as: ['Washington, DC', 'Washington DC'] },
17
+ { name: 'District of Columbia', code: 'DC' },
18
18
  { name: 'Florida', code: 'FL' },
19
19
  { name: 'Georgia', code: 'GA' },
20
20
  { name: 'Hawaii', code: 'HI' },
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StateGeoTools
4
- VERSION = '0.2.0'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 1.17'
26
25
  spec.add_development_dependency 'minitest', '~> 5'
27
26
  spec.add_development_dependency 'rake', '~> 12'
28
27
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_geo_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - colinxfleming
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-03 00:00:00.000000000 Z
11
+ date: 2019-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.17'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.17'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: minitest
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -70,7 +56,6 @@ files:
70
56
  - bin/console
71
57
  - bin/setup
72
58
  - lib/state_geo_tools.rb
73
- - lib/state_geo_tools/counters.rb
74
59
  - lib/state_geo_tools/state_constants.rb
75
60
  - lib/state_geo_tools/territory_constants.rb
76
61
  - lib/state_geo_tools/toploader.rb
@@ -95,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
80
  - !ruby/object:Gem::Version
96
81
  version: '0'
97
82
  requirements: []
98
- rubygems_version: 3.0.1
83
+ rubygems_version: 3.0.3
99
84
  signing_key:
100
85
  specification_version: 4
101
86
  summary: A US geography/state utility.
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module StateGeoTools
4
- # Methods for counting instances in a string.
5
- module Counters
6
- # Count appearances of const's elements in the string.
7
- #
8
- # Const can be any array of strings, but we generally use the list of
9
- # states and territories.
10
- #
11
- # Returns a single hash with the const element as the keys. No zeroes.
12
- def count_instances(string, const)
13
- instances = const.sort.map do |geo|
14
- { geo.to_s => string.scan(geo_regex(geo)).count }
15
- end
16
- instances.reduce { |x, y| x.merge(y) }
17
- .delete_if { |_, v| v.zero? }
18
- end
19
-
20
- private
21
-
22
- def geo_regex(geo)
23
- # Need special handling for the great state of Virginia,
24
- # because of West Virginia.
25
- return /(?<!west )virginia/i if geo == 'Virginia'
26
- return /washington(?!, D\.*C\.*)/i if geo == 'Washington'
27
- /#{geo}/i
28
- end
29
- end
30
- end