party_time 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,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTY0ZTY4MjBiZjI2MDI0ZmYxNTVhN2QxYWFlMTdjZmYzOTNhOGM2Yw==
5
+ data.tar.gz: !binary |-
6
+ NzFkZDJkMDMwZTI0ZWY1NjQ0MDZkNjMyOTcyOGVkMzdhNmNlOTNhMg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NmJmYjVhY2E0MjdjNDMyZjc1MmY4ODgwNWFhNTc3ODcyYjViOWMwOWJhMzgz
10
+ MzhiNzZlYTEwNWI5NWMyNjc0OGE4MjFhNDU4NWJmYWQ4NjY0NzUyYjBlZDYz
11
+ ODNjYWMyZjA3ZjI5ZDdkMDQ4YjQzMDVkYmNjOTNhZWM5OWNlNDg=
12
+ data.tar.gz: !binary |-
13
+ MTVlZTVlNjg3MTZlNmQ0YTA5MTVmYmI2ZGI3ZWI2MzFlM2QwZmUyMjQxZDkz
14
+ Mjg0M2M3MzViZmM3ZWI1ODFlY2E5NjE1ZjRiOGM1NzRhNjhmZmViMTA5N2Vk
15
+ NjgxYTlhZTY0ZDE2Y2QwM2JmOTNhZDFmNmZlMzg0ZWYxYjE0MWI=
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in party_time.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Scott Ballantyne
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,43 @@
1
+ # PartyTime
2
+
3
+ A quick api wrapper for the Sunlight Foundation Political Party Time api. I couldn't find one for this api.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'party_time'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install party_time
18
+
19
+ ## Usage
20
+ # open a ruby prompt to try it out
21
+ irb
22
+
23
+ # then type
24
+
25
+ require 'rubygems'
26
+ require 'party_time'
27
+ PartyTime::Config.api_key = SUNLIGHT_FOUNDATION_KEY
28
+ # get your key here http://sunlightfoundation.com/api/
29
+
30
+ PartyTime::Event.new('beneficiaries__crp_id' => 'N00003675')
31
+
32
+ # There are many more api endpoints here http://sunlightlabs.github.io/partytime-docs/
33
+ #go look at the documentation.
34
+
35
+ # I haven't really tried this gem much, let me know if there are any problems.
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,13 @@
1
+ module PartyTime
2
+ module Config
3
+
4
+ def self.api_key=(val)
5
+ @@api_key = val
6
+ end
7
+
8
+ def self.api_key
9
+ @@api_key
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module PartyTime
2
+ class Event
3
+ def initialize(options)
4
+ @data = PartyTime.request('event/', options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module PartyTime
2
+ class Host
3
+ def initialize(options)
4
+ @data = PartyTime.request('host/', options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module PartyTime
2
+ class Lawmaker
3
+ def initialize(options)
4
+ @data = PartyTime.request('lawmaker/', options)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module PartyTime
2
+ VERSION = "0.0.1"
3
+ end
data/lib/party_time.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "party_time/version"
2
+ require 'rest_client'
3
+ require 'erb'
4
+ require 'hashie'
5
+ require 'json'
6
+
7
+ module PartyTime
8
+ def self.base_url
9
+ 'http://politicalpartytime.org/api/v1/'
10
+ end
11
+
12
+ def self.request(endpoint, options)
13
+ opts = options.merge('apikey' => PartyTime::Config.api_key, 'format' => 'json')
14
+ url = base_url + endpoint + "?" + opts.to_query
15
+ # puts url
16
+ response = JSON.parse(RestClient.get(url).to_str).collect {|i| Hashie::Mash.new(i) }
17
+ response
18
+ end
19
+ end
20
+
21
+ class Hash
22
+ def to_query
23
+ self.map{|k,v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v)}"}.join("&")
24
+ end
25
+ end
26
+
27
+
28
+ Dir.glob(File.dirname(__FILE__) + '/party_time/*.rb').each { |f| require f }
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'party_time/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "party_time"
8
+ spec.version = PartyTime::VERSION
9
+ spec.authors = ["Scott Ballantyne"]
10
+ spec.email = ["ussballantyne@gmail.com"]
11
+ spec.description = %q{api wrapper for sunlight party time}
12
+ spec.summary = %q{api wrapper for sunlight party time}
13
+ spec.homepage = ""
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_dependency 'hashie'
24
+ spec.add_dependency 'rest-client'
25
+ spec.add_dependency 'json'
26
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: party_time
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Scott Ballantyne
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-20 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: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: api wrapper for sunlight party time
84
+ email:
85
+ - ussballantyne@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/party_time.rb
96
+ - lib/party_time/config.rb
97
+ - lib/party_time/event.rb
98
+ - lib/party_time/host.rb
99
+ - lib/party_time/lawmaker.rb
100
+ - lib/party_time/version.rb
101
+ - party_time.gemspec
102
+ homepage: ''
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.0.6
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: api wrapper for sunlight party time
126
+ test_files: []