open311 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1 @@
1
+ require 'autotest/bundler'
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - jruby
5
+ - rbx
6
+ - ree
data/.yardopts CHANGED
@@ -4,4 +4,4 @@
4
4
  --tag key:"Requires API key"
5
5
  --markup markdown
6
6
  -
7
- LICENSE.mkd
7
+ LICENSE.md
data/Gemfile CHANGED
@@ -1,10 +1,6 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify the gem's dependencies in open311.gemspec
4
- gemspec
1
+ source 'http://rubygems.org'
5
2
 
6
3
  group :development do
7
-
8
4
  platform :mri_18 do
9
5
  gem 'ruby-debug'
10
6
  end
@@ -12,5 +8,7 @@ group :development do
12
8
  platform :mri_19 do
13
9
  gem 'ruby-debug19'
14
10
  end
15
-
16
11
  end
12
+
13
+ # Specify the gem's dependencies in open311.gemspec
14
+ gemspec
File without changes
@@ -4,53 +4,57 @@ A Ruby wrapper for the Open311 API v2.
4
4
 
5
5
  Does your project or organization use this gem?
6
6
  ------------------------------------------
7
- Add it to the [apps](http://github.com/cfalabs/open311/wiki/apps) wiki!
7
+ Add it to the [apps](https://github.com/codeforamerica/open311/wiki/apps) wiki!
8
8
 
9
9
  Installation
10
10
  ------------
11
- $ [sudo] gem install open311
11
+ gem install open311
12
12
 
13
13
  Documentation
14
14
  -------------
15
- <http://rdoc.info/github/cfalabs/open311/master/frames>
15
+ [http://rdoc.info/gems/open311](http://rdoc.info/gems/open311)
16
+
17
+ Continuous Integration
18
+ ----------------------
19
+ [![Build Status](http://travis-ci.org/codeforamerica/open311.png)](http://travis-ci.org/codeforamerica/open311)
16
20
 
17
21
  Usage Examples
18
22
  --------------
19
23
  require 'open311'
20
-
24
+
21
25
  # Certain methods require an API key
22
26
  Open311.configure do |config|
23
27
  config.endpoint = 'https://open311.sfgov.org/dev/v2/'
24
28
  config.api_key = 'yourkeyforpostrequests'
25
29
  config.jurisdiction = 'sfgov.org'
26
30
  end
27
-
31
+
28
32
  # Provide a list of acceptable 311 service request types and their associated service codes
29
33
  Open311.service_list
30
-
34
+
31
35
  # If meta data is available, provide attributes and definition for the service code
32
36
  Open311.service_definition('033')
33
-
37
+
34
38
  # Grab service requests, limited to 90 days or 1000 entries
35
39
  Open311.service_requests
36
-
40
+
37
41
  # Grab a service request, requires ID
38
42
  Open311.get_service_request('12345')
39
-
43
+
40
44
  # Post a service request, requires an api key
41
45
  Open311.post_service_request
42
-
46
+
43
47
  # Get a service_request_id using a token after a post_service_request
44
48
  Open311.request_id('12345')
45
-
49
+
46
50
  # Get service requests with certain parameters (service_code, start_date, end_date, status)
47
51
  Open311.service_requests("status" => "opened")
48
- Open311.service_requests({"status" => "opened", "service_code"=>"broken-streetlight-report", "start_date" => "2010-03-12T03:19:52Z", "end_date" => "2010-03-14T03:19:52Z"})
49
-
52
+ Open311.service_requests({"status" => "opened", "service_code"=>"broken-streetlight-report", "start_date" => "2010-03-12T03:19:52Z", "end_date" => "2010-03-14T03:19:52Z"})
53
+
50
54
  # Use Time.now
51
55
  require 'time'
52
56
  Open311.service_requests({"start_date" => (Time.now - 86400).xmlschema, "end_date" => Time.now.xmlschema}) // last 24 hours
53
-
57
+
54
58
  # Get multiple service requests by ids, comma separated
55
59
  Open311.service_requests({"service_request_id" => "101000119824,101000119823"})
56
60
 
@@ -67,15 +71,15 @@ Here are some ways *you* can contribute:
67
71
  * by writing specifications
68
72
  * by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
69
73
  * by refactoring code
70
- * by resolving [issues](http://github.com/cfalabs/open311/issues)
74
+ * by resolving [issues](https://github.com/codeforamerica/open311/issues)
71
75
  * by reviewing patches
72
76
 
73
77
  Submitting an Issue
74
78
  -------------------
75
- We use the [GitHub issue tracker](http://github.com/cfalabs/open311/issues) to track bugs and
79
+ We use the [GitHub issue tracker](https://github.com/codeforamerica/open311/issues) to track bugs and
76
80
  features. Before submitting a bug report or feature request, check to make sure it hasn't already
77
81
  been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
78
- bug report, please include a [Gist](http://gist.github.com/) that includes a stack trace and any
82
+ bug report, please include a [Gist](https://gist.github.com/) that includes a stack trace and any
79
83
  details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
80
84
  operating system. Ideally, a bug report should include a pull request with failing specs.
81
85
 
@@ -94,4 +98,6 @@ Submitting a Pull Request
94
98
  Copyright
95
99
  ---------
96
100
  Copyright (c) 2010 Code for America Laboratories
97
- See [LICENSE](https://github.com/cfalabs/open311/blob/master/LICENSE.mkd) for details.
101
+ See [LICENSE](https://github.com/codeforamerica/open311/blob/master/LICENSE.md) for details.
102
+
103
+ [![Code for America Tracker](http://stats.codeforamerica.org/codeforamerica/open311.png)](http://stats.codeforamerica.org/projects/open311)
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env rake
2
+
1
3
  require 'bundler'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
@@ -10,7 +12,7 @@ task :default => :spec
10
12
  namespace :doc do
11
13
  require 'yard'
12
14
  YARD::Rake::YardocTask.new do |task|
13
- task.files = ['LICENSE.mkd', 'lib/**/*.rb']
15
+ task.files = ['LICENSE.md', 'lib/**/*.rb']
14
16
  task.options = [
15
17
  '--no-private',
16
18
  '--protected',
@@ -0,0 +1,31 @@
1
+ require 'faraday'
2
+
3
+ # @api private
4
+ module Faraday
5
+ class Response::RaiseError < Response::Middleware
6
+ def on_complete(response)
7
+ case response[:status].to_i
8
+ when 400
9
+ raise Open311::BadRequest, error_message(response)
10
+ when 401
11
+ raise Open311::Unauthorized, error_message(response)
12
+ when 403
13
+ raise Open311::Forbidden, error_message(response)
14
+ when 404
15
+ raise Open311::NotFound, error_message(response)
16
+ when 406
17
+ raise Open311::NotAcceptable, error_message(response)
18
+ when 500
19
+ raise Open311::InternalServerError, error_message(response)
20
+ when 502
21
+ raise Open311::BadGateway, error_message(response)
22
+ when 503
23
+ raise Open311::ServiceUnavailable, error_message(response)
24
+ end
25
+ end
26
+
27
+ def error_message(response)
28
+ "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:response_headers]['status']}#{(': ' + response[:body]['error']) if response[:body] && response[:body]['error']}"
29
+ end
30
+ end
31
+ end
data/lib/open311.rb CHANGED
@@ -1,46 +1,25 @@
1
1
  require 'open311/configuration'
2
2
  require 'open311/client'
3
+ require 'open311/error'
3
4
 
4
5
  module Open311
5
6
  extend Configuration
6
-
7
- # Alias for Open311::Client.new
8
- #
9
- # @return [Open311::Client]
10
- def self.client(options={})
11
- Open311::Client.new(options)
12
- end
13
-
14
- # Delegate to Open311::Client
15
- def self.method_missing(method, *args, &block)
16
- return super unless client.respond_to?(method)
17
- client.send(method, *args, &block)
7
+ class << self
8
+ # Alias for Open311::Client.new
9
+ #
10
+ # @return [Open311::Client]
11
+ def new(options={})
12
+ Open311::Client.new(options)
13
+ end
14
+
15
+ # Delegate to Open311::Client
16
+ def method_missing(method, *args, &block)
17
+ return super unless new.respond_to?(method)
18
+ new.send(method, *args, &block)
19
+ end
20
+
21
+ def respond_to?(method, include_private=false)
22
+ new.respond_to?(method, include_private) || super(method, include_private)
23
+ end
18
24
  end
19
-
20
- # Custom error class for rescuing from all Open311 errors
21
- class Error < StandardError; end
22
-
23
- # Raised when Open311 returns a 400 HTTP status code
24
- class BadRequest < Error; end
25
-
26
- # Raised when Open311 returns a 401 HTTP status code
27
- class Unauthorized < Error; end
28
-
29
- # Raised when Open311 returns a 403 HTTP status code
30
- class Forbidden < Error; end
31
-
32
- # Raised when Open311 returns a 404 HTTP status code
33
- class NotFound < Error; end
34
-
35
- # Raised when Open311 returns a 406 HTTP status code
36
- class NotAcceptable < Error; end
37
-
38
- # Raised when Open311 returns a 500 HTTP status code
39
- class InternalServerError < Error; end
40
-
41
- # Raised when Open311 returns a 502 HTTP status code
42
- class BadGateway < Error; end
43
-
44
- # Raised when Open311 returns a 503 HTTP status code
45
- class ServiceUnavailable < Error; end
46
25
  end
@@ -1,6 +1,5 @@
1
1
  require 'faraday_middleware'
2
- require 'faraday/multipart'
3
- require 'faraday/raise_error'
2
+ require 'faraday/response/raise_error'
4
3
 
5
4
  module Open311
6
5
  class Client
@@ -16,17 +15,19 @@ module Open311
16
15
  :url => endpoint
17
16
  }
18
17
 
19
- Faraday::Connection.new(options) do |connection|
18
+ Faraday.new(options) do |connection|
20
19
  connection.use Faraday::Request::Multipart
21
- connection.adapter(adapter)
22
- connection.use Faraday::Response::RaiseError
23
20
  unless raw
21
+ connection.use Faraday::Response::Mashify
24
22
  case format.to_s.downcase
25
- when 'json' then connection.use Faraday::Response::ParseJson
26
- when 'xml' then connection.use Faraday::Response::ParseXml
23
+ when 'json'
24
+ connection.use Faraday::Response::ParseJson
25
+ when 'xml'
26
+ connection.use Faraday::Response::ParseXml
27
27
  end
28
- connection.use Faraday::Response::Mashify
29
28
  end
29
+ connection.use Faraday::Response::RaiseError
30
+ connection.adapter(adapter)
30
31
  end
31
32
  end
32
33
  end
@@ -22,11 +22,11 @@ module Open311
22
22
  def request(method, path, options, raw)
23
23
  response = connection(raw).send(method) do |request|
24
24
  case method
25
- when :get, :delete
26
- request.url(formatted_path(path), options)
27
- when :post, :put
28
- request.path = formatted_path(path)
29
- request.body = options unless options.empty?
25
+ when :get, :delete
26
+ request.url(formatted_path(path), options)
27
+ when :post, :put
28
+ request.path = formatted_path(path)
29
+ request.body = options unless options.empty?
30
30
  end
31
31
  end
32
32
  raw ? response : response.body
@@ -0,0 +1,28 @@
1
+ module Open311
2
+ # Custom error class for rescuing from all Open311 errors
3
+ class Error < StandardError; end
4
+
5
+ # Raised when Open311 returns a 400 HTTP status code
6
+ class BadRequest < Error; end
7
+
8
+ # Raised when Open311 returns a 401 HTTP status code
9
+ class Unauthorized < Error; end
10
+
11
+ # Raised when Open311 returns a 403 HTTP status code
12
+ class Forbidden < Error; end
13
+
14
+ # Raised when Open311 returns a 404 HTTP status code
15
+ class NotFound < Error; end
16
+
17
+ # Raised when Open311 returns a 406 HTTP status code
18
+ class NotAcceptable < Error; end
19
+
20
+ # Raised when Open311 returns a 500 HTTP status code
21
+ class InternalServerError < Error; end
22
+
23
+ # Raised when Open311 returns a 502 HTTP status code
24
+ class BadGateway < Error; end
25
+
26
+ # Raised when Open311 returns a 503 HTTP status code
27
+ class ServiceUnavailable < Error; end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Open311
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/open311.gemspec CHANGED
@@ -1,36 +1,35 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require File.expand_path('../lib/open311/version', __FILE__)
3
3
 
4
- Gem::Specification.new do |s|
5
- s.add_development_dependency('json', '~> 1.5')
6
- s.add_development_dependency('maruku', '~> 0.6')
7
- s.add_development_dependency('nokogiri', '~> 1.4')
8
- s.add_development_dependency('rake', '~> 0.8')
9
- s.add_development_dependency('rspec', '~> 2.5')
10
- s.add_development_dependency('simplecov', '~> 0.4')
11
- s.add_development_dependency('webmock', '~> 1.5')
12
- s.add_development_dependency('yard', '~> 0.6')
13
- s.add_development_dependency('ZenTest', '~> 4.5')
14
- s.add_runtime_dependency('hashie', '~> 1.0.0')
15
- s.add_runtime_dependency('faraday', '~> 0.5.4')
16
- s.add_runtime_dependency('faraday_middleware', '~> 0.3.1')
17
- s.add_runtime_dependency('multi_json', '~> 0.0.5')
18
- s.add_runtime_dependency('multi_xml', '~> 0.2.0')
19
- s.authors = ["Dan Melton", "Erik Michaels-Ober"]
20
- s.description = %q{A Ruby wrapper for the Open311 API v2.}
21
- s.post_install_message =<<eos
4
+ Gem::Specification.new do |gem|
5
+ gem.add_development_dependency 'json_pure', '~> 1.5'
6
+ gem.add_development_dependency 'maruku', '~> 0.6'
7
+ gem.add_development_dependency 'nokogiri', '~> 1.4'
8
+ gem.add_development_dependency 'rake', '~> 0.9'
9
+ gem.add_development_dependency 'rspec', '~> 2.6'
10
+ gem.add_development_dependency 'simplecov', '~> 0.4'
11
+ gem.add_development_dependency 'webmock', '~> 1.5'
12
+ gem.add_development_dependency 'yard', '~> 0.7'
13
+ gem.add_development_dependency 'ZenTest', '~> 4.5'
14
+ gem.add_runtime_dependency 'hashie', '~> 1.0.0'
15
+ gem.add_runtime_dependency 'faraday', '~> 0.6.0'
16
+ gem.add_runtime_dependency 'faraday_middleware', '~> 0.6.0'
17
+ gem.add_runtime_dependency 'multi_json', '~> 1.0.0'
18
+ gem.add_runtime_dependency 'multi_xml', '~> 0.2.0'
19
+ gem.authors = ["Dan Melton", "Erik Michaels-Ober"]
20
+ gem.description = %q{A Ruby wrapper for the Open311 API v2.}
21
+ gem.post_install_message =<<eos
22
22
  Using this gem in your project or organization? Add it to the apps wiki!
23
- https://github.com/cfalabs/open311/wiki/apps
23
+ https://github.com/codeforamerica/open311/wiki/apps
24
24
  eos
25
- s.email = ['dan@codeforamerica.org', 'erik@codeforamerica.org']
26
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
27
- s.files = `git ls-files`.split("\n")
28
- s.homepage = 'http://rubygems.org/gems/open311'
29
- s.name = 'open311'
30
- s.platform = Gem::Platform::RUBY
31
- s.require_paths = ['lib']
32
- s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version=
33
- s.summary = s.description
34
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
35
- s.version = Open311::VERSION
25
+ gem.email = ['dan@codeforamerica.org', 'erik@codeforamerica.org']
26
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
27
+ gem.files = `git ls-files`.split("\n")
28
+ gem.homepage = 'https://github.com/codeforamerica/open311'
29
+ gem.name = 'open311'
30
+ gem.require_paths = ['lib']
31
+ gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
32
+ gem.summary = gem.description
33
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
34
+ gem.version = Open311::VERSION
36
35
  end
@@ -0,0 +1,33 @@
1
+ require 'helper'
2
+
3
+ describe Faraday::Response do
4
+ {
5
+ 400 => Open311::BadRequest,
6
+ 401 => Open311::Unauthorized,
7
+ 403 => Open311::Forbidden,
8
+ 404 => Open311::NotFound,
9
+ 406 => Open311::NotAcceptable,
10
+ 500 => Open311::InternalServerError,
11
+ 502 => Open311::BadGateway,
12
+ 503 => Open311::ServiceUnavailable,
13
+ }.each do |status, exception|
14
+ context "when HTTP status is #{status}" do
15
+
16
+ before do
17
+ Open311.configure do |config|
18
+ config.endpoint = 'http://api.dc.org/open311/v2_dev/'
19
+ config.jurisdiction = 'dc.gov'
20
+ end
21
+ stub_request(:get, 'http://api.dc.org/open311/v2_dev/services.xml').
22
+ with(:query => {:jurisdiction_id => 'dc.gov'}).
23
+ to_return(:status => status)
24
+ end
25
+
26
+ it "should raise #{exception.name} error" do
27
+ lambda do
28
+ Open311.service_list
29
+ end.should raise_error(exception)
30
+ end
31
+ end
32
+ end
33
+ end
data/spec/helper.rb CHANGED
@@ -1,14 +1,10 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
1
3
  require 'simplecov'
2
- SimpleCov.start do
3
- add_group 'Open311', 'lib/open311'
4
- add_group 'Faraday', 'lib/faraday'
5
- end
4
+ SimpleCov.start
6
5
  require 'open311'
7
6
  require 'rspec'
8
7
  require 'webmock/rspec'
9
- RSpec.configure do |config|
10
- config.include WebMock::API
11
- end
12
8
 
13
9
  def fixture_path
14
10
  File.expand_path("../fixtures", __FILE__)
data/spec/open311_spec.rb CHANGED
@@ -1,5 +1,23 @@
1
1
  require 'helper'
2
2
 
3
+ describe Open311 do
4
+ after do
5
+ Open311.reset
6
+ end
7
+
8
+ describe ".respond_to?" do
9
+ it "should return true if method exists" do
10
+ Open311.respond_to?(:new, true).should be_true
11
+ end
12
+ end
13
+
14
+ describe ".new" do
15
+ it "should be a Open311::Client" do
16
+ Open311.new.should be_a Open311::Client
17
+ end
18
+ end
19
+ end
20
+
3
21
  describe Open311, ".service_list" do
4
22
  before do
5
23
  Open311.configure do |config|
@@ -108,7 +126,12 @@ describe Open311, ".post_service_request" do
108
126
  config.api_key = 'xyz'
109
127
  end
110
128
 
111
- @service_request_params = {
129
+ stub_request(:post, 'blasius.ws:3003/open311/requests.xml').
130
+ to_return(:body => fixture('post_service_request.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
131
+ end
132
+
133
+ it "should return the correct results" do
134
+ service_request_params = {
112
135
  :service_code => '001',
113
136
  :address_string => '1234 5th street',
114
137
  :email => 'smit222@sfgov.edu',
@@ -118,17 +141,11 @@ describe Open311, ".post_service_request" do
118
141
  :last_name => 'smith',
119
142
  :phone => '111111111',
120
143
  :description => 'A large sinkhole is destroying the street',
121
- :media_url => 'http://farm3.static.flickr.com/2002/2212426634_5ed477a060.jpg',
144
+ :media_url => 'http://farm5.static.flickr.com/4057/4660699337_9aa4541ce1_o.jpg',
122
145
  :lat => '38.888486',
123
146
  :long => '-77.020179',
124
147
  }
125
- stub_request(:post, 'blasius.ws:3003/open311/requests.xml').
126
- with(:body => {:jurisdiction_id => 'dc.gov', :api_key => 'xyz'}.merge(@service_request_params)).
127
- to_return(:body => fixture('post_service_request.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
128
- end
129
-
130
- it "should return the correct results" do
131
- service_request_response = Open311.post_service_request(@service_request_params)
148
+ service_request_response = Open311.post_service_request(service_request_params)
132
149
  service_request_response.service_request_id.should == '293944'
133
150
  end
134
151
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: open311
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dan Melton
@@ -11,11 +11,11 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-03-20 00:00:00 -07:00
14
+ date: 2011-06-23 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
- name: json
18
+ name: json_pure
19
19
  prerelease: false
20
20
  requirement: &id001 !ruby/object:Gem::Requirement
21
21
  none: false
@@ -55,7 +55,7 @@ dependencies:
55
55
  requirements:
56
56
  - - ~>
57
57
  - !ruby/object:Gem::Version
58
- version: "0.8"
58
+ version: "0.9"
59
59
  type: :development
60
60
  version_requirements: *id004
61
61
  - !ruby/object:Gem::Dependency
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: "2.5"
69
+ version: "2.6"
70
70
  type: :development
71
71
  version_requirements: *id005
72
72
  - !ruby/object:Gem::Dependency
@@ -99,7 +99,7 @@ dependencies:
99
99
  requirements:
100
100
  - - ~>
101
101
  - !ruby/object:Gem::Version
102
- version: "0.6"
102
+ version: "0.7"
103
103
  type: :development
104
104
  version_requirements: *id008
105
105
  - !ruby/object:Gem::Dependency
@@ -132,7 +132,7 @@ dependencies:
132
132
  requirements:
133
133
  - - ~>
134
134
  - !ruby/object:Gem::Version
135
- version: 0.5.4
135
+ version: 0.6.0
136
136
  type: :runtime
137
137
  version_requirements: *id011
138
138
  - !ruby/object:Gem::Dependency
@@ -143,7 +143,7 @@ dependencies:
143
143
  requirements:
144
144
  - - ~>
145
145
  - !ruby/object:Gem::Version
146
- version: 0.3.1
146
+ version: 0.6.0
147
147
  type: :runtime
148
148
  version_requirements: *id012
149
149
  - !ruby/object:Gem::Dependency
@@ -154,7 +154,7 @@ dependencies:
154
154
  requirements:
155
155
  - - ~>
156
156
  - !ruby/object:Gem::Version
157
- version: 0.0.5
157
+ version: 1.0.0
158
158
  type: :runtime
159
159
  version_requirements: *id013
160
160
  - !ruby/object:Gem::Dependency
@@ -179,24 +179,27 @@ extensions: []
179
179
  extra_rdoc_files: []
180
180
 
181
181
  files:
182
+ - .autotest
182
183
  - .gemtest
183
184
  - .gitignore
184
185
  - .rspec
186
+ - .travis.yml
185
187
  - .yardopts
186
188
  - Gemfile
187
- - LICENSE.mkd
188
- - README.mkd
189
+ - LICENSE.md
190
+ - README.md
189
191
  - Rakefile
190
- - lib/faraday/multipart.rb
191
- - lib/faraday/raise_error.rb
192
+ - lib/faraday/response/raise_error.rb
192
193
  - lib/open311.rb
193
194
  - lib/open311/client.rb
194
195
  - lib/open311/client/connection.rb
195
196
  - lib/open311/client/request.rb
196
197
  - lib/open311/client/service.rb
197
198
  - lib/open311/configuration.rb
199
+ - lib/open311/error.rb
198
200
  - lib/open311/version.rb
199
201
  - open311.gemspec
202
+ - spec/faraday/response_spec.rb
200
203
  - spec/fixtures/403.xml
201
204
  - spec/fixtures/get_service_request.xml
202
205
  - spec/fixtures/post_service_request.xml
@@ -207,12 +210,12 @@ files:
207
210
  - spec/helper.rb
208
211
  - spec/open311_spec.rb
209
212
  has_rdoc: true
210
- homepage: http://rubygems.org/gems/open311
213
+ homepage: https://github.com/codeforamerica/open311
211
214
  licenses: []
212
215
 
213
216
  post_install_message: |
214
217
  Using this gem in your project or organization? Add it to the apps wiki!
215
- https://github.com/cfalabs/open311/wiki/apps
218
+ https://github.com/codeforamerica/open311/wiki/apps
216
219
 
217
220
  rdoc_options: []
218
221
 
@@ -233,11 +236,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
236
  requirements: []
234
237
 
235
238
  rubyforge_project:
236
- rubygems_version: 1.6.2
239
+ rubygems_version: 1.5.3
237
240
  signing_key:
238
241
  specification_version: 3
239
242
  summary: A Ruby wrapper for the Open311 API v2.
240
243
  test_files:
244
+ - spec/faraday/response_spec.rb
241
245
  - spec/fixtures/403.xml
242
246
  - spec/fixtures/get_service_request.xml
243
247
  - spec/fixtures/post_service_request.xml
@@ -1,29 +0,0 @@
1
- require 'faraday'
2
-
3
- # @api private
4
- module Faraday
5
- class Request::Multipart < Faraday::Middleware
6
- def call(env)
7
- if env[:body].is_a?(Hash)
8
- env[:body].each do |key, value|
9
- if value.is_a?(File)
10
- env[:body][key] = Faraday::UploadIO.new(value, mime_type(value), value.path)
11
- end
12
- end
13
- end
14
-
15
- @app.call(env)
16
- end
17
-
18
- private
19
-
20
- def mime_type(file)
21
- case file.path
22
- when /\.jpe?g/i then 'image/jpeg'
23
- when /\.gif$/i then 'image/gif'
24
- when /\.png$/i then 'image/png'
25
- else 'application/octet-stream'
26
- end
27
- end
28
- end
29
- end
@@ -1,40 +0,0 @@
1
- require 'faraday'
2
-
3
- # @api private
4
- module Faraday
5
- class Response::RaiseError < Response::Middleware
6
- def self.register_on_complete(env)
7
- env[:response].on_complete do |response|
8
- case response[:status].to_i
9
- when 400
10
- raise Open311::BadRequest, error_message(response)
11
- when 401
12
- raise Open311::Unauthorized, error_message(response)
13
- when 403
14
- raise Open311::Forbidden, error_message(response)
15
- when 404
16
- raise Open311::NotFound, error_message(response)
17
- when 406
18
- raise Open311::NotAcceptable, error_message(response)
19
- when 500
20
- raise Open311::InternalServerError, error_message(response)
21
- when 502
22
- raise Open311::BadGateway, error_message(response)
23
- when 503
24
- raise Open311::ServiceUnavailable, error_message(response)
25
- end
26
- end
27
- end
28
-
29
- def initialize(app)
30
- super
31
- @parser = nil
32
- end
33
-
34
- private
35
-
36
- def self.error_message(response)
37
- "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:response_headers]['status']}#{(': ' + response[:body]['error']) if response[:body] && response[:body]['error']}"
38
- end
39
- end
40
- end