sunlightcongress 0.0.5 → 0.0.6
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/lib/sunlightcongress.rb +74 -1
- metadata +2 -2
data/lib/sunlightcongress.rb
CHANGED
@@ -6,6 +6,10 @@ class SunlightCongress
|
|
6
6
|
@apikey = apikey
|
7
7
|
end
|
8
8
|
|
9
|
+
# Update gem
|
10
|
+
# Push to github
|
11
|
+
# Add to TT
|
12
|
+
|
9
13
|
# Get legislator ID
|
10
14
|
def legislator_id(name)
|
11
15
|
options = {:query => {:apikey => @apikey} }
|
@@ -78,13 +82,82 @@ class SunlightCongress
|
|
78
82
|
|
79
83
|
# Get all events (hearings, votes, bills, amendments, floor updates) for a congressperson and output JSON
|
80
84
|
def get_events(id)
|
85
|
+
# Get votes
|
81
86
|
votes = JSON.parse(get_votes(id))
|
87
|
+
votearray = Array.new
|
88
|
+
votes.each do |v|
|
89
|
+
savehash = Hash.new
|
90
|
+
vhash = Hash[*v.flatten]
|
91
|
+
|
92
|
+
savehash["start time"] = vhash["voted_at"].to_s
|
93
|
+
savehash["end time"] = nil
|
94
|
+
savehash["headline"] = "Vote(" + id + "): " + vhash["question"].to_s
|
95
|
+
savehash["text"] = "roll_type: " + vhash["roll_type"].to_s + " result: " + vhash["result"].to_s + " vote_type: " + vhash["vote_type"].to_s + " url: " + vhash["url"].to_s
|
96
|
+
|
97
|
+
votearray.push(savehash)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Get amendments
|
82
101
|
amendments = JSON.parse(get_amendments(id))
|
102
|
+
amendmentarray = Array.new
|
103
|
+
amendments.each do |a|
|
104
|
+
savehash = Hash.new
|
105
|
+
ahash = Hash[*a.flatten]
|
106
|
+
|
107
|
+
savehash["start time"] = ahash["introduced_on"].to_s
|
108
|
+
savehash["end time"] = ahash["last_action_at"].to_s
|
109
|
+
savehash["headline"] = "Amendment(" + id + "): " + ahash["purpose"].to_s
|
110
|
+
savehash["text"] = "description: " + ahash["description"].to_s + " amends_bill_id: " + ahash["amends_bill_id"].to_s
|
111
|
+
|
112
|
+
amendmentarray.push(savehash)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Get bills
|
83
116
|
bills = JSON.parse(get_bills(id))
|
117
|
+
billarray = Array.new
|
118
|
+
bills.each do |b|
|
119
|
+
savehash = Hash.new
|
120
|
+
bhash = Hash[*b.flatten]
|
121
|
+
|
122
|
+
savehash["start time"] = bhash["introduced_on"].to_s
|
123
|
+
savehash["end time"] = bhash["last_vote_at"].to_s
|
124
|
+
savehash["headline"] = "Bill(" + id + "): " + bhash["short_title"].to_s
|
125
|
+
savehash["text"] = "official_title: " + bhash["official_title"].to_s + " bill_id: " + bhash["bill_id"].to_s
|
126
|
+
|
127
|
+
billarray.push(savehash)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Get updates
|
84
131
|
updates = JSON.parse(get_updates(id))
|
132
|
+
updatearray = Array.new
|
133
|
+
updates.each do |u|
|
134
|
+
savehash = Hash.new
|
135
|
+
uhash = Hash[*u.flatten]
|
136
|
+
|
137
|
+
savehash["start time"] = uhash["timestamp"].to_s
|
138
|
+
savehash["end time"] = nil
|
139
|
+
savehash["headline"] = "Update(" + id + ")"
|
140
|
+
savehash["text"] = "update: " + uhash["update"].to_s
|
141
|
+
|
142
|
+
updatearray.push(savehash)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Get hearings
|
85
146
|
hearings = JSON.parse(get_hearings_json(get_committees(id)))
|
147
|
+
hearingarray = Array.new
|
148
|
+
hearings.each do |h|
|
149
|
+
savehash = Hash.new
|
150
|
+
hhash = Hash[*h.flatten]
|
151
|
+
|
152
|
+
savehash["start time"] = hhash["occurs_at"].to_s
|
153
|
+
savehash["end time"] = nil
|
154
|
+
savehash["headline"] = "Committee Hearing(" + id + "): " + hhash["description"].to_s
|
155
|
+
savehash["text"] = "committee_id: " + hhash["committee_id"].to_s + " url: " + hhash["url"].to_s
|
156
|
+
|
157
|
+
hearingarray.push(savehash)
|
158
|
+
end
|
86
159
|
|
87
|
-
combinedata =
|
160
|
+
combinedata = votearray + amendmentarray + billarray + updatearray + hearingarray
|
88
161
|
combinedata.to_json
|
89
162
|
end
|
90
163
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunlightcongress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Access to Sunlight Foundation's congress data.
|
15
15
|
email: shidash@shidash.com
|