awis-sdk-ruby 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3f60e08f71c0092e6c7ff4185e1e64a6af7776d9
4
+ data.tar.gz: cb3a28d169416fb66d36ff7d662295b777709de7
5
+ SHA512:
6
+ metadata.gz: b27b1755fc104f0fc196f1ed91c5e0d93408f3fbd62ccb39b3f7d02c135e2a34eca4db3d4a8a60ee819e0b9bf84aa48c8a392da7e5ed1c4d139e2f4474c0d553
7
+ data.tar.gz: 9d9e2c0011a964374a10a9d89680b57aeebbe44bc5333980f4e40fe163af26c699caecdfbf493f1222aa7f136c59ae084407409ea6223752ed78862f0bfff388
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  *.gem
11
+ awis.yml
11
12
 
12
13
  .ruby-version
13
- awis.yml
14
+ .DS_Store
@@ -0,0 +1,87 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.4
4
+ Exclude:
5
+ - '**/*.yml'
6
+ - 'test/**/*'
7
+ - 'pkg/*'
8
+ - 'tmp/*'
9
+
10
+ Style/StringLiterals:
11
+ Enabled: false
12
+
13
+ Documentation:
14
+ Enabled: false
15
+
16
+ Style/RegexpLiteral:
17
+ Enabled: false
18
+
19
+ Layout/SpaceInsideHashLiteralBraces:
20
+ Enabled: false
21
+
22
+ Metrics/LineLength:
23
+ Max: 160
24
+
25
+ Metrics/ModuleLength:
26
+ Max: 500
27
+
28
+ Metrics/BlockLength:
29
+ Exclude:
30
+ - 'test/**/*'
31
+
32
+ Layout/DotPosition:
33
+ EnforcedStyle: trailing
34
+
35
+ Style/RedundantFreeze:
36
+ Enabled: false
37
+
38
+ Style/FormatString:
39
+ Enabled: false
40
+
41
+ Metrics/ClassLength:
42
+ Enabled: false
43
+
44
+ Lint/AssignmentInCondition:
45
+ Enabled: false
46
+
47
+ Layout/EmptyLinesAroundAccessModifier:
48
+ Enabled: false
49
+
50
+ Style/SingleLineBlockParams:
51
+ Enabled: false
52
+
53
+ Style/NumericLiterals:
54
+ Exclude:
55
+ - 'spec/**/*'
56
+
57
+ Style/StringLiteralsInInterpolation:
58
+ Enabled: false
59
+
60
+ Metrics/MethodLength:
61
+ Max: 30
62
+
63
+ Layout/CaseIndentation:
64
+ # Valid values are: case, end
65
+ EnforcedStyle: end
66
+ IndentOneStep: false
67
+
68
+ Metrics/AbcSize:
69
+ Max: 40
70
+
71
+ Metrics/CyclomaticComplexity:
72
+ Max: 10
73
+
74
+ Metrics/PerceivedComplexity:
75
+ Max: 15
76
+
77
+ Metrics/ParameterLists:
78
+ Max: 10
79
+
80
+ Lint/UselessAssignment:
81
+ Enabled: false
82
+
83
+ Style/NumericLiterals:
84
+ Enabled: false
85
+
86
+ Rails:
87
+ Enabled: true
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- gem "bundler"
4
- gem "rake"
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'bundler'
6
+ gem 'rake'
5
7
 
6
8
  gemspec
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
2
+ # frozen_string_literal: true
3
3
 
4
- require "rake/testtask"
4
+ require 'bundler/gem_tasks'
5
+
6
+ require 'rake/testtask'
5
7
  Rake::TestTask.new(:test) do |test|
6
- test.libs << "lib" << "test"
7
- test.pattern = "test/**/*_test.rb"
8
+ test.libs << 'lib' << 'test'
9
+ test.pattern = 'test/**/*_test.rb'
8
10
  test.verbose = true
9
11
  end
10
12
 
11
- task :default => :test
13
+ task default: :test
@@ -1,32 +1,35 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'awis/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "awis-sdk-ruby"
8
+ spec.name = 'awis-sdk-ruby'
8
9
  spec.version = Awis::VERSION
