govkit 0.2.0 → 0.3.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.
- data/VERSION +1 -1
- data/govkit.gemspec +2 -2
- data/lib/gov_kit/configuration.rb +1 -1
- data/lib/gov_kit/open_states.rb +17 -4
- data/lib/gov_kit/resource.rb +4 -2
- data/lib/gov_kit/vote_smart.rb +4 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/govkit.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{govkit}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Participatory Politics Foundation", "Srinivas Aki", "Carl Tashian"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-10}
|
13
13
|
s.description = %q{Govkit lets you quickly get encapsulated Ruby objects for common open government APIs. We're starting with Sunlight's Open States API and the Project Vote Smart API.}
|
14
14
|
s.email = %q{carl@ppolitics.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -7,7 +7,7 @@ module GovKit
|
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@openstates_apikey = @votesmart_apikey = @ftm_apikey = ''
|
10
|
-
@openstates_base_url = '
|
10
|
+
@openstates_base_url = 'openstates.sunlightlabs.com/api/v1/'
|
11
11
|
@votesmart_base_url = 'api.votesmart.org/'
|
12
12
|
@ftm_base_url = 'api.followthemoney.org/'
|
13
13
|
@opencongress_base_url = 'www.opencongress.org/'
|
data/lib/gov_kit/open_states.rb
CHANGED
@@ -12,20 +12,20 @@ module GovKit
|
|
12
12
|
|
13
13
|
class State < OpenStatesResource
|
14
14
|
def self.find_by_abbreviation(abbreviation)
|
15
|
-
response = get("/#{abbreviation}/")
|
15
|
+
response = get("/metadata/#{abbreviation}/")
|
16
16
|
instantiate_record(response)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
class Bill < OpenStatesResource
|
21
|
-
# http://
|
21
|
+
# http://openstates.sunlightlabs.com/api/v1/ca/20092010/lower/bills/AB667/
|
22
22
|
def self.find(state_abbrev, session, chamber, bill_id)
|
23
23
|
response = get("/#{state_abbrev}/#{session}/#{chamber}/bills/#{bill_id}/")
|
24
24
|
instantiate_record(response)
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.search(query, options = {})
|
28
|
-
response = get('/bills/
|
28
|
+
response = get('/bills/', :query => {:q => query}.merge(options))
|
29
29
|
instantiate_collection(response)
|
30
30
|
end
|
31
31
|
|
@@ -42,10 +42,23 @@ module GovKit
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.search(options = {})
|
45
|
-
response = get('/legislators/
|
45
|
+
response = get('/legislators/', :query => options)
|
46
46
|
instantiate_collection(response)
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
class Committee < OpenStatesResource
|
51
|
+
def self.find(committee_id)
|
52
|
+
response = get("/committees/#{committee_id}/")
|
53
|
+
instantiate_record(response)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.search(options = {})
|
57
|
+
response = get('/committees/', :query => options)
|
58
|
+
instantiate_collection(response)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
49
62
|
|
50
63
|
class Role < OpenStatesResource; end
|
51
64
|
|
data/lib/gov_kit/resource.rb
CHANGED
@@ -3,10 +3,12 @@ module GovKit
|
|
3
3
|
include HTTParty
|
4
4
|
format :json
|
5
5
|
|
6
|
-
|
6
|
+
attr_reader :attributes
|
7
|
+
attr_reader :raw_response
|
7
8
|
|
8
9
|
def initialize(attributes = {})
|
9
10
|
@attributes = {}
|
11
|
+
@raw_response = attributes
|
10
12
|
unload(attributes)
|
11
13
|
end
|
12
14
|
|
@@ -72,7 +74,7 @@ module GovKit
|
|
72
74
|
end
|
73
75
|
|
74
76
|
def find_or_create_resource_for(name)
|
75
|
-
resource_name = name.to_s.gsub(/^_/,'').gsub(/^(\d)/, "n#{$1}").gsub(/\s/, '').camelize
|
77
|
+
resource_name = name.to_s.gsub(/^[_+]/,'').gsub(/^(\d)/, "n#{$1}").gsub(/\s/, '').camelize
|
76
78
|
if self.class.parents.size > 1
|
77
79
|
find_resource_in_modules(resource_name, self.class.parents)
|
78
80
|
else
|
data/lib/gov_kit/vote_smart.rb
CHANGED
@@ -22,6 +22,10 @@ module GovKit
|
|
22
22
|
class Bio < VoteSmartResource
|
23
23
|
def self.find(candidate_id)
|
24
24
|
response = get("/CandidateBio.getBio", :query => {"candidateId" => candidate_id})
|
25
|
+
|
26
|
+
# Sometimes this returns nil if no one is found!
|
27
|
+
raise(ResourceNotFound, 'Could not find bio for candidate ' + candidate_id.to_s) if response.blank? || response['error']
|
28
|
+
|
25
29
|
instantiate_record(response['bio']['candidate'])
|
26
30
|
end
|
27
31
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Participatory Politics Foundation
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-09-10 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|