alpha_card 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36744d2c2e89bb5acb72ae8da81b9a5c684e5d2d
4
- data.tar.gz: 1b402affc8aa94c7f20ea1895f2744c265d48296
3
+ metadata.gz: d71d35569f21cf510852e3c35f8df41399983e8a
4
+ data.tar.gz: a2266edd9c1e5df53788121264173053615c0931
5
5
  SHA512:
6
- metadata.gz: 15f2fe0c1206ff43f976ab80564944aad992e70fc61e4e7cabac1fccbe05f3afe08c1cbf4e8375bbf44bedf328b007e7528bf674e10e730f28ebb605acf9e700
7
- data.tar.gz: 60d5b8edd45ede8faed993f8aaaf99d335349d71803b9c519b41861d50318f99690e9151ee8248dbcea727f7ae68fe2b0ecdbb408c86e8ecbb244071925648e1
6
+ metadata.gz: 417ac49bc0b7a982f56d7fbc16d684b616c807e88d1adf37a0d2ab7aba3920608f678aa7eb4d59f7fdb50a2b8a2c52a94ae8660443a50dc0ace98d1e8833ae14
7
+ data.tar.gz: cebcd84f04b491a4d0bb7ad199572d89a4efb74c0e075867037ed6d2a7c5539aa2d74dc5d5ea939fa13197ba5eaa0a45a05e34413d051db0ddef854a25bd6daa
data/Gemfile CHANGED
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'virtus'
6
- gem 'rest_client'
7
- gem 'coveralls', require: false
6
+ gem 'rest-client'
7
+ gem 'coveralls', require: false
8
+ gem 'rack-test', require: false
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Nikita Bulaj
3
+ Copyright (c) 2014-2015 Nikita Bulaj
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Ruby lib for creating payments with Alpha Card Services
2
2
  [![Gem Version](https://badge.fury.io/rb/alpha_card.svg)](http://badge.fury.io/rb/alpha_card)
3
- [![Dependency Status](https://gemnasium.com/budev/alpha_card.png)](https://gemnasium.com/budev/alpha_card)
4
- [![Code Climate](https://codeclimate.com/github/budev/alpha_card.png)](https://codeclimate.com/github/budev/alpha_card)
5
- [![Coverage Status](https://coveralls.io/repos/budev/alpha_card/badge.png?branch=master)](https://coveralls.io/r/budev/alpha_card?branch=master)
6
- [![Build Status](https://travis-ci.org/budev/alpha_card.svg?branch=master)](https://travis-ci.org/budev/alpha_card)
7
- [![Inline docs](http://inch-ci.org/github/budev/alpha_card.png?branch=master)](http://inch-ci.org/github/budev/alpha_card)
3
+ [![Dependency Status](https://gemnasium.com/nbulaj/alpha_card.svg)](https://gemnasium.com/nbulaj/alpha_card)
4
+ [![Code Climate](https://codeclimate.com/github/nbulaj/alpha_card/badges/gpa.svg)](https://codeclimate.com/github/nbulaj/alpha_card)
5
+ [![Coverage Status](https://coveralls.io/repos/nbulaj/alpha_card/badge.svg)](https://coveralls.io/r/nbulaj/alpha_card)
6
+ [![Build Status](https://travis-ci.org/nbulaj/alpha_card.svg?branch=master)](https://travis-ci.org/nbulaj/alpha_card)
7
+ [![Inline docs](http://inch-ci.org/github/nbulaj/alpha_card.png?branch=master)](http://inch-ci.org/github/nbulaj/alpha_card)
8
+ [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](#license)
8
9
 
9
10
  This gem can help your Ruby or Ruby on Rails application to integrate with Alpha Card Service, Inc.
10
11
 
@@ -231,6 +232,7 @@ To contribute:
231
232
 
232
233
  Thanks.
233
234
 
234
- ## Copyright
235
+ ## License
235
236
 
236
- Copyright (c) 2014 Nikita Bulaj (bulajnikita@gmail.com).
237
+ Alpha Card gem is released under the [MIT License](http://www.opensource.org/licenses/MIT).
238
+ Copyright (c) 2014-2015 Nikita Bulaj (bulajnikita@gmail.com).
data/alpha_card.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'alpha_card/version'
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = 'alpha_card'
7
7
  gem.version = AlphaCard::VERSION
8
- gem.date = '2014-07-24'
8
+ gem.date = '2015-04-27'
9
9
  gem.summary = 'Alpha Card Services API for Ruby'
10
10
  gem.description = 'Gem for creating sales with Alpha Card Services'
11
11
  gem.authors = ['Nikita Bulaj']
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.required_ruby_version = '>= 1.9.3'
18
18
 
19
19
  gem.add_dependency 'virtus', '~> 1.0'
20
- gem.add_dependency 'rest_client', '~> 1.7'
20
+ gem.add_dependency 'rest-client', '~> 1.8'
21
21
 
22
22
  gem.add_development_dependency 'rspec', '~> 3'
23
23
  end
data/lib/alpha_card.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # encoding:utf-8
2
2
  require 'yaml'
3
3
  require 'virtus'
4
- require 'rest_client'
4
+ require 'rest-client'
5
+ require 'rack/utils'
5
6
 
6
7
  # Version
7
8
  require 'alpha_card/version'
8
9
 
9
- require 'alpha_card/utils'
10
10
  require 'alpha_card/alpha_card_object'
11
11
  require 'alpha_card/alpha_card_response'
12
12
 
@@ -28,7 +28,7 @@ module AlphaCard
28
28
  #
29
29
  # #=> #<AlphaCard::AlphaCardResponse:0x00000003f2b568 @data={"response"=>"1", "responsetext"=>"Test"}>
30
30
  def initialize(response_body)
31
- @data = AlphaCard::Utils.parse_query(response_body)
31
+ @data = Rack::Utils.parse_query(response_body)
32
32
  end
33
33
 
34
34
  ##
@@ -41,7 +41,7 @@ module AlphaCard
41
41
  # #=> true
42
42
  def create(order, account)
43
43
  [:ccexp, :ccnumber, :amount].each do |attr|
44
- fail Exception, "No #{attr} information provided" if self[attr].nil? || self[attr].empty?
44
+ fail Exception, "No #{attr} information provided!" if self[attr].nil? || self[attr].empty?
45
45
  end
46
46
 
47
47
  params = filled_attributes || {}
@@ -1,5 +1,5 @@
1
1
  module AlphaCard
2
2
  ##
3
3
  # Version information for AlphaCard gem.
4
- VERSION = '0.2.4'
4
+ VERSION = '0.2.5'
5
5
  end
@@ -110,5 +110,16 @@ describe AlphaCard do
110
110
  expect(e.message).to include('Unexpected error communicating with Alpha Card Gateway')
111
111
  end
112
112
  end
113
+
114
+ context 'With request exception' do
115
+ let!(:sale) { AlphaCard::Sale.new({ccexp: card_exp, ccnumber: '4111111111111111', amount: '5.00'}) }
116
+
117
+ it 'should handle an error' do
118
+ AlphaCard.api_base = 'https://google.com' # todo: some other service
119
+ expect { sale.create(order, account) }.to raise_error(AlphaCard::APIConnectionError)
120
+
121
+ AlphaCard.api_base = 'https://secure.alphacardgateway.com/api/transact.php'
122
+ end
123
+ end
113
124
  end
114
125
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'rack/test'
2
+
1
3
  require 'coveralls'
2
4
  Coveralls.wear!
3
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alpha_card
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Bulaj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rest_client
28
+ name: rest-client
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.7'
33
+ version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.7'
40
+ version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -77,12 +77,10 @@ files:
77
77
  - lib/alpha_card/objects/order.rb
78
78
  - lib/alpha_card/objects/sale.rb
79
79
  - lib/alpha_card/objects/shipping.rb
80
- - lib/alpha_card/utils.rb
81
80
  - lib/alpha_card/version.rb
82
81
  - spec/alpha_card/alpha_card_account_spec.rb
83
82
  - spec/alpha_card/alpha_card_response_spec.rb
84
83
  - spec/alpha_card/alpha_card_spec.rb
85
- - spec/alpha_card/alpha_card_utils_spec.rb
86
84
  - spec/spec_helper.rb
87
85
  homepage: http://github.com/nbulaj/alpha_card
88
86
  licenses:
@@ -109,3 +107,4 @@ signing_key:
109
107
  specification_version: 4
110
108
  summary: Alpha Card Services API for Ruby
111
109
  test_files: []
110
+ has_rdoc:
@@ -1,83 +0,0 @@
1
- module AlphaCard
2
- ##
3
- # Some stolen methods to clear library dependencies.
4
- class Utils
5
- ##
6
- # This one is from the rack gem. It is useful for
7
- # parsing of Alpha Card Gateway response body.
8
- # @see https://github.com/rack/rack rack gem GitHub
9
- class << self
10
- ##
11
- # Default separators for the query string.
12
- DEFAULT_SEP = /[&;] */n
13
-
14
- ##
15
- # Unescapes a URI escaped string with +encoding+. +encoding+ will be the
16
- # target encoding of the string returned, and it defaults to UTF-8
17
- #
18
- # @param [String] s
19
- # String to unescape.
20
- #
21
- # @param [Encoding] encoding
22
- # Type of <code>Encoding</code>.
23
- #
24
- # @return [String] URI encoded string
25
- #
26
- # @raise [ArgumentError] if invalid Encoding is passed
27
- #
28
- # @example
29
- #
30
- # unescape('Test%20str')
31
- # #=> "Test str"
32
- #
33
- # unescape('Test%20str', Encoding::WINDOWS_31J)
34
- # #=> "Test str"
35
- def unescape(s, encoding = Encoding::UTF_8)
36
- URI.decode_www_form_component(s, encoding)
37
- end
38
-
39
- ##
40
- # Parse query string to a <code>Hash</code> by breaking it up
41
- # at the '&' and ';' characters.
42
- #
43
- # @param [String] query
44
- # query string
45
- # @param [String] d
46
- # delimiter for the params
47
- # @yieldparam unescaper
48
- # method, that will unescape the param value
49
- #
50
- # @return [Hash] query
51
- #
52
- # @example
53
- #
54
- # query = AlphaCard::Utils.parse_query("param1=value1&params2=")
55
- # #=> {"param1"=>"value1", "params2"=>""}
56
- #
57
- # query = AlphaCard::Utils.parse_query("cars[]=Saab&cars[]=Audi")
58
- # #=> {"cars[]"=>["Saab", "Audi"]}
59
- def parse_query(query, d = nil, &unescaper)
60
- unescaper ||= method(:unescape)
61
-
62
- params = {}
63
-
64
- (query || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
65
- next if p.empty?
66
- k, v = p.split('=', 2).map(&unescaper)
67
-
68
- if cur = params[k]
69
- if cur.class == Array
70
- params[k] << v
71
- else
72
- params[k] = [cur, v]
73
- end
74
- else
75
- params[k] = v
76
- end
77
- end
78
-
79
- params
80
- end
81
- end
82
- end
83
- end
@@ -1,25 +0,0 @@
1
- #encoding: utf-8
2
- require "spec_helper"
3
-
4
- describe AlphaCard::Utils do
5
- it 'parse query strings correctly' do
6
- expect(AlphaCard::Utils.parse_query("foo=bar")).to eq("foo" => "bar")
7
- expect(AlphaCard::Utils.parse_query('cars[]=Saab&cars[]=Audi')).to eq({'cars[]' => ['Saab', 'Audi']})
8
- expect(AlphaCard::Utils.parse_query("foo=bar&foo=quux")).to eq("foo" => ["bar", "quux"])
9
- expect(AlphaCard::Utils.parse_query("foo=1&bar=2")).to eq("foo" => "1", "bar" => "2")
10
- expect(AlphaCard::Utils.parse_query("my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F")).to eq("my weird field" => "q1!2\"'w$5&7/z8)?")
11
- expect(AlphaCard::Utils.parse_query("foo%3Dbaz=bar")).to eq("foo=baz" => "bar")
12
- expect(AlphaCard::Utils.parse_query("=")).to eq("" => "")
13
- expect(AlphaCard::Utils.parse_query("=value")).to eq("" => "value")
14
- expect(AlphaCard::Utils.parse_query("key=")).to eq("key" => "")
15
- expect(AlphaCard::Utils.parse_query("&key&")).to eq("key" => nil)
16
- end
17
-
18
- it 'unescape the characters correctly' do
19
- expect(AlphaCard::Utils.unescape('%E9%9F%93', Encoding::UTF_8)).to eq('韓')
20
- expect(AlphaCard::Utils.unescape("fo%3Co%3Ebar")).to eq("fo<o>bar")
21
- expect(AlphaCard::Utils.unescape("a+space")).to eq("a space")
22
- expect(AlphaCard::Utils.unescape("a%20space")).to eq("a space")
23
- expect(AlphaCard::Utils.unescape("q1%212%22%27w%245%267%2Fz8%29%3F%5C")).to eq("q1!2\"'w$5&7/z8)?\\")
24
- end
25
- end