carriage 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/carriage.gemspec +16 -15
- data/lib/carriage.rb +7 -7
- data/lib/carriage/builder.rb +4 -4
- data/lib/carriage/locale.rb +18 -18
- data/lib/carriage/url.rb +2 -2
- data/lib/carriage/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8228bc36f8d0d5cff5944544d5fc80926ffd3962470232bb068df1f2f3656a66
|
4
|
+
data.tar.gz: 0bef66814a7980221cb90180df20995a313e36bab34086bb81a82c176d10dcbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78577f55b2f9da6f512be4138649a1b8519c3231014f13f1543949d7238acd18020cb5d73e0628fa94efdf244f41c6ca8e8107ed780de12ad7bf13c046fee333
|
7
|
+
data.tar.gz: d748fd18512e5b62cc86ed902f96f8a042550f89ec644cf739e42500d39288c2cce8d8e2de40e74d2f6aeb98e8aac00f98b5f02ab43e09b8e9f320c8425d5531
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [1.3.0]
|
8
|
+
## Add
|
9
|
+
- Code-style now adheres to standard gem
|
10
|
+
|
11
|
+
## Change
|
12
|
+
- AssociateTag is not required for Carriage.build anymore
|
13
|
+
|
7
14
|
## [1.2.1]
|
8
15
|
- Rollback some changes in gemspec
|
9
16
|
|
@@ -49,4 +56,4 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
49
56
|
- `AWSAccessKeyId` is not a required argument
|
50
57
|
|
51
58
|
## [0.1.0]
|
52
|
-
First public version, only focused on supporting one region - US.
|
59
|
+
First public version, only focused on supporting one region - US.
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<img src="./vendor/logo.jpg" alt="Carriage project logo" width="400">
|
8
8
|
</p>
|
9
9
|
|
10
|
-
Carriage is a Ruby
|
10
|
+
Carriage is a Ruby wrapper to [Amazon's Cart Form](https://webservices.amazon.com/paapi5/documentation/add-to-cart-form.html) functionality. Gem helps add any number of items to customer's shopping cart and direct him to Amazon website to complete order.
|
11
11
|
|
12
12
|
To use this gem, you will eventually require Amazon's **AssociateTag**, so consider to [register first](https://webservices.amazon.com/paapi5/documentation/register-for-pa-api.html) with Amazon Associate program and become more familiar with it.
|
13
13
|
|
data/Rakefile
CHANGED
data/carriage.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "lib/carriage/version"
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name
|
5
|
-
spec.version
|
6
|
-
spec.authors
|
7
|
-
spec.email
|
4
|
+
spec.name = "carriage"
|
5
|
+
spec.version = Carriage::VERSION
|
6
|
+
spec.authors = ["Stanislav (Stas) Katkov"]
|
7
|
+
spec.email = ["sk@skylup.com"]
|
8
8
|
|
9
|
-
spec.summary
|
10
|
-
spec.description
|
11
|
-
spec.homepage
|
12
|
-
spec.license
|
9
|
+
spec.summary = "Carriage is a Ruby micro-wrapper to Amazon's Cart Form functionality (part of Product Advertising API v5.0)"
|
10
|
+
spec.description = "Gem helps add any number of items to customer's shopping cart and direct him to Amazon website to complete order."
|
11
|
+
spec.homepage = "https://skatkov.github.io/carriage/"
|
12
|
+
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
@@ -18,15 +18,16 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files = Dir.chdir(File.expand_path(
|
21
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
22
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
23
|
end
|
24
24
|
|
25
|
-
spec.bindir
|
26
|
-
spec.executables
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
29
|
+
spec.add_development_dependency "rake"
|
30
|
+
spec.add_development_dependency "minitest"
|
31
|
+
spec.add_development_dependency "m"
|
32
|
+
spec.add_development_dependency "standard"
|
32
33
|
end
|
data/lib/carriage.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "carriage/version"
|
2
|
+
require "carriage/locale"
|
3
|
+
require "carriage/url"
|
4
|
+
require "carriage/builder"
|
5
|
+
require "forwardable"
|
6
6
|
|
7
7
|
module Carriage
|
8
8
|
class << self
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
-
def_delegator
|
12
|
-
def_delegator
|
11
|
+
def_delegator "Carriage::Url", :call
|
12
|
+
def_delegator "Carriage::Builder", :call, :build
|
13
13
|
end
|
14
14
|
end
|
data/lib/carriage/builder.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Carriage
|
2
2
|
class Builder
|
3
3
|
class << self
|
4
|
-
def call(items, tag
|
4
|
+
def call(items, tag: nil, key_id: nil, locale: :us)
|
5
5
|
params = {}
|
6
6
|
|
7
7
|
wrap(items).each_with_index do |obj, index|
|
@@ -17,8 +17,8 @@ module Carriage
|
|
17
17
|
params[:"Quantity.#{index + 1}"] = item.fetch(:QUANTITY, 1)
|
18
18
|
end
|
19
19
|
|
20
|
-
params[:AssociateTag] = tag
|
21
|
-
params[:AWSAccessKeyId] = key_id unless
|
20
|
+
params[:AssociateTag] = tag unless tag.nil? || tag.empty?
|
21
|
+
params[:AWSAccessKeyId] = key_id unless key_id.nil? || key_id.empty?
|
22
22
|
|
23
23
|
Carriage.call(locale, params)
|
24
24
|
end
|
@@ -36,4 +36,4 @@ module Carriage
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|
data/lib/carriage/locale.rb
CHANGED
@@ -5,21 +5,21 @@ module Carriage
|
|
5
5
|
class NotFound < KeyError; end
|
6
6
|
|
7
7
|
HOSTS = {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
au: "https://www.amazon.com.au/gp/aws/cart/add.html",
|
9
|
+
br: "https://www.amazon.com.br/gp/aws/cart/add.html",
|
10
|
+
ca: "https://www.amazon.ca/gp/aws/cart/add.html",
|
11
|
+
fr: "https://www.amazon.fr/gp/aws/cart/add.html",
|
12
|
+
de: "https://www.amazon.de/gp/aws/cart/add.html",
|
13
|
+
in: "https://www.amazon.in/gp/aws/cart/add.html",
|
14
|
+
it: "https://www.amazon.it/gp/aws/cart/add.html",
|
15
|
+
jp: "https://www.amazon.co.jp/gp/aws/cart/add.html",
|
16
|
+
mx: "https://www.amazon.com.mx/gp/aws/cart/add.html",
|
17
|
+
sg: "https://www.amazon.sg/gp/aws/cart/add.html",
|
18
|
+
es: "https://www.amazon.es/gp/aws/cart/add.html",
|
19
|
+
tr: "https://www.amazon.com.tr/gp/aws/cart/add.html",
|
20
|
+
ae: "https://www.amazon.ae/gp/aws/cart/add.html",
|
21
|
+
uk: "https://www.amazon.co.uk/gp/aws/cart/add.html",
|
22
|
+
us: "https://www.amazon.com/gp/aws/cart/add.html",
|
23
23
|
}.freeze
|
24
24
|
|
25
25
|
private_constant :HOSTS
|
@@ -27,9 +27,9 @@ module Carriage
|
|
27
27
|
attr_reader :host
|
28
28
|
|
29
29
|
def initialize(locale)
|
30
|
-
@host = HOSTS.fetch(locale.to_sym.downcase)
|
30
|
+
@host = HOSTS.fetch(locale.to_sym.downcase) { |value|
|
31
31
|
raise NotFound, "Locale not found: :#{value}"
|
32
|
-
|
32
|
+
}
|
33
33
|
end
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
data/lib/carriage/url.rb
CHANGED
data/lib/carriage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carriage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanislav (Stas) Katkov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: standard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Gem helps add any number of items to customer's shopping cart and direct
|
56
70
|
him to Amazon website to complete order.
|
57
71
|
email:
|
@@ -103,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
117
|
- !ruby/object:Gem::Version
|
104
118
|
version: '0'
|
105
119
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
120
|
+
rubygems_version: 3.1.2
|
107
121
|
signing_key:
|
108
122
|
specification_version: 4
|
109
123
|
summary: Carriage is a Ruby micro-wrapper to Amazon's Cart Form functionality (part
|