retentiongrid 0.1.1 → 0.2.0

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: fbab0954075794e4599bf99ff930dc0d804f208e
4
- data.tar.gz: 11d8fe0f7624dd1fe4562519000100fdfa13ce31
3
+ metadata.gz: 8d0fa613d3babf6c177b1aac2f3ee7cd0fe7a1af
4
+ data.tar.gz: 625ee2cab1d11aacd52ba112ee8a206e1ffef971
5
5
  SHA512:
6
- metadata.gz: 7366ec154355f36d1da8178ebf01aadc62ade1fda549f368b4ed343a5cd09d6edfda2e113f70610df12929ccc4fce8bc64f9eb3f161e79bb5341cb9ff67716ef
7
- data.tar.gz: 46820483122f5e7a84a9a75ddde2c9a31c4102033a047780a166cd8f03ca7bb34c21a2371568cf17ef8fb9426eceef423b3a2fbf57a19a57e3ddfe367bfdda73
6
+ metadata.gz: 5aba78ecd284681abec3f5389656d0c4616f9e9d81475dc7212fd1a03998aa309640a789d7bfb969e3fe2ea66f295e77737f434364bd824c7fb172fd451b9e9f
7
+ data.tar.gz: 27025e4f718fc732c5467b8aef7d64d9fa4b6a89864cd072ba05c6a7b9c5c49db93a82e24ab4431217e013aca56c4262534c4f3d7a959205dc2703d7ff51f539
@@ -34,7 +34,8 @@ module Retentiongrid
34
34
  def get_with_response_check(*args)
35
35
  check_response_codes(get_without_response_check(*args))
36
36
  end
37
- alias_method_chain :get, :response_check
37
+ alias_method :get_without_response_check, :get
38
+ alias_method :get, :get_with_response_check
38
39
 
39
40
  # Do a HTTP POST requests with the given arguments
40
41
  # and then check for the response code.
@@ -46,7 +47,8 @@ module Retentiongrid
46
47
  def post_with_response_check(*args)
47
48
  check_response_codes(post_without_response_check(*args))
48
49
  end
49
- alias_method_chain :post, :response_check
50
+ alias_method :post_without_response_check, :post
51
+ alias_method :post, :post_with_response_check
50
52
 
51
53
  # Do a HTTP DELETE requests with the given arguments
52
54
  # and then check for the response code.
@@ -58,7 +60,8 @@ module Retentiongrid
58
60
  def delete_with_response_check(*args)
59
61
  check_response_codes(delete_without_response_check(*args))
60
62
  end
61
- alias_method_chain :delete, :response_check
63
+ alias_method :delete_without_response_check, :delete
64
+ alias_method :delete, :delete_with_response_check
62
65
 
63
66
  end
64
67
 
@@ -9,9 +9,8 @@ module Retentiongrid
9
9
  # customer = Retentiongrid::Customer.find('C123')
10
10
  #
11
11
  class Customer < Resource
12
- include ActiveModel::Validations
13
12
 
14
- BASE_PATH = '/customers'
13
+ BASE_PATH = '/customers'.freeze
15
14
 
16
15
  # The set of attributes defined by the API documentation