9
- spec.authors = ["Encore Shao"]
10
- spec.email = ["encore.shao@gmail.com"]
10
+ spec.authors = ['Encore Shao']
11
+ spec.email = ['encore.shao@gmail.com']
11
12
 
12
- spec.summary = %q{Ruby - Amazon Alexa Web Information Service Library (AWIS)}
13
- spec.description = %q{Ruby - Amazon Alexa Web Information Service Library (AWIS)}
14
- spec.homepage = "https://github.com/encoreshao/amazon-awis"
13
+ spec.summary = 'Ruby - Amazon Alexa Web Information Service Library (AWIS)'
14
+ spec.description = 'Ruby - Amazon Alexa Web Information Service Library (AWIS)'
15
+ spec.homepage = 'https://github.com/encoreshao/amazon-awis'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
18
  f.match(%r{^(test|spec|features)/})
18
19
  end
19
- spec.bindir = "exe"
20
+ spec.bindir = 'exe'
20
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
22
+ spec.require_paths = ['lib']
22
23
 
23
- spec.required_ruby_version = ">= 1.9.3"
24
+ # spec.required_ruby_version = '>= 1.9.3'
24
25
 
25
- spec.add_dependency "multi_xml", ">= 0.5.0"
26
- spec.add_dependency "nokogiri", '~> 1.6.8'
26
+ spec.add_dependency 'aws-sigv4'
27
+ spec.add_dependency 'multi_xml'
28
+ spec.add_dependency 'nokogiri'
27
29
 
28
- spec.add_development_dependency "minitest"
29
- spec.add_development_dependency "mocha"
30
- spec.add_development_dependency "webmock"
31
- spec.add_development_dependency "pry"
30
+ spec.add_development_dependency 'minitest'
31
+ spec.add_development_dependency 'mocha'
32
+ spec.add_development_dependency 'pry'
33
+ spec.add_development_dependency 'rubocop'
34
+ spec.add_development_dependency 'webmock'
32
35
  end
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "awis"
4
+ require 'bundler/setup'
5
+ require 'awis'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "awis"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,24 +1,22 @@
1
- require "multi_xml"
2
- require "nokogiri"
1
+ # frozen_string_literal: true
3
2
 
4
- require "awis/version"
5
- require "awis/hash"
6
- require "awis/utils"
7
- require "awis/exceptions"
8
- require "awis/connection"
9
- require "awis/config"
10
- require "awis/client"
11
- require "awis/api"
12
- require "awis/models"
3
+ require 'multi_xml'
4
+ require 'nokogiri'
5
+ require 'aws-sigv4'
13
6
 
14
- module Awis
15
- SERVICE_HOST = "awis.amazonaws.com".freeze
16
- SERVICE_ENDPOINT = "awis.us-west-1.amazonaws.com".freeze
17
- SERVICE_PORT = 443
18
- SERVICE_URI = "/api".freeze
19
- SERVICE_REGION = "us-west-1".freeze
20
- SERVICE_NAME = "awis".freeze
7
+ require 'awis/version'
8
+ require 'awis/hash'
9
+ require 'awis/utils'
10
+ require 'awis/exceptions'
11
+ require 'awis/connection'
12
+ require 'awis/config'
13
+ require 'awis/client'
14
+ require 'awis/api'
15
+ require 'awis/models'
21
16
 
22
- class << self
23
- end
17
+ module Awis
18
+ SERVICE_PATH = 'api'
19
+ SERVICE_NAME = 'awis'
20
+ SERVICE_REGION = 'us-west-1'
21
+ SERVICE_HOST = "#{SERVICE_NAME}.amazonaws.com"
24
22
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Awis
2
4
  module API
3
- autoload :Base, "awis/api/base"
4
- autoload :UrlInfo, "awis/api/url_info"
5
- autoload :TrafficHistory, "awis/api/traffic_history"
6
- autoload :SitesLinkingIn, "awis/api/sites_linking_in"
7
- autoload :CategoryListings, "awis/api/category_listings"
8
- autoload :CategoryBrowse, "awis/api/category_browse"
5
+ autoload :Base, 'awis/api/base'
6
+ autoload :UrlInfo, 'awis/api/url_info'
7
+ autoload :TrafficHistory, 'awis/api/traffic_history'
8
+ autoload :SitesLinkingIn, 'awis/api/sites_linking_in'
9
+ autoload :CategoryListings, 'awis/api/category_listings'
10
+ autoload :CategoryBrowse, 'awis/api/category_browse'
9
11
  end
