sunlightpartytime 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sunlightpartytime.rb +35 -0
- metadata +47 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
class SunlightPartyTime
|
5
|
+
def initialize(apikey)
|
6
|
+
@apikey = apikey
|
7
|
+
end
|
8
|
+
|
9
|
+
# Make clean event
|
10
|
+
# Integrate with TT
|
11
|
+
# Test with tables
|
12
|
+
# Test with timelinegen
|
13
|
+
|
14
|
+
# Get legislator ID
|
15
|
+
def crp_id(name)
|
16
|
+
options = {:query => {:apikey => @apikey} }
|
17
|
+
namearray = name.split(" ")
|
18
|
+
data = HTTParty.get("http://congress.api.sunlightfoundation.com/legislators?query="+namearray.last, options)["results"]
|
19
|
+
|
20
|
+
data.each do |l|
|
21
|
+
dhash = Hash[*l.flatten]
|
22
|
+
if data.length > 1
|
23
|
+
return dhash["crp_id"] if dhash["first_name"] == namearray.first
|
24
|
+
else return dhash["crp_id"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get all events a legislator is a beneficiary of
|
30
|
+
def parties(cid)
|
31
|
+
options = {:query => {:apikey => @apikey} }
|
32
|
+
data = HTTParty.get("http://politicalpartytime.org/api/v1/event/?beneficiaries__crp_id=" + cid.to_s + "&format=json", options)["objects"]
|
33
|
+
return data.to_json
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sunlightpartytime
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- M. C. McGrath
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Access to Sunlight Foundation's Party Time data.
|
15
|
+
email: shidash@shidash.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/sunlightpartytime.rb
|
21
|
+
homepage: https://github.com/Shidash/sunlightpartytime
|
22
|
+
licenses:
|
23
|
+
- GPL
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 1.8.23
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: Wrapper for Sunlight Foundation's Party Time API
|
46
|
+
test_files: []
|
47
|
+
has_rdoc:
|