govkit-h 0.7.1.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.
Files changed (72) hide show
  1. data/.document +5 -0
  2. data/.rspec +3 -0
  3. data/Gemfile +13 -0
  4. data/LICENSE +20 -0
  5. data/README.md +70 -0
  6. data/Rakefile +82 -0
  7. data/USAGE +1 -0
  8. data/VERSION +1 -0
  9. data/generators/govkit/govkit_generator.rb +24 -0
  10. data/generators/govkit/templates/govkit.rb +24 -0
  11. data/govkit.gemspec +130 -0
  12. data/init.rb +4 -0
  13. data/lib/generators/govkit/govkit_generator.rb +21 -0
  14. data/lib/generators/govkit/templates/create_mentions.rb +21 -0
  15. data/lib/generators/govkit/templates/govkit.rb +24 -0
  16. data/lib/generators/govkit/templates/mention.rb +15 -0
  17. data/lib/gov_kit.rb +45 -0
  18. data/lib/gov_kit/acts_as_noteworthy.rb +63 -0
  19. data/lib/gov_kit/configuration.rb +58 -0
  20. data/lib/gov_kit/follow_the_money.rb +176 -0
  21. data/lib/gov_kit/open_congress.rb +125 -0
  22. data/lib/gov_kit/open_congress/bill.rb +171 -0
  23. data/lib/gov_kit/open_congress/blog_post.rb +15 -0
  24. data/lib/gov_kit/open_congress/news_post.rb +15 -0
  25. data/lib/gov_kit/open_congress/person.rb +141 -0
  26. data/lib/gov_kit/open_congress/person_stat.rb +13 -0
  27. data/lib/gov_kit/open_congress/roll_call.rb +14 -0
  28. data/lib/gov_kit/open_congress/roll_call_comparison.rb +28 -0
  29. data/lib/gov_kit/open_congress/voting_comparison.rb +44 -0
  30. data/lib/gov_kit/open_states.rb +132 -0
  31. data/lib/gov_kit/railtie.rb +24 -0
  32. data/lib/gov_kit/resource.rb +190 -0
  33. data/lib/gov_kit/search_engines.rb +7 -0
  34. data/lib/gov_kit/search_engines/bing.rb +38 -0
  35. data/lib/gov_kit/search_engines/google_blog.rb +32 -0
  36. data/lib/gov_kit/search_engines/google_news.rb +47 -0
  37. data/lib/gov_kit/search_engines/technorati.rb +35 -0
  38. data/lib/gov_kit/search_engines/wikipedia.rb +27 -0
  39. data/lib/gov_kit/transparency_data.rb +144 -0
  40. data/lib/gov_kit/vote_smart.rb +126 -0
  41. data/lib/govkit.rb +1 -0
  42. data/spec/fixtures/bing/news_search.response +1 -0
  43. data/spec/fixtures/bing/no_results.response +1 -0
  44. data/spec/fixtures/follow_the_money/business-page0.response +28 -0
  45. data/spec/fixtures/follow_the_money/business-page1.response +12 -0
  46. data/spec/fixtures/follow_the_money/contribution.response +12 -0
  47. data/spec/fixtures/follow_the_money/unauthorized.response +8 -0
  48. data/spec/fixtures/open_congress/person.response +8 -0
  49. data/spec/fixtures/open_states/401.response +10 -0
  50. data/spec/fixtures/open_states/404.response +9 -0
  51. data/spec/fixtures/open_states/410.response +6 -0
  52. data/spec/fixtures/open_states/bill.response +240 -0
  53. data/spec/fixtures/open_states/bill_query.response +1990 -0
  54. data/spec/fixtures/open_states/committee_find.response +53 -0
  55. data/spec/fixtures/open_states/committee_query.response +190 -0
  56. data/spec/fixtures/open_states/legislator.response +34 -0
  57. data/spec/fixtures/open_states/legislator_query.response +144 -0
  58. data/spec/fixtures/open_states/state.response +60 -0
  59. data/spec/fixtures/search_engines/google_news.response +8 -0
  60. data/spec/fixtures/transparency_data/contributions.response +18 -0
  61. data/spec/fixtures/transparency_data/entities_search.response +7 -0
  62. data/spec/fixtures/transparency_data/entities_search_limit_0.response +7 -0
  63. data/spec/fixtures/transparency_data/entities_search_limit_1.response +7 -0
  64. data/spec/fixtures/transparency_data/grants_find_all.response +7 -0
  65. data/spec/fixtures/transparency_data/lobbyists_find_all.response +7 -0
  66. data/spec/follow_the_money_spec.rb +61 -0
  67. data/spec/open_congress_spec.rb +108 -0
  68. data/spec/open_states_spec.rb +213 -0
  69. data/spec/search_engines_spec.rb +44 -0
  70. data/spec/spec_helper.rb +36 -0
  71. data/spec/transparency_data_spec.rb +106 -0
  72. metadata +258 -0
