diff --git a/Gemfile.lock b/Gemfile.lock index d57647c..4c1eb88 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,20 +2,16 @@ PATH remote: . specs: ideal (0.2.0) - activesupport builder nap GEM remote: http://rubygems.org/ specs: - activesupport (3.1.3) - multi_json (~> 1.0) builder (3.0.0) metaclass (0.0.1) mocha (0.10.0) metaclass (~> 0.0.1) - multi_json (1.0.4) nap (0.4) rake (0.9.2.2) diff --git a/ideal.gemspec b/ideal.gemspec index 9e322e1..f7b6f01 100644 --- a/ideal.gemspec +++ b/ideal.gemspec @@ -22,7 +22,6 @@ Gem::Specification.new do |s| s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] - s.add_dependency "activesupport" s.add_dependency "builder" s.add_dependency "nap" s.add_development_dependency "mocha" diff --git a/lib/ideal.rb b/lib/ideal.rb index 286d6e0..56fce30 100644 --- a/lib/ideal.rb +++ b/lib/ideal.rb @@ -1,6 +1,5 @@ # encoding: utf-8 -require 'active_support/core_ext' require 'builder' require 'rest' diff --git a/lib/ideal/gateway.rb b/lib/ideal/gateway.rb index 8328a92..86c615f 100644 --- a/lib/ideal/gateway.rb +++ b/lib/ideal/gateway.rb @@ -273,6 +273,14 @@ def created_at_timestamp Time.now.gmtime.strftime("%Y-%m-%dT%H:%M:%S.000Z") end + def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) + if first_letter_in_uppercase + lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } + else + lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1] + end + end + # iDeal doesn't really seem to care about nice looking keys in their XML. # Probably some Java XML class, hence the method name. def javaize_key(key) @@ -291,7 +299,7 @@ def javaize_key(key) when 'merchant_return_url' 'merchantReturnURL' when 'token_code', 'expiration_period', 'entrance_code' - key[0,1] + key.camelize[1..-1] + key[0,1] + camelize(key)[1..-1] when /^(\w+)_id$/ "#{$1}ID" else @@ -324,7 +332,7 @@ def xml_from_array(builder, tags_and_values) def requires!(options, *keys) missing = keys - options.keys unless missing.empty? - raise ArgumentError, "Missing required options: #{missing.to_sentence}" + raise ArgumentError, "Missing required options: #{missing.map { |m| m.to_s }.join(', ')}" end end diff --git a/lib/ideal/response.rb b/lib/ideal/response.rb index 2a3d459..98b1cb5 100644 --- a/lib/ideal/response.rb +++ b/lib/ideal/response.rb @@ -190,7 +190,7 @@ def initialize(response_body, options = {}) # :failure. def status status = text('//status') - status.downcase.to_sym unless status.blank? + status.downcase.to_sym unless (status.strip == '') end # Returns whether or not the authenticity of the message could be diff --git a/test/helper.rb b/test/helper.rb index f8494f1..b5f8bf1 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -19,7 +19,7 @@ class TestCase private def all_fixtures - @@fixtures ||= load_fixtures + @fixtures ||= load_fixtures end def fixtures(key) @@ -29,17 +29,7 @@ def fixtures(key) def load_fixtures file = File.exists?(LOCAL_CREDENTIALS) ? LOCAL_CREDENTIALS : DEFAULT_CREDENTIALS - yaml_data = YAML.load(File.read(file)) - symbolize_keys(yaml_data) - - yaml_data - end - - def symbolize_keys(hash) - return unless hash.is_a?(Hash) - - hash.symbolize_keys! - hash.each{|k,v| symbolize_keys(v)} + YAML.load(File.read(file)) end end end diff --git a/test/remote_test.rb b/test/remote_test.rb index 818574d..75095d7 100644 --- a/test/remote_test.rb +++ b/test/remote_test.rb @@ -4,7 +4,7 @@ class IdealTest < Test::Unit::TestCase def setup - setup_ideal_gateway(fixtures(:default)) + setup_ideal_gateway(fixtures('default')) Ideal::Gateway.environment = :test @gateway = Ideal::Gateway.new @@ -132,7 +132,7 @@ def test_transaction(type) def setup_ideal_gateway(fixture) fixture = fixture.dup # The passphrase needs to be set first, otherwise the key won't initialize properly - if passphrase = fixture.delete(:passphrase) + if passphrase = fixture.delete('passphrase') Ideal::Gateway.passphrase = passphrase end fixture.each { |key, value| Ideal::Gateway.send("#{key}=", value) }