alpha_card 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6af86a7de326ef53708c81f07ed025792c44841c
4
- data.tar.gz: 5a670c2177f9b7ac326f34ea1c3e34decd5ea37c
3
+ metadata.gz: 706d4fb925ed92b75aeb824e9ac0cb1353b4cd5e
4
+ data.tar.gz: ddd2530759a1516a3008c10635105acdb19d7782
5
5
  SHA512:
6
- metadata.gz: ca0333c53125849ca415b73a10d9a4c659d54cff80879bc0f2aadd3aa502ffecc3af758ed87709ce83ba7016d57679b7a6f023f672952d7e9f3788fda29f7ad1
7
- data.tar.gz: 0bea0ef881a98bd593a99a20883de46f2b94f1d6cf384caa39dbeaed8f95f53a99afa8855a22becba76f0e0f6b5ac90017263dda9d2473a4564e7938c525d7a9
6
+ metadata.gz: 35b50540e1457d8f9774307dcb7443d084c24ede72a009dca98430a265bb5a0dea4162b3fe9f7785a66c62dbdb2094c280a6fb164d08afd6d628515c30bca624
7
+ data.tar.gz: ee1eb394decc0933f881f4f8e9931ae083cb215b4d1a0d622d15befa0d361cbdbfefb1cdd7d3bdd63e8651317c428c11ed11ec9d733e9bff4e7910f61ecb967a
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Code Climate](https://codeclimate.com/github/budev/alpha_card.png)](https://codeclimate.com/github/budev/alpha_card)
5
5
  [![Coverage Status](https://coveralls.io/repos/budev/alpha_card/badge.png?branch=master)](https://coveralls.io/r/budev/alpha_card?branch=master)
6
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)
7
8
 
8
9
  This gem can help your Ruby or Ruby on Rails application to integrate with Alpha Card Service, Inc.
9
10
 
@@ -37,7 +38,6 @@ gem install alpha_card
37
38
  Dependencies required:
38
39
 
39
40
  * ruby >= 1.9.3;
40
- * rack;
41
41
  * rest_client;
42
42
  * virtus (for nice OOP objects of AlphaCard).
43
43
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'alpha_card'
3
- gem.version = '0.1.7'
4
- gem.date = '2014-06-27'
3
+ gem.version = '0.1.8'
4
+ gem.date = '2014-07-01'
5
5
  gem.summary = 'Alpha Card Services DirectPost API for Ruby'
6
6
  gem.description = 'Gem for creating sales with Alpha Card Services DirectPost API'
7
7
  gem.authors = ['Nikita Bulaj']
@@ -4,7 +4,6 @@ require 'virtus'
4
4
  require 'rest_client'
5
5
 
6
6
  require 'alpha_card/utils'
7
- require 'alpha_card/object'
8
7
  require 'alpha_card/alpha_card_object'
9
8
  require 'alpha_card/alpha_card_response'
10
9
  require 'alpha_card/alpha_card_error'
@@ -41,7 +41,8 @@ module AlphaCard
41
41
  #
42
42
  # #=> false
43
43
  def filled?
44
- [self.username, self.password].all?(&:present?)
44
+ attrs = [username, password]
45
+ !attrs.empty? && attrs.all? {|attr| attr && !attr.strip.empty? }
45
46
  end
46
47
  end
47
48
  end
@@ -18,7 +18,7 @@ module AlphaCard
18
18
  #
19
19
  # #=> {orderid: '1', ponumber: 'PO123'}
20
20
  def filled_attributes
21
- self.attributes.select { |key, value| value.present? }
21
+ self.attributes.select { |_, value| !value.nil? }
22
22
  end
23
23
  end
24
24
  end
@@ -3,7 +3,7 @@ module AlphaCard
3
3
  # Implementation of Alpha Card Services Order object.
4
4
  # Contains all the information about order (id, description, etc).
5
5
  class Order < AlphaCardObject
6
- attribute :orderid, Integer
6
+ attribute :orderid, String
7
7
  attribute :orderdescription, String
8
8
  attribute :ponumber, String
9
9
  attribute :tax, String
@@ -41,11 +41,11 @@ module AlphaCard
41
41
  # #=> true
42
42
  def create(order, account)
43
43
  [:ccexp, :ccnumber, :amount].each do |attr|
44
- raise Exception.new("No #{attr} information provided") if self[attr].blank?
44
+ raise Exception.new("No #{attr} information provided") if self[attr].nil? || self[attr].empty?
45
45
  end
46
46
 
47
47
  params = self.filled_attributes || {}
48
- [order, order.billing, order.shipping].compact.each { |obj| params.merge!(obj.try(:filled_attributes)) }
48
+ [order, order.billing, order.shipping].compact.each { |obj| params.merge!(obj ? obj.filled_attributes : {}) }
49
49
 
50
50
  AlphaCard.request(params, account).success?
51
51
  end
@@ -8,7 +8,7 @@ module AlphaCard
8
8
  # @see https://github.com/rack/rack rack gem GitHub
9
9
  class << self
10
10
  ##
11
- # Default separators for query string.
11
+ # Default separators for the query string.
12
12
  DEFAULT_SEP = /[&;] */n
13
13
 
14
14
  # A part of the rack gem.
@@ -29,10 +29,15 @@ module AlphaCard
29
29
  @params[key] = value
30
30
  end
31
31
 
32
+ ##
33
+ # Returns <code>true</code> if the given key is present
34
+ # in <i>params</i>.
32
35
  def key?(key)
33
36
  @params.key?(key)
34
37
  end
35
38
 
39
+ ##
40
+ # Converts params to <code>Hash</code> object.
36
41
  def to_params_hash
37
42
  hash = @params
38
43
  hash.keys.each do |key|
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.1.7
4
+ version: 0.1.8
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-06-27 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -45,7 +45,6 @@ files:
45
45
  - lib/alpha_card/alpha_card_response.rb
46
46
  - lib/alpha_card/billing.rb
47
47
  - lib/alpha_card/data/codes.yml
48
- - lib/alpha_card/object.rb
49
48
  - lib/alpha_card/order.rb
50
49
  - lib/alpha_card/sale.rb
51
50
  - lib/alpha_card/shipping.rb
@@ -1,52 +0,0 @@
1
- ##
2
- # Some stolen methods from the active_support gem.
3
- # For the clear dependencies.
4
- # @todo Remove this class, rewrite library code
5
- class Object
6
- # An object is blank if it's false, empty, or a whitespace string.
7
- # For example, '', ' ', +nil+, [], and {} are all blank.
8
- #
9
- # This simplifies
10
- #
11
- # address.nil? || address.empty?
12
- #
13
- # to
14
- #
15
- # address.blank?
16
- #
17
- # @return [true, false]
18
- def blank?
19
- respond_to?(:empty?) ? !!empty? : !self
20
- end
21
-
22
- # An object is present if it's not blank.
23
- #
24
- # @return [true, false]
25
- def present?
26
- !blank?
27
- end
28
-
29
- # Invokes the public method whose name goes as first argument just like
30
- # +public_send+ does, except that if the receiver does not respond to it the
31
- # call returns +nil+ rather than raising an exception.
32
- #
33
- # This method is defined to be able to write
34
- #
35
- # @person.try(:name)
36
- #
37
- # instead of
38
- #
39
- # @person ? @person.name : nil
40
- #
41
- # +try+ returns +nil+ when called on +nil+ regardless of whether it responds
42
- # to the method:
43
- #
44
- # nil.try(:to_i) # => nil, rather than 0
45
- def try(*a, &b)
46
- if a.empty? && block_given?
47
- yield self
48
- else
49
- public_send(*a, &b) if respond_to?(a.first)
50
- end
51
- end
52
- end