hulse 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -0
- data/hulse.gemspec +1 -0
- data/lib/hulse/house_vote.rb +10 -3
- data/lib/hulse/version.rb +1 -1
- data/lib/hulse.rb +3 -3
- data/test/test_helper.rb +2 -0
- data/test/utils_test.rb +31 -0
- metadata +33 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ded08df41744269d3ff29c0963310cd71c6d9a2f
|
4
|
+
data.tar.gz: f78c202e8f5f140586d990db213fe68f0726ae14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6d939fd1e7ec77e20e8b9c2cd472ffc574bfd5c17e4abd941d200163abae7cc4b3f2f0684b4690597aa19b994f753ac17a08ec0a0c5412e0d161d2939285bbf
|
7
|
+
data.tar.gz: 0abd003544ed00748fbf56f337d929652b357336ba552146534a01d6326400cbf3db9c389430f301e7b7787fc1240ec8e7abcc07f55c929091c376575fe8260c
|
data/Rakefile
CHANGED
data/hulse.gemspec
CHANGED
data/lib/hulse/house_vote.rb
CHANGED
@@ -18,8 +18,10 @@ module Hulse
|
|
18
18
|
|
19
19
|
def self.create_from_vote(response)
|
20
20
|
party_totals = []
|
21
|
-
response['vote_metadata']['vote_totals']['totals_by_party']
|
22
|
-
|
21
|
+
if response['vote_metadata']['vote_totals']['totals_by_party']
|
22
|
+
response['vote_metadata']['vote_totals']['totals_by_party'].each do |p|
|
23
|
+
party_totals << p.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
24
|
+
end
|
23
25
|
end
|
24
26
|
members = []
|
25
27
|
mappings = {"__content__" => "name"}
|
@@ -29,6 +31,11 @@ module Hulse
|
|
29
31
|
m['legislator']['vote'] = m['vote']
|
30
32
|
members << m['legislator'].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
31
33
|
end
|
34
|
+
if response['vote_metadata']['vote_question'] == 'Election of the Speaker'
|
35
|
+
vote_counts = response['vote_metadata']['vote_totals']['totals_by_candidate'].reject{|k,v| k == 'total_stub'}.inject({}){|memo,(k,v)| memo[k['candidate'].to_sym] = k['candidate_total'].to_i; memo}
|
36
|
+
else
|
37
|
+
vote_counts = 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}
|
38
|
+
end
|
32
39
|
self.new(majority: response['vote_metadata']['majority'],
|
33
40
|
congress: response['vote_metadata']['congress'].to_i,
|
34
41
|
session: response['vote_metadata']['session'],
|
@@ -43,7 +50,7 @@ module Hulse
|
|
43
50
|
vote_timestamp: DateTime.parse(response['vote_metadata']['action_date'] + ' ' + response['vote_metadata']['action_time']['time_etz']),
|
44
51
|
description: response['vote_metadata']['vote_desc'],
|
45
52
|
party_summary: party_totals,
|
46
|
-
vote_count:
|
53
|
+
vote_count: vote_counts,
|
47
54
|
members: members)
|
48
55
|
end
|
49
56
|
end
|
data/lib/hulse/version.rb
CHANGED
data/lib/hulse.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'oj'
|
1
3
|
require "hulse/version"
|
2
4
|
require "hulse/house_vote"
|
3
5
|
require "hulse/senate_vote"
|
4
|
-
require 'httparty'
|
5
|
-
require 'oj'
|
6
6
|
|
7
7
|
module Hulse
|
8
8
|
class Utils
|
@@ -15,7 +15,7 @@ module Hulse
|
|
15
15
|
|
16
16
|
def self.convert_year_to_congress_and_session(year)
|
17
17
|
congress = congress_for_year year
|
18
|
-
session = year.odd? ? 1 : 2
|
18
|
+
session = year.to_i.odd? ? 1 : 2
|
19
19
|
return [congress, session]
|
20
20
|
end
|
21
21
|
|
data/test/test_helper.rb
ADDED
data/test/utils_test.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require_relative '../lib/hulse'
|
3
|
+
|
4
|
+
module Hulse
|
5
|
+
class UtilsTest < Minitest::Test
|
6
|
+
def test_congress_for_year
|
7
|
+
assert_equal 101, Utils.congress_for_year(1990)
|
8
|
+
assert_equal 106, Utils.congress_for_year('2000')
|
9
|
+
assert_equal 6, Utils.congress_for_year('1800')
|
10
|
+
assert_equal 1, Utils.congress_for_year('1789')
|
11
|
+
|
12
|
+
# TODO: probably not what is expected
|
13
|
+
assert_equal -4, Utils.congress_for_year('1780')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_convert_year_to_congress_and_session
|
17
|
+
congress, session = Utils.convert_year_to_congress_and_session(1990)
|
18
|
+
assert_equal 101, congress
|
19
|
+
assert_equal 2, session
|
20
|
+
|
21
|
+
congress, session = Utils.convert_year_to_congress_and_session('1789')
|
22
|
+
assert_equal 1, congress
|
23
|
+
assert_equal 1, session
|
24
|
+
|
25
|
+
# TODO: probably not what is expected
|
26
|
+
congress, session = Utils.convert_year_to_congress_and_session('1780')
|
27
|
+
assert_equal -4, congress
|
28
|
+
assert_equal 2, session
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,69 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hulse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Willis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: httparty
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: oj
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
description: Turns House and Senate votes into Ruby objects for your legislative pleasure.
|
@@ -73,7 +87,7 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
|
-
- .gitignore
|
90
|
+
- ".gitignore"
|
77
91
|
- Gemfile
|
78
92
|
- LICENSE.txt
|
79
93
|
- README.md
|
@@ -83,6 +97,8 @@ files:
|
|
83
97
|
- lib/hulse/house_vote.rb
|
84
98
|
- lib/hulse/senate_vote.rb
|
85
99
|
- lib/hulse/version.rb
|
100
|
+
- test/test_helper.rb
|
101
|
+
- test/utils_test.rb
|
86
102
|
homepage: ''
|
87
103
|
licenses:
|
88
104
|
- MIT
|
@@ -93,19 +109,21 @@ require_paths:
|
|
93
109
|
- lib
|
94
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
111
|
requirements:
|
96
|
-
- -
|
112
|
+
- - ">="
|
97
113
|
- !ruby/object:Gem::Version
|
98
114
|
version: '0'
|
99
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
116
|
requirements:
|
101
|
-
- -
|
117
|
+
- - ">="
|
102
118
|
- !ruby/object:Gem::Version
|
103
119
|
version: '0'
|
104
120
|
requirements: []
|
105
121
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.2.2
|
107
123
|
signing_key:
|
108
124
|
specification_version: 4
|
109
125
|
summary: Hulse is a Ruby gem for accessing House and Senate roll call votes from the
|
110
126
|
official sources on house.gov and senate.gov
|
111
|
-
test_files:
|
127
|
+
test_files:
|
128
|
+
- test/test_helper.rb
|
129
|
+
- test/utils_test.rb
|