@@ -0,0 +1,44 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module GovKit::SearchEngines
4
+ describe GovKit::SearchEngines do
5
+ before(:all) do
6
+ google_news_uri = "http://news.google.com/"
7
+
8
+ # An array of uris and filenames
9
+ # Use FakeWeb to intercept net requests;
10
+ # if a requested uri matches one of the following,
11
+ # then return the contents of the corresponding file
12
+ # as the result.
13
+ urls = [
14
+ [ "news?q=congress&output=rss&num=50", "google_news.response" ]
15
+ ]
16
+
17
+ urls.each do |u|
18
+ FakeWeb.register_uri(:get, "#{google_news_uri}#{u[0]}", :response => File.join(FIXTURES_DIR, 'search_engines', u[1]))
19
+ end
20
+ end
21
+
22
+ context "#GoogleNews" do
23
+ it "should return results when passed an array" do
24
+ lambda do
25
+ @mentions = GoogleNews.search(["congress"])
26
+ end.should_not raise_error
27
+
28
+ @mentions.should be_an_instance_of(Array)
29
+ @mentions.first.title.should == "White House and Congress Clear Trade Deal Hurdle"
30
+ @mentions.first.source.should == "New York Times"
31
+ end
32
+
33
+ it "should return results when passed a string" do
34
+ lambda do
35
+ @mentions = GoogleNews.search("congress")
36
+ end.should_not raise_error
37
+
38
+ @mentions.should be_an_instance_of(Array)
39
+ @mentions.first.title.should == "White House and Congress Clear Trade Deal Hurdle"
40
+ @mentions.first.source.should == "New York Times"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'rspec'
3
+ require 'fakeweb'
4
+ require File.dirname(__FILE__) + '/../lib/govkit'
5
+
6
+ # prevent the use of `` in tests
7
+ RSpec.configure do |c|
8
+ end
9
+
10
+ # When running specs in TextMate, provide an rputs method to cleanly print objects into HTML display
11
+ # From http://talklikeaduck.denhaven2.com/2009/09/23/rspec-textmate-pro-tip
12
+ module Kernel
13
+ if ENV.keys.find {|env_var| env_var.index("TM_")}
14
+ def rputs(*args)
15
+ require 'cgi'
16
+ puts( *["<pre>", args.collect {|a| CGI.escapeHTML(a.to_s)}, "</pre>"])
17
+ end
18
+ def rp(*args)
19
+ require 'cgi'
20
+ puts( *["<pre>", args.collect {|a| CGI.escapeHTML(a.inspect)}, "</pre>"])
21
+ end
22
+ else
23
+ alias_method :rputs, :puts
24
+ alias_method :rp, :p
25
+ end
26
+ end
27
+
28
+ FakeWeb.allow_net_connect = false
29
+
30
+ FIXTURES_DIR = File.join(File.dirname(__FILE__), 'fixtures')
31
+
32
+ GovKit.configure do |config|
33
+ config.openstates_apikey = 'YOUR_OPENSTATES_API_KEY'
34
+ config.votesmart_apikey = 'YOUR_VOTESMART_API_KEY'
35
+ config.ftm_apikey = 'YOUR_FTM_API_KEY'
36
+ end
@@ -0,0 +1,106 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ # Provides "String.singularize"
4
+ # which is used by resource_for_collection, in resource.rb
5
+ require 'active_support/inflector'
6
+
7
+ # Provides string.last()
8
+ # which is used by method_missing in resource.rb
9
+ require 'active_support/core_ext/string'
10
+
11
+ module GovKit::TransparencyData
12
+
13
+ describe GovKit::TransparencyData do
14
+ before(:all) do
15
+ base_uri = GovKit::TransparencyDataResource.base_uri.gsub(/\./, '\.')
16
+
17
+ urls = [
18
+ ['/contributions.json\?', 'contributions.response'],
19
+ ['/lobbying.json\?', 'lobbyists_find_all.response'],
20
+ ['/grants.json\?', 'grants_find_all.response'],
21
+ ['/entities.json\?apikey=&search=$', 'entities_search.response'],
22
+ ['/entities.json\?apikey=&search=harry%20pelosi', 'entities_search_limit_0.response'],
23
+ ['/entities.json\?apikey=&search=nancy%2Bpelosi', 'entities_search_limit_1.response']
24
+ ]
25
+
26
+ urls.each do |u|
27
+ FakeWeb.register_uri(:get, %r|#{base_uri}#{u[0]}|, :response => File.join(FIXTURES_DIR, 'transparency_data', u[1]))
28
+ end
29
+ end
30
+
31
+ it "should have the base uri set properly" do
32
+ [Contribution, Entity].each do |klass|
33
+ klass.base_uri.should == 'http://transparencydata.com/api/1.0'
34
+ end
35
+ end
36
+ end
37
+
38
+ describe Contribution do
39
+ context "#search" do
40
+ it "should find all contributions" do
41
+ lambda do
42
+ @contributions = Contribution.search
43
+ end.should_not raise_error
44
+
45
+ @contributions.length.should eql(8)
46
+ @contributions[0].contributor_city.should eql("ANCHORAGE")
47
+ end
48
+ end
49
+ end
50
+
51
+ describe Entity do
52
+ context "#search" do
53
+ it "should find all entities" do
54
+ lambda do
55
+ @entities = Entity.search
56
+ end.should_not raise_error
57
+
58
+ @entities.length.should eql(2)
59
+ @entities[0].name.should eql("Nancy Pelosi (D)")
60
+ @entities[1].name.should eql("Nancy Pelosi for Congress")
61
+ end
62
+
63
+ it 'should return an empty list when no elements found' do
64
+ lambda do
65
+ @entities = Entity.search( "harry pelosi" )
66
+ end.should_not raise_error
67
+
68
+ @entities.length.should eql(0)
69
+ end
70
+ it 'should return a list when one element found' do
71
+ lambda do
72
+ @entities = Entity.search( "nancy+pelosi" )
73
+ end.should_not raise_error
74
+
75
+ @entities.length.should eql(1)
76
+ end
77
+ end
78
+ end
79
+
80
+ describe LobbyingRecord do
81
+ context "#search" do
82
+ it "should find all contributions" do
83
+ lambda do
84
+ @records = LobbyingRecord.search
85
+ end.should_not raise_error
86
+
87
+ @records.length.should eql(5)
88
+ @records[0].lobbyists[0].lobbyist_name.should eql('Dunn, Jennifer B')
89
+ end
90
+ end
91
+ end
92
+
93
+ describe Grant do
94
+ context "#search" do
95
+ it "should find all contributions" do
96
+ lambda do
97
+ @records = Grant.search
98
+ end.should_not raise_error
99
+
100
+ @records.length.should eql(3)
101
+ @records[0].project_description.should eql('NATIONAL FLOOD INSURANCE PROGRAM')
102
+ end
103
+ end
104
+ end
105
+ end
106
+
metadata ADDED
@@ -0,0 +1,258 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: govkit-h
3
+ version: !ruby/object:Gem::Version
4
+ hash: 115
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 1
10
+ - 0
11
+ version: 0.7.1.0
12
+ platform: ruby
13
+ authors:
14
+ - Participatory Politics Foundation
15
+ - Srinivas Aki
16
+ - Carl Tashian
17
+ autorequire:
18
+ bindir: bin
19
+ cert_chain: []
20
+
21
+ date: 2011-06-30 00:00:00 Z
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: active_support
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 3
32
+ segments:
33
+ - 0
34
+ version: "0"
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: nokogiri
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: httparty
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: i18n
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ type: :runtime
78
+ version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ name: httparty
81
+ prerelease: false
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 11
88
+ segments:
89
+ - 0
90
+ - 7
91
+ - 4
92
+ version: 0.7.4
93
+ type: :runtime
94
+ version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ name: json
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 1
104
+ segments:
105
+ - 1
106
+ - 4
107
+ - 3
108
+ version: 1.4.3
109
+ type: :runtime
110
+ version_requirements: *id006
111
+ - !ruby/object:Gem::Dependency
112
+ name: nokogiri
113
+ prerelease: false
114
+ requirement: &id007 !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 15
120
+ segments:
121
+ - 1
122
+ - 4
123
+ - 4
124
+ version: 1.4.4
125
+ type: :runtime
126
+ version_requirements: *id007
127
+ - !ruby/object:Gem::Dependency
128
+ name: fastercsv
129
+ prerelease: false
130
+ requirement: &id008 !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ hash: 5
136
+ segments:
137
+ - 1
138
+ - 5
139
+ - 3
140
+ version: 1.5.3
141
+ type: :runtime
142
+ version_requirements: *id008
143
+ description: 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.
144
+ email: develop@opencongress.org
145
+ executables: []
146
+
147
+ extensions: []
148
+
149
+ extra_rdoc_files:
150
+ - LICENSE
151
+ - README.md
152
+ files:
153
+ - .document
154
+ - .rspec
155
+ - Gemfile
156
+ - LICENSE
157
+ - README.md
158
+ - Rakefile
159
+ - USAGE
160
+ - VERSION
161
+ - generators/govkit/govkit_generator.rb
162
+ - generators/govkit/templates/govkit.rb
163
+ - govkit.gemspec
164
+ - init.rb
165
+ - lib/generators/govkit/govkit_generator.rb
166
+ - lib/generators/govkit/templates/govkit.rb
167
+ - lib/generators/govkit/templates/mention.rb
168
+ - lib/generators/govkit/templates/create_mentions.rb
169
+ - lib/gov_kit.rb
170
+ - lib/gov_kit/acts_as_noteworthy.rb
171
+ - lib/gov_kit/configuration.rb
172
+ - lib/gov_kit/follow_the_money.rb
173
+ - lib/gov_kit/open_congress.rb
174
+ - lib/gov_kit/open_congress/bill.rb
175
+ - lib/gov_kit/open_congress/blog_post.rb
176
+ - lib/gov_kit/open_congress/news_post.rb
177
+ - lib/gov_kit/open_congress/person.rb
178
+ - lib/gov_kit/open_congress/person_stat.rb
179
+ - lib/gov_kit/open_congress/roll_call.rb
180
+ - lib/gov_kit/open_congress/roll_call_comparison.rb
181
+ - lib/gov_kit/open_congress/voting_comparison.rb
182
+ - lib/gov_kit/open_states.rb
183
+ - lib/gov_kit/railtie.rb
184
+ - lib/gov_kit/resource.rb
185
+ - lib/gov_kit/search_engines.rb
186
+ - lib/gov_kit/search_engines/bing.rb
187
+ - lib/gov_kit/search_engines/google_blog.rb
188
+ - lib/gov_kit/search_engines/google_news.rb
189
+ - lib/gov_kit/search_engines/technorati.rb
190
+ - lib/gov_kit/search_engines/wikipedia.rb
191
+ - lib/gov_kit/transparency_data.rb
192
+ - lib/gov_kit/vote_smart.rb
193
+ - lib/govkit.rb
194
+ - spec/fixtures/bing/news_search.response
195
+ - spec/fixtures/bing/no_results.response
196
+ - spec/fixtures/follow_the_money/business-page0.response
197
+ - spec/fixtures/follow_the_money/business-page1.response
198
+ - spec/fixtures/follow_the_money/contribution.response
199
+ - spec/fixtures/follow_the_money/unauthorized.response
200
+ - spec/fixtures/open_congress/person.response
201
+ - spec/fixtures/open_states/401.response
202
+ - spec/fixtures/open_states/404.response
203
+ - spec/fixtures/open_states/410.response
204
+ - spec/fixtures/open_states/bill.response
205
+ - spec/fixtures/open_states/bill_query.response
206
+ - spec/fixtures/open_states/committee_find.response
207
+ - spec/fixtures/open_states/committee_query.response
208
+ - spec/fixtures/open_states/legislator.response
209
+ - spec/fixtures/open_states/legislator_query.response
210
+ - spec/fixtures/open_states/state.response
211
+ - spec/fixtures/search_engines/google_news.response
212
+ - spec/fixtures/transparency_data/contributions.response
213
+ - spec/fixtures/transparency_data/entities_search.response
214
+ - spec/fixtures/transparency_data/entities_search_limit_0.response
215
+ - spec/fixtures/transparency_data/entities_search_limit_1.response
216
+ - spec/fixtures/transparency_data/grants_find_all.response
217
+ - spec/fixtures/transparency_data/lobbyists_find_all.response
218
+ - spec/follow_the_money_spec.rb
219
+ - spec/open_congress_spec.rb
220
+ - spec/open_states_spec.rb
221
+ - spec/search_engines_spec.rb
222
+ - spec/spec_helper.rb
223
+ - spec/transparency_data_spec.rb
224
+ homepage: http://github.com/opengovernment/govkit
225
+ licenses: []
226
+
227
+ post_install_message:
228
+ rdoc_options: []
229
+
230
+ require_paths:
231
+ - lib
232
+ required_ruby_version: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ hash: 3
238
+ segments:
239
+ - 0
240
+ version: "0"
241
+ required_rubygems_version: !ruby/object:Gem::Requirement
242
+ none: false
243
+ requirements:
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ hash: 3
247
+ segments:
248
+ - 0
249
+ version: "0"
250
+ requirements: []
251
+
252
+ rubyforge_project:
253
+ rubygems_version: 1.8.15
254
+ signing_key:
255
+ specification_version: 3
256
+ summary: Simple access to open government APIs around the web
257
+ test_files: []
258
+