rate_center 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/.release-please-manifest.json +3 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +26 -0
  5. data/.tool-versions +1 -0
  6. data/CHANGELOG.md +17 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +102 -0
  9. data/Rakefile +12 -0
  10. data/data/cities/us/ak.yml +6420 -0
  11. data/data/cities/us/al.yml +10684 -0
  12. data/data/cities/us/ar.yml +11308 -0
  13. data/data/cities/us/az.yml +8396 -0
  14. data/data/cities/us/ca.yml +30626 -0
  15. data/data/cities/us/co.yml +9787 -0
  16. data/data/cities/us/ct.yml +3388 -0
  17. data/data/cities/us/dc.yml +12 -0
  18. data/data/cities/us/de.yml +1424 -0
  19. data/data/cities/us/fl.yml +17198 -0
  20. data/data/cities/us/ga.yml +12062 -0
  21. data/data/cities/us/hi.yml +2846 -0
  22. data/data/cities/us/ia.yml +18822 -0
  23. data/data/cities/us/id.yml +4324 -0
  24. data/data/cities/us/il.yml +27206 -0
  25. data/data/cities/us/in.yml +17594 -0
  26. data/data/cities/us/ks.yml +13626 -0
  27. data/data/cities/us/ky.yml +9958 -0
  28. data/data/cities/us/la.yml +8786 -0
  29. data/data/cities/us/ma.yml +2288 -0
  30. data/data/cities/us/md.yml +10738 -0
  31. data/data/cities/us/me.yml +1194 -0
  32. data/data/cities/us/mi.yml +13662 -0
  33. data/data/cities/us/mn.yml +16378 -0
  34. data/data/cities/us/mo.yml +21572 -0
  35. data/data/cities/us/ms.yml +7762 -0
  36. data/data/cities/us/mt.yml +9032 -0
  37. data/data/cities/us/nc.yml +14140 -0
  38. data/data/cities/us/nd.yml +7300 -0
  39. data/data/cities/us/ne.yml +10622 -0
  40. data/data/cities/us/nh.yml +740 -0
  41. data/data/cities/us/nj.yml +11848 -0
  42. data/data/cities/us/nm.yml +9352 -0
  43. data/data/cities/us/nv.yml +2652 -0
  44. data/data/cities/us/ny.yml +17946 -0
  45. data/data/cities/us/oh.yml +22704 -0
  46. data/data/cities/us/ok.yml +15154 -0
  47. data/data/cities/us/or.yml +7680 -0
  48. data/data/cities/us/pa.yml +32546 -0
  49. data/data/cities/us/pr.yml +5121 -0
  50. data/data/cities/us/ri.yml +560 -0
  51. data/data/cities/us/sc.yml +8768 -0
  52. data/data/cities/us/sd.yml +8768 -0
  53. data/data/cities/us/tn.yml +9404 -0
  54. data/data/cities/us/tx.yml +36996 -0
  55. data/data/cities/us/ut.yml +6308 -0
  56. data/data/cities/us/va.yml +12194 -0
  57. data/data/cities/us/vt.yml +1910 -0
  58. data/data/cities/us/wa.yml +11900 -0
  59. data/data/cities/us/wi.yml +14564 -0
  60. data/data/cities/us/wv.yml +7984 -0
  61. data/data/cities/us/wy.yml +3674 -0
  62. data/data/rate_centers/us/.keep +0 -0
  63. data/data/rate_centers/us/ak.yml +4584 -0
  64. data/data/rate_centers/us/al.yml +9798 -0
  65. data/data/rate_centers/us/ar.yml +15882 -0
  66. data/data/rate_centers/us/as.yml +119 -0
  67. data/data/rate_centers/us/az.yml +4159 -0
  68. data/data/rate_centers/us/ca.yml +21059 -0
  69. data/data/rate_centers/us/co.yml +6502 -0
  70. data/data/rate_centers/us/ct.yml +4086 -0
  71. data/data/rate_centers/us/dc.yml +16 -0
  72. data/data/rate_centers/us/de.yml +1133 -0
  73. data/data/rate_centers/us/fl.yml +10773 -0
  74. data/data/rate_centers/us/ga.yml +10143 -0
  75. data/data/rate_centers/us/gu.yml +218 -0
  76. data/data/rate_centers/us/hi.yml +1130 -0
  77. data/data/rate_centers/us/ia.yml +15438 -0
  78. data/data/rate_centers/us/id.yml +4357 -0
  79. data/data/rate_centers/us/il.yml +25322 -0
  80. data/data/rate_centers/us/in.yml +13924 -0
  81. data/data/rate_centers/us/ks.yml +12312 -0
  82. data/data/rate_centers/us/ky.yml +18629 -0
  83. data/data/rate_centers/us/la.yml +7785 -0
  84. data/data/rate_centers/us/ma.yml +7947 -0
  85. data/data/rate_centers/us/md.yml +6956 -0
  86. data/data/rate_centers/us/me.yml +9213 -0
  87. data/data/rate_centers/us/mi.yml +15653 -0
  88. data/data/rate_centers/us/mn.yml +15195 -0
  89. data/data/rate_centers/us/mo.yml +18238 -0
  90. data/data/rate_centers/us/mp.yml +29 -0
  91. data/data/rate_centers/us/ms.yml +7913 -0
  92. data/data/rate_centers/us/mt.yml +5659 -0
  93. data/data/rate_centers/us/nc.yml +11641 -0
  94. data/data/rate_centers/us/nd.yml +7341 -0
  95. data/data/rate_centers/us/ne.yml +8727 -0
  96. data/data/rate_centers/us/nh.yml +4499 -0
  97. data/data/rate_centers/us/nj.yml +13710 -0
  98. data/data/rate_centers/us/nm.yml +4636 -0
  99. data/data/rate_centers/us/nv.yml +2629 -0
  100. data/data/rate_centers/us/ny.yml +34576 -0
  101. data/data/rate_centers/us/oh.yml +20184 -0
  102. data/data/rate_centers/us/ok.yml +9970 -0
  103. data/data/rate_centers/us/or.yml +6867 -0
  104. data/data/rate_centers/us/pa.yml +40360 -0
  105. data/data/rate_centers/us/pr.yml +1899 -0
  106. data/data/rate_centers/us/ri.yml +1225 -0
  107. data/data/rate_centers/us/sc.yml +6251 -0
  108. data/data/rate_centers/us/sd.yml +6256 -0
  109. data/data/rate_centers/us/tn.yml +9289 -0
  110. data/data/rate_centers/us/tx.yml +27690 -0
  111. data/data/rate_centers/us/ut.yml +4712 -0
  112. data/data/rate_centers/us/va.yml +17679 -0
  113. data/data/rate_centers/us/vi.yml +146 -0
  114. data/data/rate_centers/us/vt.yml +4667 -0
  115. data/data/rate_centers/us/wa.yml +8151 -0
  116. data/data/rate_centers/us/wi.yml +12872 -0
  117. data/data/rate_centers/us/wv.yml +14818 -0
  118. data/data/rate_centers/us/wy.yml +2852 -0
  119. data/lib/rate_center/city.rb +33 -0
  120. data/lib/rate_center/collection.rb +23 -0
  121. data/lib/rate_center/data_loader.rb +75 -0
  122. data/lib/rate_center/data_prep.rb +121 -0
  123. data/lib/rate_center/data_source/local_calling_guide.rb +107 -0
  124. data/lib/rate_center/data_source/simple_maps.rb +93 -0
  125. data/lib/rate_center/distance.rb +3 -0
  126. data/lib/rate_center/errors.rb +6 -0
  127. data/lib/rate_center/rate_center.rb +34 -0
  128. data/lib/rate_center/vector.rb +3 -0
  129. data/lib/rate_center/version.rb +5 -0
  130. data/lib/rate_center.rb +21 -0
  131. data/release-please-config.json +15 -0
  132. metadata +400 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9db3ac1a24873d160945edd60490f3af04715c4858f232a73c408cd48783a5d3
