nintendo_eshop 0.1.0.alpha3 → 0.1.0.alpha4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e94ec5b299a5682fbc2cbb5cd3657515dd88ddd20b6b1102da17bb9386d8149
4
- data.tar.gz: ee16d11185eac66b1cf8c7ae802f6f971e41154bd83f14b10ed307c67938e9b8
3
+ metadata.gz: e399f05fe13f9ec613499cf69bc067ea100af0f9ceb26019cb49f5cd87c04e2b
4
+ data.tar.gz: a8c433708538c30cec7bb587b37a3491ebeee696ad3bc15f1186dc6534061145
5
5
  SHA512:
6
- metadata.gz: 1e87038f95f781ac0d4dabf85d57ba78d2e2570d4e7f39a7db8bf6f09e8531900ae0ff0c511ae09250b3fa26f4e2d8a6bc70bb969bed176d301c827ed15bbd97
7
- data.tar.gz: 21747be84dda661be38463d61c8f0780fd2ac29dcdb405ce70b9ca966ec8a083555862864ba615f9bb4fb99cd7d4c9f64c804a6eee406bdca8d285cbc6d640c7
6
+ metadata.gz: 421f83bf9d48a559a730102479b4a55e780dcd41ac42bfed343f7684a14e23d5aa332dcdfd4b568048510cf996a8f49accf5ae76b4de68915be481467af52890
7
+ data.tar.gz: 9cd06480f21d667383580dc57493e4ecf44ac1ac13dff64f92730007e7e41fa3046c9b2323497ecdc94768e93dc337916af310b6fc947706fa85e2ffa727fd67
data/.codeclimate.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  version: "2"
2
- prepare:
3
- fetch:
4
- - url: "https://raw.githubusercontent.com/RamseyInHouse/ramsey-cop/master/default.yml"
5
- path: "alternate-rubocop-path.yml"
2
+ # prepare:
3
+ # fetch:
4
+ # - url: "https://raw.githubusercontent.com/RamseyInHouse/ramsey-cop/master/default.yml"
5
+ # path: "alternate-rubocop-path.yml"
6
6
  plugins:
7
7
  rubocop:
8
8
  enabled: true
data/.rspec_status CHANGED
@@ -1,7 +1,9 @@
1
1
  example_id | status | run_time |
2
2
  ------------------------------------------------------ | ------ | --------------- |
3
- ./spec/acceptance/retrieve_a_valid_record_spec.rb[1:1] | passed | 0.11786 seconds |
4
- ./spec/nintendo_eshop/game_spec.rb[1:1:1] | passed | 0.00419 seconds |
5
- ./spec/nintendo_eshop/game_spec.rb[1:1:2] | passed | 0.00606 seconds |
6
- ./spec/nintendo_eshop/game_spec.rb[1:1:3] | passed | 0.00398 seconds |
7
- ./spec/nintendo_eshop_spec.rb[1:1] | passed | 0.00083 seconds |
3
+ ./spec/acceptance/retrieve_a_valid_record_spec.rb[1:1] | passed | 0.14289 seconds |
4
+ ./spec/nintendo_eshop/game_spec.rb[1:1:1] | passed | 0.00375 seconds |
5
+ ./spec/nintendo_eshop/game_spec.rb[1:1:2] | passed | 0.00616 seconds |
6
+ ./spec/nintendo_eshop/game_spec.rb[1:1:3] | passed | 0.00564 seconds |
7
+ ./spec/nintendo_eshop/games_list_spec.rb[1:1] | passed | 0.00254 seconds |
8
+ ./spec/nintendo_eshop/games_list_spec.rb[1:2:1] | passed | 0.00393 seconds |
9
+ ./spec/nintendo_eshop_spec.rb[1:1] | passed | 0.00331 seconds |
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
1
  inherit_gem:
2
2
  ramsey_cop:
3
3
  - default.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nintendo_eshop (0.1.0.alpha3)
