Make compatible with Ruby versions < 1.9

This commit is contained in:
Erik Michaels-Ober 2010-11-30 08:54:49 -08:00
parent 3fb8d858ff
commit 3ddda07d91
4 changed files with 16 additions and 6 deletions

View file

@ -2,4 +2,5 @@ require 'base64'
require 'cgi'
require 'openssl'
require 'uri'
require File.expand_path('../simple_oauth/core_ext/object', __FILE__)
require File.expand_path('../simple_oauth/header', __FILE__)

View file

@ -0,0 +1,10 @@
major, minor, patch = RUBY_VERSION.split('.')
if major.to_i == 1 && minor.to_i < 9
class Object
def tap
yield self
self
end
end
end

View file

@ -11,9 +11,8 @@ Gem::Specification.new do |spec|
spec.homepage = 'http://github.com/laserlemon/simple_oauth'
spec.name = 'simple_oauth'
spec.rdoc_options = ['--charset=UTF-8']
spec.required_ruby_version = '>= 1.8.7'
spec.required_rubygems_version = '>= 1.2.0'
spec.summary = 'Simply builds and verifies OAuth headers'
spec.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if spec.respond_to? :required_rubygems_version=
spec.summary = spec.description
spec.test_files = `git ls-files -- test/**/*_test.rb`.split("\n")
spec.version = SimpleOAuth::Version::STRING
end

View file

@ -237,7 +237,7 @@ class SimpleOAuthTest < Test::Unit::TestCase
# The signature parameters should be sorted and the keys/values URL encoded
# first.
assert_equal signature_params.sort_by(&:to_s), pairs.map{|k,v| [URI.decode(k), URI.decode(v)] }
assert_equal signature_params.sort_by{|p| p.to_s}, pairs.map{|k, v| [URI.decode(k), URI.decode(v)]}
end
def test_signature_params
@ -250,8 +250,8 @@ class SimpleOAuthTest < Test::Unit::TestCase
# parameters into an array of key value pairs.
signature_params = header.send(:signature_params)
assert_kind_of Array, signature_params
assert_equal [:attribute, 'param', 'url_param', 'url_param'], signature_params.map(&:first)
assert_equal ['ATTRIBUTE', 'PARAM', '1', '2'], signature_params.map(&:last)
assert_equal [:attribute, 'param', 'url_param', 'url_param'], signature_params.map{|p| p.first}
assert_equal ['ATTRIBUTE', 'PARAM', '1', '2'], signature_params.map{|p| p.last}
end
def test_url_params