Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove the ActiveSupport dependency.
  • Loading branch information
Manfred committed Jan 3, 2012
1 parent 7614974 commit 56c975c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 23 deletions.
4 changes: 0 additions & 4 deletions Gemfile.lock
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion ideal.gemspec
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion lib/ideal.rb
@@ -1,6 +1,5 @@
# encoding: utf-8

require 'active_support/core_ext'
require 'builder'
require 'rest'

Expand Down
12 changes: 10 additions & 2 deletions lib/ideal/gateway.rb
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/ideal/response.rb
Expand Up @@ -190,7 +190,7 @@ def initialize(response_body, options = {})
# <tt>:failure</tt>.
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
Expand Down
14 changes: 2 additions & 12 deletions test/helper.rb
Expand Up @@ -19,7 +19,7 @@ class TestCase
private

def all_fixtures
@@fixtures ||= load_fixtures
@fixtures ||= load_fixtures
end

def fixtures(key)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/remote_test.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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) }
Expand Down

0 comments on commit 56c975c

Please sign in to comment.