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 +5 -5
- data/.travis.yml +1 -1
- data/lib/mad_cart/model/base.rb +2 -2
- data/lib/mad_cart/store/base.rb +2 -2
- data/lib/mad_cart/store/big_commerce.rb +4 -5
- data/lib/mad_cart/store/spree.rb +4 -4
- data/lib/mad_cart/version.rb +1 -1
- data/mad_cart.gemspec +1 -1
- data/spec/lib/configuration_spec.rb +0 -6
- data/spec/lib/model/base_spec.rb +0 -1
- data/spec/lib/model/customer_spec.rb +0 -5
- data/spec/lib/model/product_spec.rb +0 -5
- data/spec/lib/store/base_spec.rb +5 -5
- data/spec/lib/store/etsy_spec.rb +2 -5
- data/spec/lib/store/spree_spec.rb +5 -5
- data/spec/spec_helper.rb +5 -7
- metadata +5 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: a80578ffa5622853d9e5b888aafeabaab3ff747d9bdfb3878bb1f135cb07a1fb
         | 
| 4 | 
            +
              data.tar.gz: c7bf4b3c4c7187ce8a1f86626c12c9bcb106c5f811ec5ee705fca53f6e0398ef
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a20e18302a6e26b6569b43312ee4aa0ccd3de58a19fc85dfc664a8134ff7927dd6f37fad97474a8299337d70c4d544c7621b5906d6c253d2e0ceb3ec1dea43f1
         | 
| 7 | 
            +
              data.tar.gz: 2709111a2709b0afea3d6324e66b3cbe002ac8e0a86ad788ec84a7166213edebebd2e53166a5116acfe663e5412443c28eb9fbf9e0778f5a81e803a884df33c9
         | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/lib/mad_cart/model/base.rb
    CHANGED
    
    | @@ -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 | 
| 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 | 
| 57 | 
            +
                      attr_accessor(*args)
         | 
| 58 58 | 
             
                    end
         | 
| 59 59 |  | 
| 60 60 | 
             
                    def exposed_attributes
         | 
    
        data/lib/mad_cart/store/base.rb
    CHANGED
    
    | @@ -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 | 
| 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 | 
| 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 | 
            -
                     | 
| 55 | 
            +
                    for_each(:make_customer_request) {|c| result << c }
         | 
| 56 56 | 
             
                    result
         | 
| 57 57 | 
             
                  end
         | 
| 58 58 |  | 
| 59 | 
            -
                  def  | 
| 60 | 
            -
             | 
| 59 | 
            +
                  def for_each(source, &block)
         | 
| 61 60 | 
             
                    items = send(source, :min_id => 1)
         | 
| 62 61 |  | 
| 63 | 
            -
                     | 
| 64 | 
            -
                      items.each | 
| 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
         | 
    
        data/lib/mad_cart/store/spree.rb
    CHANGED
    
    | @@ -30,10 +30,10 @@ module MadCart | |
| 30 30 | 
             
                    parse_response { connection.get('products.json', params) }
         | 
| 31 31 | 
             
                  end
         | 
| 32 32 |  | 
| 33 | 
            -
                  def get_products( | 
| 33 | 
            +
                  def get_products(_options={})
         | 
| 34 34 | 
             
                    product_hashes = []
         | 
| 35 35 |  | 
| 36 | 
            -
                     | 
| 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 | 
            -
                     | 
| 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  | 
| 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']
         | 
    
        data/lib/mad_cart/version.rb
    CHANGED
    
    
    
        data/mad_cart.gemspec
    CHANGED
    
    | @@ -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  | 
| 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
         | 
    
        data/spec/lib/model/base_spec.rb
    CHANGED
    
    
| @@ -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',
         | 
    
        data/spec/lib/store/base_spec.rb
    CHANGED
    
    | @@ -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( | 
| 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 | 
| 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(* | 
| 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 | 
| 220 | 
            +
                    after_initialize(Proc.new { |_arg| TestResult.new })
         | 
| 221 221 | 
             
                    create_connection_with :connect_method
         | 
| 222 222 |  | 
| 223 | 
            -
                    def connect_method(* | 
| 223 | 
            +
                    def connect_method(*_args)
         | 
| 224 224 | 
             
                      return @my_instance_var
         | 
| 225 225 | 
             
                    end
         | 
| 226 226 | 
             
                  end
         | 
    
        data/spec/lib/store/etsy_spec.rb
    CHANGED
    
    | @@ -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 | 
| 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 | 
| 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 | 
| 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 | 
| 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 | 
| 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 | 
| 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 | 
| 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
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -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. | 
| 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:  | 
| 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. | 
| 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
         |