govkit 0.6.0 → 0.6.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.
- data/README.md +14 -1
- data/VERSION +1 -1
- data/generators/govkit/templates/govkit.rb +7 -1
- data/govkit.gemspec +3 -4
- data/lib/gov_kit/acts_as_noteworthy.rb +3 -3
- data/lib/gov_kit/resource.rb +7 -0
- data/lib/gov_kit/search_engines/google_blog.rb +8 -13
- data/lib/gov_kit.rb +1 -0
- metadata +6 -6
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Govkit
|
2
2
|
|
3
|
-
Govkit is a Ruby gem that provides simple access to open government APIs around the web, including:
|
3
|
+
Govkit is a Ruby gem that provides simple access to US open government APIs around the web, including:
|
4
4
|
|
5
5
|
* [OpenCongress](http://www.opencongress.org/api), which has an API for federal bills, votes, people, and news and blog coverage
|
6
6
|
* [The Open States project](http://fiftystates-dev.sunlightlabs.com/), which has a RESTful API for accessing data about state legislators, bills, votes, etc.
|
@@ -51,4 +51,17 @@ Please join the [Govkit Google Group](http://groups.google.com/group/govkit), es
|
|
51
51
|
|
52
52
|
Govkit's main repo is on Github: [http://github.com/opengovernment/govkit](http://github.com/opengovernment/govkit), where your contributions, forks, and feedback are greatly welcomed.
|
53
53
|
|
54
|
+
# Dear Canadians
|
55
|
+
|
56
|
+
For Canadian open government data, our friends up north have created a [govkit-ca](https://github.com/jpmckinney/govkit-ca) gem that lives in the GovKit::CA namespace and should interoperate just fine with this gem.
|
57
|
+
|
58
|
+
# A GovKit for your country?
|
59
|
+
|
60
|
+
Let us know if you'd like to build a govkit for your region! We'd love to link to you. Your gem should be called, for example, govkit-uk (ISO 3166 country code), and your methods should live in the GovKit::GB namespace (for example).
|
61
|
+
|
62
|
+
# TODOs
|
63
|
+
|
64
|
+
* Guaranteed Eachability: If an API call is expected to return zero or more records, then GovKit should always return an array or nil to the caller, not a single object, even if there's only one record returned in this particular API call.
|
65
|
+
* Migration & documentation for acts_as_noteworthy
|
66
|
+
|
54
67
|
Copyright (c) 2010 Participatory Politics Foundation, released under the MIT license
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
@@ -2,7 +2,7 @@ if defined? GovKit
|
|
2
2
|
GovKit.configure do |config|
|
3
3
|
# Get an API key for Sunlight's Open States project here:
|
4
4
|
# http://services.sunlightlabs.com/accounts/register/
|
5
|
-
config.
|
5
|
+
config.sunlight_apikey = 'YOUR_SUNLIGHT_API_KEY'
|
6
6
|
|
7
7
|
##API key for Votesmart
|
8
8
|
# http://votesmart.org/services_api.php
|
@@ -15,5 +15,11 @@ if defined? GovKit
|
|
15
15
|
# Api key for OpenCongress
|
16
16
|
# http://www.opencongress.org/api
|
17
17
|
config.opencongress_apikey = 'YOUR_OPENCONGRESS_API_KEY'
|
18
|
+
|
19
|
+
# Technorati API key
|
20
|
+
config.technorati_apikey = 'YOUR_TECHNORATI_APIKEY'
|
21
|
+
|
22
|
+
# Other things you could set here include alternate URLs for
|
23
|
+
# the APIs. See GovKit::Configuration for available attributes.
|
18
24
|
end
|
19
25
|
end
|
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.6.
|
8
|
+
s.version = "0.6.1"
|
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{2011-
|
12
|
+
s.date = %q{2011-03-03}
|
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{develop@opencongress.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -71,7 +71,7 @@ Gem::Specification.new do |s|
|
|
71
71
|
]
|
72
72
|
s.homepage = %q{http://github.com/opengovernment/govkit}
|
73
73
|
s.require_paths = ["lib"]
|
74
|
-
s.rubygems_version = %q{1.
|
74
|
+
s.rubygems_version = %q{1.5.2}
|
75
75
|
s.summary = %q{Simple access to open government APIs around the web}
|
76
76
|
s.test_files = [
|
77
77
|
"spec/follow_the_money_spec.rb",
|
@@ -80,7 +80,6 @@ Gem::Specification.new do |s|
|
|
80
80
|
]
|
81
81
|
|
82
82
|
if s.respond_to? :specification_version then
|
83
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
84
83
|
s.specification_version = 3
|
85
84
|
|
86
85
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -16,9 +16,9 @@ module GovKit::ActsAsNoteworthy
|
|
16
16
|
has_many :mentions, :as => :owner
|
17
17
|
|
18
18
|
with_options :as => :owner, :class_name => "Mention" do |c|
|
19
|
-
c.has_many :google_news_mentions, :conditions => {:search_source => "Google News"}
|
20
|
-
c.has_many :google_blog_mentions, :conditions => {:search_source => "Google Blogs"}
|
21
|
-
c.has_many :technorati_mentions, :conditions => {:search_source => "Technorati"}
|
19
|
+
c.has_many :google_news_mentions, :conditions => {:search_source => "Google News"}, :order => 'date desc'
|
20
|
+
c.has_many :google_blog_mentions, :conditions => {:search_source => "Google Blogs"}, :order => 'date desc'
|
21
|
+
c.has_many :technorati_mentions, :conditions => {:search_source => "Technorati"}, :order => 'date desc'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
data/lib/gov_kit/resource.rb
CHANGED
@@ -13,6 +13,13 @@ module GovKit
|
|
13
13
|
unload(attributes)
|
14
14
|
end
|
15
15
|
|
16
|
+
# Returns a hash of the response object, potentially useful for comparison
|
17
|
+
# on sync
|
18
|
+
#
|
19
|
+
def to_md5
|
20
|
+
@md5 = Digest::MD5.hexdigest(@raw_response.body)
|
21
|
+
end
|
22
|
+
|
16
23
|
def self.parse(response)
|
17
24
|
# This method handles the basic responses we might get back from
|
18
25
|
# Net::HTTP. But if a service returns something other than a 404 when an object is not found,
|
@@ -4,24 +4,19 @@ module GovKit
|
|
4
4
|
def self.search(options=[])
|
5
5
|
query = options.join('+')
|
6
6
|
host = GovKit::configuration.google_blog_base_url
|
7
|
-
path = "/
|
7
|
+
path = "/blogsearch_feeds?q=#{URI::encode(query)}&hl=en&output=rss&num=50"
|
8
8
|
|
9
|
-
doc = Nokogiri::
|
10
|
-
stories = doc.search("td.j")
|
11
|
-
titles = (doc/"a").select { |a| (a.attributes["id"] && a.attributes["id"].value.match(/p-(.*)/)) }
|
9
|
+
doc = Nokogiri::XML(make_request(host, path))
|
12
10
|
|
13
11
|
mentions = []
|
14
12
|
|
15
|
-
|
13
|
+
doc.xpath('//item').each do |i|
|
16
14
|
mention = GovKit::Mention.new
|
17
|
-
|
18
|
-
|
19
|
-
mention.
|
20
|
-
|
21
|
-
mention.
|
22
|
-
mention.excerpt = (story.at("br + font").text) #.unpack("C*").pack("U*")
|
23
|
-
mention.source = story.at("a.f1").text
|
24
|
-
mention.url = story.at("a.f1").attributes["href"].value
|
15
|
+
mention.title = i.xpath('title').inner_text
|
16
|
+
mention.date = i.xpath('dc:date').inner_text
|
17
|
+
mention.excerpt = i.xpath('description').inner_text
|
18
|
+
mention.source = i.xpath('dc:publisher').inner_text
|
19
|
+
mention.url = i.xpath('link').inner_text
|
25
20
|
|
26
21
|
mentions << mention
|
27
22
|
end
|
data/lib/gov_kit.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 5
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 1
|
10
|
+
version: 0.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Participatory Politics Foundation
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
20
|
+
date: 2011-03-03 00:00:00 -08:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
requirements: []
|
176
176
|
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 1.
|
178
|
+
rubygems_version: 1.5.2
|
179
179
|
signing_key:
|
180
180
|
specification_version: 3
|
181
181
|
summary: Simple access to open government APIs around the web
|