hulse 0.0.1 → 0.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.
- checksums.yaml +8 -8
- data/README.md +2 -2
- data/hulse.gemspec +1 -0
- data/lib/hulse/house_vote.rb +21 -21
- data/lib/hulse/senate_vote.rb +27 -27
- data/lib/hulse/version.rb +1 -1
- data/lib/hulse.rb +10 -33
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2U1NzMxZWVmZWZmZDI3YTQ5YWNkNzg2ODIyMzE3NWI1ZjM2MWY3Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTlkN2I2N2EyOWIwNTQ4Y2YyZWIwN2JlYWZkYmVmYzE0ZDcxNWU5NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGM4NzAzMjNjM2FiYzA2ZWFlMDBlNjQyZTk4Yzk2NGEwYWI2NDkyMTFhYjAw
|
10
|
+
NWFjMGYzOThiMmY0YmY4NmZjYzljNjkzZGY1MDQwMjQ3MDhjZWM5ZmMxNTBk
|
11
|
+
NWE2NmI2N2U3MGRkMWJiZTlmMWIyMGQ5MzRhYjNjMGZjOGEzYjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Njk5MWY2MTE2ZGI0OWRkZjU1MWMzNzg2ZjNiMTZmN2FhZGExMzI3MDk2MDI0
|
14
|
+
OWEyM2I2ZDQyYjc3NWZjYTJhZGUwNzY2MzcxNWM0YzBlYTg2NjJhNDAyNTcz
|
15
|
+
ZTVkMGI4MjhiZDE2MTE3MmMzNGJmNmRlOGY3MDU3YzEzNjRhOWY=
|
data/README.md
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Hulse is a Ruby gem for accessing House and Senate roll call votes from the official sources on [house.gov](http://clerk.house.gov/evs/2013/index.asp) and [senate.gov](http://www.senate.gov/pagelayout/legislative/a_three_sections_with_teasers/votes.htm). It is developed under Ruby 1.9.3.
|
4
4
|
|
5
|
-
Hulse has two classes, `HouseVote` and `SenateVote
|
5
|
+
Hulse has two classes, `HouseVote` and `SenateVote`, which create Ruby objects using the XML attributes available from roll call vote data (voice votes are not covered by Hulse or available as data from official sources). Hulse makes a few changes, renaming some attributes for clarity and consistency, and collapsing each House vote's date and time into a single datetime attribute. Otherwise it does not alter the original data.
|
6
6
|
|
7
7
|
`HouseVote` and `SenateVote` have different attributes due to parliamentary conventions and the presence or absence of data in one chamber or the other. Senators are uniquely identified by a `lis_member_id`; House members are uniquely identified by a `bioguide_id` beginning in 2003. Prior to 2003, there is no unique ID for House members, but using a combination of name, state and political party one can be manfactured. House member attributes also include an `unaccented_name` and an `name` attribute that may contain accent characters.
|
8
8
|
|
9
|
-
Hulse is named for Carl Hulse, a longtime congressional correspondent for The New York Times.
|
9
|
+
Hulse is named for [Carl Hulse](https://www.nytimes.com/learning/students/ask_reporters/Carl_Hulse.html), a longtime congressional correspondent for The New York Times.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
data/hulse.gemspec
CHANGED
data/lib/hulse/house_vote.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
module Hulse
|
2
2
|
class HouseVote
|
3
|
-
|
3
|
+
|
4
4
|
attr_reader :majority, :congress, :session, :chamber, :vote_number, :bill_number, :question, :vote_type, :vote_result, :vote_timestamp, :description,
|
5
5
|
:party_summary, :vote_count, :members, :amendment_number, :amendment_author
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(params={})
|
8
8
|
params.each_pair do |k,v|
|
9
9
|
instance_variable_set("@#{k}", v)
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
12
12
|
|
13
13
|
def self.find(year, vote)
|
14
|
-
url = "http://clerk.house.gov/evs/#{year.to_s}/roll#{vote}.xml"
|
14
|
+
url = "http://clerk.house.gov/evs/#{year.to_s}/roll#{vote.to_s.rjust(3,"0")}.xml"
|
15
15
|
response = HTTParty.get(url)
|
16
16
|
self.create_from_vote(response.parsed_response['rollcall_vote'])
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def self.create_from_vote(response)
|
20
20
|
party_totals = []
|
21
21
|
response['vote_metadata']['vote_totals']['totals_by_party'].each do |p|
|
@@ -29,22 +29,22 @@ module Hulse
|
|
29
29
|
m['legislator']['vote'] = m['vote']
|
30
30
|
members << m['legislator'].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
31
31
|
end
|
32
|
-
self.new(:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
32
|
+
self.new(majority: response['vote_metadata']['majority'],
|
33
|
+
congress: response['vote_metadata']['congress'].to_i,
|
34
|
+
session: response['vote_metadata']['session'],
|
35
|
+
chamber: response['vote_metadata']['chamber'],
|
36
|
+
vote_number: response['vote_metadata']['rollcall_num'].to_i,
|
37
|
+
bill_number: response['vote_metadata']['legis_num'],
|
38
|
+
question: response['vote_metadata']['vote_question'],
|
39
|
+
amendment_number: response['vote_metadata']['amendment_num'],
|
40
|
+
amendment_author: response['vote_metadata']['amendment_author'],
|
41
|
+
vote_type: response['vote_metadata']['vote_type'],
|
42
|
+
vote_result: response['vote_metadata']['vote_result'],
|
43
|
+
vote_timestamp: DateTime.parse(response['vote_metadata']['action_date'] + ' ' + response['vote_metadata']['action_time']['time_etz']),
|
44
|
+
description: response['vote_metadata']['vote_desc'],
|
45
|
+
party_summary: party_totals,
|
46
|
+
vote_count: response['vote_metadata']['vote_totals']['totals_by_vote'].reject{|k,v| k == 'total_stub'}.inject({}){|memo,(k,v)| memo[k.to_sym] = v.to_i; memo},
|
47
|
+
members: members)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/hulse/senate_vote.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
1
|
module Hulse
|
2
2
|
class SenateVote
|
3
|
-
|
4
|
-
attr_reader :congress, :session, :year, :vote_number, :vote_timestamp, :updated_at, :vote_question_text, :vote_document_text,
|
3
|
+
|
4
|
+
attr_reader :congress, :session, :year, :vote_number, :vote_timestamp, :updated_at, :vote_question_text, :vote_document_text,
|
5
5
|
:vote_result_text, :question, :vote_title, :majority_requirement, :vote_result, :document, :amendment, :vote_count, :tie_breaker, :members
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(params={})
|
8
8
|
params.each_pair do |k,v|
|
9
9
|
instance_variable_set("@#{k}", v)
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def self.find(year, vote)
|
14
14
|
# TODO: need to special-case 2013 votes from 112th congress, 2nd session
|
15
15
|
congress, session = Hulse::Utils.convert_year_to_congress_and_session(year)
|
16
|
-
url = "http://www.senate.gov/legislative/LIS/roll_call_votes/vote#{congress
|
16
|
+
url = "http://www.senate.gov/legislative/LIS/roll_call_votes/vote#{congress}#{session}/vote_#{congress}_#{session}_#{vote.to_s.rjust(5,"0")}.xml"
|
17
17
|
response = HTTParty.get(url)
|
18
18
|
self.create_from_vote(response.parsed_response['roll_call_vote'])
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def self.create_from_vote(response)
|
22
22
|
members = []
|
23
23
|
response['members']['member'].each do |m|
|
24
24
|
members << m.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
25
25
|
end
|
26
|
-
self.new(:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
)
|
26
|
+
self.new(congress: response['congress'].to_i,
|
27
|
+
session: response['session'].to_i,
|
28
|
+
year: response['congress_year'].to_i,
|
29
|
+
vote_number: response['vote_number'].to_i,
|
30
|
+
vote_timestamp: DateTime.parse(response['vote_date']),
|
31
|
+
updated_at: DateTime.parse(response['modify_date']),
|
32
|
+
vote_question_text: response['vote_question_text'],
|
33
|
+
vote_document_text: response['vote_document_text'],
|
34
|
+
vote_result_text: response['vote_result_text'],
|
35
|
+
question: response['question'],
|
36
|
+
vote_title: response['vote_title'],
|
37
|
+
majority_requirement: response['majority_requirement'],
|
38
|
+
vote_result: response['vote_result'],
|
39
|
+
document: response['document'].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo},
|
40
|
+
amendment: response['amendment'].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo},
|
41
|
+
vote_count: response['count'].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo},
|
42
|
+
tie_breaker: response['tie_breaker'].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo},
|
43
|
+
members: members
|
44
|
+
)
|
45
45
|
end
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
end
|
49
49
|
end
|
data/lib/hulse/version.rb
CHANGED
data/lib/hulse.rb
CHANGED
@@ -6,42 +6,19 @@ require 'oj'
|
|
6
6
|
|
7
7
|
module Hulse
|
8
8
|
class Utils
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
2009 => 111,
|
17
|
-
2008 => 110,
|
18
|
-
2007 => 110,
|
19
|
-
2006 => 109,
|
20
|
-
2005 => 109,
|
21
|
-
2004 => 108,
|
22
|
-
2003 => 108,
|
23
|
-
2002 => 107,
|
24
|
-
2001 => 107,
|
25
|
-
2000 => 106,
|
26
|
-
1999 => 106,
|
27
|
-
1998 => 106,
|
28
|
-
1997 => 105,
|
29
|
-
1996 => 105,
|
30
|
-
1995 => 104,
|
31
|
-
1994 => 104,
|
32
|
-
1993 => 103,
|
33
|
-
1992 => 103,
|
34
|
-
1991 => 102,
|
35
|
-
1990 => 102,
|
36
|
-
1989 => 101
|
37
|
-
}
|
38
|
-
|
9
|
+
|
10
|
+
# this function is more intuitive when you solve for the other side:
|
11
|
+
# year = 1789 + (2 * (congress - 1))
|
12
|
+
def self.congress_for_year(year)
|
13
|
+
((year.to_i + 1) / 2) - 894
|
14
|
+
end
|
15
|
+
|
39
16
|
def self.convert_year_to_congress_and_session(year)
|
40
|
-
congress =
|
17
|
+
congress = congress_for_year year
|
41
18
|
session = year.odd? ? 1 : 2
|
42
19
|
return [congress, session]
|
43
20
|
end
|
44
|
-
|
45
|
-
|
21
|
+
|
22
|
+
|
46
23
|
end
|
47
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hulse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Willis
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: oj
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Turns House and Senate votes into Ruby objects for your legislative pleasure.
|
56
70
|
email:
|
57
71
|
- dwillis@gmail.com
|