magento 0.23.0 → 0.24.0

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
  SHA256:
3
- metadata.gz: 2212acd226570a0dc73fc66683290aca3469006680b1e7946f3426177d0368a3
4
- data.tar.gz: 1b3029f0f0eb3f0c6b583e4c025f8ab5d53dba8bfeed197e6e8ffc3c08ebf473
3
+ metadata.gz: 6cc3c4705cb31c6aab0ee3e39b0513bd9e21fa7f98fa6c0564e832a01c488b68
4
+ data.tar.gz: 20354ed49b5e998940775d8e3f07aea5ca0a0e2be5d482634c77528f3209e330
5
5
  SHA512:
6
- metadata.gz: 6d4b55ba92ddfe5e7831da80ccdf170139a6b8f3459be07d35bfc877ee0638cbcaf15f98d7215f01b017510bb4d8458cf45e229acca7b3dc5d5fa2054e8f00b1
7
- data.tar.gz: e35feff6cb0a82ece59cf57cb4bde0b0f9d7ea5989ff307c17211045fee78fff1dafbbcc8aaec34be3249e14c784679569d2d9d8dfc773124033592cc82189cf
6
+ metadata.gz: 8e927a070c8b469cc0b3019ca27c9d74c51cb270b4165e3fb2343fd3c54d406d0d33507ad2aba9a53250d4c513e70eeb3c92adea579c0b2c775e23667e4fd1c8
7
+ data.tar.gz: f91fd2fcaca2777d599eac5eb665553adf5054eaa8a42593c2bad95226b953c43e14e1e7687e4c64c4351cc9f6e05fc35b3edd1e181fcd99976f481706e2d791
@@ -22,6 +22,7 @@ jobs:
22
22
  touch $HOME/.gem/credentials
23
23
  chmod 0600 $HOME/.gem/credentials
24
24
  printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
25
+ sed "s/'magento'/'magento-ruby'/" magento.gemspec > magento-ruby.gemspec
25
26
  gem build magento-ruby.gemspec
26
27
  gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
27
28
  env:
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ example_id | status | run_time |
2
+ ------------------------------- | ------ | --------------- |
3
+ ./spec/magento_spec.rb[1:1] | passed | 0.00057 seconds |
4
+ ./spec/product_spec.rb[1:1:1:1] | passed | 0.00102 seconds |
5
+ ./spec/product_spec.rb[1:1:2:1] | passed | 0.00111 seconds |
data/Gemfile CHANGED
@@ -4,3 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in magento.gemspec
6
6
  gemspec
7
+
8
+ gem "rake", "~> 12.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem 'byebug', '~> 11.1', '>= 11.1.3'
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Add in your Gemfile
6
6
 
7
7
  ```rb
8
- gem 'magento', '~> 0.23.0'
8
+ gem 'magento', '~> 0.24.0'
9
9
  ```
10
10
 
11
11
  or run