4
+ nintendo_eshop (0.1.0.alpha4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -35,6 +35,8 @@ NintendoEshop.base_url = "https://u3b6gr4ua3-dsn.algolia.net"
35
35
  NintendoEshop.api_key = "9a20c93440cf63cf1a7008d75f7438bf"
36
36
  NintendoEshop.app_id = "U3B6GR4UA3"
37
37
 
38
+ ### Retrieve a game by ID
39
+
38
40
  game = NintendoEshop::Game.retrieve("70010000001130")
39
41
 
40
42
  game.art # "/content/dam/noa/en_US/games/switch/s/super-mario-odyssey-switch/Switch_SuperMarioOdyssey_box.png"
@@ -62,6 +64,14 @@ game.title # "Sonic Forces"
62
64
  game.url # "/games/detail/sonic-forces-switch"
63
65
  ```
64
66
 
67
+ ### Search by Title
68
+
69
+ ```ruby
70
+ games = NintendoEshop::GamesList.by_title("Super Mario Odyssey")
71
+
72
+ games.first.title # "Super Mario Odyssey: Starter"
73
+ ```
74
+
65
75
  ## Errors
66
76
 
67
77
  Error handling is still a work in progress
@@ -0,0 +1,90 @@
1
+ require: rubocop-performance
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - db/schema.rb
6
+ - vendor/**/*
7
+ TargetRubyVersion: 2.4.6
8
+
9
+ Documentation:
10
+ Enabled: false
11
+
12
+ Layout/AccessModifierIndentation:
13
+ EnforcedStyle: outdent
14
+
15
+ Metrics/AbcSize:
16
+ Exclude:
17
+ - spec/**/*
18
+ - test/**/*
19
+
20
+ Metrics/BlockLength:
21
+ Exclude:
22
+ - config/initializers/*
23
+ - config/routes.rb
24
+ - Gemfile
25
+ - spec/**/*
26
+ - test/**/*
27
+ - "*.gemspec"
28
+ - "**/*.rake"
29
+
30
+ Metrics/BlockNesting:
31
+ Exclude:
32
+ - spec/**/*
33
+ - test/**/*
34
+
35
+ Metrics/CyclomaticComplexity:
36
+ Exclude:
37
+ - spec/**/*
38
+ - test/**/*
39
+
40
+ Metrics/LineLength:
41
+ Max: 120
42
+ Exclude:
43
+ - config/routes.rb
44
+ - config/routes/*
45
+ - db/migrate/*
46
+
47
+ Metrics/MethodLength:
48
+ Exclude:
49
+ - db/migrate/*
50
+ - spec/**/*
51
+ - test/**/*
52
+
53
+ Metrics/ModuleLength:
54
+ Exclude:
55
+ - spec/**/*
56
+ - test/**/*
57
+
58
+ Style/Alias:
59
+ EnforcedStyle: prefer_alias_method
60
+
61
+ Style/AndOr:
62
+ EnforcedStyle: conditionals
63
+
64
+ Style/DateTime:
65
+ Enabled: false
66
+
67
+ Style/FrozenStringLiteralComment:
68
+ Enabled: false
69
+
70
+ Style/Lambda:
71
+ Enabled: false
72
+
73
+ Style/NumericLiterals:
74
+ Enabled: false
75
+
76
+ Style/PercentLiteralDelimiters:
77
+ PreferredDelimiters:
78
+ '%i': ()
79
+ '%I': ()
80
+ '%q': ()
81
+ '%Q': ()
82
+ '%r': '{}'
83
+ '%s': ()
84
+ '%w': ()
85
+ '%W': ()
86
+ '%x': ()
87
+
88
+ Style/StringLiterals:
89
+ EnforcedStyle: double_quotes
90
+ Enabled: true
@@ -7,6 +7,7 @@ require "net/http"
7
7
  require_relative "nintendo_eshop/api_client"
8
8
  require_relative "nintendo_eshop/api_request"
9
9
  require_relative "nintendo_eshop/game"
10
+ require_relative "nintendo_eshop/games_list"
10
11
  require_relative "nintendo_eshop/version"
11
12
 
12
13
  module NintendoEshop
@@ -0,0 +1,56 @@
1
+ module NintendoEshop
2
+ class GamesList < APIRequest
3
+ include Enumerable
4
+
5
+ attr_accessor :title
6
+ attr_accessor :games
7
+
8
+ RESOURCE_PATH = "/1/indexes/noa_aem_game_en_us/query".freeze
9
+
10
+ def initialize(title)
11
+ self.title = title
12
+ end
13
+
14
+ def refresh
15
+ response = request(:post, to_json: body)
16
+ result = response.dig(:hits)
17
+ self.games = refresh_list_objects(result)
18
+ self
19
+ end
20
+
21
+ def each
22
+ games.each do |game|
23
+ yield(game)
24
+ end
25
+ end
26
+
27
+ def self.by_title(title)
28
+ instance = new(title)
29
+ instance.refresh
30
+ end
31
+
32
+ private
33
+
34
+ def body
35
+ {
36
+ "query": title.to_s,
37
+ "restrictSearchableAttributes": [
38
+ "title"
39
+ ]
40
+ }
41
+ end
42
+
43
+ def refresh_list_objects(objects)
44
+ objects.map do |object|
45
+ game = Game.new(object.dig(:nsuid))
46
+ game.art = object.dig(:boxArt)
47
+ game.msrp = object.dig(:msrp)
48
+ game.platform = object.dig(:platform)
49
+ game.sale_price = object.dig(:salePrice)
50
+ game.title = object.dig(:title)
51
+ game.url = object.dig(:url)
52
+ game
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,3 +1,3 @@
1
1
  module NintendoEshop
2
- VERSION = "0.1.0.alpha3".freeze
2
+ VERSION = "0.1.0.alpha4".freeze
3
3
  end
@@ -9,12 +9,22 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["peytorb@gmail.com"]
10
10
 
11
11
  spec.summary = "Retrieve game prices from the Nintendo eShop"
12
- spec.homepage = "https://github.com/rickpeyton/nintendo_eshop"
13
- spec.license = "MIT"
12
+ spec.description = <<~DESCRIPTION
13
+ When I want to check the price of a game on the Nintendo eShop I want to search Nintendo's
14
+ API by external key so that I am confident I am getting the correct price.
15
+ DESCRIPTION
16
+ spec.homepage = "https://github.com/rickpeyton/nintendo_eshop"
17
+ spec.metadata = {
18
+ "changelog_uri" => "https://github.com/rickpeyton/nintendo_eshop/releases",
19
+ "homepage_uri" => "https://github.com/rickpeyton/nintendo_eshop",
20
+ "source_code_uri" => "https://github.com/rickpeyton/nintendo_eshop"
21
+ }
22
+ spec.license = "MIT"
23
+ spec.required_ruby_version = ">= 2.4.6"
14
24
 
15
25
  # Specify which files should be added to the gem when it is released.
16
26
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
28
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
29
  end
20
30
  spec.bindir = "exe"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nintendo_eshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha3
4
+ version: 0.1.0.alpha4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Peyton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-22 00:00:00.000000000 Z
11
+ date: 2019-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -164,7 +164,9 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
- description:
167
+ description: |
168
+ When I want to check the price of a game on the Nintendo eShop I want to search Nintendo's
169
+ API by external key so that I am confident I am getting the correct price.
168
170
  email:
169
171
  - peytorb@gmail.com
170
172
  executables: []
@@ -186,18 +188,23 @@ files:
186
188
  - LICENSE
187
189
  - README.md
188
190
  - Rakefile
191
+ - alternate-rubocop-path.yml
189
192
  - bin/console
190
193
  - bin/setup
191
194
  - lib/nintendo_eshop.rb
192
195
  - lib/nintendo_eshop/api_client.rb
193
196
  - lib/nintendo_eshop/api_request.rb
194
197
  - lib/nintendo_eshop/game.rb
198
+ - lib/nintendo_eshop/games_list.rb
195
199
  - lib/nintendo_eshop/version.rb
196
200
  - nintendo_eshop.gemspec
197
201
  homepage: https://github.com/rickpeyton/nintendo_eshop
198
202
  licenses:
199
203
  - MIT
200
- metadata: {}
204
+ metadata:
205
+ changelog_uri: https://github.com/rickpeyton/nintendo_eshop/releases
206
+ homepage_uri: https://github.com/rickpeyton/nintendo_eshop
207
+ source_code_uri: https://github.com/rickpeyton/nintendo_eshop
201
208
  post_install_message:
202
209
  rdoc_options: []
203
210
  require_paths:
@@ -206,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
213
  requirements:
207
214
  - - ">="
208
215
  - !ruby/object:Gem::Version
209
- version: '0'
216
+ version: 2.4.6
210
217
  required_rubygems_version: !ruby/object:Gem::Requirement
211
218
  requirements:
212
219
  - - ">"