mad_cart 0.1.6 → 0.1.7

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
- SHA1:
3
- metadata.gz: 4b414baa5cd556c5664acb0daf217ee9e41d9489
4
- data.tar.gz: 1e64b3d30bb94d163532c25cfcc11d8773effc7f
2
+ SHA256:
3
+ metadata.gz: a80578ffa5622853d9e5b888aafeabaab3ff747d9bdfb3878bb1f135cb07a1fb
4
+ data.tar.gz: c7bf4b3c4c7187ce8a1f86626c12c9bcb106c5f811ec5ee705fca53f6e0398ef
5
5
  SHA512:
6
- metadata.gz: 2341f979b1f6f50db08f1077574a521c40e877087431d130eb552c6b0098ed35f08598b2c81b1bcbd2a05b23d6ddf7eb3dfa473bb1d2518d8f53095c6645cb16
7
- data.tar.gz: c8491b179797a5e7fc17aa4e3427353a0a38235e7f79f3bdf6c9aad615a2157d907ade75330528db96f1fc522f51cb8dd346cfb47fc93343c2b75ab1e63781f4
6
+ metadata.gz: a20e18302a6e26b6569b43312ee4aa0ccd3de58a19fc85dfc664a8134ff7927dd6f37fad97474a8299337d70c4d544c7621b5906d6c253d2e0ceb3ec1dea43f1
7
+ data.tar.gz: 2709111a2709b0afea3d6324e66b3cbe002ac8e0a86ad788ec84a7166213edebebd2e53166a5116acfe663e5412443c28eb9fbf9e0778f5a81e803a884df33c9
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.5
3
+ - 2.5.3
4
4
  cache:
5
5
  - bundler
6
6
  script:
@@ -14,7 +14,7 @@ module MadCart
14
14
  include InheritableAttributes
15
15
  attr_accessor :additional_attributes
16
16
  inheritable_attributes :required_attrs
17
- attr_accessor *exposed_attributes
17
+ attr_accessor(*exposed_attributes)
18
18
  end
19
19
  end
20
20
 
@@ -54,7 +54,7 @@ module MadCart
54
54
  module ClassMethods
55
55
  def required_attributes(*args)
56
56
  @required_attrs = args.map{|a| a.to_s }
57
- attr_accessor *args
57
+ attr_accessor(*args)
58
58
  end
59
59
 
60
60
  def exposed_attributes
@@ -54,12 +54,12 @@ module MadCart
54
54
  private :valid_by_path?
55
55
 
56
56
  def parse_response(&block)
57
- response = check_for_errors &block
57
+ response = check_for_errors(&block)
58
58
  empty_body?(response) ? [] : response.body
59
59
  end
60
60
  private :parse_response
61
61
 
62
- def check_for_errors(&block)
62
+ def check_for_errors
63
63
  response = yield
64
64
 
65
65
  case response.status
@@ -52,16 +52,15 @@ module MadCart
52
52
 
53
53
  def get_customer_hashes
54
54
  result = []
55
- loop(:make_customer_request) {|c| result << c }
55
+ for_each(:make_customer_request) {|c| result << c }
56
56
  result
57
57
  end
58
58
 
59
- def loop(source, &block)
60
-
59
+ def for_each(source, &block)
61
60
  items = send(source, :min_id => 1)
62
61
 
63
- while true
64
- items.each &block
62
+ loop do
63
+ items.each(&block)
65
64
  break if items.count < 50
66
65
  items = send(source, :min_id => items.last['id'] + 1 )
67
66
  end
@@ -30,10 +30,10 @@ module MadCart
30
30
  parse_response { connection.get('products.json', params) }
31
31
  end
32
32
 
33
- def get_products(options={})
33
+ def get_products(_options={})
34
34
  product_hashes = []
35
35
 
36
- loop(:make_product_request, :products) do |r|
36
+ for_each(:make_product_request, :products) do |r|
37
37
  product_hashes << r
38
38
  end
39
39
 
@@ -64,7 +64,7 @@ module MadCart
64
64
  def get_customer_hashes
65
65
  orders = []
66
66
 
