sunlight-congress 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 14b596efff0167886474b2e53744861023cafba6
4
+ data.tar.gz: 034603db8d988f9d005154006047bd28cfb7cd4d
5
+ SHA512:
6
+ metadata.gz: 5f66bce90f5960ee2072833395aac761219fdbae5c5a37957c7b327967f879fa50b1739cb46f3cb3b0d7bf1d3bfcce7171c47c9160dbd7e051341758db0f21e7
7
+ data.tar.gz: f9588c53359d64dea2072bbb841da5162e2b0250f33eb00599ec09ad1ee182da9aaa1467a64c8eb061652db3a49472cbb389b06f25c5553fc117699b26d9b6e2
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - jruby-19mode
7
+ - rbx-19mode
8
+ - ruby-head
9
+
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sunlight-congress.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Steve Klabnik
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Sunlight::Congress
2
+
3
+ This is a wrapper for the [Sunlight Foundation's Congress API](http://sunlightlabs.github.io/congress/).
4
+
5
+ It is very much a work in progress, and only supports part of the API. Any
6
+ assistance with implementing extra calls would be appreciated!
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'sunlight-congress'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install sunlight-congress
21
+
22
+ ## Usage
23
+
24
+ The first thing you need to do is set up an API key. You can apply for one
25
+ [here](http://services.sunlightlabs.com/accounts/register/). They're free and
26
+ have no usage limits.
27
+
28
+ Once you have your key:
29
+
30
+ ```ruby
31
+ Sunlight::Congress.api_key = "lolthisisnotarealkey"
32
+ ```
33
+
34
+ Then, you can build various objects relating to the API. For example:
35
+
36
+ ```ruby
37
+ Sunlight::Congress::Legislator.for_zip("90210")
38
+ => [#<Sunlight::Congress::Legislator:0x007fad4a2f67b0 @first_name="Henry"...
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ t.ruby_opts = ['-r./test/test_helper.rb']
9
+ t.verbose = true
10
+ end
11
+
12
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ require "sunlight/congress/version"
2
+ require "sunlight/congress/legislator"
3
+
4
+ module Sunlight
5
+ module Congress
6
+ def self.api_key
7
+ @api_key
8
+ end
9
+
10
+ def self.api_key=(api_key)
11
+ @api_key = api_key
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module Sunlight
5
+ module Congress
6
+ end
7
+ end
8
+
9
+ class Sunlight::Congress::Legislator
10
+ attr_accessor :first_name
11
+
12
+ def initialize(options)
13
+ self.first_name = options["first_name"]
14
+ end
15
+
16
+ def self.by_zipcode(zipcode)
17
+ uri = URI("http://congress.api.sunlightfoundation.com/legislators/locate?zip=#{zipcode}&apikey=#{Sunlight::Congress.api_key}")
18
+
19
+ JSON.load(Net::HTTP.get(uri))["results"].collect{|json| new(json) }
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ module Sunlight
2
+ module Congress
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sunlight/congress/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sunlight-congress"
8
+ spec.version = Sunlight::Congress::VERSION
9
+ spec.authors = ["Steve Klabnik"]
10
+ spec.email = ["steve@steveklabnik.com"]
11
+ spec.description = %q{A wrapper for the Sunlight Labs Congress API.}
12
+ spec.summary = %q{A wrapper for the Sunlight Labs Congress API.}
13
+ spec.homepage = "https://github.com/steveklabnik/sunlight-congress"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "webmock"
24
+ end
@@ -0,0 +1,18 @@
1
+ require 'sunlight/congress'
2
+ require 'webmock/minitest'
3
+
4
+ class TestIntegrationCongress < MiniTest::Unit::TestCase
5
+ def setup
6
+ Sunlight::Congress.api_key = "thisismykey"
7
+ end
8
+
9
+ def test_legislators_by_zipcode
10
+
11
+ stub_request(:get, "http://congress.api.sunlightfoundation.com/legislators/locate?apikey=thisismykey&zip=90210")
12
+ .to_return(body: '{"results":[{"first_name":"Joe"}]}')
13
+
14
+ legislators = Sunlight::Congress::Legislator.by_zipcode(90210)
15
+
16
+ assert_equal "Joe", legislators.first.first_name
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ require 'minitest/autorun'
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sunlight-congress
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Steve Klabnik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
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
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A wrapper for the Sunlight Labs Congress API.
56
+ email:
57
+ - steve@steveklabnik.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .travis.yml
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/sunlight/congress.rb
69
+ - lib/sunlight/congress/legislator.rb
70
+ - lib/sunlight/congress/version.rb
71
+ - sunlight-congress.gemspec
72
+ - test/integration/legislators_test.rb
73
+ - test/test_helper.rb
74
+ homepage: https://github.com/steveklabnik/sunlight-congress
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.0.0
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: A wrapper for the Sunlight Labs Congress API.
98
+ test_files:
99
+ - test/integration/legislators_test.rb
100
+ - test/test_helper.rb
101
+ has_rdoc: