govkit-h 0.7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +3 -0
- data/Gemfile +13 -0
- data/LICENSE +20 -0
- data/README.md +70 -0
- data/Rakefile +82 -0
- data/USAGE +1 -0
- data/VERSION +1 -0
- data/generators/govkit/govkit_generator.rb +24 -0
- data/generators/govkit/templates/govkit.rb +24 -0
- data/govkit.gemspec +130 -0
- data/init.rb +4 -0
- data/lib/generators/govkit/govkit_generator.rb +21 -0
- data/lib/generators/govkit/templates/create_mentions.rb +21 -0
- data/lib/generators/govkit/templates/govkit.rb +24 -0
- data/lib/generators/govkit/templates/mention.rb +15 -0
- data/lib/gov_kit.rb +45 -0
- data/lib/gov_kit/acts_as_noteworthy.rb +63 -0
- data/lib/gov_kit/configuration.rb +58 -0
- data/lib/gov_kit/follow_the_money.rb +176 -0
- data/lib/gov_kit/open_congress.rb +125 -0
- data/lib/gov_kit/open_congress/bill.rb +171 -0
- data/lib/gov_kit/open_congress/blog_post.rb +15 -0
- data/lib/gov_kit/open_congress/news_post.rb +15 -0
- data/lib/gov_kit/open_congress/person.rb +141 -0
- data/lib/gov_kit/open_congress/person_stat.rb +13 -0
- data/lib/gov_kit/open_congress/roll_call.rb +14 -0
- data/lib/gov_kit/open_congress/roll_call_comparison.rb +28 -0
- data/lib/gov_kit/open_congress/voting_comparison.rb +44 -0
- data/lib/gov_kit/open_states.rb +132 -0
- data/lib/gov_kit/railtie.rb +24 -0
- data/lib/gov_kit/resource.rb +190 -0
- data/lib/gov_kit/search_engines.rb +7 -0
- data/lib/gov_kit/search_engines/bing.rb +38 -0
- data/lib/gov_kit/search_engines/google_blog.rb +32 -0
- data/lib/gov_kit/search_engines/google_news.rb +47 -0
- data/lib/gov_kit/search_engines/technorati.rb +35 -0
- data/lib/gov_kit/search_engines/wikipedia.rb +27 -0
- data/lib/gov_kit/transparency_data.rb +144 -0
- data/lib/gov_kit/vote_smart.rb +126 -0
- data/lib/govkit.rb +1 -0
- data/spec/fixtures/bing/news_search.response +1 -0
- data/spec/fixtures/bing/no_results.response +1 -0
- data/spec/fixtures/follow_the_money/business-page0.response +28 -0
- data/spec/fixtures/follow_the_money/business-page1.response +12 -0
- data/spec/fixtures/follow_the_money/contribution.response +12 -0
- data/spec/fixtures/follow_the_money/unauthorized.response +8 -0
- data/spec/fixtures/open_congress/person.response +8 -0
- data/spec/fixtures/open_states/401.response +10 -0
- data/spec/fixtures/open_states/404.response +9 -0
- data/spec/fixtures/open_states/410.response +6 -0
- data/spec/fixtures/open_states/bill.response +240 -0
- data/spec/fixtures/open_states/bill_query.response +1990 -0
- data/spec/fixtures/open_states/committee_find.response +53 -0
- data/spec/fixtures/open_states/committee_query.response +190 -0
- data/spec/fixtures/open_states/legislator.response +34 -0
- data/spec/fixtures/open_states/legislator_query.response +144 -0
- data/spec/fixtures/open_states/state.response +60 -0
- data/spec/fixtures/search_engines/google_news.response +8 -0
- data/spec/fixtures/transparency_data/contributions.response +18 -0
- data/spec/fixtures/transparency_data/entities_search.response +7 -0
- data/spec/fixtures/transparency_data/entities_search_limit_0.response +7 -0
- data/spec/fixtures/transparency_data/entities_search_limit_1.response +7 -0
- data/spec/fixtures/transparency_data/grants_find_all.response +7 -0
- data/spec/fixtures/transparency_data/lobbyists_find_all.response +7 -0
- data/spec/follow_the_money_spec.rb +61 -0
- data/spec/open_congress_spec.rb +108 -0
- data/spec/open_states_spec.rb +213 -0
- data/spec/search_engines_spec.rb +44 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/transparency_data_spec.rb +106 -0
- metadata +258 -0
@@ -0,0 +1,171 @@
|
|
1
|
+
module GovKit
|
2
|
+
module OpenCongress
|
3
|
+
class Bill < OpenCongressObject
|
4
|
+
attr_accessor :bill_type, :id, :introduced, :last_speech, :last_vote_date, :last_vote_roll, :last_vote_where, :last_action, :number, :plain_language_summary, :session, :sponsor, :co_sponsors, :title_full_common, :status, :most_recent_actions, :bill_titles, :recent_blogs, :recent_news, :ident
|
5
|
+
|
6
|
+
def initialize(params)
|
7
|
+
super Bill, params
|
8
|
+
end
|
9
|
+
|
10
|
+
def ident
|
11
|
+
"#{session}-#{bill_type}#{number}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find(params)
|
15
|
+
|
16
|
+
url = construct_url("bills", params)
|
17
|
+
|
18
|
+
if (result = make_call(url))
|
19
|
+
parse_results(result)
|
20
|
+
else
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.most_blogged_bills_this_week
|
27
|
+
url = construct_url("most_blogged_bills_this_week", {})
|
28
|
+
if (result = make_call(url))
|
29
|
+
bills = parse_results(result)
|
30
|
+
return bills
|
31
|
+
else
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.bills_in_the_news_this_week
|
37
|
+
url = construct_url("bills_in_the_news_this_week", {})
|
38
|
+
if (result = make_call(url))
|
39
|
+
bills = parse_results(result)
|
40
|
+
return bills
|
41
|
+
else
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.most_tracked_bills_this_week
|
47
|
+
url = construct_url("most_tracked_bills_this_week", {})
|
48
|
+
if (result = make_call(url))
|
49
|
+
bills = parse_results(result)
|
50
|
+
return bills
|
51
|
+
else
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.most_supported_bills_this_week
|
57
|
+
url = construct_url("most_supported_bills_this_week", {})
|
58
|
+
if (result = make_call(url))
|
59
|
+
bills = parse_results(result)
|
60
|
+
return bills
|
61
|
+
else
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.most_opposed_bills_this_week
|
67
|
+
url = construct_url("most_opposed_bills_this_week", {})
|
68
|
+
if (result = make_call(url))
|
69
|
+
bills = parse_results(result)
|
70
|
+
return bills
|
71
|
+
else
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.find_by_query(q)
|
77
|
+
url = Bill.construct_url("bills_by_query", {:q => q})
|
78
|
+
|
79
|
+
if (result = make_call(url))
|
80
|
+
bills = parse_results(result)
|
81
|
+
else
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.find_by_idents(idents)
|
87
|
+
q = []
|
88
|
+
if idents.class.to_s == "Array"
|
89
|
+
q = idents
|
90
|
+
else
|
91
|
+
q = idents.split(',')
|
92
|
+
end
|
93
|
+
|
94
|
+
url = Bill.construct_url("bills_by_ident", {:ident => q.join(',')})
|
95
|
+
|
96
|
+
if (result = make_call(url))
|
97
|
+
bills = parse_results(result)
|
98
|
+
else
|
99
|
+
nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def opencongress_users_supporting_bill_are_also
|
104
|
+
url = Bill.construct_url("opencongress_users_supporting_bill_are_also/#{ident}", {})
|
105
|
+
if (result = Bill.make_call(url))
|
106
|
+
bills = Bill.parse_supporting_results(result)
|
107
|
+
return bills
|
108
|
+
else
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def opencongress_users_opposing_bill_are_also
|
114
|
+
url = Bill.construct_url("opencongress_users_opposing_bill_are_also/#{ident}", {})
|
115
|
+
if (result = Bill.make_call(url))
|
116
|
+
bills = Bill.parse_supporting_results(result)
|
117
|
+
return bills
|
118
|
+
else
|
119
|
+
nil
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.parse_results(result)
|
124
|
+
|
125
|
+
bills = []
|
126
|
+
result["bills"].each do |bill|
|
127
|
+
|
128
|
+
these_recent_blogs = bill["recent_blogs"]
|
129
|
+
blogs = []
|
130
|
+
|
131
|
+
if these_recent_blogs
|
132
|
+
these_recent_blogs.each do |trb|
|
133
|
+
blogs << BlogPost.new(trb)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
bill["recent_blogs"] = blogs
|
138
|
+
|
139
|
+
|
140
|
+
these_recent_news = bill["recent_news"]
|
141
|
+
news = []
|
142
|
+
if these_recent_news
|
143
|
+
these_recent_news.each do |trb|
|
144
|
+
news << NewsPost.new(trb)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
bill["recent_news"] = news
|
149
|
+
|
150
|
+
these_co_sponsors = bill["co_sponsors"]
|
151
|
+
co_sponsors = []
|
152
|
+
if these_co_sponsors
|
153
|
+
these_co_sponsors.each do |tcs|
|
154
|
+
co_sponsors << Person.new(tcs)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
bill["co_sponsors"] = co_sponsors
|
159
|
+
|
160
|
+
|
161
|
+
bill["sponsor"] = Person.new(bill["sponsor"]) if bill["sponsor"]
|
162
|
+
|
163
|
+
|
164
|
+
bills << Bill.new(bill)
|
165
|
+
end
|
166
|
+
bills
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module GovKit
|
2
|
+
module OpenCongress
|
3
|
+
|
4
|
+
class Person < OpenCongressObject
|
5
|
+
|
6
|
+
attr_accessor :firstname, :lastname, :bioguideid, :birthday, :district, :email, :gender, :id, :metavid_id, :middlename,
|
7
|
+
:name, :nickname, :osid, :party, :religion, :state, :title, :unaccented_name, :url, :user_approval,
|
8
|
+
:youtube_id, :oc_user_comments, :oc_users_tracking, :abstains_percentage, :with_party_percentage, :recent_news,
|
9
|
+
:recent_blogs, :person_stats
|
10
|
+
|
11
|
+
def initialize(params)
|
12
|
+
super Person, params
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.find(params)
|
16
|
+
|
17
|
+
url = construct_url("people", params)
|
18
|
+
if (result = make_call(url))
|
19
|
+
people = parse_results(result)
|
20
|
+
return people
|
21
|
+
else
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.compare(person1, person2)
|
28
|
+
url = "#{GovKit::configuration.opencongress_base_url}person/compare.json?person1=#{person1.id}&person2=#{person2.id}"
|
29
|
+
if (result = make_call(url))
|
30
|
+
comparison = VotingComparison.new(result["comparison"])
|
31
|
+
else
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.senators_most_in_the_news_this_week
|
38
|
+
|
39
|
+
url = construct_url("senators_most_in_the_news_this_week", {})
|
40
|
+
if (result = make_call(url))
|
41
|
+
people = parse_results(result)
|
42
|
+
return people
|
43
|
+
else
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.representatives_most_in_the_news_this_week
|
50
|
+
|
51
|
+
url = construct_url("representatives_most_in_the_news_this_week", {})
|
52
|
+
if (result = make_call(url))
|
53
|
+
people = parse_results(result)
|
54
|
+
return people
|
55
|
+
else
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.most_blogged_senators_this_week
|
62
|
+
|
63
|
+
url = construct_url("most_blogged_senators_this_week", {})
|
64
|
+
if (result = make_call(url))
|
65
|
+
people = parse_results(result)
|
66
|
+
return people
|
67
|
+
else
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.most_blogged_representatives_this_week
|
74
|
+
|
75
|
+
url = construct_url("most_blogged_representatives_this_week", {})
|
76
|
+
if (result = make_call(url))
|
77
|
+
people = parse_results(result)
|
78
|
+
return people
|
79
|
+
else
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
def opencongress_users_supporting_person_are_also
|
86
|
+
url = Person.construct_url("opencongress_users_supporting_person_are_also/#{id}", {})
|
87
|
+
if (result = Person.make_call(url))
|
88
|
+
people = Person.parse_supporting_results(result)
|
89
|
+
return people
|
90
|
+
else
|
91
|
+
nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def opencongress_users_opposing_person_are_also
|
96
|
+
url = Person.construct_url("opencongress_users_opposing_person_are_also/#{id}", {})
|
97
|
+
if (result = Person.make_call(url))
|
98
|
+
people = Person.parse_supporting_results(result)
|
99
|
+
return people
|
100
|
+
else
|
101
|
+
nil
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.parse_results(result)
|
106
|
+
|
107
|
+
people = []
|
108
|
+
result["people"].each do |person|
|
109
|
+
|
110
|
+
these_recent_blogs = person["recent_blogs"]
|
111
|
+
blogs = []
|
112
|
+
these_recent_blogs.each do |trb|
|
113
|
+
blogs << BlogPost.new(trb)
|
114
|
+
end
|
115
|
+
|
116
|
+
person["recent_blogs"] = blogs
|
117
|
+
|
118
|
+
|
119
|
+
these_recent_news = person["recent_news"]
|
120
|
+
news = []
|
121
|
+
these_recent_news.each do |trb|
|
122
|
+
news << NewsPost.new(trb)
|
123
|
+
end
|
124
|
+
|
125
|
+
person["person_stats"] = PersonStat.new(person["person_stats"]) if person["person_stats"]
|
126
|
+
|
127
|
+
person["recent_news"] = news
|
128
|
+
|
129
|
+
people << Person.new(person)
|
130
|
+
end
|
131
|
+
|
132
|
+
people
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module GovKit
|
2
|
+
module OpenCongress
|
3
|
+
class PersonStat < OpenCongressObject
|
4
|
+
|
5
|
+
attr_accessor :votes_most_often_with_id, :opposing_party_votes_most_often_with_id, :votes_least_often_with_id, :same_party_votes_least_often_with_id, :party_votes_percentage, :abstains_percentage, :abstains_percentage_rank, :party_votes_percentage_rank, :sponsored_bills, :cosponsored_bills, :abstains, :sponsored_bills_passed_rank, :cosponsored_bills_passed_rank, :sponsored_bills_passed, :cosponsored_bills_passed, :sponsored_bills_rank, :cosponsored_bills_rank
|
6
|
+
|
7
|
+
def initialize(params)
|
8
|
+
super PersonStat, params
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module GovKit
|
2
|
+
module OpenCongress
|
3
|
+
class RollCall < OpenCongressObject
|
4
|
+
|
5
|
+
attr_accessor :abstains, :presents, :roll_type, :title, :question, :republican_position, :democratic_position,
|
6
|
+
:amendment_id, :ayes, :nays, :bill, :date, :number, :id, :required, :where
|
7
|
+
|
8
|
+
def initialize(params)
|
9
|
+
super RollCall, params
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GovKit
|
2
|
+
module OpenCongress
|
3
|
+
class RollCallComparison < OpenCongressObject
|
4
|
+
|
5
|
+
attr_accessor :roll_call, :person1, :person2
|
6
|
+
|
7
|
+
def initialize(params)
|
8
|
+
super RollCallComparison, params
|
9
|
+
|
10
|
+
set_people
|
11
|
+
set_roll_call
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_people
|
16
|
+
self.person1 = self.person1["stong"]
|
17
|
+
self.person2 = self.person2["stong"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_roll_call
|
21
|
+
self.roll_call = RollCall.new(self.roll_call)
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module GovKit
|
2
|
+
module OpenCongress
|
3
|
+
|
4
|
+
class VotingComparison < OpenCongressObject
|
5
|
+
|
6
|
+
attr_accessor :total_votes, :same_vote, :percentage, :person1, :person2, :shared_committees, :hot_votes,
|
7
|
+
:other_votes
|
8
|
+
|
9
|
+
def initialize(params)
|
10
|
+
super VotingComparison, params
|
11
|
+
|
12
|
+
set_people
|
13
|
+
set_votes
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_people
|
18
|
+
self.person1 = Person.new(self.person1["person"])
|
19
|
+
self.person2 = Person.new(self.person2["person"])
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_votes
|
23
|
+
|
24
|
+
these_hot_votes = []
|
25
|
+
hot_votes["vote"].each do |v|
|
26
|
+
nv = RollCallComparison.new(v)
|
27
|
+
these_hot_votes << nv
|
28
|
+
end
|
29
|
+
|
30
|
+
self.hot_votes = these_hot_votes
|
31
|
+
|
32
|
+
these_other_votes = []
|
33
|
+
other_votes["vote"].each do |v|
|
34
|
+
nv = RollCallComparison.new(v)
|
35
|
+
these_other_votes << nv
|
36
|
+
end
|
37
|
+
|
38
|
+
self.other_votes = these_other_votes
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|