govkit 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/README.markdown +2 -2
  2. data/Rakefile +4 -5
  3. data/VERSION +1 -1
  4. data/generators/govkit/templates/govkit.rb +4 -4
  5. data/govkit.gemspec +22 -7
  6. data/init.rb +4 -0
  7. data/lib/gov_kit/acts_as_citeable.rb +1 -1
  8. data/lib/gov_kit/configuration.rb +4 -4
  9. data/lib/gov_kit/follow_the_money.rb +30 -16
  10. data/lib/gov_kit/{fifty_states.rb → open_states.rb} +25 -13
  11. data/lib/gov_kit/railtie.rb +20 -0
  12. data/lib/gov_kit/resource.rb +17 -37
  13. data/lib/gov_kit/search_engines/google_news.rb +4 -4
  14. data/lib/gov_kit/search_engines/wikipedia.rb +21 -0
  15. data/lib/gov_kit/search_engines.rb +1 -0
  16. data/lib/gov_kit/vote_smart.rb +68 -4
  17. data/lib/gov_kit.rb +25 -24
  18. data/spec/fixtures/follow_the_money/business-page0.response +28 -0
  19. data/spec/fixtures/follow_the_money/business-page1.response +12 -0
  20. data/spec/fixtures/follow_the_money/contribution.response +12 -0
  21. data/spec/fixtures/follow_the_money/unauthorized.response +8 -0
  22. data/spec/fixtures/open_states/401.response +6 -0
  23. data/spec/fixtures/open_states/410.response +6 -0
  24. data/spec/fixtures/open_states/bill.response +240 -0
  25. data/spec/fixtures/open_states/bill_query.response +1990 -0
  26. data/spec/fixtures/open_states/legislator.response +34 -0
  27. data/spec/fixtures/open_states/legislator_query.response +144 -0
  28. data/spec/fixtures/open_states/state.response +60 -0
  29. data/spec/follow_the_money_spec.rb +57 -0
  30. data/spec/open_states_spec.rb +131 -0
  31. data/spec/spec_helper.rb +13 -0
  32. metadata +23 -14
  33. data/rails/init.rb +0 -3
  34. data/spec/fifty_states_spec.rb +0 -90
data/lib/gov_kit.rb CHANGED
@@ -1,40 +1,41 @@
1
1
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
2
2
 
3
3
  require 'active_support'
4
- require 'gov_kit/configuration'
4
+ require 'hpricot'
5
5
  require 'iconv'
6
- require 'gov_kit/search_engines'
6
+ require 'httparty'
7
+ require 'json'
8
+ require 'gov_kit/configuration'
7
9
 
8
10
  module GovKit
9
- autoload :FiftyStates, 'gov_kit/fifty_states'
11
+ autoload :Resource, 'gov_kit/resource'
12
+ autoload :OpenStates, 'gov_kit/open_states'
10
13
  autoload :VoteSmart, 'gov_kit/vote_smart'
11
14
  autoload :ActsAsCiteable, 'gov_kit/acts_as_citeable'
12
15
  autoload :FollowTheMoney, 'gov_kit/follow_the_money'
13
16
  autoload :OpenCongress, 'gov_kit/open_congress'
14
-
15
- class Bill < Resource;
16
- end
17
- class Vote < Resource;
18
- end
19
- class Session < Resource;
20
- end
21
- class Role < Resource;
22
- end
23
- class Legislator < Resource;
24
- end
25
- class Vote < Resource;
26
- end
27
- class Sponsor < Resource;
28
- end
29
- class Version < Resource;
30
- end
31
- class Source < Resource;
32
- end
33
- class Address < Resource;
34
- end
17
+ autoload :SearchEngines, 'gov_kit/search_engines'
35
18
 
36
19
  class Citation
37
20
  attr_accessor :url, :excerpt, :title, :source, :date, :weight
38
21
  end
39
22
 
