magentwo 0.1.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 +7 -0
- data/.gitignore +50 -0
- data/.rspec +3 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +4 -0
- data/lib/connection.rb +74 -0
- data/lib/dataset.rb +130 -0
- data/lib/filter.rb +105 -0
- data/lib/magentwo.rb +17 -0
- data/lib/model/base.rb +35 -0
- data/lib/model/customer.rb +16 -0
- data/lib/model/order.rb +5 -0
- data/lib/model/product.rb +9 -0
- data/magentwo.gemspec +12 -0
- data/magentwo.rb +6 -0
- data/spec/base_model_spec.rb +4 -0
- data/spec/dataset_spec.rb +0 -0
- data/spec/product_spec.rb +8 -0
- data/spec/server_spec.rb +7 -0
- data/spec/spec_helper.rb +100 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 57c5ce2bff9ba6b24431270fec36de370ae8a1637c0b336cf8f5bd7a741d4cdb
|
4
|
+
data.tar.gz: 2dfe12316718b6e2882db03b7b057ba128c7f6e41df1a23717a21bbb2e59aa11
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 57390590bb9ccb28a3fefce2ea23417768a1e01c7dacb1ab388bcd7e6d5ecb3abf6103a9059ec9d21e95137137ce1a4025c30993a5ea3f58638722d0435ed0ec
|
7
|
+
data.tar.gz: d57e227ce4ec86df09fbdf12ac14f915180e9fe53bcdc08c7c15a02834425491d3547dfc84884abc202e5a639aaebe5331741e9e05fefe1a3adfce26fc8d2f86
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Arkad82x
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
data/lib/connection.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
module Magentwo
|
2
|
+
class Connection
|
3
|
+
attr_accessor :host, :port, :user, :password, :token, :base_path
|
4
|
+
|
5
|
+
def initialize host, user, password, base_path:nil
|
6
|
+
if host.include? ":"
|
7
|
+
@host = host.split(":").first
|
8
|
+
@port = host.split(":").last.to_i
|
9
|
+
else
|
10
|
+
@host = host
|
11
|
+
@port = 80
|
12
|
+
end
|
13
|
+
@user = user
|
14
|
+
@password = password
|
15
|
+
@base_path = base_path || "/rest/default/V1"
|
16
|
+
request_token
|
17
|
+
end
|
18
|
+
|
19
|
+
def request_token
|
20
|
+
p self
|
21
|
+
Net::HTTP.start(self.host,self.port) do |http|
|
22
|
+
req = Net::HTTP::Post.new("#{base_path}/integration/admin/token")
|
23
|
+
req.body = {:username=> self.user, :password=> self.password}.to_json
|
24
|
+
req['Content-Type'] = "application/json"
|
25
|
+
req['Content-Length'] = req.body.length
|
26
|
+
@token = JSON.parse http.request(req).body
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def call method, path, query
|
31
|
+
url = "#{base_path}/#{path}?#{query}"
|
32
|
+
case method
|
33
|
+
when :get then self.get url
|
34
|
+
when :post then self.post url
|
35
|
+
when :delete then self.delete url
|
36
|
+
when :put then self.put url
|
37
|
+
else
|
38
|
+
raise "unknown http method, cannot call #{method}, expected :get, :post, :delete or :put"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def put
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def post
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def get url
|
55
|
+
p "get: #{url}"
|
56
|
+
Net::HTTP.start(self.host,self.port) do |http|
|
57
|
+
req = Net::HTTP::Get.new(url)
|
58
|
+
req["Authorization"] = "Bearer #{self.token}"
|
59
|
+
req['Content-Type'] = "application/json"
|
60
|
+
resp = http.request(req)
|
61
|
+
handle_response resp
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def handle_response response
|
67
|
+
case response.code
|
68
|
+
when "200" then JSON.parse response.body
|
69
|
+
else
|
70
|
+
raise "request failed #{response.code} #{response.body}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/dataset.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
module Magentwo
|
2
|
+
class Dataset
|
3
|
+
attr_accessor :model, :opts
|
4
|
+
def initialize model, opts=nil
|
5
|
+
self.model = model
|
6
|
+
self.opts = opts || {
|
7
|
+
:filters => [],
|
8
|
+
:pagination => {
|
9
|
+
:current_page => Filter::CurrentPage.new(1),
|
10
|
+
:page_size => Filter::PageSize.new(20)
|
11
|
+
},
|
12
|
+
:ordering => []
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
#################
|
17
|
+
# Filters
|
18
|
+
################
|
19
|
+
def filter hash_or_other, invert:false
|
20
|
+
filter = case hash_or_other
|
21
|
+
when Hash
|
22
|
+
raise ArgumentError, "empty hash supplied" if hash_or_other.empty?
|
23
|
+
key, value = hash_or_other.first
|
24
|
+
klass = case value
|
25
|
+
when Array
|
26
|
+
invert ? Filter::Nin : Filter::In
|
27
|
+
else
|
28
|
+
invert ? Filter::Neq : Filter::Eq
|
29
|
+
end
|
30
|
+
klass.new(key, value)
|
31
|
+
else
|
32
|
+
raise ArgumentError, "filter function expects Hash as input"
|
33
|
+
end
|
34
|
+
Dataset.new self.model, self.opts.merge(:filters => self.opts[:filters] + [filter])
|
35
|
+
end
|
36
|
+
|
37
|
+
def exclude args
|
38
|
+
filter args, invert:true
|
39
|
+
end
|
40
|
+
|
41
|
+
def select *fields
|
42
|
+
Dataset.new self.model, self.opts.merge(:filters => self.opts[:filters] + [Filter::Fields.new(fields)])
|
43
|
+
end
|
44
|
+
|
45
|
+
def like args
|
46
|
+
Dataset.new self.model, self.opts.merge(:filters => self.opts[:filters] + [Filter::Like.new(args.keys.first, args.values.first)])
|
47
|
+
end
|
48
|
+
|
49
|
+
#################
|
50
|
+
# Pagination
|
51
|
+
################
|
52
|
+
def page page, page_size=20
|
53
|
+
Dataset.new self.model, self.opts.merge(:pagination => {:current_page => Filter::CurrentPage.new(page), :page_size => Filter::PageSize.new(page_size)})
|
54
|
+
end
|
55
|
+
|
56
|
+
#################
|
57
|
+
# Ordering
|
58
|
+
################
|
59
|
+
def order_by field, direction="ASC"
|
60
|
+
Dataset.new self.model, self.opts.merge(:ordering => self.opts[:ordering] + [Filter::OrderBy.new(field, direction)])
|
61
|
+
end
|
62
|
+
|
63
|
+
#################
|
64
|
+
# Fetching
|
65
|
+
################
|
66
|
+
def info
|
67
|
+
result = self.model.call :get, self.page(1, 1).to_query
|
68
|
+
{
|
69
|
+
:fields => result["items"]&.first&.keys,
|
70
|
+
:total_count => result["total_count"]
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def count
|
75
|
+
self.info[:total_count]
|
76
|
+
end
|
77
|
+
|
78
|
+
def fields
|
79
|
+
self.info[:fields]
|
80
|
+
end
|
81
|
+
|
82
|
+
def first
|
83
|
+
result = self.model.call :get, self.page(1, 1).to_query
|
84
|
+
self.model.new result["items"].first
|
85
|
+
end
|
86
|
+
|
87
|
+
def all
|
88
|
+
result = self.model.call :get, self.to_query
|
89
|
+
return [] if result.nil?
|
90
|
+
(result["items"] || []).map do |item|
|
91
|
+
self.model.new item
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
#################
|
96
|
+
# Transformation
|
97
|
+
################
|
98
|
+
def to_query
|
99
|
+
[
|
100
|
+
self.opts[:filters]
|
101
|
+
.each_with_index
|
102
|
+
.map { |opt, idx| opt.to_query(idx) }
|
103
|
+
.join("&"),
|
104
|
+
|
105
|
+
self.opts[:pagination]
|
106
|
+
.map { |k, v| v.to_query}
|
107
|
+
.join("&"),
|
108
|
+
|
109
|
+
|
110
|
+
self.opts[:ordering]
|
111
|
+
.map { |opt, idx| opt.to_query(idx) }
|
112
|
+
.join("&"),
|
113
|
+
].reject(&:empty?)
|
114
|
+
.join("&")
|
115
|
+
end
|
116
|
+
|
117
|
+
#################
|
118
|
+
# Functors
|
119
|
+
################
|
120
|
+
def map(&block)
|
121
|
+
raise ArgumentError, "no block given" unless block_given?
|
122
|
+
self.all.map(&block)
|
123
|
+
end
|
124
|
+
|
125
|
+
def each &block
|
126
|
+
raise ArgumentError, "no block given" unless block_given?
|
127
|
+
self.all.each(&block)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
data/lib/filter.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
module Magentwo
|
2
|
+
module Filter
|
3
|
+
class Compare
|
4
|
+
attr_accessor :field, :value
|
5
|
+
def initialize field, value
|
6
|
+
@field = field
|
7
|
+
@value = value
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_query idx
|
11
|
+
[
|
12
|
+
"searchCriteria[filter_groups][#{idx}][filters][0][field]=#{self.field}",
|
13
|
+
"searchCriteria[filter_groups][#{idx}][filters][0][value]=#{URI::encode(self.value)}",
|
14
|
+
"searchCriteria[filter_groups][#{idx}][filters][0][condition_type]=#{self.class.name.split("::").last.downcase}"]
|
15
|
+
.join("&")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class CompareArray < Compare
|
20
|
+
def to_query idx
|
21
|
+
[
|
22
|
+
"searchCriteria[filter_groups][#{idx}][filters][0][field]=#{self.field}",
|
23
|
+
"searchCriteria[filter_groups][#{idx}][filters][0][value]=#{URI::encode(self.value.join(","))}",
|
24
|
+
"searchCriteria[filter_groups][#{idx}][filters][0][condition_type]=#{self.class.name.split("::").last.downcase}"]
|
25
|
+
.join("&")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Simple
|
30
|
+
attr_accessor :key, :value
|
31
|
+
def initialize key, value
|
32
|
+
@key = key
|
33
|
+
@value = value
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_query idx=nil
|
37
|
+
"searchCriteria[#{key}]=#{value}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Multi
|
42
|
+
attr_accessor :kvps
|
43
|
+
def initialize kvps
|
44
|
+
@kvps = kvps
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_query idx=nil
|
48
|
+
kvps.map do |kvp|
|
49
|
+
"searchCriteria[#{kvp[:key]}]=#{kvp[:value]}"
|
50
|
+
end.join("&")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
class Eq < Magentwo::Filter::Compare
|
56
|
+
end
|
57
|
+
|
58
|
+
class Neq < Magentwo::Filter::Compare
|
59
|
+
end
|
60
|
+
|
61
|
+
class In < Magentwo::Filter::CompareArray
|
62
|
+
end
|
63
|
+
|
64
|
+
class Nin < Magentwo::Filter::CompareArray
|
65
|
+
end
|
66
|
+
|
67
|
+
class Like < Magentwo::Filter::Compare
|
68
|
+
end
|
69
|
+
|
70
|
+
class PageSize < Magentwo::Filter::Simple
|
71
|
+
def initialize value
|
72
|
+
super(:page_size, value)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class CurrentPage < Magentwo::Filter::Simple
|
77
|
+
def initialize value
|
78
|
+
super(:current_page, value)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class OrderBy < Magentwo::Filter::Multi
|
83
|
+
def initialize field, direction
|
84
|
+
super([{:key => :field, :value => field}, {:key => :direction, :value => direction}])
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_query idx=nil
|
88
|
+
self.kvps.map do |kvp|
|
89
|
+
"searchCriteria[sortOrders][0][#{kvp[:key]}]=#{kvp[:value]}"
|
90
|
+
end.join("&")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class Fields
|
95
|
+
attr_accessor :fields
|
96
|
+
def initialize fields
|
97
|
+
@fields = fields
|
98
|
+
end
|
99
|
+
def to_query idx=nil
|
100
|
+
#TODO api supports nested field selection e.g. items[address[street]]
|
101
|
+
"fields=items[#{URI::encode(self.fields.join(","))}]"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/magentwo.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Magentwo
|
6
|
+
Models = %w(base product customer order)
|
7
|
+
def self.connect host, user_name, password
|
8
|
+
Base.connection = Connection.new host, user_name, password
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
require_relative 'connection.rb'
|
13
|
+
require_relative 'filter.rb'
|
14
|
+
require_relative 'dataset.rb'
|
15
|
+
Magentwo::Models.each do |file_name|
|
16
|
+
require_relative("model/#{file_name}.rb")
|
17
|
+
end
|
data/lib/model/base.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Magentwo
|
2
|
+
class Base
|
3
|
+
DatasetMethods = %i(all filter exclude select fields first count fields info page order_by like)
|
4
|
+
|
5
|
+
def initialize args
|
6
|
+
args.each do |key, value|
|
7
|
+
key_sym = :"@#{key}"
|
8
|
+
if self.respond_to? :"#{key}="
|
9
|
+
instance_variable_set key_sym, value
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self; attr_accessor :connection end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
#args may container searchCriteria, fields, ...
|
18
|
+
def call method, query
|
19
|
+
model_name = "#{self.name.split("::").last.downcase}s"
|
20
|
+
Magentwo::Base.connection.call method, model_name, query
|
21
|
+
end
|
22
|
+
|
23
|
+
def dataset
|
24
|
+
Magentwo::Dataset.new(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
DatasetMethods.each do |name|
|
28
|
+
define_method name do |*args|
|
29
|
+
return dataset.send(name, *args)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Magentwo
|
2
|
+
class Customer < Base
|
3
|
+
Attributes = %i(id group_id default_billing default_shipping created_at updated_at created_in dob email firstname lastname gender store_id website_id addresses disable_auto_group_change)
|
4
|
+
|
5
|
+
Attributes.each do |attr|
|
6
|
+
attr_accessor attr
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def call method, query
|
11
|
+
model_name = "customers/search"
|
12
|
+
Magentwo::Base.connection.call method, model_name, query
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/model/order.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
module Magentwo
|
2
|
+
class Product < Base
|
3
|
+
Attributes = %i(id sku name attribute_set_id price status visibility type_id created_at updated_at extension_attributes product_links options media_gallery_entries tier_prices custom_attributes)
|
4
|
+
|
5
|
+
Attributes.each do |attr|
|
6
|
+
attr_accessor attr
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/magentwo.gemspec
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'magentwo'
|
3
|
+
s.version = '0.1.0'
|
4
|
+
s.date = '2019-01-17'
|
5
|
+
s.summary = "Magento 2 API Wrapper"
|
6
|
+
s.description = "Provides a simple Ruby Interface to interact with the Magento 2 API"
|
7
|
+
s.authors = ["André Mueß"]
|
8
|
+
s.email = 'andre.cux90@gmail.com'
|
9
|
+
s.license = 'MIT'
|
10
|
+
s.homepage = "https://github.com/Arkad82x/magentwo"
|
11
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
12
|
+
end
|
data/magentwo.rb
ADDED
File without changes
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative '../lib/magentwo.rb'
|
2
|
+
|
3
|
+
describe 'product' do
|
4
|
+
Magentwo::Base.connection = Magentwo::Connection.new('magento2.local',"admin","magentorocks1")
|
5
|
+
it 'returns an array when list is called' do
|
6
|
+
expect(Magentwo::Product.list.class).to eq Array
|
7
|
+
end
|
8
|
+
end
|
data/spec/server_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# This allows you to limit a spec run to individual examples or groups
|
51
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
52
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
53
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
54
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
55
|
+
config.filter_run_when_matching :focus
|
56
|
+
|
57
|
+
# Allows RSpec to persist some state between runs in order to support
|
58
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
59
|
+
# you configure your source control system to ignore this file.
|
60
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
61
|
+
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
63
|
+
# recommended. For more details, see:
|
64
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
65
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
66
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
67
|
+
config.disable_monkey_patching!
|
68
|
+
|
69
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
70
|
+
# be too noisy due to issues in dependencies.
|
71
|
+
config.warnings = true
|
72
|
+
|
73
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
74
|
+
# file, and it's useful to allow more verbose output when running an
|
75
|
+
# individual spec file.
|
76
|
+
if config.files_to_run.one?
|
77
|
+
# Use the documentation formatter for detailed output,
|
78
|
+
# unless a formatter has already been configured
|
79
|
+
# (e.g. via a command-line flag).
|
80
|
+
config.default_formatter = "doc"
|
81
|
+
end
|
82
|
+
|
83
|
+
# Print the 10 slowest examples and example groups at the
|
84
|
+
# end of the spec run, to help surface which specs are running
|
85
|
+
# particularly slow.
|
86
|
+
config.profile_examples = 10
|
87
|
+
|
88
|
+
# Run specs in random order to surface order dependencies. If you find an
|
89
|
+
# order dependency and want to debug it, you can fix the order by providing
|
90
|
+
# the seed, which is printed after each run.
|
91
|
+
# --seed 1234
|
92
|
+
config.order = :random
|
93
|
+
|
94
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
95
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
96
|
+
# test failures related to randomization by passing the same `--seed` value
|
97
|
+
# as the one that triggered the failure.
|
98
|
+
Kernel.srand config.seed
|
99
|
+
=end
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magentwo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- André Mueß
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Provides a simple Ruby Interface to interact with the Magento 2 API
|
14
|
+
email: andre.cux90@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- ".gitignore"
|
20
|
+
- ".rspec"
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
24
|
+
- lib/connection.rb
|
25
|
+
- lib/dataset.rb
|
26
|
+
- lib/filter.rb
|
27
|
+
- lib/magentwo.rb
|
28
|
+
- lib/model/base.rb
|
29
|
+
- lib/model/customer.rb
|
30
|
+
- lib/model/order.rb
|
31
|
+
- lib/model/product.rb
|
32
|
+
- magentwo.gemspec
|
33
|
+
- magentwo.rb
|
34
|
+
- spec/base_model_spec.rb
|
35
|
+
- spec/dataset_spec.rb
|
36
|
+
- spec/product_spec.rb
|
37
|
+
- spec/server_spec.rb
|
38
|
+
- spec/spec_helper.rb
|
39
|
+
homepage: https://github.com/Arkad82x/magentwo
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubygems_version: 3.0.2
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: Magento 2 API Wrapper
|
62
|
+
test_files: []
|