congress 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6f9234cbf7d9536bb2e50c670633efbf02c7038
4
- data.tar.gz: a4664f6a79651dc2e4a05e2731b6edc4cacc0b80
3
+ metadata.gz: 5516ea302639f934b2fcba072da933205a5bec83
4
+ data.tar.gz: 9af7c88cd0983c83a733c577a01e9f44727ad67c
5
5
  SHA512:
6
- metadata.gz: d4c5500a56021013a611f81c24ec5b6cd5b92ef6e73397ad075a3ec929fb968102adf193e8483c7171bbd7a014d17a3df7b5a8b23ca81777b9e1e7172b10d708
7
- data.tar.gz: 82a3854a324a88e56cb341689a2f10211ecafdcc169426595b87ed9250911f3e66c66ad415965dad1fdc4b5027b49493b460804b5be8b6a9475e57340d4cfc28
6
+ metadata.gz: 1779fe53f8cddf90e2f3772fd52fc662230c99505be175ae88a48116327d9663b096e283daa0826776e55cbcb35e7ee0c64332ea9ce8a96215a1f9cb3264a3bb
7
+ data.tar.gz: d77c88f13a9c5d87503eec2952eeab89fdce5507c1358ccc80a7c5219d5d9f6a50756d4ff08a9823c840b3c9f525b32f312c775c204cae68339dd4e1eae4e7b7
@@ -1,43 +1,36 @@
1
1
  AllCops:
2
- Includes:
2
+ Include:
3
3
  - 'Gemfile'
4
4
  - 'Rakefile'
5
5
  - 'congress.gemspec'
6
6
 
7
7
  # Avoid long parameter lists
8
8
  ParameterLists:
9
- Max: 4
9
+ Max: 3
10
10
  CountKeywordArgs: true
11
11
 
12
+ ClassLength:
13
+ Max: 60
14
+
15
+ LineLength:
16
+ Enabled: false
17
+
12
18
  MethodLength:
13
19
  CountComments: false
14
- Max: 15
20
+ Max: 14
15
21
 
16
22
  # Avoid more than `Max` levels of nesting.
17
23
  BlockNesting:
18
- Max: 3
24
+ Max: 2
19
25
 
20
26
  # Align with the style guide.
21
27
  CollectionMethods:
22
28
  PreferredMethods:
23
- collect: 'map'
24
- inject: 'reduce'
29
+ map: 'collect'
30
+ reduce: 'inject'
25
31
  find: 'detect'
26
32
  find_all: 'select'
27
33
 
28
- # Do not force public/protected/private keyword to be indented at the same
29
- # level as the def keyword. My personal preference is to outdent these keywords
30
- # because I think when scanning code it makes it easier to identify the
31
- # sections of code and visually separate them. When the keyword is at the same
32
- # level I think it sort of blends in with the def keywords and makes it harder
33
- # to scan the code and see where the sections are.
34
- AccessModifierIndentation:
35
- Enabled: false
36
-
37
- # Limit line length
38
- LineLength:
39
- Enabled: false
40
-
41
34
  # Disable documentation checking until a class needs to be documented once
42
35
  Documentation:
43
36
  Enabled: false
@@ -77,5 +70,20 @@ CaseIndentation:
77
70
  Lambda:
78
71
  Enabled: false
79
72
 
73
+ RaiseArgs:
74
+ EnforcedStyle: compact
75
+
76
+ PercentLiteralDelimiters:
77
+ PreferredDelimiters:
78
+ '%': ()
79
+ '%i': ()
80
+ '%q': ()
81
+ '%Q': ()
82
+ '%r': '{}'
83
+ '%s': ()
84
+ '%w': '[]'
85
+ '%W': '[]'
86
+ '%x': ()
87
+
80
88
  NumericLiterals:
81
89
  Enabled: false
data/Gemfile CHANGED
@@ -19,7 +19,7 @@ group :test do
19
19
  gem 'coveralls', :require => false
20
20
  gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
21
21
  gem 'rspec', '>= 2.14'
22
- gem 'rubocop', '>= 0.16', :platforms => [:ruby_19, :ruby_20, :ruby_21]
22
+ gem 'rubocop', '>= 0.20', :platforms => [:ruby_19, :ruby_20, :ruby_21]
23
23
  gem 'simplecov', :require => false
24
24
  gem 'webmock'
25
25
  gem 'yardstick'
data/README.md CHANGED
@@ -45,13 +45,13 @@ Congress.legislators
45
45
  ###### Fetch representatives and senators for a latitude/longitude or zip code
46
46
  ```ruby
47
47
  Congress.legislators_locate(37.775, -122.418)
48
- Congress.legislators_locate(94107)
48
+ Congress.legislators_locate('94107')
49
49
  ```
50
50
 
51
51
  ###### Fetch congressional districts for a latitude/longitude or zip code
52
52
  ```ruby
53
53
  Congress.districts_locate(37.775, -122.418)
54
- Congress.districts_locate(94107)
54
+ Congress.districts_locate('94107')
55
55
  ```
56
56
 
57
57
  ###### Fetch current committees, subcommittees, and their membership
@@ -10,14 +10,14 @@ Gem::Specification.new do |spec|
10
10
  spec.add_dependency 'geocoder', '~> 1.1.9'
11
11
  spec.add_development_dependency 'bundler', '~> 1.0'
12
12
  spec.author = 'Erik Michaels-Ober'
