Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit b528271f2dd34da29525d46bfaf16198c21a2c08 0 parents
@sferik sferik authored
1  .autotest
@@ -0,0 +1 @@
+require 'autotest/bundler'
0  .gemtest
No changes.
41 .gitignore
@@ -0,0 +1,41 @@
+!.gitignore
+*.gem
+*.rbc
+*.sw[a-p]
+*.tmproj
+*.tmproject
+*.un~
+*~
+.DS_Store
+.Spotlight-V100
+.Trashes
+._*
+.bundle
+.config
+.directory
+.elc
+.redcar
+.yardoc
+/.emacs.desktop
+/.emacs.desktop.lock
+Desktop.ini
+Gemfile.lock
+Icon?
+InstalledFiles
+Session.vim
+Thumbs.db
+\#*\#
+_yardoc
+auto-save-list
+coverage
+doc/
+lib/bundler/man
+pkg
+pkg/*
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
+tmtags
+tramp
3  .rspec
@@ -0,0 +1,3 @@
+--color
+--format=nested
+--backtrace
7 .travis.yml
@@ -0,0 +1,7 @@
+rvm:
+ - 1.8.7
+ - 1.9.1
+ - 1.9.2
+ - jruby
+ - ree
+ - ruby-head
3  .yardopts
@@ -0,0 +1,3 @@
+--markup markdown
+-
+LICENSE.md
7 Gemfile
@@ -0,0 +1,7 @@
+source 'http://rubygems.org'
+
+platforms :jruby do
+ gem 'jruby-openssl', '~> 0.7'
+end
+
+gemspec
10 LICENSE.md
@@ -0,0 +1,10 @@
+Copyright (c) 2011, Code for America
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+* Neither the name of Code for America nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
99 README.md
@@ -0,0 +1,99 @@
+# Ruby wrapper for the Real-Time Congress API
+
+The Real Time Congress (RTC) API is a RESTful API over the artifacts of
+Congress, in as close to real-time as possible.
+
+Installation
+------------
+ gem install congress
+
+Documentation
+-------------
+[http://rdoc.info/gems/congress](http://rdoc.info/gems/congress)
+
+Continuous Integration
+----------------------
+[![Build Status](http://travis-ci.org/codeforamerica/congress.png)](http://travis-ci.org/codeforamerica/congress)
+
+Usage Examples
+--------------
+ require 'rubygems'
+ require 'congress'
+
+ # An API key is required
+ # You can obtain one from http://services.sunlightlabs.com/accounts/register/
+ Congress.key = YOUR_RTC_API_KEY
+
+ # Fetch bills introduced bills and resolutions in Congress
+ puts Congress.bills
+
+ # Fetch votes taken in Congress
+ puts Congress.votes
+
+ # Fetch amendments to bills and resolutions offered in Congress
+ puts Congress.amendments
+
+ # Fetch videos from the U.S. House of Representatives and from the White House
+ puts Congress.videos
+
+ # Fetch updates from the floor of each chamber of Congress
+ puts Congress.floor_updates
+
+ # Fetch upcoming scheduled committee hearings in the House and Senate
+ puts Congress.committee_hearings
+
+ # Fetch links to various kinds of documents produced by agencies within Congress
+ puts Congress.documents
+
+Contributing
+------------
+In the spirit of [free
+software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is
+encouraged to help improve this project.
+
+Here are some ways *you* can contribute:
+
+* by using alpha, beta, and prerelease versions
+* by reporting bugs
+* by suggesting new features
+* by writing or editing documentation
+* by writing specifications
+* by writing code (**no patch is too small**: fix typos, add comments, clean up
+ inconsistent whitespace)
+* by refactoring code
+* by closing [issues](https://github.com/codeforamerica/congress/issues)
+* by reviewing patches
+
+Submitting an Issue
+-------------------
+We use the [GitHub issue tracker](https://github.com/codeforamerica/congress/issues) to
+track bugs and features. Before submitting a bug report or feature request,
+check to make sure it hasn't already been submitted. You can indicate support
+for an existing issuse by voting it up. When submitting a bug report, please
+include a [Gist](https://gist.github.com/) that includes a stack trace and any
+details that may be necessary to reproduce the bug, including your gem version,
+Ruby version, and operating system. Ideally, a bug report should include a pull
+request with failing specs.
+
+Submitting a Pull Request
+-------------------------
+1. Fork the project.
+2. Create a topic branch.
+3. Implement your feature or bug fix.
+4. Add documentation for your feature or bug fix.
+5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100%
+ documented, go back to step 4.
+6. Add specs for your feature or bug fix.
+7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go
+ back to step 6.
+8. Commit and push your changes.
+9. Submit a pull request. Please do not include changes to the gemspec,
+ version, or history file. (If you want to create your own version for some
+ reason, please do so in a separate commit.)
+
+Copyright
+---------
+Copyright (c) 2011, Code for America. All rights reserved.
+See [LICENSE](https://github.com/codeforamerica/congress/blob/master/LICENSE.md) for details.
+
+[![Code for America Tracker](http://stats.codeforamerica.org/codeforamerica/congress.png)](http://stats.codeforamerica.org/projects/congress)
18 Rakefile
@@ -0,0 +1,18 @@
+#!/usr/bin/env rake
+
+require 'bundler'
+Bundler::GemHelper.install_tasks
+
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec)
+
+task :default => :spec
+task :test => :spec
+
+require 'yard'
+namespace :doc do
+ YARD::Rake::YardocTask.new do |task|
+ task.files = ['LICENSE.md', 'lib/**/*.rb']
+ task.options = ['--markup', 'markdown']
+ end
+end
31 congress.gemspec
@@ -0,0 +1,31 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/congress/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.name = 'congress'
+ gem.version = Congress::VERSION
+ gem.author = "Erik Michaels-Ober"
+ gem.email = 'sferik@gmail.com'
+ gem.homepage = 'https://github.com/sferik/congress'
+ gem.summary = %q{Ruby wrapper for the Mt. Gox Trade API}
+ gem.description = %q{Ruby wrapper for the Mt. Gox Trade API. Mt. Gox allows you to trade US Dollars (USD) for Bitcoins (BTC) or Bitcoins for US Dollars.}
+
+ gem.files = `git ls-files`.split("\n")
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
+ gem.require_paths = ['lib']
+
+ gem.add_development_dependency 'ZenTest', '~> 4.5'
+ gem.add_development_dependency 'maruku', '~> 0.6'
+ gem.add_development_dependency 'rake', '~> 0.9'
+ gem.add_development_dependency 'rspec', '~> 2.6'
+ gem.add_development_dependency 'simplecov', '~> 0.4'
+ gem.add_development_dependency 'webmock', '~> 1.6'
+ gem.add_development_dependency 'yard', '~> 0.7'
+
+ gem.add_runtime_dependency 'faraday', '~> 0.6.1'
+ gem.add_runtime_dependency 'faraday_middleware', '~> 0.6.3'
+ gem.add_runtime_dependency 'hashie', '~> 1.0.0'
+ gem.add_runtime_dependency 'multi_json', '~> 1.0.3'
+ gem.add_runtime_dependency 'rash', '~> 0.3.0'
+end
27 lib/congress.rb
@@ -0,0 +1,27 @@
+require 'congress/client'
+
+module Congress
+ class << self
+ attr_accessor :key
+ def configure
+ yield self
+ end
+ end
+
+ # Alias for Congress::Client.new
+ #
+ # @return [Congress::Client]
+ def self.new
+ Congress::Client.new
+ end
+
+ # Delegate to Congress::Client
+ def self.method_missing(method, *args, &block)
+ return super unless new.respond_to?(method)
+ new.send(method, *args, &block)
+ end
+
+ def self.respond_to?(method, include_private=false)
+ new.respond_to?(method, include_private) || super(method, include_private)
+ end
+end
86 lib/congress/client.rb
@@ -0,0 +1,86 @@
+require 'congress/connection'
+require 'congress/request'
+
+module Congress
+ class Client
+ include Congress::Connection
+ include Congress::Request
+
+ # Fetch bills introduced bills and resolutions in Congress
+ #
+ # @return [Hashie::Rash]
+ # @example
+ # Congress.key = YOUR_RTC_API_KEY
+ # Congress.bills
+ def bills(options={})
+ get('/api/v1/bills.json', options.merge(api_key))
+ end
+
+ # Fetch votes taken in Congress
+ #
+ # @return [Hashie::Rash]
+ # @example
+ # Congress.key = YOUR_RTC_API_KEY
+ # Congress.votes
+ def votes(options={})
+ get('/api/v1/votes.json', options.merge(api_key))
+ end
+
+ # Fetch amendments to bills and resolutions offered in Congress
+ #
+ # @return [Hashie::Rash]
+ # @example
+ # Congress.key = YOUR_RTC_API_KEY
+ # Congress.amendments
+ def amendments(options={})
+ get('/api/v1/amendments.json', options.merge(api_key))
+ end
+
+ # Fetch videos from the U.S. House of Representatives and from the White House
+ #
+ # @return [Hashie::Rash]
+ # @example
+ # Congress.key = YOUR_RTC_API_KEY
+ # Congress.videos
+ def videos(options={})
+ get('/api/v1/videos.json', options.merge(api_key))
+ end
+
+ # Fetch updates from the floor of each chamber of Congress
+ #
+ # @return [Hashie::Rash]
+ # @example
+ # Congress.key = YOUR_RTC_API_KEY
+ # Congress.floor_updates
+ def floor_updates(options={})
+ get('/api/v1/floor_updates.json', options.merge(api_key))
+ end
+
+ # Fetch upcoming scheduled committee hearings in the House and Senate
+ #
+ # @return [Hashie::Rash]
+ # @example
+ # Congress.key = YOUR_RTC_API_KEY
+ # Congress.committee_hearings
+ def committee_hearings(options={})
+ get('/api/v1/committee_hearings.json', options.merge(api_key))
+ end
+
+ # Fetch links to various kinds of documents produced by agencies within Congress
+ #
+ # @return [Hashie::Rash]
+ # @example
+ # Congress.key = YOUR_RTC_API_KEY
+ # Congress.documents
+ def documents(options={})
+ get('/api/v1/documents.json', options.merge(api_key))
+ end
+
+ private
+
+ def api_key
+ {:apikey => Congress.key}
+ end
+
+ end
+end
17 lib/congress/connection.rb
@@ -0,0 +1,17 @@
+require 'faraday_middleware'
+
+module Congress
+ module Connection
+ private
+
+ def connection
+ Faraday.new(:url => 'http://api.realtimecongress.org') do |connection|
+ connection.use Faraday::Request::UrlEncoded
+ connection.use Faraday::Response::RaiseError
+ connection.use Faraday::Response::Rashify
+ connection.use Faraday::Response::ParseJson
+ connection.adapter(Faraday.default_adapter)
+ end
+ end
+ end
+end
16 lib/congress/request.rb
@@ -0,0 +1,16 @@
+module Congress
+ module Request
+ def get(path, options={})
+ request(:get, path, options)
+ end
+
+ private
+
+ def request(method, path, options)
+ response = connection.send(method) do |request|
+ request.url(path, options)
+ end
+ response.body
+ end
+ end
+end
3  lib/congress/version.rb
@@ -0,0 +1,3 @@
+module Congress
+ VERSION = "0.0.1"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.