17
16
  ATTRIBUTES_NAMES = [ :customer_id, :full_name, :first_name, :email,
@@ -22,8 +21,6 @@ module Retentiongrid
22
21
  attr_accessor attrib
23
22
  end
24
23
 
25
- validates :customer_id, :full_name, presence: true
26
-
27
24
  # API Stuff here
28
25
 
29
26
  # Find a customer with given id
@@ -8,9 +8,8 @@ module Retentiongrid
8
8
  # order = Retentiongrid::Order.find('A123')
9
9
  #
10
10
  class Order < Resource
11
- include ActiveModel::Validations
12
11
 
13
- BASE_PATH = '/orders'
12
+ BASE_PATH = '/orders'.freeze
14
13
 
15
14
  # The set of attributes defined by the API documentation
16
15
  ATTRIBUTES_NAMES = [ :order_id, :customer_id, :status, :total_price, :total_discounts,
@@ -23,8 +22,6 @@ module Retentiongrid
23
22
 
24
23
  attr_accessor :customer
25
24
 
26
- validates :order_id, :customer_id, :currency, :total_price, :order_created_at, presence: true
27
-
28
25
  def initialize(attribs={})
29
26
  super
30
27
  @order_created_at = Time.parse(order_created_at) unless order_created_at.nil?
@@ -1,7 +1,7 @@
1
1
  module Retentiongrid
2
2
  class Product < Resource
3
3
 
4
- BASE_PATH = '/products'
4
+ BASE_PATH = '/products'.freeze
5
5
 
6
6
  # The set of attributes defined by the API documentation
7
7
  ATTRIBUTES_NAMES = [ :product_id, :available, :metadata,
@@ -4,7 +4,6 @@ module Retentiongrid
4
4
  # Base class for all API resources.
5
5
  #
6
6
  class Resource
7
- include ActiveModel::Validations
8
7
 
9
8
  ATTRIBUTES_NAMES = []
10
9
 
@@ -12,10 +11,6 @@ module Retentiongrid
12
11
  attr_accessor attrib
13
12
  end
14
13
 
15
- def self.base_path
16
- '/'
17
- end
18
-
19
14
  def initialize(attribs={})
20
15
  attribs.each do |attrib, value|
21
16
  self.send("#{attrib}=", value)
@@ -1,3 +1,3 @@
1
1
  module Retentiongrid
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/retentiongrid.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'active_model'
2
1
  require 'retentiongrid/version'
3
2
  require 'retentiongrid/resource'
4
3
  require 'retentiongrid/api'
@@ -20,15 +20,12 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency 'httparty', '0.13.1'
23
- spec.add_dependency 'activemodel', '>=3.2.0'
24
-
25
23
 
26
24
  spec.add_development_dependency 'bundler', '~> 1.6'
27
25
  spec.add_development_dependency 'rake'
28
26
  spec.add_development_dependency 'yard'
29
27
 
30
28
  spec.add_development_dependency 'rspec'
31
- spec.add_development_dependency 'shoulda-matchers'
32
29
  spec.add_development_dependency 'webmock'
33
30
  spec.add_development_dependency 'factory_girl'
34
31
 
@@ -49,10 +49,6 @@ RSpec.describe Customer do
49
49
 
50
50
  context '#delete' do
51
51
 
52
- subject do
53
- FactoryGirl.build(:customer)
54
- end
55
-
56
52
  before :each do
57
53
  stub_request(:delete, "http://retentiongrid.apiary-mock.com/customers/#{subject.customer_id}").to_return(:status => 204, :body => '')
58
54
  end
@@ -83,14 +83,6 @@ RSpec.describe Product do
83
83
 
84
84
  context '#delete' do
85
85
 
86
- let :product do
87
- FactoryGirl.build(:product)
88
- end
89
-
90
- subject do
91
- FactoryGirl.build(:product)
92
- end
93
-
94
86
  before :each do
95
87
  stub_request(:delete, "http://retentiongrid.apiary-mock.com/products/#{subject.product_id}").to_return(:status => 204, :body => '')
96
88
  end
@@ -6,10 +6,8 @@ RSpec.describe Customer do
6
6
  FactoryGirl.build(:customer)
7
7
  end
8
8
 
9
- context "validations" do
10
- it { expect(subject).to validate_presence_of :customer_id }
11
- it { expect(subject).to validate_presence_of :full_name }
12
- it { expect(subject).to be_valid }
9
+ it "sets the base path correctly" do
10
+ expect(Customer::BASE_PATH).to eql '/customers'
13
11
  end
14
12
 
15
13
  it "makes sure the customer id is populated" do
@@ -10,13 +10,8 @@ RSpec.describe Order do
10
10
  FactoryGirl.build(:order, customer: customer)
11
11
  end
12
12
 
13
- context "validations" do
14
- it { expect(subject).to validate_presence_of :order_id }
15
- it { expect(subject).to validate_presence_of :customer_id }
16
- it { expect(subject).to validate_presence_of :currency }
17
- it { expect(subject).to validate_presence_of :total_price }
18
- it { expect(subject).to validate_presence_of :order_created_at }
19
- it { expect(subject).to be_valid }
13
+ it "sets the base path correctly" do
14
+ expect(Order::BASE_PATH).to eql '/orders'
20
15
  end
21
16
 
22
17
  it "makes sure the order id is populated" do
@@ -6,6 +6,10 @@ RSpec.describe Product do
6
6
  FactoryGirl.build(:product)
7
7
  end
8
8
 
9
+ it "sets the base path correctly" do
10
+ expect(Product::BASE_PATH).to eql '/products'
11
+ end
12
+
9
13
  it "makes sure the product id is populated" do
10
14
  expect(subject.product_id).to_not eql nil
11
15
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'webmock/rspec'
2
2
  require 'factory_girl'
3
3
  require 'retentiongrid'
4
- require 'shoulda/matchers'
5
4
 
6
5
  require 'rspec'
7
6
  require 'coveralls'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retentiongrid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Bünte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-09 00:00:00.000000000 Z
11
+ date: 2014-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.13.1
27
- - !ruby/object:Gem::Dependency
28
- name: activemodel
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 3.2.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 3.2.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +80,6 @@ dependencies:
94
80
  - - ">="
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: shoulda-matchers
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: webmock
113
85
  requirement: !ruby/object:Gem::Requirement