Skip to content

Commit

Permalink
Require Ruby 1.9.3 or higher
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Nov 1, 2014
1 parent d92fc5f commit c0bfd58
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 84 deletions.
12 changes: 0 additions & 12 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ Metrics/ParameterLists:
Max: 4
CountKeywordArgs: true

Metrics/AbcSize:
Enabled: false

Style/AccessModifierIndentation:
EnforcedStyle: outdent

Expand All @@ -35,18 +32,9 @@ Style/DotPosition:
Style/DoubleNegation:
Enabled: false

Style/EachWithObject:
Enabled: false

Style/Encoding:
Enabled: false

Style/HashSyntax:
EnforcedStyle: hash_rockets

Style/Lambda:
Enabled: false

Style/RaiseArgs:
EnforcedStyle: compact

Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ matrix:
allow_failures:
- rvm: ruby-head
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1
- jruby-18mode
- jruby-19mode
- jruby-head
- rbx-2
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gem 'yard'
group :test do
gem 'backports'
gem 'rspec'
gem 'rubocop', '>= 0.27', :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem 'rubocop', '>= 0.27'
gem 'simplecov'
gem 'webmock'
gem 'yardstick'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ This library aims to support and is [tested
against](http://travis-ci.org/codeforamerica/open311) the following Ruby
implementations:

* Ruby 1.8.7
* Ruby 1.9.2
* Ruby 1.9.3
* Ruby 2.0.0
* Ruby 2.1
* [JRuby](http://www.jruby.org/)
* [Rubinius](http://rubini.us/)

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :test => :spec
task test: :spec

begin
require 'rubocop/rake_task'
Expand Down Expand Up @@ -40,4 +40,4 @@ Yardstick::Rake::Verify.new do |verify|
verify.threshold = 57.3
end

task :default => [:spec, :rubocop, :verify_measurements]
task default: [:spec, :rubocop, :verify_measurements]
6 changes: 3 additions & 3 deletions lib/open311/client/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module Connection
def options
{
# :headers => {'Accept' => "*/#{format}", 'User-Agent' => user_agent},
:proxy => proxy,
:ssl => {:verify => false},
:url => endpoint,
proxy: proxy,
ssl: {verify: false},
url: endpoint,
}
end

Expand Down
4 changes: 2 additions & 2 deletions lib/open311/client/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def service_requests(options = {})
# @see http://wiki.open311.org/GeoReport_v2#POST_Service_Request
# Open311.post_service_request
def post_service_request(options = {})
merge_options!(options, :api_key => api_key)
merge_options!(options, api_key: api_key)
response = post('requests', options)
unpack_if_xml(response) do
response['service_requests']['request']
Expand Down Expand Up @@ -99,7 +99,7 @@ def request_id_from_token(token_id, options = {})
private

def merge_options!(options, additional_options = {})
options.merge!(:jurisdiction_id => jurisdiction) if jurisdiction
options.merge!(jurisdiction_id: jurisdiction) if jurisdiction
options.merge!(additional_options)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/open311/response/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Open311
module Response
class RaiseError < Faraday::Response::Middleware
def on_complete(response) # rubocop:disable CyclomaticComplexity, MethodLength
def on_complete(response) # rubocop:disable AbcSize, CyclomaticComplexity, MethodLength
case response[:status].to_i
when 400
fail Open311::BadRequest.new(error_message(response))
Expand Down
37 changes: 19 additions & 18 deletions open311.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@ lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'open311/version'

Gem::Specification.new do |gem|
gem.add_dependency 'faraday', '~> 0.7'
gem.add_dependency 'faraday_middleware', '~> 0.7'
gem.add_dependency 'hashie', '~> 3.3'
gem.add_dependency 'multi_json', '~> 1.0'
gem.add_dependency 'multi_xml', '~> 0.4'
gem.add_development_dependency 'bundler', '~> 1.0'
gem.authors = ['Dan Melton', 'Erik Michaels-Ober']
gem.description = 'A Ruby wrapper for the Open311 API v2.'
gem.email = ['dan@codeforamerica.org', 'erik@codeforamerica.org']
gem.files = %w(.yardopts LICENSE.md README.md open311.gemspec) + Dir['lib/**/*.rb']
gem.homepage = 'https://github.com/codeforamerica/open311'
gem.name = 'open311'
gem.post_install_message = <<eos
Gem::Specification.new do |spec|
spec.add_dependency 'faraday', '~> 0.7'
spec.add_dependency 'faraday_middleware', '~> 0.7'
spec.add_dependency 'hashie', '~> 3.3'
spec.add_dependency 'multi_json', '~> 1.0'
spec.add_dependency 'multi_xml', '~> 0.4'
spec.add_development_dependency 'bundler', '~> 1.0'
spec.authors = ['Dan Melton', 'Erik Michaels-Ober']
spec.description = 'A Ruby wrapper for the Open311 API v2.'
spec.email = ['dan@codeforamerica.org', 'erik@codeforamerica.org']
spec.files = %w(.yardopts LICENSE.md README.md open311.gemspec) + Dir['lib/**/*.rb']
spec.homepage = 'https://github.com/codeforamerica/open311'
spec.name = 'open311'
spec.post_install_message = <<eos
Using this gem in your project or organization? Add it to the apps wiki!
https://github.com/codeforamerica/open311/wiki/apps
eos
gem.require_paths = ['lib']
gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
gem.summary = gem.description
gem.version = Open311::VERSION
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 1.9.3'
spec.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
spec.summary = spec.description
spec.version = Open311::VERSION
end
4 changes: 2 additions & 2 deletions spec/faraday/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
config.jurisdiction = 'dc.gov'
end
stub_request(:get, 'http://api.dc.org/open311/v2_dev/services.xml').
with(:query => {:jurisdiction_id => 'dc.gov'}).
to_return(:status => status)
with(query: {jurisdiction_id: 'dc.gov'}).
to_return(status: status)
end

it "should raise #{exception.name} error" do
Expand Down
10 changes: 4 additions & 6 deletions spec/helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
if RUBY_VERSION >= '1.9'
require 'simplecov'
require 'simplecov'

SimpleCov.start do
add_filter '/spec/'
minimum_coverage(97.44)
end
SimpleCov.start do
add_filter '/spec/'
minimum_coverage(97.44)
end

require 'open311'
Expand Down
66 changes: 33 additions & 33 deletions spec/open311_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
config.jurisdiction = 'dc.gov'
end
stub_request(:get, 'http://api.dc.org/open311/v2_dev/services.xml').
with(:query => {:jurisdiction_id => 'dc.gov'}).
to_return(:body => fixture('services.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
with(query: {jurisdiction_id: 'dc.gov'}).
to_return(body: fixture('services.xml'), headers: {'Content-Type' => 'text/xml; charset=utf-8'})
end

it 'should request the correct resource' do
Open311.service_list
expect(a_request(:get, 'http://api.dc.org/open311/v2_dev/services.xml').
with(:query => {:jurisdiction_id => 'dc.gov'})).
with(query: {jurisdiction_id: 'dc.gov'})).
to have_been_made
end

Expand All @@ -50,14 +50,14 @@
config.jurisdiction = 'dc.gov'
end
stub_request(:get, 'http://blasius.ws:3003/open311/services/033.xml').
with(:query => {:jurisdiction_id => 'dc.gov'}).
to_return(:body => fixture('service_definition.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
with(query: {jurisdiction_id: 'dc.gov'}).
to_return(body: fixture('service_definition.xml'), headers: {'Content-Type' => 'text/xml; charset=utf-8'})
end

it 'should request the correct resource' do
Open311.service_definition('033')
expect(a_request(:get, 'http://blasius.ws:3003/open311/services/033.xml').
with(:query => {:jurisdiction_id => 'dc.gov'})).
with(query: {jurisdiction_id: 'dc.gov'})).
to have_been_made
end

Expand All @@ -75,14 +75,14 @@
config.jurisdiction = 'dc.gov'
end
stub_request(:get, 'http://blasius.ws:3003/open311/requests.xml').
with(:query => {:jurisdiction_id => 'dc.gov'}).
to_return(:body => fixture('service_requests.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
with(query: {jurisdiction_id: 'dc.gov'}).
to_return(body: fixture('service_requests.xml'), headers: {'Content-Type' => 'text/xml; charset=utf-8'})
end

it 'should request the correct resource' do
Open311.service_requests
expect(a_request(:get, 'http://blasius.ws:3003/open311/requests.xml').
with(:query => {:jurisdiction_id => 'dc.gov'})).
with(query: {jurisdiction_id: 'dc.gov'})).
to have_been_made
end

Expand All @@ -95,8 +95,8 @@
describe 'with no results' do
before do
stub_request(:get, 'http://blasius.ws:3003/open311/requests.xml').
with(:query => {:jurisdiction_id => 'dc.gov'}).
to_return(:body => fixture('service_requests_empty.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
with(query: {jurisdiction_id: 'dc.gov'}).
to_return(body: fixture('service_requests_empty.xml'), headers: {'Content-Type' => 'text/xml; charset=utf-8'})
end

it 'returns an empty array' do
Expand All @@ -113,14 +113,14 @@
config.jurisdiction = 'dc.gov'
end
stub_request(:get, 'http://blasius.ws:3003/open311/requests/638344.xml').
with(:query => {:jurisdiction_id => 'dc.gov'}).
to_return(:body => fixture('get_service_request.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
with(query: {jurisdiction_id: 'dc.gov'}).
to_return(body: fixture('get_service_request.xml'), headers: {'Content-Type' => 'text/xml; charset=utf-8'})
end

it 'should request the correct resource' do
Open311.get_service_request(638_344)
expect(a_request(:get, 'http://blasius.ws:3003/open311/requests/638344.xml').
with(:query => {:jurisdiction_id => 'dc.gov'})).
with(query: {jurisdiction_id: 'dc.gov'})).
to have_been_made
end

Expand All @@ -133,8 +133,8 @@
describe 'when service_request_id is not valid' do
before do
stub_request(:get, 'http://blasius.ws:3003/open311/requests/not-an-id.xml').
with(:query => {:jurisdiction_id => 'dc.gov'}).
to_return(:body => fixture('get_service_request_not_found.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'}, :status => 404)
with(query: {jurisdiction_id: 'dc.gov'}).
to_return(body: fixture('get_service_request_not_found.xml'), headers: {'Content-Type' => 'text/xml; charset=utf-8'}, status: 404)
end

it 'raises Open311::NotFound' do
Expand All @@ -152,23 +152,23 @@
end

stub_request(:post, 'blasius.ws:3003/open311/requests.xml').
to_return(:body => fixture('post_service_request.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
to_return(body: fixture('post_service_request.xml'), headers: {'Content-Type' => 'text/xml; charset=utf-8'})
end

it 'should return the correct results' do
service_request_params = {
:service_code => '001',
:address_string => '1234 5th street',
:email => 'smit222@sfgov.edu',
:device_id => 'tt222111',
:account_id => '12345',
:first_name => 'john',
:last_name => 'smith',
:phone => '111111111',
:description => 'A large sinkhole is destroying the street',
:media_url => 'http://farm5.static.flickr.com/4057/4660699337_9aa4541ce1_o.jpg',
:lat => '38.888486',
:long => '-77.020179',
service_code: '001',
address_string: '1234 5th street',
email: 'smit222@sfgov.edu',
device_id: 'tt222111',
account_id: '12345',
first_name: 'john',
last_name: 'smith',
phone: '111111111',
description: 'A large sinkhole is destroying the street',
media_url: 'http://farm5.static.flickr.com/4057/4660699337_9aa4541ce1_o.jpg',
lat: '38.888486',
long: '-77.020179',
}
service_request_response = Open311.post_service_request(service_request_params)
expect(service_request_response.service_request_id).to eq('293944')
Expand All @@ -183,14 +183,14 @@
config.jurisdiction = 'sfgov.org'
end
stub_request(:get, 'http://open311.sfgov.org/dev/v2/tokens/12345.xml').
with(:query => {:jurisdiction_id => 'sfgov.org'}).
to_return(:body => fixture('request_id_from_token.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
with(query: {jurisdiction_id: 'sfgov.org'}).
to_return(body: fixture('request_id_from_token.xml'), headers: {'Content-Type' => 'text/xml; charset=utf-8'})
end

it 'should request the correct resource' do
Open311.request_id_from_token(12_345)
expect(a_request(:get, 'http://open311.sfgov.org/dev/v2/tokens/12345.xml').
with(:query => {:jurisdiction_id => 'sfgov.org'})).
with(query: {jurisdiction_id: 'sfgov.org'})).
to have_been_made
end

Expand All @@ -210,7 +210,7 @@
end

stub_request(:get, 'http://311api.cityofchicago.org/open311/v2/requests/638344.xml').
to_return(:body => fixture('service_requests.xml'), :headers => {'Content-Type' => 'text/xml; charset=utf-8'})
to_return(body: fixture('service_requests.xml'), headers: {'Content-Type' => 'text/xml; charset=utf-8'})
end

it 'should request the correct resource without a jurisdiction parameter' do
Expand Down

0 comments on commit c0bfd58

Please sign in to comment.