10
12
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Awis
2
4
  module API
3
5
  class Base
@@ -39,7 +41,7 @@ module Awis
39
41
 
40
42
  def before_validation_arguments(arguments)
41
43
  raise ArgumentError, "Invalid arguments. should be like { url: 'site.com' }" unless arguments.is_a?(Hash)
42
- raise ArgumentError, "Invalid arguments. the url must be configured." unless arguments.has_key?(:url)
44
+ raise ArgumentError, 'Invalid arguments. the url must be configured.' unless arguments.key?(:url)
43
45
  end
44
46
 
45
47
  class << self
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Awis
2
4
  module API
3
5
  class CategoryBrowse < Base
4
- DEFAULT_RESPONSE_GROUP = %w(categories related_categories language_categories letter_bars).freeze
6
+ DEFAULT_RESPONSE_GROUP = %w[categories related_categories language_categories letter_bars].freeze
5
7
 
6
8
  def load_request_uri(arguments = {})
7
9
  validation_arguments!(arguments)
@@ -10,9 +12,10 @@ module Awis
10
12
  end
11
13
 
12
14
  private
15
+
13
16
  def before_validation_arguments(arguments)
14
17
  raise ArgumentError, "Invalid arguments. should be like { path: 'Top/Arts' }" unless arguments.is_a?(Hash)
15
- raise ArgumentError, "Invalid arguments. the path must be configured." unless arguments.has_key?(:path)
18
+ raise ArgumentError, 'Invalid arguments. the path must be configured.' unless arguments.key?(:path)
16
19
  end
17
20
 
18
21
  def validation_arguments!(arguments)
@@ -25,15 +28,15 @@ module Awis
25
28
 
26
29
  def params
27
30
  {
28
- "Action" => action_name,
29
- "ResponseGroup" => response_groups,
30
- "Path" => arguments[:path],
31
- "Descriptions" => request_description_params
31
+ 'Action' => action_name,
32
+ 'ResponseGroup' => response_groups,
33
+ 'Path' => arguments[:path],
34
+ 'Descriptions' => request_description_params
32
35
  }
33
36
  end
34
37
 
35
38
  def response_groups
36
- arguments[:response_group].sort.map { |group| camelize(group) }.join(",")
39
+ arguments[:response_group].sort.map { |group| camelize(group) }.join(',')
37
40
  end
38
41
  end
39
42
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Awis
2
4
  module API
3
5
  class CategoryListings < Base
4
- DEFAULT_RESPONSE_GROUP = %w(listings).freeze
6
+ DEFAULT_RESPONSE_GROUP = %w[listings].freeze
5
7
 
6
8
  def load_request_uri(arguments = {})
7
9
  validation_arguments!(arguments)
@@ -10,16 +12,17 @@ module Awis
10
12
  end
11
13
 
12
14
  private
15
+
13
16
  def before_validation_arguments(arguments)
14
17
  raise ArgumentError, "Invalid arguments. should be like { path: '/Top/Games/Card_Games' }" unless arguments.is_a?(Hash)
15
- raise ArgumentError, "Invalid arguments. the path must be configured." unless arguments.has_key?(:path)
18
+ raise ArgumentError, 'Invalid arguments. the path must be configured.' unless arguments.key?(:path)
16
19
  end
17
20
 
18
21
  def validation_arguments!(arguments)
19
22
  before_validation_arguments(arguments)
20
23
 
21
24
  @arguments = arguments
22
- @arguments[:sort_by] = arguments.fetch(:sort_by, "popularity")
25
+ @arguments[:sort_by] = arguments.fetch(:sort_by, 'popularity')
23
26
  @arguments[:recursive] = arguments.fetch(:recursive, true)
24
27
  @arguments[:descriptions] = arguments.fetch(:descriptions, true)
25
28
  @arguments[:start] = arguments.fetch(:start, 0)
@@ -28,14 +31,14 @@ module Awis
28
31
 
29
32
  def params