4
+ data.tar.gz: 8223be2c58e26f85eab8c48f7e688184ad328718a5227295dfcfe143522c3bed
5
+ SHA512:
6
+ metadata.gz: d27eec5024e6119026e587230de98ae8fafa0312bae05809c39d7a937163595babaa0fdf8bbf112a527c334dcae6c89e6df0be61b3fd98552f35a3d437630d62
7
+ data.tar.gz: 7e1e1fa432a40960500f0d45a4322300a533bc43b5997a976297ee244988c52b887d04149676398839f9e26cc0431612337a89fb69c2ecfaa0da4c45328e717b
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.1.2"
3
+ }
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-performance
4
+
5
+ # Omakase Ruby styling for Rails
6
+ inherit_gem:
7
+ rubocop-rails-omakase: rubocop.yml
8
+
9
+ AllCops:
10
+ NewCops: enable
11
+ TargetRubyVersion: 3.3
12
+
13
+ Lint:
14
+ Enabled: true
15
+
16
+ Style/FrozenStringLiteralComment:
17
+ Enabled: false
18
+
19
+ RSpec/DescribedClass:
20
+ Enabled: false
21
+
22
+ RSpec/ExampleLength:
23
+ Enabled: false
24
+
25
+ RSpec/MultipleExpectations:
26
+ Enabled: false
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.3.5
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## [0.1.2](https://github.com/somleng/rate_center/compare/v0.1.1...v0.1.2) (2024-10-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Gemspec ([#9](https://github.com/somleng/rate_center/issues/9)) ([9f3a313](https://github.com/somleng/rate_center/commit/9f3a3138f005523c48b98ec64c827f73f67e25d1))
9
+
10
+ ## [0.1.1](https://github.com/somleng/rate_center/compare/v0.1.0...v0.1.1) (2024-10-05)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Test Deploy ([#8](https://github.com/somleng/rate_center/issues/8)) ([8fa90ac](https://github.com/somleng/rate_center/commit/8fa90ace1d9cf4aa9be8a8ef98c2cb93712f13ca))
16
+ * Test release ([#7](https://github.com/somleng/rate_center/issues/7)) ([ddc802d](https://github.com/somleng/rate_center/commit/ddc802d9bb2e3b5c3d4ce69774ec34d850837474))
17
+ * test release 2 ([#3](https://github.com/somleng/rate_center/issues/3)) ([4ca433a](https://github.com/somleng/rate_center/commit/4ca433a4ddeb936899969e2ac146a200ca3cef5b))
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 David Wilkie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # RateCenter
2
+
3
+ [![Build](https://github.com/somleng/rate_center/actions/workflows/main.yml/badge.svg)](https://github.com/somleng/rate_center/actions/workflows/main.yml)
4
+
5
+ A collection of useful data about [NANPA Rate Centers](https://en.wikipedia.org/wiki/Rate_center).
6
+
7
+ Data is currently sourced from [Simple Maps](https://simplemaps.com/data/us-cities) and [Local Calling Guide](https://localcallingguide.com/).
8
+
9
+ ## Installation
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add rate_centers
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install rate_centers
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Working with Rate Centers
26
+
27
+ ```rb
28
+ # Load rate centers
29
+ RateCenter.load(:rate_centers, only: { us: [:ny, :ca] }) # Loads rate centers in New York and California
30
+ # RateCenter.load(:rate_centers, only: { us: { ny: [ "NWYRCYZN01" ], ca: [ "LSAN DA 01"] } }) # Loads only specific rate centers
31
+ # RateCenter.load(:rate_centers, only: { [ :us ] }) # Load all rate centers in US
32
+ # RateCenter.load(:rate_centers, :all) # Load all rate centers
33
+
34
+ # RateCenter::RateCenter.all # returns all rate centers loaded
35
+
36
+ rate_center = RateCenter::RateCenter.find_by!(country: "US", region: "NY", name: "NWYRCYZN01")
37
+ rate_center.full_name # "New York City Zone 01"
38
+ rate_center.lata # 132
39
+ rate_center.ilec_name # "VERIZON NEW YORK, INC."
40
+ rate_center.lat # "40.739362"
41
+ rate_center.long # "-73.991043"
42
+ rate_center.closest_city.name # "Manhattan"
43
+ rate_center.closest_city.distance.value # 5.33
44
+ rate_center.closest_city.distance.units # km
45
+ ```
46
+
47
+ ### Working with Cities
48
+
49
+ ```rb
50
+ # Load cities
51
+ RateCenter.load(:cities, only: { us: [:ny, :ca] }) # Loads cities in New York and California
52
+ # RateCenter.load(:cities, only: { us: { ny: [ "New York" ], ca: [ "Los Angeles"] } }) # Loads only specific cities
53
+ # RateCenter.load(:cities, only: { [ :us ] }) # Load all cities in US
54
+ # RateCenter.load(:cities, :all) # Load all cities
55
+
56
+ # RateCenter::City.all # returns all cities loaded
57
+
58
+ city = RateCenter::City.find_by!(country: "US", region: "NY", name: "New York")
59
+ city.lat # "40.6943"
60
+ city.log # "-73.9249"
61
+ city.nearby_rate_centers.each do |rate_center|
62
+ puts "Rate Center: #{rate_center.name}, Distance: #{rate_center.distance.value} #{rate_center.distance.units}"
63
+ end
64
+ # Rate Center: NWYRCYZN14, Distance: 7.5 km
65
+ # Rate Center: NWYRCYZN15, Distance: 7.5 km
66
+ # Rate Center: NWYRCYZN11, Distance: 7.5 km
67
+ # Rate Center: NWYRCYZN10, Distance: 7.5 km
68
+ # Rate Center: NWYRCYZN13, Distance: 7.5 km
69
+ # Rate Center: NWYRCYZN09, Distance: 7.5 km
70
+ # Rate Center: NWYRCYZN08, Distance: 7.5 km
71
+ # Rate Center: NWYRCYZN07, Distance: 7.5 km
72
+ # Rate Center: NWYRCYZN06, Distance: 7.5 km
73
+ # Rate Center: NWYRCYZN05, Distance: 7.5 km
74
+ # Rate Center: NWYRCYZN12, Distance: 7.5 km
75
+ # Rate Center: NWYRCYZN04, Distance: 7.5 km
76
+ # Rate Center: NWYRCYZN03, Distance: 7.5 km
77
+ # Rate Center: NWYRCYZN01, Distance: 7.5 km
78
+ # Rate Center: NASSAUZN02, Distance: 18.96 km
79
+ # Rate Center: NASSAUZN03, Distance: 20.16 km
80
+ ```
81
+
82
+ ## Updating Data
83
+
84
+ In order to pull data from the sources, run the following script
85
+
86
+ ```bash
87
+ bin/update_data
88
+ ```
89
+
90
+ ## Development
91
+
92
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
93
+
94
+ To install this gem onto your local machine, run `bundle exec rake install`.
95
+
96
+ ## Contributing
97
+
98
+ Bug reports and pull requests are welcome on GitHub at https://github.com/somleng/rate_center.
99
+
100
+ ## License
101
+
102
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]