civic_information 0.1.0 → 1.0.1
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/.gitignore +4 -0
- data/Gemfile.lock +30 -1
- data/README.md +16 -0
- data/Rakefile +9 -1
- data/civic_information.gemspec +4 -0
- data/lib/civic_information.rb +4 -1
- data/lib/civic_information/models/representatives_resource.rb +28 -0
- data/lib/civic_information/models/representatives_resource/address.rb +16 -0
- data/lib/civic_information/models/representatives_resource/channel.rb +10 -0
- data/lib/civic_information/models/representatives_resource/official.rb +27 -0
- data/lib/civic_information/version.rb +1 -1
- metadata +86 -3
- data/lib/civic_information/models/representative.rb +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f4b11cfc5030aaa88eda0379f0371d88f9f9c85704c5178c529245763fe61a34
|
|
4
|
+
data.tar.gz: 3c1f2659cccac88e8a0264640d4d50095923eb4f1fe5575787c573c3db306d6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e277a8058ce64b1456154e5e86ca5b8091be1e5491e3d153ccd8e22526ec0d8c425c57cd2e6b5389abb27bd38e614a646cf2d04454e47d60a3280aa6534ac3e
|
|
7
|
+
data.tar.gz: cebc4524362c82d29238b3421757c96852bec0fe7f41d8f8038589b1b534c8460a9b4bcc7d92452147ef186f87a670ba0ec8999bc6ff3991efa7ffb7426857eb
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,28 +1,57 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
civic_information (0.1
|
|
4
|
+
civic_information (1.0.1)
|
|
5
5
|
httparty (= 0.18.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
+
addressable (2.7.0)
|
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
12
|
+
byebug (11.1.3)
|
|
13
|
+
crack (0.4.3)
|
|
14
|
+
safe_yaml (~> 1.0.0)
|
|
15
|
+
hashdiff (1.0.1)
|
|
10
16
|
httparty (0.18.0)
|
|
11
17
|
mime-types (~> 3.0)
|
|
12
18
|
multi_xml (>= 0.5.2)
|
|
13
19
|
mime-types (3.3.1)
|
|
14
20
|
mime-types-data (~> 3.2015)
|
|
15
21
|
mime-types-data (3.2020.0512)
|
|
22
|
+
minitest (5.14.1)
|
|
16
23
|
multi_xml (0.6.0)
|
|
24
|
+
mustermann (1.1.1)
|
|
25
|
+
ruby2_keywords (~> 0.0.1)
|
|
26
|
+
public_suffix (4.0.5)
|
|
27
|
+
rack (2.2.3)
|
|
28
|
+
rack-protection (2.0.8.1)
|
|
29
|
+
rack
|
|
17
30
|
rake (12.3.3)
|
|
31
|
+
ruby2_keywords (0.0.2)
|
|
32
|
+
safe_yaml (1.0.5)
|
|
33
|
+
sinatra (2.0.8.1)
|
|
34
|
+
mustermann (~> 1.0)
|
|
35
|
+
rack (~> 2.0)
|
|
36
|
+
rack-protection (= 2.0.8.1)
|
|
37
|
+
tilt (~> 2.0)
|
|
38
|
+
tilt (2.0.10)
|
|
39
|
+
webmock (3.8.3)
|
|
40
|
+
addressable (>= 2.3.6)
|
|
41
|
+
crack (>= 0.3.2)
|
|
42
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
18
43
|
|
|
19
44
|
PLATFORMS
|
|
20
45
|
ruby
|
|
21
46
|
|
|
22
47
|
DEPENDENCIES
|
|
23
48
|
bundler (~> 1.17)
|
|
49
|
+
byebug (~> 11.1, >= 11.1.3)
|
|
24
50
|
civic_information!
|
|
51
|
+
minitest (~> 5.14, >= 5.14.1)
|
|
25
52
|
rake (~> 12.3, >= 12.3.3)
|
|
53
|
+
sinatra (~> 2.0, >= 2.0.8)
|
|
54
|
+
webmock (~> 3.8, >= 3.8.3)
|
|
26
55
|
|
|
27
56
|
BUNDLED WITH
|
|
28
57
|
1.17.2
|
data/README.md
CHANGED
|
@@ -42,6 +42,22 @@ CivicInformation.configure do |config|
|
|
|
42
42
|
end
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
After configuration, you can do the following things.
|
|
48
|
+
|
|
49
|
+
### Representatives Resource
|
|
50
|
+
|
|
51
|
+
[https://developers.google.com/civic-information/docs/v2/representatives](https://developers.google.com/civic-information/docs/v2/representatives)
|
|
52
|
+
|
|
53
|
+
#### Searching
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
CivicInformation::RepresentativesResource.
|
|
57
|
+
where(address: '55555', roles: ['legislatorLowerBody', 'legislatorUpperBody']).
|
|
58
|
+
officials.map(&:name)
|
|
59
|
+
```
|
|
60
|
+
|
|
45
61
|
## Development
|
|
46
62
|
|
|
47
63
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Rakefile
CHANGED
data/civic_information.gemspec
CHANGED
|
@@ -38,6 +38,10 @@ Gem::Specification.new do |spec|
|
|
|
38
38
|
|
|
39
39
|
spec.add_development_dependency "bundler", "~> 1.17"
|
|
40
40
|
spec.add_development_dependency "rake", "~> 12.3", ">= 12.3.3"
|
|
41
|
+
spec.add_development_dependency "minitest", "~> 5.14", ">= 5.14.1"
|
|
42
|
+
spec.add_development_dependency "webmock", "~> 3.8", ">= 3.8.3"
|
|
43
|
+
spec.add_development_dependency "sinatra", "~> 2.0", ">= 2.0.8"
|
|
44
|
+
spec.add_development_dependency "byebug", "~> 11.1", ">= 11.1.3"
|
|
41
45
|
|
|
42
46
|
spec.add_dependency "httparty", "0.18.0"
|
|
43
47
|
end
|
data/lib/civic_information.rb
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
require "httparty"
|
|
2
2
|
require "civic_information/version"
|
|
3
3
|
require "civic_information/configuration"
|
|
4
|
-
require "civic_information/models/
|
|
4
|
+
require "civic_information/models/representatives_resource"
|
|
5
|
+
require "civic_information/models/representatives_resource/official"
|
|
6
|
+
require "civic_information/models/representatives_resource/channel"
|
|
7
|
+
require "civic_information/models/representatives_resource/address"
|
|
5
8
|
|
|
6
9
|
module CivicInformation
|
|
7
10
|
include HTTParty
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module CivicInformation
|
|
2
|
+
class RepresentativesResource
|
|
3
|
+
attr_accessor :officials
|
|
4
|
+
|
|
5
|
+
def self.where(address: nil, roles: nil)
|
|
6
|
+
response = CivicInformation.get "/representatives", query: {
|
|
7
|
+
key: CivicInformation.configuration.google_api_key,
|
|
8
|
+
address: address,
|
|
9
|
+
roles: roles
|
|
10
|
+
}.delete_if { |k, v| v.nil? }
|
|
11
|
+
|
|
12
|
+
self.new(
|
|
13
|
+
officials: build_officials(response.parsed_response["officials"] || [])
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def initialize(officials:)
|
|
18
|
+
@officials = officials
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def self.build_officials(officials_response)
|
|
24
|
+
officials_response.
|
|
25
|
+
map { |official| RepresentativesResource::Official.new(official) }
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module CivicInformation
|
|
2
|
+
class RepresentativesResource::Address
|
|
3
|
+
attr_accessor :location_name, :line_one, :line_two, :line_three, :city,
|
|
4
|
+
:state, :zip
|
|
5
|
+
|
|
6
|
+
def initialize(address_json)
|
|
7
|
+
@location_name = address_json["locationName"]
|
|
8
|
+
@line_one = address_json["line1"]
|
|
9
|
+
@line_two = address_json["line2"]
|
|
10
|
+
@line_three = address_json["line3"]
|
|
11
|
+
@city = address_json["city"]
|
|
12
|
+
@state = address_json["state"]
|
|
13
|
+
@zip = address_json["zip"]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module CivicInformation
|
|
2
|
+
class RepresentativesResource::Official
|
|
3
|
+
attr_accessor :name, :photo_url, :party, :phones, :emails, :urls, :channels,
|
|
4
|
+
:addresses
|
|
5
|
+
|
|
6
|
+
def initialize(official_json)
|
|
7
|
+
@name = official_json["name"]
|
|
8
|
+
@photo_url = official_json["photoUrl"]
|
|
9
|
+
@party = official_json["party"]
|
|
10
|
+
@phones = official_json["phones"] || []
|
|
11
|
+
@emails = official_json["emails"] || []
|
|
12
|
+
@urls = official_json["urls"] || []
|
|
13
|
+
@channels = build_channels(official_json["channels"] || [])
|
|
14
|
+
@addresses = build_addresses(official_json["address"] || [])
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def build_addresses(address_json)
|
|
20
|
+
address_json.map { |address| RepresentativesResource::Address.new(address) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def build_channels(channels_json)
|
|
24
|
+
channels_json.map { |channel| RepresentativesResource::Channel.new(channel) }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: civic_information
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Will Olson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-06-
|
|
11
|
+
date: 2020-06-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -44,6 +44,86 @@ dependencies:
|
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
46
|
version: 12.3.3
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: minitest
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '5.14'
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: 5.14.1
|
|
57
|
+
type: :development
|
|
58
|
+
prerelease: false
|
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - "~>"
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '5.14'
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: 5.14.1
|
|
67
|
+
- !ruby/object:Gem::Dependency
|
|
68
|
+
name: webmock
|
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - "~>"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '3.8'
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: 3.8.3
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - "~>"
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '3.8'
|
|
84
|
+
- - ">="
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: 3.8.3
|
|
87
|
+
- !ruby/object:Gem::Dependency
|
|
88
|
+
name: sinatra
|
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - "~>"
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '2.0'
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 2.0.8
|
|
97
|
+
type: :development
|
|
98
|
+
prerelease: false
|
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '2.0'
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: 2.0.8
|
|
107
|
+
- !ruby/object:Gem::Dependency
|
|
108
|
+
name: byebug
|
|
109
|
+
requirement: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - "~>"
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '11.1'
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: 11.1.3
|
|
117
|
+
type: :development
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '11.1'
|
|
124
|
+
- - ">="
|
|
125
|
+
- !ruby/object:Gem::Version
|
|
126
|
+
version: 11.1.3
|
|
47
127
|
- !ruby/object:Gem::Dependency
|
|
48
128
|
name: httparty
|
|
49
129
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -77,7 +157,10 @@ files:
|
|
|
77
157
|
- civic_information.gemspec
|
|
78
158
|
- lib/civic_information.rb
|
|
79
159
|
- lib/civic_information/configuration.rb
|
|
80
|
-
- lib/civic_information/models/
|
|
160
|
+
- lib/civic_information/models/representatives_resource.rb
|
|
161
|
+
- lib/civic_information/models/representatives_resource/address.rb
|
|
162
|
+
- lib/civic_information/models/representatives_resource/channel.rb
|
|
163
|
+
- lib/civic_information/models/representatives_resource/official.rb
|
|
81
164
|
- lib/civic_information/version.rb
|
|
82
165
|
homepage: https://github.com/frankolson/ruby-civic-information
|
|
83
166
|
licenses:
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module CivicInformation
|
|
2
|
-
class Representative
|
|
3
|
-
attr_accessor :name, :phones
|
|
4
|
-
|
|
5
|
-
def self.where(address: nil, roles: nil)
|
|
6
|
-
response = CivicInformation.get "/representatives", query: {
|
|
7
|
-
key: CivicInformation.configuration.google_api_key,
|
|
8
|
-
address: address,
|
|
9
|
-
roles: roles
|
|
10
|
-
}.delete_if { |k, v| v.nil? }
|
|
11
|
-
officials = response.parsed_response["officials"] || []
|
|
12
|
-
|
|
13
|
-
officials.map do |representative|
|
|
14
|
-
self.new(representative)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def initialize(representative_json)
|
|
19
|
-
@name = representative_json["name"]
|
|
20
|
-
@phones = representative_json["phones"]
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|