23
+ class GovKitError < StandardError
24
+ attr_reader :response
25
+
26
+ def initialize(response, message = nil)
27
+ @response = response
28
+ @message = message
29
+ end
30
+
31
+ def to_s
32
+ "Failed with #{response.code if response.respond_to?(:code)} #{response.message if response.respond_to?(:message)}"
33
+ end
34
+ end
35
+
36
+ class NotAuthorized < GovKitError; end
37
+
38
+ class InvalidRequest < GovKitError; end
39
+
40
+ class ResourceNotFound < GovKitError; end
40
41
  end
@@ -0,0 +1,28 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Wed, 16 Jun 2010 21:59:36 GMT
3
+ Server: Apache/1.3.37 (Unix) PHP/5.2.0 mod_ssl/2.8.28 OpenSSL/0.9.8b
4
+ X-Powered-By: PHP/5.2.0
5
+ Transfer-Encoding: chunked
6
+ Content-Type: text/xml
7
+
8
+ <base_level.industries.list sort="" page="0" next_page="yes" record_count="19" origin="Institute on Money in State Politics" process_timestamp="06-16-2010 14:59:36" update_timestamp="06-16-2010 02:08:46">
9
+ <business_detail imsp_sector_code="1" sector_name="Agriculture" imsp_industry_code="1" industry_name="Miscellaneous Agriculture" business_name="Miscellaneous agriculture"></business_detail>
10
+ <business_detail imsp_sector_code="1" sector_name="Agriculture" imsp_industry_code="2" industry_name="Crop Production &amp; Basic Processing" business_name="Farmers, in general"></business_detail>
11
+ <business_detail imsp_sector_code="1" sector_name="Agriculture" imsp_industry_code="2" industry_name="Crop Production &amp; Basic Processing" business_name="Cotton growers, cotton ginners"></business_detail>
12
+ <business_detail imsp_sector_code="1" sector_name="Agriculture" imsp_industry_code="2" industry_name="Crop Production &amp; Basic Processing" business_name="Includes all sugar growers and sugar co-ops"></business_detail>
13
+ <business_detail imsp_sector_code="1" sector_name="Agriculture" imsp_industry_code="3" industry_name="Tobacco" business_name="Tobacco &amp; tobacco products"></business_detail>
14
+ <business_detail imsp_sector_code="1" sector_name="Agriculture" imsp_industry_code="2" industry_name="Crop Production &amp; Basic Processing" business_name="Vegetables, fruits &amp; tree nuts"></business_detail>
15
+ <business_detail imsp_sector_code="1" sector_name="Agriculture" imsp_industry_code="2" industry_name="Crop Production &amp; Basic Processing" business_name="Wheat, corn, soybeans &amp; cash grain"></business_detail>
16
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="11" industry_name="General Contractors" business_name="Construction &amp; public works"></business_detail>
17
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="11" industry_name="General Contractors" business_name="Builders associations"></business_detail>
18
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="11" industry_name="General Contractors" business_name="Public works, industrial &amp; commercial construction"></business_detail>
19
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="11" industry_name="General Contractors" business_name="Construction, unclassified"></business_detail>
20
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="12" industry_name="Home Builders" business_name="Residential construction"></business_detail>
21
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="12" industry_name="Home Builders" business_name="Mobile home construction"></business_detail>
22
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="13" industry_name="Special Trade Contractors" business_name="Special trade contractors"></business_detail>
23
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="13" industry_name="Special Trade Contractors" business_name="Electrical contractors"></business_detail>
24
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="13" industry_name="Special Trade Contractors" business_name="Plumbing, heating &amp; air conditioning"></business_detail>
25
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="13" industry_name="Special Trade Contractors" business_name="Landscaping &amp; excavation services"></business_detail>
26
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="14" industry_name="Construction Services" business_name="Engineering, architecture &amp; construction management services"></business_detail>
27
+ <business_detail imsp_sector_code="2" sector_name="Construction" imsp_industry_code="14" industry_name="Construction Services" business_name="Architectural services"></business_detail>
28
+ </base_level.industries.list>
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Wed, 16 Jun 2010 22:00:52 GMT
3
+ Server: Apache/1.3.37 (Unix) PHP/5.2.0 mod_ssl/2.8.28 OpenSSL/0.9.8b
4
+ X-Powered-By: PHP/5.2.0
5
+ Transfer-Encoding: chunked
6
+ Content-Type: text/xml
7
+
8
+ <base_level.industries.list sort="" page="1" next_page="no" record_count="3" origin="Institute on Money in State Politics" process_timestamp="06-16-2010 15:00:52" update_timestamp="06-16-2010 02:08:46">
9
+ <business_detail imsp_sector_code="7" sector_name="General Business" imsp_industry_code="62" industry_name="Recreation &amp; Live Entertainment" business_name="Recreation &amp; entertainment"></business_detail>
10
+ <business_detail imsp_sector_code="7" sector_name="General Business" imsp_industry_code="62" industry_name="Recreation &amp; Live Entertainment" business_name="Amusement &amp; recreation centers"></business_detail>
11
+ <business_detail imsp_sector_code="7" sector_name="General Business" imsp_industry_code="62" industry_name="Recreation &amp; Live Entertainment" business_name="Professional sports, arenas &amp; related equipment and services"></business_detail>
12
+ </base_level.industries.list>
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Wed, 16 Jun 2010 22:10:59 GMT
3
+ Server: Apache/1.3.37 (Unix) PHP/5.2.0 mod_ssl/2.8.28 OpenSSL/0.9.8b
4
+ X-Powered-By: PHP/5.2.0
5
+ Transfer-Encoding: chunked
6
+ Content-Type: text/xml
7
+
8
+ <candidates.contributions imsp_cadidate_id="111933" imsp_sector_code="0" sector_name="" imsp_industry_code="0" industry_name="" contributor_name="" contributor_city="" contributor_state="" contributor_zipcode="" contribution_date_range="" contribution_amount_range="" candidate_name="GONZALES, VERONICA" state="TX" year="2008" party="DEMOCRAT" office="HOUSE" district="041" sort="" page="0" next_page="no" record_count="3" origin="Institute on Money in State Politics" process_timestamp="06-16-2010 15:10:59" update_timestamp="06-16-2010 02:08:46">
9
+ <contribution contributor_name="KITTLEMAN THOMAS &amp; GONZALES" date="2007-06-30" amount="220" contributor_employer="" contributor_occupation="" contributor_city="" contributor_state="" contributor_zipcode="" imsp_sector_code="11" sector_name="Lawyers &amp; Lobbyists" imsp_industry_code="98" industry_name="Lawyers &amp; Lobbyists" business_name="Attorneys &amp; law firms"></contribution>
10
+ <contribution contributor_name="KRALJ, NICK" date="2007-06-25" amount="957.8" contributor_employer="SELF-EMPLOYED" contributor_occupation="LOBBYIST" contributor_city="" contributor_state="" contributor_zipcode="" imsp_sector_code="14" sector_name="Uncoded" imsp_industry_code="121" industry_name="Uncoded" business_name="Uncoded"></contribution>
11
+ <contribution contributor_name="LAMANTIA, GREG" date="2007-06-27" amount="1000" contributor_employer="L&amp;F DISTRIBUTORS" contributor_occupation="BEER DISTRIBUTOR/OWNER" contributor_city="" contributor_state="" contributor_zipcode="" imsp_sector_code="7" sector_name="General Business" imsp_industry_code="57" industry_name="Beer, Wine &amp; Liquor" business_name="Liquor wholesalers"></contribution>
12
+ </candidates.contributions>
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Wed, 16 Jun 2010 17:31:45 GMT
3
+ Server: Apache/1.3.37 (Unix) PHP/5.2.0 mod_ssl/2.8.28 OpenSSL/0.9.8b
4
+ X-Powered-By: PHP/5.2.0
5
+ Connection: close
6
+ Content-Type: text/xml
7
+
8
+ <error code="100" text="invalid key" origin="Institute on Money in State Politics" process_timestamp="06-16-2010 10:30:03" update_timestamp="06-16-2010 02:08:46"></error>
@@ -0,0 +1,6 @@
1
+ HTTP/1.1 401 UNAUTHORIZED
2
+ Server: nginx/0.6.35
3
+ Date: Tue, 15 Jun 2010 22:34:56 GMT
4
+ Content-Type: text/plain
5
+ Connection: close
6
+ Vary: Authorization
@@ -0,0 +1,6 @@
1
+ HTTP/1.1 410 GONE
2
+ Server: nginx/0.6.35
3
+ Date: Tue, 15 Jun 2010 22:34:56 GMT
4
+ Content-Type: text/plain
5
+ Connection: close
6
+ Vary: Authorization
@@ -0,0 +1,240 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.6.35
3
+ Date: Tue, 15 Jun 2010 21:50:08 GMT
4
+ Content-Type: application/json; charset=utf-8
5
+ Connection: close
6
+ Vary: Authorization
7
+
8
+ {
9
+ "votes": [
10
+ {
11
+ "other_count": 6,
12
+ "sources": [],
13
+ "yes_count": 34,
14
+ "updated_at": "2010-03-27 21:30:38",
15
+ "motion": "Special Consent #12 AB667 Block By Alquist",
16
+ "chamber": "upper",
17
+ "passed": true,
18
+ "date": "2009-07-09 05:50:00",
19
+ "vote_id": 13695,
20
+ "no_count": 0
21
+ },
22
+ {
23
+ "other_count": 3,
24
+ "sources": [],
25
+ "yes_count": 77,
26
+ "updated_at": "2010-03-27 21:30:38",
27
+ "motion": "AB 667 BLOCK Consent Calendar Second Day Regular Session",
28
+ "chamber": "lower",
29
+ "passed": true,
30
+ "date": "2009-05-21 08:07:00",
31
+ "vote_id": 13694,
32
+ "no_count": 0
33
+ },
34
+ {
35
+ "other_count": 3,
36
+ "sources": [],
37
+ "yes_count": 10,
38
+ "updated_at": "2010-03-27 21:30:38",
39
+ "motion": "Do pass and be re-referred to the Committee on Appropriations.",
40
+ "chamber": "lower",
41
+ "passed": true,
42
+ "date": "2009-04-13 20:00:00",
43
+ "vote_id": 13693,
44
+ "no_count": 0
45
+ },
46
+ {
47
+ "other_count": 0,
48
+ "sources": [],
49
+ "yes_count": 7,
50
+ "updated_at": "2010-03-27 21:30:38",
51
+ "motion": "Do pass, to Consent Calendar.",
52
+ "chamber": "lower",
53
+ "passed": true,
54
+ "date": "2009-05-12 20:00:00",
55
+ "vote_id": 13692,
56
+ "no_count": 0
57
+ },
58
+ {
59
+ "other_count": 0,
60
+ "sources": [],
61
+ "yes_count": 7,
62
+ "updated_at": "2010-03-27 21:30:38",
63
+ "motion": "Do pass, but re-refer to the Committee on Appropriations.",
64
+ "chamber": "upper",
65
+ "passed": true,
66
+ "date": "2009-04-27 20:00:00",
67
+ "vote_id": 13691,
68
+ "no_count": 4
69
+ },
70
+ {
71
+ "other_count": 0,
72
+ "sources": [],
73
+ "yes_count": 5,
74
+ "updated_at": "2010-03-27 21:30:37",
75
+ "motion": "Do pass, but re-refer to the Committee on Appropriations.",
76
+ "chamber": "upper",
77
+ "passed": true,
78
+ "date": "2009-06-21 20:00:00",
79
+ "vote_id": 13690,
80
+ "no_count": 2
81
+ }
82
+ ],
83
+ "last_action": "2009-08-05 20:00:00",
84
+ "first_action": "2009-02-24 19:00:00",
85
+ "title": "An act to amend Section 1750.1 of the Business and Professions Code, and to amend Section 104830 of, and to add Section 104762 to, the Health and Safety Code, relating to oral health.",
86
+ "updated_at": "2010-03-27 21:30:38",
87
+ "actions": [
88
+ {
89
+ "date": "2009-08-05 20:00:00",
90
+ "action": "Chaptered by Secretary of State - Chapter 119, Statutes of 2009.",
91
+ "updated_at": "2010-03-27 21:30:37",
92
+ "actor": "Secretary of State"
93
+ },
94
+ {
95
+ "date": "2009-08-04 20:00:00",
96
+ "action": "Approved by the Governor.",
97
+ "updated_at": "2010-03-27 21:30:37",
98
+ "actor": "Governor"
99
+ },
100
+ {
101
+ "date": "2009-07-29 20:00:00",
102
+ "action": "Enrolled and to the Governor at 2:30 p.m.",
103
+ "updated_at": "2010-03-27 21:30:37",
104
+ "actor": "Governor"
105
+ },
106
+ {
107
+ "date": "2009-07-08 20:00:00",
108
+ "action": "In Assembly. To enrollment.",
109
+ "updated_at": "2010-03-27 21:30:37",
110
+ "actor": "Assembly (E&E Enrollment)"
111
+ },
112
+ {
113
+ "date": "2009-07-08 20:00:00",
114
+ "action": "Read third time, passed, and to Assembly. (Ayes 34. Noes 0. Page 1667.)",
115
+ "updated_at": "2010-03-27 21:30:37",
116
+ "actor": "Senate (Desk)"
117
+ },
118
+ {
119
+ "date": "2009-07-01 20:00:00",
120
+ "action": "Ordered to Special Consent Calendar.",
121
+ "updated_at": "2010-03-27 21:30:37",
122
+ "actor": "Senate (Floor Special Consent)"
123
+ },
124
+ {
125
+ "date": "2009-06-29 20:00:00",
126
+ "action": "Read second time. To third reading.",
127
+ "updated_at": "2010-03-27 21:30:37",
128
+ "actor": "Senate (Floor Third Reading)"
129
+ },
130
+ {
131
+ "date": "2009-06-28 20:00:00",
132
+ "action": "From committee: Be placed on second reading file pursuant to Senate Rule 28.8.",
133
+ "updated_at": "2010-03-27 21:30:37",
134
+ "actor": "Senate (Floor Second Reading)"
135
+ },
136
+ {
137
+ "date": "2009-06-21 20:00:00",
138
+ "action": "From committee: Do pass, and re-refer to Com. on APPR. Re-referred. (Ayes 10. Noes 0.) (June 22).",
139
+ "updated_at": "2010-03-27 21:30:37",
140
+ "actor": "Senate (Committee)"
141
+ },
142
+ {
143
+ "date": "2009-06-03 20:00:00",
144
+ "action": "Referred to Com. on B., P. & E.D.",
145
+ "updated_at": "2010-03-27 21:30:37",
146
+ "actor": "Senate (Committee CS42)"
147
+ },
148
+ {
149
+ "date": "2009-05-20 20:00:00",
150
+ "action": "Read third time, passed, and to Senate. (Ayes 77. Noes 0. Page 1628.)",
151
+ "updated_at": "2010-03-27 21:30:37",
152
+ "actor": "Assembly (E&E Engrossing)"
153
+ },
154
+ {
155
+ "date": "2009-05-20 20:00:00",
156
+ "action": "In Senate. Read first time. To Com. on RLS. for assignment.",
157
+ "updated_at": "2010-03-27 21:30:37",
158
+ "actor": "Senate (Rules)"
159
+ },
160
+ {
161
+ "date": "2009-05-17 20:00:00",
162
+ "action": "Read second time. To Consent Calendar.",
163
+ "updated_at": "2010-03-27 21:30:37",
164
+ "actor": "Assembly (Floor Consent)"
165
+ },
166
+ {
167
+ "date": "2009-05-13 20:00:00",
168
+ "action": "From committee: Do pass. To Consent Calendar. (May 13).",
169
+ "updated_at": "2010-03-27 21:30:37",
170
+ "actor": "Assembly (Floor Second Reading)"
171
+ },
172
+ {
173
+ "date": "2009-05-04 20:00:00",
174
+ "action": "Re-referred to Com. on APPR.",
175
+ "updated_at": "2010-03-27 21:30:37",
176
+ "actor": "Assembly (Committee CX25)"
177
+ },
178
+ {
179
+ "date": "2009-05-03 20:00:00",
180
+ "action": "From committee chair, with author's amendments: Amend, and re-refer to Com. on APPR. Read second time and amended.",
181
+ "updated_at": "2010-03-27 21:30:37",
182
+ "actor": "Assembly (E&E Engrossing)"
183
+ },
184
+ {
185
+ "date": "2009-04-28 20:00:00",
186
+ "action": "From committee: Do pass, and re-refer to Com. on APPR. with recommendation: To Consent Calendar. Re-referred. (Ayes 10. Noes 0.) (April 28).",
187
+ "updated_at": "2010-03-27 21:30:37",
188
+ "actor": "Assembly (Committee)"
189
+ },
190
+ {
191
+ "date": "2009-04-14 20:00:00",
192
+ "action": "From committee: Do pass, and re-refer to Com. on B. & P. with recommendation: To Consent Calendar. Re-referred. (Ayes 19. Noes 0.) (April 14).",
193
+ "updated_at": "2010-03-27 21:30:37",
194
+ "actor": "Assembly (Committee)"
195
+ },
196
+ {
197
+ "date": "2009-04-12 20:00:00",
198
+ "action": "Re-referred to Com. on HEALTH.",
199
+ "updated_at": "2010-03-27 21:30:37",
200
+ "actor": "Assembly (Committee CX08)"
201
+ },
202
+ {
203
+ "date": "2009-04-01 20:00:00",
204
+ "action": "From committee chair, with author's amendments: Amend, and re-refer to Com. on HEALTH. Read second time and amended.",
205
+ "updated_at": "2010-03-27 21:30:37",
206
+ "actor": "Assembly (E&E Engrossing)"
207
+ },
208
+ {
209
+ "date": "2009-03-22 20:00:00",
210
+ "action": "Referred to Com. on HEALTH.",
211
+ "updated_at": "2010-03-27 21:30:37",
212
+ "actor": "Assembly (Committee CX08)"
213
+ },
214
+ {
215
+ "date": "2009-02-25 19:00:00",
216
+ "action": "From printer. May be heard in committee March 28.",
217
+ "updated_at": "2010-03-27 21:30:37",
218
+ "actor": "Assembly (Desk)"
219
+ },
220
+ {
221
+ "date": "2009-02-24 19:00:00",
222
+ "action": "Read first time. To print.",
223
+ "updated_at": "2010-03-27 21:30:37",
224
+ "actor": "Assembly (Desk)"
225
+ }
226
+ ],
227
+ "sponsors": [
228
+ {
229
+ "leg_id": 2504,
230
+ "type": "LEAD_AUTHOR",
231
+ "full_name": "Block, Marty"
232
+ }
233
+ ],
234
+ "chamber": "lower",
235
+ "state": "ca",
236
+ "session": "20092010",
237
+ "sources": [],
238
+ "versions": [],
239
+ "bill_id": "AB667"
240
+ }