@@ -680,3 +680,14 @@ Magento::Product.where(name_like: 'some name%').last
680
680
  ```
681
681
 
682
682
  ### Tests
683
+
684
+
685
+ ## Development
686
+
687
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
688
+
689
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
690
+
691
+ ## Contributing
692
+
693
+ Bug reports and pull requests are welcome on GitHub at https://github.com/WallasFaria/nfce_crawler.
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ Bundler::GemHelper.install_tasks name: 'magento'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "magento"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -4,6 +4,7 @@ require 'time'
4
4
  require 'dry/inflector'
5
5
  require 'active_support/core_ext/string/inflections'
6
6
  require 'active_support/core_ext/hash/keys'
7
+ require 'active_support/core_ext/module/delegation'
7
8
 
8
9
  require_relative 'magento/configuration'
9
10
  require_relative 'magento/errors'
@@ -20,6 +20,20 @@ module Magento
20
20
  @custom_attributes&.find { |a| a.attribute_code == attribute_code.to_s }&.value
21
21
  end
22
22
 
23
+ def set_custom_attribute(code, value)
24
+ @custom_attributes ||= []
25
+ attribute = @custom_attributes.find { |a| a.attribute_code == code.to_s }
26
+
27
+ if attribute
28
+ attribute.value = value
29
+ else
30
+ @custom_attributes << Magento::CustomAttribute.build(
31
+ attribute_code: code.to_s,
32
+ value: value
33
+ )
34
+ end
35
+ end
36
+
23
37
  def respond_to?(attribute_code)
24
38
  super || @custom_attributes&.any? { |a| a.attribute_code == attribute_code.to_s }
25
39
  end
@@ -1,4 +1,5 @@
1
1
  module Magento
2
2
  class CustomAttribute
3
+ include Magento::ModelParser
3
4
  end
4
5
  end
@@ -1,3 +1,3 @@
1
1
  module Magento
2
- VERSION = '0.23.0'
2
+ VERSION = '0.24.0'
3
3
  end
@@ -0,0 +1,5 @@
1
+ RSpec.describe Magento do
2
+ it "has a version number" do
3
+ expect(Magento::VERSION).not_to be nil
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ RSpec.describe Magento::Product do
2
+ describe '#set_custom_attribute' do
3
+ let(:product) { Magento::Product.build(
4
+ sku: 25,
5
+ custom_attributes: [
6
+ { attribute_code: 'description', value: 'Some description' }
7
+ ]
8
+ ) }
9
+
10
+ context 'when the custom attribute already exists' do
11
+ it 'must change the attribute value' do
12
+ expect(product.description).to eql('Some description')
13
+ product.set_custom_attribute(:description, 'description updated')
14
+ expect(product.attr(:description)).to eql('description updated')
15
+ end
16
+ end
17
+
18
+ context 'when the custom attribute does not exists' do
19
+ it 'must add a new attribute' do
20
+ expect(product.attr(:new_attribute)).to be_nil
21
+ expect(product.attr(:other_new_attribute)).to be_nil
22
+
23
+ product.set_custom_attribute(:new_attribute, 'value')
24
+ product.set_custom_attribute('other_new_attribute', [1, 2])
25
+
26
+ expect(product.attr(:new_attribute)).to eql('value')
27
+ expect(product.attr(:other_new_attribute)).to eql([1, 2])
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ require "bundler/setup"
2
+ require 'byebug'
3
+ require "magento"
4
+
5
+ RSpec.configure do |config|
6
+ # Enable flags like --only-failures and --next-failure
7
+ config.example_status_persistence_file_path = ".rspec_status"
8
+
9
+ # Disable RSpec exposing methods globally on `Module` and `main`
10
+ config.disable_monkey_patching!
11
+
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magento
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wallas Faria
@@ -88,8 +88,13 @@ extra_rdoc_files: []
88
88
  files:
89
89
  - ".github/workflows/gem-push.yml"
90
90
  - ".gitignore"
91
+ - ".rspec"
92
+ - ".rspec_status"
91
93
  - Gemfile
92
94
  - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
93
98
  - lib/magento.rb
94
99
  - lib/magento/category.rb
95
100
  - lib/magento/configuration.rb
@@ -150,8 +155,10 @@ files:
150
155
  - lib/magento/shared/total.rb
151
156
  - lib/magento/shared/value.rb
152
157
  - lib/magento/version.rb
153
- - magento-ruby.gemspec
154
158
  - magento.gemspec
159
+ - spec/magento_spec.rb
160
+ - spec/product_spec.rb
161
+ - spec/spec_helper.rb
155
162
  homepage: https://github.com/WallasFaria/magento-ruby
156
163
  licenses: []
157
164
  metadata: {}
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require 'magento/version'
7
-
8
- Gem::Specification.new do |s|
9
- s.name = 'magento-ruby'
10
- s.version = Magento::VERSION
11
- s.date = '2020-07-31'
12
- s.summary = 'Magento Ruby library'
13
- s.description = 'Magento Ruby library'
14
- s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
- s.authors = ['Wallas Faria']
16
- s.email = 'wallasfaria@hotmail.com'
17
- s.homepage = 'https://github.com/WallasFaria/magento-ruby'
18
- s.require_paths = ['lib']
19
-
20
- s.add_dependency 'dry-inflector', '~> 0.2.0'
21
- s.add_dependency 'http', '~> 4.4'
22
- s.add_dependency 'dry-struct'
23
- s.add_dependency 'activesupport'
24
- s.add_dependency 'mini_magick'
25
- end