congress 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/LICENSE.md +1 -1
- data/README.md +25 -29
- data/congress.gemspec +3 -4
- data/lib/congress.rb +0 -26
- data/lib/congress/client.rb +15 -25
- data/lib/congress/connection.rb +6 -4
- data/lib/congress/version.rb +43 -1
- metadata +7 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c322571660c22a62b5ac3a1dcf9e94c6b919341e
|
4
|
+
data.tar.gz: 91f8266395e2b5eff9730419759f412814ad8050
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7e3753cae8bd88f29fac104b9461e51ebe38f790de0ec4a33d2d73d66242b946276b2e3074d2aa2dd23672da4835efa3332face317895c74b6d4fc5bcae05f9
|
7
|
+
data.tar.gz: 32cc75b113a7e0c3e07eba143d1d18422d394b9bb8a04d65e6c32cfd218975236aaea9536c00a6127b402a8aa9ee2f5fedc56b51db584860d72f9af800f1abfe
|
data/.travis.yml
CHANGED
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# Ruby wrapper for the Sunlight Congress API
|
2
2
|
|
3
|
-
[![Gem Version](
|
4
|
-
[![Build Status](
|
5
|
-
[![Dependency Status](
|
6
|
-
[![Code Climate](
|
7
|
-
[![Coverage Status](
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/congress.svg)][gem]
|
4
|
+
[![Build Status](https://travis-ci.org/codeforamerica/congress.svg?branch=master)][travis]
|
5
|
+
[![Dependency Status](https://gemnasium.com/codeforamerica/congress.svg)][gemnasium]
|
6
|
+
[![Code Climate](https://codeclimate.com/github/codeforamerica/congress/badges/gpa.svg)][codeclimate]
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/codeforamerica/congress/badge.svg?branch=master&service=github)][coveralls]
|
8
8
|
|
9
9
|
[gem]: https://rubygems.org/gems/congress
|
10
|
-
[travis]:
|
10
|
+
[travis]: https://travis-ci.org/codeforamerica/congress
|
11
11
|
[gemnasium]: https://gemnasium.com/codeforamerica/congress
|
12
12
|
[codeclimate]: https://codeclimate.com/github/codeforamerica/congress
|
13
|
-
[coveralls]: https://coveralls.io/
|
13
|
+
[coveralls]: https://coveralls.io/github/codeforamerica/congress?branch=master
|
14
14
|
|
15
15
|
The Sunlight Congress API is a live JSON API for the people and work of
|
16
16
|
Congress, provided by the Sunlight Foundation.
|
@@ -23,70 +23,68 @@ Congress, provided by the Sunlight Foundation.
|
|
23
23
|
[documentation]: http://rdoc.info/gems/congress
|
24
24
|
|
25
25
|
## Authentication
|
26
|
-
|
27
26
|
All requests to the Congress API require a Sunlight API key. An API key is
|
28
27
|
[free to register][register] and has no usage limits.
|
29
28
|
|
30
29
|
[register]: http://services.sunlightlabs.com/accounts/register/
|
31
30
|
|
32
31
|
## Usage Examples
|
33
|
-
|
34
32
|
###### Setup
|
35
33
|
```ruby
|
36
34
|
require 'congress'
|
37
|
-
|
35
|
+
client = Congress::Client.new(YOUR_SUNLIGHT_API_KEY)
|
38
36
|
```
|
39
37
|
|
40
38
|
###### Fetch current legislators' names, IDs, biography, and social media
|
41
39
|
```ruby
|
42
|
-
|
40
|
+
client.legislators
|
43
41
|
```
|
44
42
|
|
45
43
|
###### Fetch representatives and senators for a latitude/longitude or zip code
|
46
44
|
```ruby
|
47
|
-
|
48
|
-
|
45
|
+
client.legislators_locate(37.775, -122.418)
|
46
|
+
client.legislators_locate('94107')
|
49
47
|
```
|
50
48
|
|
51
49
|
###### Fetch congressional districts for a latitude/longitude or zip code
|
52
50
|
```ruby
|
53
|
-
|
54
|
-
|
51
|
+
client.districts_locate(37.775, -122.418)
|
52
|
+
client.districts_locate('94107')
|
55
53
|
```
|
56
54
|
|
57
55
|
###### Fetch current committees, subcommittees, and their membership
|
58
56
|
```ruby
|
59
|
-
|
57
|
+
client.committees
|
60
58
|
```
|
61
59
|
|
62
60
|
###### Fetch legislation in the House and Senate
|
63
61
|
```ruby
|
64
|
-
|
62
|
+
client.bills
|
65
63
|
```
|
66
64
|
|
67
65
|
###### Fetch legislation related to health care
|
68
66
|
```ruby
|
69
|
-
|
67
|
+
client.bills_search(:query => "health care")
|
70
68
|
```
|
71
69
|
|
72
70
|
###### Fetch roll call votes in Congress
|
73
71
|
```ruby
|
74
|
-
|
72
|
+
client.votes
|
75
73
|
```
|
76
74
|
|
77
75
|
###### Fetch to-the-minute updates from the floor of the House and Senate
|
78
76
|
```ruby
|
79
|
-
|
77
|
+
client.floor_updates
|
80
78
|
```
|
81
79
|
|
82
80
|
###### Fetch committee hearings in Congress
|
83
81
|
```ruby
|
84
|
-
|
82
|
+
client.hearings
|
85
83
|
```
|
86
84
|
|
87
85
|
###### Fetch bills scheduled for debate in the future, as announced by party leadership
|
88
86
|
```ruby
|
89
|
-
|
87
|
+
client.upcoming_bills
|
90
88
|
```
|
91
89
|
|
92
90
|
## Supported Ruby Versions
|
@@ -95,12 +93,10 @@ implementations:
|
|
95
93
|
|
96
94
|
* Ruby 1.9.3
|
97
95
|
* Ruby 2.0.0
|
98
|
-
* Ruby 2.1
|
99
|
-
*
|
100
|
-
*
|
101
|
-
|
102
|
-
[jruby]: http://www.jruby.org/
|
103
|
-
[rubinius]: http://rubini.us/
|
96
|
+
* Ruby 2.1
|
97
|
+
* Ruby 2.2
|
98
|
+
* JRuby 1.7
|
99
|
+
* JRuby 9.0.0.0
|
104
100
|
|
105
101
|
If something doesn't work on one of these interpreters, it should be considered
|
106
102
|
a bug.
|
@@ -117,6 +113,6 @@ timely fashion. If critical issues for a particular implementation exist at the
|
|
117
113
|
time of a major release, support for that Ruby version may be dropped.
|
118
114
|
|
119
115
|
## Copyright
|
120
|
-
Copyright (c) 2011-
|
116
|
+
Copyright (c) 2011-2015, Code for America. See [LICENSE][] for details.
|
121
117
|
|
122
118
|
[license]: https://github.com/codeforamerica/congress/blob/master/LICENSE.md
|
data/congress.gemspec
CHANGED
@@ -3,9 +3,8 @@ require File.expand_path('../lib/congress/version', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.add_dependency 'faraday', '~> 0.9.0'
|
6
|
-
spec.add_dependency 'faraday_middleware', '~> 0.
|
7
|
-
spec.add_dependency 'hashie', '~>
|
8
|
-
spec.add_dependency 'rash', '~> 0.4'
|
6
|
+
spec.add_dependency 'faraday_middleware', '~> 0.10.0'
|
7
|
+
spec.add_dependency 'hashie', '~> 3.0'
|
9
8
|
spec.add_dependency 'geocoder', '~> 1.2'
|
10
9
|
spec.add_development_dependency 'bundler', '~> 1.0'
|
11
10
|
spec.author = 'Erik Michaels-Ober'
|
@@ -18,5 +17,5 @@ Gem::Specification.new do |spec|
|
|
18
17
|
spec.require_paths = ['lib']
|
19
18
|
spec.required_ruby_version = '>= 1.9.3'
|
20
19
|
spec.summary = 'Ruby wrapper for the Sunlight Congress API'
|
21
|
-
spec.version = Congress::
|
20
|
+
spec.version = Congress::Version
|
22
21
|
end
|
data/lib/congress.rb
CHANGED
@@ -1,27 +1 @@
|
|
1
1
|
require 'congress/client'
|
2
|
-
|
3
|
-
module Congress
|
4
|
-
extend self # rubocop:disable ModuleFunction
|
5
|
-
attr_accessor :key
|
6
|
-
|
7
|
-
# Alias for Congress::Client.new
|
8
|
-
#
|
9
|
-
# @return [Congress::Client]
|
10
|
-
def new(key = key)
|
11
|
-
yield self if block_given?
|
12
|
-
return @client if instance_variable_defined?(:@client) && @client.key == key
|
13
|
-
@client = Congress::Client.new(key)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Delegate to Congress::Client
|
17
|
-
def method_missing(method, *args, &block)
|
18
|
-
return super unless new.respond_to?(method)
|
19
|
-
new.send(method, *args, &block)
|
20
|
-
end
|
21
|
-
|
22
|
-
# @return [Boolean]
|
23
|
-
def respond_to?(method, include_private = false) new.respond_to?(method, include_private) end if RUBY_VERSION < '1.9' # rubocop:disable SingleLineMethods
|
24
|
-
|
25
|
-
# @return [Boolean]
|
26
|
-
def respond_to_missing?(method_name, include_private = false) new.respond_to?(method_name, include_private) end if RUBY_VERSION >= '1.9' # rubocop:disable SingleLineMethods
|
27
|
-
end
|
data/lib/congress/client.rb
CHANGED
@@ -16,8 +16,7 @@ module Congress
|
|
16
16
|
#
|
17
17
|
# @return [Hashie::Rash]
|
18
18
|
# @example
|
19
|
-
#
|
20
|
-
# Congress.legislators
|
19
|
+
# client.legislators
|
21
20
|
def legislators(options = {})
|
22
21
|
get('/legislators', options)
|
23
22
|
end
|
@@ -26,10 +25,9 @@ module Congress
|
|
26
25
|
#
|
27
26
|
# @return [Hashie::Rash]
|
28
27
|
# @example
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# Congress.legislators_locate('2169 Mission Street, San Francisco, CA 94110')
|
28
|
+
# client.legislators_locate('94107')
|
29
|
+
# client.legislators_locate(37.775, -122.418)
|
30
|
+
# client.legislators_locate('2169 Mission Street, San Francisco, CA 94110')
|
33
31
|
def legislators_locate(*args)
|
34
32
|
get('/legislators/locate', extract_location(args))
|
35
33
|
end
|
@@ -38,10 +36,9 @@ module Congress
|
|
38
36
|
#
|
39
37
|
# @return [Hashie::Rash]
|
40
38
|
# @example
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
# Congress.districts_locate('2169 Mission Street, San Francisco, CA 94110')
|
39
|
+
# client.districts_locate('94107')
|
40
|
+
# client.districts_locate(37.775, -122.418)
|
41
|
+
# client.districts_locate('2169 Mission Street, San Francisco, CA 94110')
|
45
42
|
def districts_locate(*args)
|
46
43
|
get('/districts/locate', extract_location(args))
|
47
44
|
end
|
@@ -50,8 +47,7 @@ module Congress
|
|
50
47
|
#
|
51
48
|
# @return [Hashie::Rash]
|
52
49
|
# @example
|
53
|
-
#
|
54
|
-
# Congress.committees
|
50
|
+
# client.committees
|
55
51
|
def committees(options = {})
|
56
52
|
get('/committees', options)
|
57
53
|
end
|
@@ -60,8 +56,7 @@ module Congress
|
|
60
56
|
#
|
61
57
|
# @return [Hashie::Rash]
|
62
58
|
# @example
|
63
|
-
#
|
64
|
-
# Congress.bills
|
59
|
+
# client.bills
|
65
60
|
def bills(options = {})
|
66
61
|
get('/bills', options)
|
67
62
|
end
|
@@ -70,8 +65,7 @@ module Congress
|
|
70
65
|
#
|
71
66
|
# @return [Hashie::Rash]
|
72
67
|
# @example
|
73
|
-
#
|
74
|
-
# Congress.bills_search
|
68
|
+
# client.bills_search
|
75
69
|
def bills_search(options = {})
|
76
70
|
get('/bills/search', options)
|
77
71
|
end
|
@@ -80,8 +74,7 @@ module Congress
|
|
80
74
|
#
|
81
75
|
# @return [Hashie::Rash]
|
82
76
|
# @example
|
83
|
-
#
|
84
|
-
# Congress.votes
|
77
|
+
# client.votes
|
85
78
|
def votes(options = {})
|
86
79
|
get('/votes', options)
|
87
80
|
end
|
@@ -90,18 +83,16 @@ module Congress
|
|
90
83
|
#
|
91
84
|
# @return [Hashie::Rash]
|
92
85
|
# @example
|
93
|
-
#
|
94
|
-
# Congress.floor_updates
|
86
|
+
# client.floor_updates
|
95
87
|
def floor_updates(options = {})
|
96
88
|
get('/floor_updates', options)
|
97
89
|
end
|
98
90
|
|
99
|
-
# Committee hearings in
|
91
|
+
# Committee hearings in client. Updated as hearings are announced.
|
100
92
|
#
|
101
93
|
# @return [Hashie::Rash]
|
102
94
|
# @example
|
103
|
-
#
|
104
|
-
# Congress.hearings
|
95
|
+
# client.hearings
|
105
96
|
def hearings(options = {})
|
106
97
|
get('/hearings', options)
|
107
98
|
end
|
@@ -110,8 +101,7 @@ module Congress
|
|
110
101
|
#
|
111
102
|
# @return [Hashie::Rash]
|
112
103
|
# @example
|
113
|
-
#
|
114
|
-
# Congress.upcoming_bills
|
104
|
+
# client.upcoming_bills
|
115
105
|
def upcoming_bills(options = {})
|
116
106
|
get('/upcoming_bills', options)
|
117
107
|
end
|
data/lib/congress/connection.rb
CHANGED
@@ -18,10 +18,12 @@ module Congress
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def middlewares
|
21
|
-
[
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
[
|
22
|
+
Faraday::Request::UrlEncoded,
|
23
|
+
Faraday::Response::RaiseError,
|
24
|
+
Faraday::Response::Mashify,
|
25
|
+
Faraday::Response::ParseJson,
|
26
|
+
]
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
data/lib/congress/version.rb
CHANGED
@@ -1,3 +1,45 @@
|
|
1
1
|
module Congress
|
2
|
-
|
2
|
+
module Version
|
3
|
+
module_function
|
4
|
+
|
5
|
+
# @return [Integer]
|
6
|
+
def major
|
7
|
+
0
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [Integer]
|
11
|
+
def minor
|
12
|
+
3
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Integer]
|
16
|
+
def patch
|
17
|
+
0
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [Integer, NilClass]
|
21
|
+
def pre
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Hash]
|
26
|
+
def to_h
|
27
|
+
{
|
28
|
+
major: major,
|
29
|
+
minor: minor,
|
30
|
+
patch: patch,
|
31
|
+
pre: pre,
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Array]
|
36
|
+
def to_a
|
37
|
+
to_h.values.compact
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def to_s
|
42
|
+
to_a.join('.')
|
43
|
+
end
|
44
|
+
end
|
3
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: congress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Michaels-Ober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -30,42 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.10.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.10.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hashie
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rash
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.4'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.4'
|
54
|
+
version: '3.0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: geocoder
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
123
|
version: '0'
|
138
124
|
requirements: []
|
139
125
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.4.
|
126
|
+
rubygems_version: 2.4.5
|
141
127
|
signing_key:
|
142
128
|
specification_version: 4
|
143
129
|
summary: Ruby wrapper for the Sunlight Congress API
|