hulse 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ded08df41744269d3ff29c0963310cd71c6d9a2f
4
- data.tar.gz: f78c202e8f5f140586d990db213fe68f0726ae14
3
+ metadata.gz: 904848309e824d9e0c4ded85597ba3f0e7409d46
4
+ data.tar.gz: 9dc85ec003bf1b9c1c5cd3b8602150413109b283
5
5
  SHA512:
6
- metadata.gz: f6d939fd1e7ec77e20e8b9c2cd472ffc574bfd5c17e4abd941d200163abae7cc4b3f2f0684b4690597aa19b994f753ac17a08ec0a0c5412e0d161d2939285bbf
7
- data.tar.gz: 0abd003544ed00748fbf56f337d929652b357336ba552146534a01d6326400cbf3db9c389430f301e7b7787fc1240ec8e7abcc07f55c929091c376575fe8260c
6
+ metadata.gz: 8277fdc3417493c205504d907a17b68aa4d5d9dcb5cd8a7898e4f21db786912450814749218468ee997e1dffde0d3f97eed145ffba2edf89dff804dd22862f0c
7
+ data.tar.gz: 97c18eccfd0850e1b116223e132ee5b066881b1b472e250489baa59d48b80ca30df3d6ebef679685a19adff93babfebdb9b4ec973941a8427adf5f791827137d
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Hulse
2
2
 
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 works using Ruby 1.9.3 and 2.0.0.
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 works using Ruby 1.9.3 and 2.x.
4
4
 
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.
5
+ Hulse has two vote 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
- `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.
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 manufactured. House member attributes also include an `unaccented_name` and a `name` attribute that may contain accent characters.
8
+
9
+ Hulse also has two member classes, `HouseMember` and `SenateMember`, which create Ruby objects using the XML made available by the Clerk of the House and the Secretary of the Senate. House members have some basic information, including the unique `bioguide_id`, along with office details and committee and subcommittee assignment data. For vacant seats, information on the seat's previous occupant is available. Senate members have less information, but their data includes the Senate class and the URLs of their websites and email forms.
8
10
 
9
11
  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
12
 
data/hulse.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Hulse::VERSION
9
9
  spec.authors = ["Derek Willis"]
10
10
  spec.email = ["dwillis@gmail.com"]
11
- spec.summary = %q{Hulse is a Ruby gem for accessing House and Senate roll call votes from the official sources on house.gov and senate.gov}
12
- spec.description = %q{Turns House and Senate votes into Ruby objects for your legislative pleasure.}
11
+ spec.summary = %q{Hulse is a Ruby gem for accessing House and Senate roll call votes and member data from the official sources on house.gov and senate.gov}
12
+ spec.description = %q{Turns House and Senate votes and members into Ruby objects for your legislative pleasure.}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "minitest"
24
24
  spec.add_dependency "httparty"
25
25
  spec.add_dependency "oj"
26
+ spec.add_dependency "american_date"
26
27
  end
@@ -0,0 +1,68 @@
1
+ module Hulse
2
+ class HouseMember
3
+
4
+ attr_reader :bioguide_id, :sort_name, :last_name, :first_name, :middle_name, :suffix, :courtesy, :official_name,
5
+ :formal_name, :party, :caucus_party, :state_postal, :state_name, :district_code, :hometown, :office_building,
6
+ :office_room, :office_zip, :phone, :last_elected_date, :sworn_date, :committees, :subcommittees, :is_vacant,
7
+ :footnote, :predecessor, :vacancy_date
8
+
9
+ def initialize(params={})
10
+ params.each_pair do |k,v|
11
+ instance_variable_set("@#{k}", v)
12
+ end
13
+ end
14
+
15
+ def self.current
16
+ url = "http://clerk.house.gov/xml/lists/MemberData.xml"
17
+ response = HTTParty.get(url)
18
+ self.create_from_xml(response)
19
+ end
20
+
21
+
22
+ def self.create_from_xml(response)
23
+ members = []
24
+ response['MemberData']['members']['member'].each do |member|
25
+ if member['member_info']['elected_date']['date'] == ''
26
+ footnote = member['member_info']['footnote']
27
+ predecessor = member['predecessor_info']
28
+ vacancy_date = Date.parse(member['predecessor_info']['pred_vacate_date']['date'])
29
+ vacant = true
30
+ else
31
+ footnote, predecessor, vacancy_date = nil
32
+ vacant = false
33
+ end
34
+
35
+ members << self.new(bioguide_id: member['member_info']['bioguideID'],
36
+ sort_name: member['member_info']['sort_name'],
37
+ last_name: member['member_info']['lastname'],
38
+ first_name: member['member_info']['firstname'],
39
+ middle_name: member['member_info']['middlename'],
40
+ suffix: member['member_info']['suffix'],
41
+ courtesy: member['member_info']['courtesy'],
42
+ official_name: member['member_info']['official_name'],
43
+ formal_name: member['member_info']['formal_name'],
44
+ party: member['member_info']['party'],
45
+ caucus_party: member['member_info']['caucus'],
46
+ state_postal: member['member_info']['state']['postal_code'],
47
+ state_name: member['member_info']['state']['state_fullname'],
48
+ district: member['member_info']['district'],
49
+ district_code: member['statedistrict'],
50
+ hometown: member['member_info']['townname'],
51
+ office_building: member['member_info']['office_building'],
52
+ office_room: member['member_info']['office_room'],
53
+ office_zip: member['member_info']['office_zip']+'-'+member['member_info']['office_zip_suffix'],
54
+ phone: member['member_info']['phone'],
55
+ last_elected_date: begin Date.parse(member['member_info']['elected_date']['date']) rescue nil end,
56
+ sworn_date: begin Date.parse(member['member_info']['sworn_date']['date']) rescue nil end,
57
+ committees: member['committee_assignments']['committee'],
58
+ subcommittees: member['committee_assignments']['subcommittee'],
59
+ is_vacant: vacant,
60
+ footnote: footnote,
61
+ predecessor: predecessor,
62
+ vacancy_date: vacancy_date
63
+ )
64
+ end
65
+ members
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,39 @@
1
+ module Hulse
2
+ class SenateMember
3
+
4
+ attr_reader :bioguide_id, :last_name, :first_name, :title, :senate_class, :address, :email, :website,
5
+ :party, :state_postal
6
+
7
+ def initialize(params={})
8
+ params.each_pair do |k,v|
9
+ instance_variable_set("@#{k}", v)
10
+ end
11
+ end
12
+
13
+ def self.current
14
+ url = "http://www.senate.gov/general/contact_information/senators_cfm.xml"
15
+ response = HTTParty.get(url)
16
+ self.create_from_xml(response)
17
+ end
18
+
19
+
20
+ def self.create_from_xml(response)
21
+ members = []
22
+ response['contact_information']['member'].each do |member|
23
+ members << self.new(bioguide_id: member['bioguide_id'],
24
+ title: member['member_full'],
25
+ last_name: member['last_name'],
26
+ first_name: member['first_name'],
27
+ party: member['party'],
28
+ state_postal: member['state'],
29
+ senate_class: member['class'],
30
+ address: member['address'],
31
+ phone: member['phone'],
32
+ email: member['email'],
33
+ website: member['website']
34
+ )
35
+ end
36
+ members
37
+ end
38
+ end
39
+ end
data/lib/hulse/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hulse
2
- VERSION = "0.4"
2
+ VERSION = "0.5"
3
3
  end
data/lib/hulse.rb CHANGED
@@ -2,7 +2,9 @@ require 'httparty'
2
2
  require 'oj'
3
3
  require "hulse/version"
4
4
  require "hulse/house_vote"
5
+ require "hulse/house_member"
5
6
  require "hulse/senate_vote"
7
+ require "hulse/senate_member"
6
8
 
7
9
  module Hulse
8
10
  class Utils
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hulse
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Willis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,22 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: Turns House and Senate votes into Ruby objects for your legislative pleasure.
83
+ - !ruby/object:Gem::Dependency
84
+ name: american_date
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Turns House and Senate votes and members into Ruby objects for your legislative
98
+ pleasure.
84
99
  email:
85
100
  - dwillis@gmail.com
86
101
  executables: []
@@ -94,7 +109,9 @@ files:
94
109
  - Rakefile
95
110
  - hulse.gemspec
96
111
  - lib/hulse.rb
112
+ - lib/hulse/house_member.rb
97
113
  - lib/hulse/house_vote.rb
114
+ - lib/hulse/senate_member.rb
98
115
  - lib/hulse/senate_vote.rb
99
116
  - lib/hulse/version.rb
100
117
  - test/test_helper.rb
@@ -122,8 +139,9 @@ rubyforge_project:
122
139
  rubygems_version: 2.2.2
123
140
  signing_key:
124
141
  specification_version: 4
125
- summary: Hulse is a Ruby gem for accessing House and Senate roll call votes from the
126
- official sources on house.gov and senate.gov
142
+ summary: Hulse is a Ruby gem for accessing House and Senate roll call votes and member
143
+ data from the official sources on house.gov and senate.gov
127
144
  test_files:
128
145
  - test/test_helper.rb
129
146
  - test/utils_test.rb
147
+ has_rdoc: