mcll4r 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ # Add dependencies to develop your gem here.
6
+ # Include everything needed to run rake, tests, features, etc.
7
+ group :development do
8
+ gem "rdoc", "~> 3.12"
9
+ gem "bundler", "~> 1.0.0"
10
+ gem "jeweler", "~> 1.8.3"
11
+ gem "rcov", ">= 0"
12
+ end
data/MIT-LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Mobile Commons
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ === mcll4r
2
+
3
+ - [Code on GitHub](http://github.com/mcommons/mcll4r)
4
+
5
+ === Description
6
+
7
+ Ruby client for Mobile Commons Legislative Lookup API
8
+
9
+ Based on the API described at http://congress.mcommons.com
10
+
11
+
12
+ === Authors
13
+
14
+ - Maintained by [Benjamin Stein](mailto:ben@mcommons.com), [Mal McKay](mailto:mal@mcommons.com) & [Nathan Woodhull](mailto:nathan@mcommons.com)
15
+
16
+ === License
17
+
18
+ Copyright (c) 2008 Mobile Commons
19
+ See MIT-LICENSE in this directory.
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "mcll4r"
18
+ gem.homepage = "http://github.com/Empact/mcll4r"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Ruby client for Mobile Commons Legislative Lookup API}
21
+ gem.description = %Q{Based on the API described at http://congress.mcommons.com}
22
+ gem.email = "ben.woosley@gmail.com"
23
+ gem.authors = ["Benjamin Stein", "Mal McKay", "Nathan Woodhull", "Ben Woosley"]
24
+ # dependencies defined in Gemfile
25
+ gem.add_dependency 'httparty'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ test.rcov_opts << '--exclude "gems/*"'
42
+ end
43
+
44
+ task :default => :test
45
+
46
+ require 'rdoc/task'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "mcll4r #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/lib/mcll4r.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+
4
+ class Mcll4r
5
+ include HTTParty
6
+ base_uri "http://congress.mcommons.com"
7
+ format :xml
8
+
9
+ def district_lookup(lat, lng)
10
+ filter_for_errors self.class.get("/districts/lookup.xml", :query=>{:lat=>lat, :lng=>lng})
11
+ end
12
+
13
+ private
14
+
15
+ def filter_for_errors(hash)
16
+ if hash['response']['error']
17
+ raise DistrictNotFound.new(hash['response']['error'])
18
+ end
19
+ hash
20
+ end
21
+
22
+ end
23
+
24
+ class DistrictNotFound < Exception; end
data/mcll4r.gemspec ADDED
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "mcll4r"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Benjamin Stein", "Mal McKay", "Nathan Woodhull", "Ben Woosley"]
12
+ s.date = "2012-02-09"
13
+ s.description = "Based on the API described at http://congress.mcommons.com"
14
+ s.email = "ben.woosley@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "MIT-LICENSE.txt",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/mcll4r.rb",
25
+ "mcll4r.gemspec",
26
+ "test/helper.rb",
27
+ "test/test_mcll4r.rb"
28
+ ]
29
+ s.homepage = "http://github.com/Empact/mcll4r"
30
+ s.licenses = ["MIT"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = "1.8.10"
33
+ s.summary = "Ruby client for Mobile Commons Legislative Lookup API"
34
+
35
+ if s.respond_to? :specification_version then
36
+ s.specification_version = 3
37
+
38
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
40
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
41
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
42
+ s.add_development_dependency(%q<rcov>, [">= 0"])
43
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
44
+ else
45
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
46
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
47
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
48
+ s.add_dependency(%q<rcov>, [">= 0"])
49
+ s.add_dependency(%q<httparty>, [">= 0"])
50
+ end
51
+ else
52
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
55
+ s.add_dependency(%q<rcov>, [">= 0"])
56
+ s.add_dependency(%q<httparty>, [">= 0"])
57
+ end
58
+ end
59
+
data/test/helper.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ require 'mcll4r'
15
+
16
+ class Test::Unit::TestCase
17
+ end
@@ -0,0 +1,36 @@
1
+ require 'mcll4r'
2
+ require 'test/unit'
3
+
4
+ class TestMcll4r < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @mcll4r = Mcll4r.new
8
+ end
9
+
10
+ def test_assert_we_get_back_correct_district_data
11
+ expected = {
12
+ "response" => {
13
+ "state_upper" => { "district" => "029", "display_name" => "TX 29th", "state" => "TX" },
14
+ "federal" => { "district" => "16", "display_name" => "TX 16th", "state" => "TX" },
15
+ "state_lower" => { "district" => "077", "display_name" => "TX 77th", "state" => "TX" },
16
+ "lng" => "-106.490969",
17
+ "lat" => "31.76321"
18
+ }
19
+ }
20
+ result = @mcll4r.district_lookup(31.76321, -106.490969)
21
+ assert_equal expected, result.to_hash
22
+ end
23
+
24
+ def test_assert_raise_on_error
25
+ assert_raise DistrictNotFound do
26
+ @mcll4r.district_lookup(nil,nil)
27
+ end
28
+ end
29
+
30
+ def test_assert_raise_on_district_not_found
31
+ assert_raise DistrictNotFound do
32
+ @mcll4r.district_lookup( 1.0, 1.0 )
33
+ end
34
+ end
35
+
36
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mcll4r
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Benjamin Stein
9
+ - Mal McKay
10
+ - Nathan Woodhull
11
+ - Ben Woosley
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2012-02-09 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: mcll4r
19
+ requirement: &70145162715220 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: *70145162715220
28
+ - !ruby/object:Gem::Dependency
29
+ name: rdoc
30
+ requirement: &70145162722680 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: '3.12'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: *70145162722680
39
+ - !ruby/object:Gem::Dependency
40
+ name: bundler
41
+ requirement: &70145162719440 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.0
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: *70145162719440
50
+ - !ruby/object:Gem::Dependency
51
+ name: jeweler
52
+ requirement: &70145162729920 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: 1.8.3
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: *70145162729920
61
+ - !ruby/object:Gem::Dependency
62
+ name: rcov
63
+ requirement: &70145162728120 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: *70145162728120
72
+ - !ruby/object:Gem::Dependency
73
+ name: rdoc
74
+ requirement: &70145162726860 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: '3.12'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: *70145162726860
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: &70145162725800 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 1.0.0
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: *70145162725800
94
+ - !ruby/object:Gem::Dependency
95
+ name: jeweler
96
+ requirement: &70145162735680 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.8.3
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: *70145162735680
105
+ - !ruby/object:Gem::Dependency
106
+ name: rcov
107
+ requirement: &70145162744040 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: *70145162744040
116
+ - !ruby/object:Gem::Dependency
117
+ name: httparty
118
+ requirement: &70145162753240 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: *70145162753240
127
+ description: Based on the API described at http://congress.mcommons.com
128
+ email: ben.woosley@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files:
132
+ - README.rdoc
133
+ files:
134
+ - Gemfile
135
+ - MIT-LICENSE.txt
136
+ - README.rdoc
137
+ - Rakefile
138
+ - VERSION
139
+ - lib/mcll4r.rb
140
+ - mcll4r.gemspec
141
+ - test/helper.rb
142
+ - test/test_mcll4r.rb
143
+ homepage: http://github.com/Empact/mcll4r
144
+ licenses:
145
+ - MIT
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ segments:
157
+ - 0
158
+ hash: 608418053478975721
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 1.8.10
168
+ signing_key:
169
+ specification_version: 3
170
+ summary: Ruby client for Mobile Commons Legislative Lookup API
171
+ test_files: []