30
33
  {
31
- "Action" => action_name,
32
- "ResponseGroup" => response_groups,
33
- "Path" => arguments[:path],
34
- "Recursive" => recursive_param,
35
- "Descriptions" => request_description_params,
36
- "SortBy" => sort_by_param,
37
- "Count" => arguments[:count],
38
- "Start" => arguments[:start],
34
+ 'Action' => action_name,
35
+ 'ResponseGroup' => response_groups,
36
+ 'Path' => arguments[:path],
37
+ 'Recursive' => recursive_param,
38
+ 'Descriptions' => request_description_params,
39
+ 'SortBy' => sort_by_param,
40
+ 'Count' => arguments[:count],
41
+ 'Start' => arguments[:start]
39
42
  }
40
43
  end
41
44
 
@@ -48,7 +51,7 @@ module Awis
48
51
  end
49
52
 
50
53
  def response_groups
51
- DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(",")
54
+ DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(',')
52
55
  end
53
56
  end
54
57
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Awis
2
4
  module API
3
5
  class SitesLinkingIn < Base
4
- DEFAULT_RESPONSE_GROUP = %w(sites_linking_in).freeze
6
+ DEFAULT_RESPONSE_GROUP = %w[sites_linking_in].freeze
5
7
 
6
8
  def load_request_uri(arguments = {})
7
9
  validation_arguments!(arguments)
@@ -10,6 +12,7 @@ module Awis
10
12
  end
11
13
 
12
14
  private
15
+
13
16
  def validation_arguments!(arguments)
14
17
  before_validation_arguments(arguments)
15
18
 
@@ -20,16 +23,16 @@ module Awis
20
23
 
21
24
  def params
22
25
  {
23
- "Action" => action_name,
24
- "Url" => arguments[:url],
25
- "ResponseGroup" => response_groups,
26
- "Count" => arguments[:count],
27
- "Start" => arguments[:start]
26
+ 'Action' => action_name,
27
+ 'Url' => arguments[:url],
28
+ 'ResponseGroup' => response_groups,
29
+ 'Count' => arguments[:count],
30
+ 'Start' => arguments[:start]
28
31
  }
29
32
  end
30
33
 
31
34
  def response_groups
32
- DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(",")
35
+ DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(',')
33
36
  end
34
37
  end
35
38
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Awis
2
4
  module API
3
5
  class TrafficHistory < Base
4
- DEFAULT_RESPONSE_GROUP = %w(history).freeze
6
+ DEFAULT_RESPONSE_GROUP = %w[history].freeze
5
7
 
6
8
  def load_request_uri(arguments = {})
7
9
  validation_arguments!(arguments)
@@ -10,13 +12,14 @@ module Awis
10
12
  end
11
13
 
12
14
  private
15
+
13
16
  def params
14
17
  {
15
- "Action" => action_name,
16
- "Url" => arguments[:url],
17
- "ResponseGroup" => response_groups,
18
- "Range" => arguments[:range],
19
- "Start" => start_date,
18
+ 'Action' => action_name,
19
+ 'Url' => arguments[:url],
20
+ 'ResponseGroup' => response_groups,
21
+ 'Range' => arguments[:range],
22
+ 'Start' => start_date
20
23
  }
21
24
  end
22
25
 
@@ -25,15 +28,15 @@ module Awis
25
28
 
26
29
  @arguments = arguments
27
30
  @arguments[:range] = arguments.fetch(:range, 31)
28
- @arguments[:start] = arguments.fetch(:start) { Time.now - (3600 * 24 * @arguments[:range].to_i) }
31
+ @arguments[:start] = arguments.fetch(:start) { Time.zone.now - (3600 * 24 * @arguments[:range].to_i) }
29
32
  end
30
33
 
31
34
  def start_date
32
- arguments[:start].respond_to?(:strftime) ? arguments[:start].strftime("%Y%m%d") : arguments[:start]
35
+ arguments[:start].respond_to?(:strftime) ? arguments[:start].strftime('%Y%m%d') : arguments[:start]
33
36
  end
34
37
 
35
38
  def response_groups
36
- DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(",")
39
+ DEFAULT_RESPONSE_GROUP.map { |group| camelize(group) }.join(',')
37
40
  end
38
41
  end
39
42
  end