diff --git a/.travis.yml b/.travis.yml index 21444f8..cc1efae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,9 @@ language: ruby rvm: - - '1.9.3' - - '2.0.0' - - '2.1.1' + - '1.9' + - '2.0' + - '2.1' - ruby-head - jruby-19mode - jruby-head diff --git a/Rakefile b/Rakefile index 78136ed..def0299 100644 --- a/Rakefile +++ b/Rakefile @@ -4,15 +4,18 @@ begin require 'hen' Hen.lay! {{ - :gem => { - :name => %q{wadl}, - :version => WADL::VERSION, - :summary => %q{Ruby client for the Web Application Description Language.}, - :authors => ['Leonard Richardson', 'Jens Wille'], - :email => ['leonardr@segfault.org', 'jens.wille@gmail.com'], - :license => %q{AGPL-3.0}, - :homepage => :blackwinter, - :dependencies => %w[cyclops rf-rest-open-uri mime-types safe_yaml] + gem: { + name: %q{wadl}, + version: WADL::VERSION, + summary: %q{Super cheap Ruby WADL client.}, + description: %q{Ruby client for the Web Application Description Language.}, + authors: ['Leonard Richardson', 'Jens Wille'], + email: 'jens.wille@gmail.com', + license: %q{AGPL-3.0}, + homepage: :blackwinter, + dependencies: %w[cyclops rf-rest-open-uri mime-types safe_yaml], + + required_ruby_version: '>= 1.9.3' } }} rescue LoadError => err diff --git a/lib/wadl.rb b/lib/wadl.rb index dafa41e..8e84a6a 100644 --- a/lib/wadl.rb +++ b/lib/wadl.rb @@ -4,7 +4,7 @@ # wadl -- Super cheap Ruby WADL client # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,7 +26,7 @@ ############################################################################### #++ -require 'wadl/version' +require_relative 'wadl/version' module WADL diff --git a/lib/wadl/address.rb b/lib/wadl/address.rb index 63b0a99..ca75121 100644 --- a/lib/wadl/address.rb +++ b/lib/wadl/address.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL # The Address class keeps track of the user's path through a resource diff --git a/lib/wadl/application.rb b/lib/wadl/application.rb index dae0e72..bb2be59 100644 --- a/lib/wadl/application.rb +++ b/lib/wadl/application.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -27,7 +27,6 @@ #++ require 'rexml/document' -require 'wadl' module WADL diff --git a/lib/wadl/cheap_schema.rb b/lib/wadl/cheap_schema.rb index 97d41d4..f539937 100644 --- a/lib/wadl/cheap_schema.rb +++ b/lib/wadl/cheap_schema.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL # A cheap way of defining an XML schema as Ruby classes and then parsing @@ -389,8 +387,3 @@ def to_s(indent = 0, collection = false) end end - -# Simple backport for Ruby <= 1.8.5 -class Object # :nodoc: - def instance_variable_defined?(sym); instance_eval("defined?(#{sym})"); end -end unless Object.method_defined?(:instance_variable_defined?) diff --git a/lib/wadl/cli.rb b/lib/wadl/cli.rb index 8561f9f..6950438 100644 --- a/lib/wadl/cli.rb +++ b/lib/wadl/cli.rb @@ -25,8 +25,8 @@ #++ require 'cgi' -require 'stringio' require 'cyclops' +require 'stringio' require 'wadl' begin @@ -53,12 +53,12 @@ def usage(*) def defaults super.merge( - :config => 'config.yaml', - :method => 'GET', - :user => ENV['USER'] || '', - :request_token_url => '%s/oauth/request_token', - :access_token_url => '%s/oauth/access_token', - :authorize_url => '%s/oauth/authorize' + config: 'config.yaml', + method: 'GET', + user: ENV['USER'] || '', + request_token_url: '%s/oauth/request_token', + access_token_url: '%s/oauth/access_token', + authorize_url: '%s/oauth/authorize' ) end @@ -85,7 +85,7 @@ def run(arguments) stderr.puts api if debug >= 2 end - response = auth_resource.send(options[:method].downcase, :query => query) + response = auth_resource.send(options[:method].downcase, query: query) stderr.puts response.code.join(' ') stdout.puts response.representation unless response.code.first =~ /\A[45]/ @@ -182,7 +182,7 @@ def add_param(params, key, value) def basic_auth_resource user, pass = options.values_at(:user, :password) - pass ||= ask("Password for user #{user}: ") { |q| q.echo = false } + pass ||= askpass("Password for user #{user}: ") quit 'USER and PASSWORD required' unless user && pass diff --git a/lib/wadl/documentation.rb b/lib/wadl/documentation.rb index 797b01f..78c2bc4 100644 --- a/lib/wadl/documentation.rb +++ b/lib/wadl/documentation.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class Documentation < CheapSchema diff --git a/lib/wadl/fault.rb b/lib/wadl/fault.rb index cdce6ab..e7a842f 100644 --- a/lib/wadl/fault.rb +++ b/lib/wadl/fault.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class Fault < Exception diff --git a/lib/wadl/fault_format.rb b/lib/wadl/fault_format.rb index d23cd7d..5066209 100644 --- a/lib/wadl/fault_format.rb +++ b/lib/wadl/fault_format.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class FaultFormat < RepresentationFormat diff --git a/lib/wadl/has_docs.rb b/lib/wadl/has_docs.rb index ab16654..12ecef3 100644 --- a/lib/wadl/has_docs.rb +++ b/lib/wadl/has_docs.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class HasDocs < CheapSchema diff --git a/lib/wadl/http_method.rb b/lib/wadl/http_method.rb index d473e19..5cd79e7 100644 --- a/lib/wadl/http_method.rb +++ b/lib/wadl/http_method.rb @@ -28,7 +28,6 @@ require 'safe_yaml/load' require 'rf-rest-open-uri' -require 'wadl' begin require 'oauth/client/helper' @@ -95,11 +94,11 @@ def set_oauth_header(headers, uri) request = OpenURI::Methods[headers[:method]].new(uri.to_s) headers[OAUTH_HEADER] = OAuth::Client::Helper.new(request, - :request_uri => request.path, - :consumer => consumer = OAuth::Consumer.new(*args[0, 2]), - :token => OAuth::AccessToken.new(consumer, *args[2, 2]), - :scheme => 'header', - :signature_method => 'HMAC-SHA1' + request_uri: request.path, + consumer: consumer = OAuth::Consumer.new(*args[0, 2]), + token: OAuth::AccessToken.new(consumer, *args[2, 2]), + scheme: 'header', + signature_method: 'HMAC-SHA1' ).header end diff --git a/lib/wadl/link.rb b/lib/wadl/link.rb index 9655074..3918b08 100644 --- a/lib/wadl/link.rb +++ b/lib/wadl/link.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class Link < HasDocs diff --git a/lib/wadl/option.rb b/lib/wadl/option.rb index 80055a0..4112313 100644 --- a/lib/wadl/option.rb +++ b/lib/wadl/option.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class Option < HasDocs diff --git a/lib/wadl/param.rb b/lib/wadl/param.rb index 5b4601f..1664df2 100644 --- a/lib/wadl/param.rb +++ b/lib/wadl/param.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class Param < HasDocs diff --git a/lib/wadl/representation_container.rb b/lib/wadl/representation_container.rb index 8d890ba..c6b5df0 100644 --- a/lib/wadl/representation_container.rb +++ b/lib/wadl/representation_container.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL # A mixin for objects that contain representations diff --git a/lib/wadl/representation_format.rb b/lib/wadl/representation_format.rb index 084ca5a..b6e3da2 100644 --- a/lib/wadl/representation_format.rb +++ b/lib/wadl/representation_format.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -27,7 +27,6 @@ #++ require 'cgi' -require 'wadl' module WADL @@ -38,15 +37,17 @@ class RepresentationFormat < HasDocs has_many Param may_be_reference + FORM_TYPES = %w[application/x-www-form-urlencoded multipart/form-data] + def is_form_representation? - mediaType == 'application/x-www-form-urlencoded' || mediaType == 'multipart/form-data' + FORM_TYPES.include?(mediaType) end # Creates a representation by plugging a set of parameters # into a representation format. def %(values) - unless mediaType == 'application/x-www-form-urlencoded' - raise "wadl.rb can't instantiate a representation of type #{mediaType}" + unless is_form_representation? + raise "wadl can't instantiate a representation of type #{mediaType}" end representation = [] diff --git a/lib/wadl/request_format.rb b/lib/wadl/request_format.rb index 2cdd32e..5d8c181 100644 --- a/lib/wadl/request_format.rb +++ b/lib/wadl/request_format.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class RequestFormat < HasDocs diff --git a/lib/wadl/resource.rb b/lib/wadl/resource.rb index be45e1f..8ab52c5 100644 --- a/lib/wadl/resource.rb +++ b/lib/wadl/resource.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -27,7 +27,6 @@ #++ require 'set' -require 'wadl' module WADL diff --git a/lib/wadl/resource_and_address.rb b/lib/wadl/resource_and_address.rb index d473a34..bb95ca9 100644 --- a/lib/wadl/resource_and_address.rb +++ b/lib/wadl/resource_and_address.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -27,7 +27,6 @@ #++ require 'delegate' -require 'wadl' module WADL diff --git a/lib/wadl/resource_container.rb b/lib/wadl/resource_container.rb index 9588345..8d31681 100644 --- a/lib/wadl/resource_container.rb +++ b/lib/wadl/resource_container.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL # A mixin for objects that contain resources. If you include this, be diff --git a/lib/wadl/resource_type.rb b/lib/wadl/resource_type.rb index be3390e..e0ad10b 100644 --- a/lib/wadl/resource_type.rb +++ b/lib/wadl/resource_type.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL # A type of resource. Basically a mixin of methods and params for actual diff --git a/lib/wadl/resources.rb b/lib/wadl/resources.rb index 00c3acd..2907b58 100644 --- a/lib/wadl/resources.rb +++ b/lib/wadl/resources.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class Resources < HasDocs diff --git a/lib/wadl/response.rb b/lib/wadl/response.rb index 148a663..ffb31d2 100644 --- a/lib/wadl/response.rb +++ b/lib/wadl/response.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL class Response < Struct.new(:code, :headers, :representation, :format) diff --git a/lib/wadl/response_format.rb b/lib/wadl/response_format.rb index b8ea8e1..65f11be 100644 --- a/lib/wadl/response_format.rb +++ b/lib/wadl/response_format.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -31,8 +31,6 @@ rescue LoadError end -require 'wadl' - module WADL class ResponseFormat < HasDocs diff --git a/lib/wadl/uri_parts.rb b/lib/wadl/uri_parts.rb index 6997e22..522670f 100644 --- a/lib/wadl/uri_parts.rb +++ b/lib/wadl/uri_parts.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -26,8 +26,6 @@ ############################################################################### #++ -require 'wadl' - module WADL # Classes to keep track of the logical structure of a URI. diff --git a/lib/wadl/xml_representation.rb b/lib/wadl/xml_representation.rb index 1e06d4d..9e6c570 100644 --- a/lib/wadl/xml_representation.rb +++ b/lib/wadl/xml_representation.rb @@ -4,7 +4,7 @@ # A component of wadl, the super cheap Ruby WADL client. # # # # Copyright (C) 2006-2008 Leonard Richardson # -# Copyright (C) 2010-2013 Jens Wille # +# Copyright (C) 2010-2014 Jens Wille # # # # Authors: # # Leonard Richardson (Original author) # @@ -27,7 +27,6 @@ #++ require 'rexml/document' -require 'wadl' module WADL diff --git a/test/wadl_test.rb b/test/wadl_test.rb index 2d73062..0a672e3 100644 --- a/test/wadl_test.rb +++ b/test/wadl_test.rb @@ -1,10 +1,5 @@ # Unit tests for the Ruby WADL library. -begin - require 'rubygems' -rescue LoadError -end - $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__)) require 'test/unit' @@ -125,15 +120,15 @@ def test_path_parameter_substitution insult_resource = @wadl.find_resource_by_path('the/{person}/is/{a}') # Test simple substitution. - assert_equal(insult_resource.uri(:path => { 'person' => 'king', 'a' => 'fink' }), + assert_equal(insult_resource.uri(path: { 'person' => 'king', 'a' => 'fink' }), 'http://www.example.com/the/king/is/;a=fink') # Test default values. - assert_equal(insult_resource.uri(:path => { 'person' => 'king' }), + assert_equal(insult_resource.uri(path: { 'person' => 'king' }), 'http://www.example.com/the/king/is/;a=dork') # Test use of optional paramaters. - assert_equal(insult_resource.uri(:path => { 'person' => 'king', 'a' => 'fink', - 'and' => 'he can bite me' }), + assert_equal(insult_resource.uri(path: { 'person' => 'king', 'a' => 'fink', + 'and' => 'he can bite me' }), 'http://www.example.com/the/king/is/;a=fink/;and=he%20can%20bite%20me') # Don't provide required argument. @@ -141,7 +136,7 @@ def test_path_parameter_substitution # Provide multiple values for single-valued argument. assert_raises(ArgumentError) { - insult_resource.uri(:path => { :person => 'king', :a => ['fink', 'dolt'] }) + insult_resource.uri(path: { person: 'king', a: %w[fink dolt] }) } end @@ -159,10 +154,10 @@ def test_options EOT - assert_equal(resource.uri(:path => { :fate => 'Clotho' }), + assert_equal(resource.uri(path: { fate: 'Clotho' }), 'http://www.example.com/fates/Clotho') - assert_raises(ArgumentError) { resource.uri(:path => { :fate => 'Groucho' }) } + assert_raises(ArgumentError) { resource.uri(path: { fate: 'Groucho' }) } end # This one's complicated. We bind a resource's path parameters to @@ -174,19 +169,19 @@ def test_bound_resource_traversal assert_equal(im_mad_because.uri, 'http://www.example.com/im/mad/because') insult = im_mad_because.find_resource('insult') - assert_equal(insult.uri(:path => { 'person' => 'king', 'a' => 'fink' }), + assert_equal(insult.uri(path: { 'person' => 'king', 'a' => 'fink' }), 'http://www.example.com/im/mad/because/the/king/is/;a=fink') - im_mad_because_hes_a_fink = insult.bind!(:path => { 'person' => 'king', 'a' => 'fink' }) + im_mad_because_hes_a_fink = insult.bind!(path: { 'person' => 'king', 'a' => 'fink' }) assert_equal(im_mad_because_hes_a_fink.uri, 'http://www.example.com/im/mad/because/the/king/is/;a=fink') im_mad_because_hes_a_fink_lets = im_mad_because_hes_a_fink.find_resource("so-let's") - assert_equal(im_mad_because_hes_a_fink_lets.uri(:path => { 'do something' => 'revolt' }), + assert_equal(im_mad_because_hes_a_fink_lets.uri(path: { 'do something' => 'revolt' }), "http://www.example.com/im/mad/because/the/king/is/;a=fink/so-let's/revolt") im_mad_because_hes_a_fink_lets_revolt = im_mad_because_hes_a_fink_lets. - bind(:path => { 'person' => 'fink', 'do something' => 'revolt' }) + bind(path: { 'person' => 'fink', 'do something' => 'revolt' }) assert_equal(im_mad_because_hes_a_fink_lets_revolt.uri, "http://www.example.com/im/mad/because/the/king/is/;a=fink/so-let's/revolt") @@ -206,7 +201,7 @@ def test_repeating_arguments { 'plain' => 'http://www.example.com/i/want/pony,water%20slide,BB%20gun', 'matrix' => 'http://www.example.com/i/want/;a=pony;a=water%20slide;a=BB%20gun' }.each { |style, uri| list = wadl(text % style).find_resource('list') - assert_equal(list.uri(:path => { :a => ['pony', 'water slide', 'BB gun'] }), uri) + assert_equal(list.uri(path: { a: ['pony', 'water slide', 'BB gun'] }), uri) } end @@ -219,7 +214,7 @@ def test_fixed_values EOT - assert_equal(poll.uri(:opinion => 'ungood'), + assert_equal(poll.uri(opinion: 'ungood'), 'http://www.example.com/big-brother-is/doubleplusgood') end @@ -237,14 +232,14 @@ def test_matrix_values on_uri = 'http://www.example.com/light-panel/;light1;light3' off_uri = 'http://www.example.com/light-panel/;light1' - assert_equal(lights.uri(:path => { :light3 => 'true' }), on_uri) - assert_equal(lights.uri(:path => { :light3 => '1' }), on_uri) + assert_equal(lights.uri(path: { light3: 'true' }), on_uri) + assert_equal(lights.uri(path: { light3: '1' }), on_uri) assert_equal(lights.uri, off_uri) - assert_equal(lights.uri(:path => { :light3 => 'false' }), off_uri) - assert_equal(lights.uri(:path => { :light3 => false }), off_uri) - assert_equal(lights.uri(:path => { :light3 => 'True' }), off_uri) - assert_equal(lights.uri(:path => { :light3 => true }), off_uri) + assert_equal(lights.uri(path: { light3: 'false' }), off_uri) + assert_equal(lights.uri(path: { light3: false }), off_uri) + assert_equal(lights.uri(path: { light3: 'True' }), off_uri) + assert_equal(lights.uri(path: { light3: true }), off_uri) end end @@ -279,15 +274,15 @@ def setup EOT - @color = @wadl.find_resource('top').bind(:query => { :api_key => 'foobar' }).find_resource('color') + @color = @wadl.find_resource('top').bind(query: { api_key: 'foobar' }).find_resource('color') end def test_query_vars graphic = @color.find_method('get_graphic') - path = { :color => 'blue' } - query = { :shade => 'light' } + path = { color: 'blue' } + query = { shade: 'light' } - assert_equal(graphic.request.uri(@color, :path => path, :query => query), + assert_equal(graphic.request.uri(@color, path: path, query: query), 'http://www.example.com/palette/colors/blue?shade=light') assert_raises(ArgumentError) { graphic.request.uri(@color, path) } @@ -297,10 +292,10 @@ def test_representation graphic = @color.find_method('set_graphic') representation = graphic.request.find_form - assert_equal(representation % { :new_graphic => 'foobar', 'filename' => 'blue.jpg' }, + assert_equal(representation % { new_graphic: 'foobar', 'filename' => 'blue.jpg' }, 'new_graphic=foobar&filename=blue.jpg') - assert_raises(ArgumentError) { representation % { :new_graphic => 'foobar' } } + assert_raises(ArgumentError) { representation % { new_graphic: 'foobar' } } end end @@ -390,7 +385,7 @@ def test_basic_auth end def test_template_params_with_basic_auth - arg = { :path => { :id => 42 } } + arg = { path: { id: 42 } } uri = 'http://www.example.com/service/42.json' assert_equal(uri, u1 = @service.bind(arg).uri)