67
- loop(:make_order_request, :orders) do |r|
67
+ for_each(:make_order_request, :orders) do |r|
68
68
  orders << {
69
69
  order_number: r["number"],
70
70
  user_email: r["email"]
@@ -84,7 +84,7 @@ module MadCart
84
84
  end.compact
85
85
  end
86
86
 
87
- def loop(source, items_key, &block)
87
+ def for_each(source, items_key, &block)
88
88
  response = send(source, { :page => 1 })
89
89
  items = response[items_key.to_s]
90
90
  pages_count = response['pages']
@@ -1,3 +1,3 @@
1
1
  module MadCart
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "etsy", "0.2.6"
24
24
  spec.add_dependency "money", "~> 6.7"
25
25
  spec.add_dependency "monetize", "~> 1.4"
26
- spec.add_dependency 'activesupport', "~> 4.2"
26
+ spec.add_dependency "activesupport", ">= 4.2"
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 1.3"
29
29
  spec.add_development_dependency "rake"
@@ -1,12 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "configuration" do
4
-
5
- # use a clean instance for each test
6
- before(:each) do
7
- clear_config
8
- end
9
-
10
4
  describe "stores" do
11
5
  it "does not require store to be added if credentials are passed to constructor" do
12
6
  expect { MadCart::Store::BigCommerce.new({:api_key => 'a_fake_key', :store_url => '/path/to/store', :username => 'bob'}) }.not_to raise_error
@@ -3,7 +3,6 @@ require "spec_helper"
3
3
  describe MadCart::Store::Base do
4
4
 
5
5
  before(:each) do
6
- clear_config
7
6
  Object.send(:remove_const, :MyModel) if Object.const_defined?(:MyModel)
8
7
  class MyModel
9
8
  include MadCart::Model::Base
@@ -1,11 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe MadCart::Model::Customer do
4
-
5
- before(:each) do
6
- clear_config
7
- end
8
-
9
4
  it "returns the default attributes" do
10
5
  attrs = {"first_name" => 'Bob', "last_name" => 'Sagat', "email" => 'bob@sagat.com'}
11
6
  c = MadCart::Model::Customer.new(attrs)
@@ -1,11 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe MadCart::Model::Product do
4
-
5
- before(:each) do
6
- clear_config
7
- end
8
-
9
4
  it "returns the default attributes" do
10
5
  extra_attrs = {"external_id" => 'id', "price" => '12USD',
11
6
  "url" => 'path/to/product', "currency_code" => 'ZAR',
@@ -16,7 +16,7 @@ describe MadCart::Store::Base do
16
16
  MyStore.class_eval do
17
17
  create_connection_with :connection_method
18
18
 
19
- def connection_method(args={})
19
+ def connection_method(_args={})
20
20
  return TestResult
21
21
  end
22
22
  end
@@ -26,7 +26,7 @@ describe MadCart::Store::Base do
26
26
 
27
27
  it "accepts a proc" do
28
28
  MyStore.class_eval do
29
- create_connection_with Proc.new {|args| TestResult }
29
+ create_connection_with(Proc.new {|_args| TestResult })
30
30
  end
31
31
 
32
32
  expect(MyStore.new.connection).to eql(TestResult)
@@ -207,7 +207,7 @@ describe MadCart::Store::Base do
207
207
  @my_instance_var = args.first[:connection]
208
208
  end
209
209
 
210
- def connect_method(*args)
210
+ def connect_method(*_args)
211
211
  return @my_instance_var
212
212
  end
213
213
  end
@@ -217,10 +217,10 @@ describe MadCart::Store::Base do
217
217
 
218
218
  it "accepts a proc" do
219
219
  MyStore.class_eval do
220
- after_initialize Proc.new {|arg| TestResult.new }
220
+ after_initialize(Proc.new { |_arg| TestResult.new })
221
221
  create_connection_with :connect_method
222
222
 
223
- def connect_method(*args)
223
+ def connect_method(*_args)
224
224
  return @my_instance_var
225
225
  end
226
226
  end
@@ -1,9 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe MadCart::Store::Etsy do
4
-
5
- before(:each) { clear_config }
6
-
7
4
  describe "retrieving products" do
8
5
  context "the store doesn't exist" do
9
6
  let(:invalid_store_name) { 'MadeUpStore' }
@@ -35,7 +32,7 @@ describe MadCart::Store::Etsy do
35
32
  expect(first_product.name).not_to be_nil
36
33
  expect(first_product.description).not_to be_nil
37
34
  expect(first_product.image_url).not_to be_nil
38
- expect(first_product.additional_attributes['price']).to eql(BigDecimal.new('2.5'))
35
+ expect(first_product.additional_attributes['price']).to eql(BigDecimal('2.5'))
39
36
  end
40
37
  end
41
38
 
@@ -52,7 +49,7 @@ describe MadCart::Store::Etsy do
52
49
  expect(first_product.name).not_to be_nil
53
50
  expect(first_product.description).not_to be_nil
54
51
  expect(first_product.image_url).not_to be_nil
55
- expect(first_product.additional_attributes['price']).to eql(BigDecimal.new('2.2'))
52
+ expect(first_product.additional_attributes['price']).to eql(BigDecimal('2.2'))
56
53
  end
57
54
  end
58
55
  end
@@ -32,7 +32,7 @@ describe MadCart::Store::Spree do
32
32
  context "retrieval" do
33
33
  context "basic spree installation" do
34
34
  it "returns all products" do
35
- VCR.use_cassette(spree_cassette, :record => :new_episodes) do
35
+ VCR.use_cassette(spree_cassette) do
36
36
  api = MadCart::Store::Spree.new(valid_credentials)
37
37
 
38
38
  expect(api.products.size).to eql(58)
@@ -50,7 +50,7 @@ describe MadCart::Store::Spree do
50
50
 
51
51
  context "alternative spree installation" do
52
52
  it "returns all products" do
53
- VCR.use_cassette(spree_alternative_cassette, :record => :new_episodes) do
53
+ VCR.use_cassette(spree_alternative_cassette) do
54
54
  api = MadCart::Store::Spree.new(valid_alternative_credentials)
55
55
 
56
56
  expect(api.products.size).to eql(148)
@@ -78,7 +78,7 @@ describe MadCart::Store::Spree do
78
78
  context "count" do
79
79
 
80
80
  it "returns how many products there are" do
81
- VCR.use_cassette(spree_cassette, :record => :new_episodes) do
81
+ VCR.use_cassette(spree_cassette) do
82
82
  api = MadCart::Store::Spree.new(valid_credentials)
83
83
  expect(api.products_count).to eql(58)
84
84
  end
@@ -92,7 +92,7 @@ describe MadCart::Store::Spree do
92
92
  context "retrieval" do
93
93
 
94
94
  it "returns all customers" do
95
- VCR.use_cassette(spree_cassette, :record => :new_episodes) do
95
+ VCR.use_cassette(spree_cassette) do
96
96
  api = MadCart::Store::Spree.new(valid_credentials)
97
97
 
98
98
  expect(api.customers.size).to be > 0
@@ -112,7 +112,7 @@ describe MadCart::Store::Spree do
112
112
 
113
113
  describe "validating credentials" do
114
114
  it "succeeds if it can get orders.json from Spree" do
115
- VCR.use_cassette(spree_cassette, :record => :new_episodes) do
115
+ VCR.use_cassette(spree_cassette) do
116
116
  api = MadCart::Store::Spree.new(valid_credentials)
117
117
 
118
118
  expect(api).to be_valid
@@ -24,6 +24,11 @@ RSpec.configure do |config|
24
24
  config.order = 'random'
25
25
 
26
26
  config.include WebMock::API
27
+
28
+ config.after(:each) do
29
+ # Re-initialize the MadCart::Configuration singleton instance
30
+ Singleton.__init__(MadCart::Configuration)
31
+ end
27
32
  end
28
33
 
29
34
  VCR.configure do |c|
@@ -32,10 +37,3 @@ VCR.configure do |c|
32
37
  #c.default_cassette_options = { :record => :new_episodes }
33
38
  #c.debug_logger = File.open('vcr.log', 'w')
34
39
  end
35
-
36
-
37
- # helper methods
38
- def clear_config
39
- # Re-initialize the MadCart::Configuration singleton instance
40
- Singleton.__init__(MadCart::Configuration)
41
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mad_cart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Heiligers
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-12-26 00:00:00.000000000 Z
13
+ date: 2018-12-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -86,14 +86,14 @@ dependencies:
86
86
  name: activesupport
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - "~>"
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: '4.2'
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - "~>"
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '4.2'
99
99
  - !ruby/object:Gem::Dependency
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  version: '0'
273
273
  requirements: []
274
274
  rubyforge_project:
275
- rubygems_version: 2.5.1
275
+ rubygems_version: 2.7.6
276
276
  signing_key:
277
277
  specification_version: 4
278
278
  summary: Allows communication with various e-commerce merchants such as BigCommerce