13
- spec.description = %q{Ruby wrapper for the Sunlight Congress API, a live JSON API for the people and work of Congress, provided by the Sunlight Foundation.}
13
+ spec.description = %q(Ruby wrapper for the Sunlight Congress API, a live JSON API for the people and work of Congress, provided by the Sunlight Foundation.)
14
14
  spec.email = 'sferik@gmail.com'
15
15
  spec.files = `git ls-files`.split("\n")
16
16
  spec.homepage = 'https://github.com/codeforamerica/congress'
17
17
  spec.licenses = ['MIT']
18
18
  spec.name = 'congress'
19
19
  spec.require_paths = ['lib']
20
- spec.summary = %q{Ruby wrapper for the Sunlight Congress API}
20
+ spec.summary = %q(Ruby wrapper for the Sunlight Congress API)
21
21
  spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
22
  spec.version = Congress::VERSION
23
23
  end
@@ -27,7 +27,7 @@ module Congress
27
27
  # @return [Hashie::Rash]
28
28
  # @example
29
29
  # Congress.key = YOUR_SUNLIGHT_API_KEY
30
- # Congress.legislators_locate(94107)
30
+ # Congress.legislators_locate('94107')
31
31
  # Congress.legislators_locate(37.775, -122.418)
32
32
  # Congress.legislators_locate('2169 Mission Street, San Francisco, CA 94110')
33
33
  def legislators_locate(*args)
@@ -39,7 +39,7 @@ module Congress
39
39
  # @return [Hashie::Rash]
40
40
  # @example
41
41
  # Congress.key = YOUR_SUNLIGHT_API_KEY
42
- # Congress.districts_locate(94107)
42
+ # Congress.districts_locate('94107')
43
43
  # Congress.districts_locate(37.775, -122.418)
44
44
  # Congress.districts_locate('2169 Mission Street, San Francisco, CA 94110')
45
45
  def districts_locate(*args)
@@ -120,24 +120,26 @@ module Congress
120
120
 
121
121
  def extract_location(args)
122
122
  options = args.last.is_a?(::Hash) ? args.pop : {}
123
- case [args.size, args.first.class]
124
- when [1, Fixnum]
125
- options.merge(:zip => to_zip_code(args.pop))
126
- when [1, String]
127
- placemark = Geocoder.search(args.pop).first
128
- options.merge(:longitude => placemark.longitude, :latitude => placemark.latitude)
129
- when [2, Float]
130
- options.merge(:longitude => args.pop, :latitude => args.pop)
131
- else
132
- fail ArgumentError, 'Must pass a latitude/longitude, zip or address'
123
+ case args.size
124
+ when 1
125
+ case args[0]
126
+ when Integer, /\A[\d]{5}\Z/
127
+ options.merge!(:zip => to_zip_code(args[0]))
128
+ when String
129
+ placemark = Geocoder.search(args[0]).first
130
+ options.merge!(:latitude => placemark.latitude, :longitude => placemark.longitude)
131
+ end
132
+ when 2
133
+ options.merge!(:latitude => args[0], :longitude => args[1])
133
134
  end
135
+ options
134
136
  end
135
137
 
136
138
  # Proper zip code from a number, adding leading zeroes if required
137
139
  # @param number [Integer] zip code as an integer
138
140
  # @return [String]
139
141
  def to_zip_code(number)
140
- sprintf('%05d', number)
142
+ format('%05d', number.to_i)
141
143
  end
142
144
  end
143
145
  end
@@ -1,3 +1,3 @@
1
1
  module Congress
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
@@ -38,6 +38,12 @@ describe Congress::Client do
38
38
  expect(a_get('/legislators/locate?zip=06511').with(:headers => {'X-APIKEY' => 'abc123'})).to have_been_made
39
39
  end
40
40
  end
41
+ context 'zip code as string' do
42
+ it 'interprets five-digit strings as zip codes' do
43
+ @client.legislators_locate('06511')
44
+ expect(a_get('/legislators/locate?zip=06511').with(:headers => {'X-APIKEY' => 'abc123'})).to have_been_made
45
+ end
46
+ end
41
47
  end
42
48
  context 'with a latitude and longitude passed' do
43
49
  before do
@@ -65,11 +71,6 @@ describe Congress::Client do
65
71
  expect(legislators_locate['results'].first.bioguide_id).to eq('P000197')
66
72
  end
67
73
  end
68
- context 'with no arguments passed' do
69
- it 'raises an argument error' do
70
- expect { @client.legislators_locate }.to raise_error ArgumentError
71
- end
72
- end
73
74
  end
74
75
 
75
76
  describe '#districts_locate' do
@@ -111,11 +112,6 @@ describe Congress::Client do
111
112
  expect(districts_locate['results'].first.district).to eq(12)
112
113
  end
113
114
  end
114
- context 'with no arguments passed' do
115
- it 'raises an argument error' do
116
- expect { @client.districts_locate }.to raise_error ArgumentError
117
- end
118
- end
119
115
  end
120
116
 
121
117
  describe '#committees' do
@@ -1,10 +1,7 @@
1
1
  require 'simplecov'
2
2
  require 'coveralls'
3
3
 
4
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
- SimpleCov::Formatter::HTMLFormatter,
6
- Coveralls::SimpleCov::Formatter
7
- ]
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
8
5
 
9
6
  SimpleCov.start do
10
7
  add_filter '/spec/'
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.2.2
4
+ version: 0.2.3
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: 2014-03-06 00:00:00.000000000 Z
11
+ date: 2014-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday