Code Monkey home page Code Monkey logo

govkit's Introduction

Govkit Build Status

Govkit is a Ruby gem that provides simple access to US open government APIs around the web, including:

Installation

From gemcutter:

gem install govkit

Setup

Add govkit to your environment.rb or Gemfile

Run rails generate govkit (Rails 3.x) or script/generate govkit (Rails 2.x) to copy a config file into config/initializers/govkit.rb. You will need to add your API keys to this config file.

Outside of Rails you can configure your API keys like so:

>> GovKit.configure do |config|
>>   config.sunlight_apikey   = 'YOUR_SUNLIGHT_API_KEY'
>>   config.votesmart_apikey  = 'YOUR_VOTESMART_API_KEY'
>>   config.ftm_apikey        = 'YOUR_FTM_API_KEY'
>> end

Usage Examples

>> GovKit::OpenStates::State.find_by_abbreviation('CA')
>> GovKit::VoteSmart::Address.find(votesmart_candidate_id)
>> GovKit::OpenCongress::Bill.find(:number => 5479, :type => 'h', :congress => '111')

Objects returned from GovKit will have attributes for each field coming back from the API:

>> x = GovKit::OpenStates::State.find_by_abbreviation('CA')
=> #<GovKit::OpenStates::State:0x00000100f6a5a8 @attributes={"lower_chamber_title"=>"Assemblymember", "lower_chamber_name"=>"Assembly", "upper_chamber_title"=>"Senator", "terms"=>[#<GovKit::OpenStates::State::Term:0x00000100f2a8e0 @attributes={"....
>> x.name
=> "California"

GovKit will raise GovKit::ResourceNotFound if a requested item isn't available.

Testing & Debugging

For debugging purposes, there's a raw_response reader provided for each object, which typically returns an HTTParty::Response object. To see the body of the HTTP response, you might look here:

(continuing the example from above)
>> x.raw_response.response.body
=> "{\n    \"lower_chamber_title\": \"Assemblymember\", \n    \"lower_chamber_name\": \"Assembly\", \n  ....

Bugs? Questions?

Please join the Govkit Google Group, especially if you'd like to talk about a new feature and get announcements.

Report a bug on our Lighthouse page.

Govkit's main repo is on Github: http://github.com/opengovernment/govkit, where your contributions, forks, and feedback are greatly welcomed.

Dear Canadians

For Canadian open government data, our friends up north have created a govkit-ca gem that lives in the GovKit::CA namespace and should interoperate just fine with this gem.

A GovKit for your country?

Let us know if you'd like to build a govkit for your region! We'd love to link to you. Your gem should be called, for example, govkit-uk (ISO 3166 country code), and your methods should live in the GovKit::GB namespace (for example).

Copyright (c) 2010 Participatory Politics Foundation, released under the MIT license

govkit's People

Contributors

ajb avatar aross avatar bak avatar eostrom avatar jeff-r avatar mertonium avatar natebarnes avatar oneacross avatar saki avatar tashian avatar whatbird avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

govkit's Issues

Add iconv gem dependency

After installing and adding govkit to my rails project Gemfile, I was unable to run "rails generate" because gov_kit.rb requires iconv. I got it working after installing iconv and adding it to my rails project Gemfile.

Should iconv be added to the govkit Gemfile?

Create rails migration & docs for acts_as_noteworthy

Maybe this should be a separate gem -- but right now it's part of govkit, and is separate from the SearchEngines classes.

It's an ActiveRecord mixin for adding "mentions" to newsworthy objects, like legislators or bills.

I think it needs better documentation and a Rails database migration.

It'd be nice if we could make it ORM-agnostic, also -- but that's perhaps a stretch.

Unsupported repo?

Based on the lack of activity should we understand that this repository's status is inactive or unsupported?

It'd be useful to add the badge to the README if this repo is inactive:

Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.

Markdown:

[![Project Status: Inactive – The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.](https://www.repostatus.org/badges/latest/inactive.svg)](https://www.repostatus.org/#inactive)

Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.

Markdown:

[![Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it. A new maintainer may be desired.](https://www.repostatus.org/badges/latest/unsupported.svg)](https://www.repostatus.org/#unsupported)

Cheers!

Cannot install govkit gem

Fetching: govkit-0.7.2.gem (100%)
ERROR:  Error installing govkit:
    govkit requires govkit (>= 0)

I think you just need to remove the line from the gemspec that makes govkit a dependency:

s.add_dependency(%q<govkit>, [">= 0"])

VERSION error

FYI:

rails generate govkit
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/govkit-0.6.1/lib/gov_kit.rb:13:in <top (required)>': uninitialized constant VERSION (NameError) from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/govkit-0.6.1/lib/govkit.rb:1:in<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.17/lib/bundler/runtime.rb:68:in require' from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.17/lib/bundler/runtime.rb:68:inblock (2 levels) in require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.17/lib/bundler/runtime.rb:66:in each' from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.17/lib/bundler/runtime.rb:66:inblock in require'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.17/lib/bundler/runtime.rb:55:in each' from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.17/lib/bundler/runtime.rb:55:inrequire'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.17/lib/bundler.rb:120:in require' from /home/albertlash/savonix/operations/dev/www.2012-presidential-election.info/config/application.rb:7:in<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:21:in require' from /usr/local/rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0/lib/rails/commands.rb:21:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'

Add support for more Vote Smart API methods

Hey all,

Is there a reason that only select Vote Smart API methods are implemented in this gem?

I've extended the gem to add the Local methods from their API. If this is a welcome change, I'll package it up, write some tests and send a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.