blizzard_api 3.4.3 → 4.0.0

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: f8a5178383a51b7598cc64b98159fc06b59f368602ea7735386183fb17db2f3c
4
- data.tar.gz: e8980a8052eec717672b577070346225c6bf466692a3ea3b282a922bff4bd323
3
+ metadata.gz: 79f824ffc1cb26dddb1fc23ae4c029930feaf2c16f2d9bdbed6bbd20b815e47e
4
+ data.tar.gz: 92271ac4aed4dd441dc9b43f74afae3794035b6fde44dd76651e9f4596868978
5
5
  SHA512:
6
- metadata.gz: 3c261788c93ed802647a809d5fffc394899b50ee33e211d86a355673fdbd429f5009819ac0ec917f788afaa39aae1030f5ae2afde042d2c57ce5f4a65ff3e1d9
7
- data.tar.gz: f9afd208d352a2473f9bc17e76a15999f64c116efb18ed81e9e54d6eb1d7d425ac5fb54824226aaff88eca5d23471f909e5684ab6330c996873f3ed559a0f7d2
6
+ metadata.gz: 564512eb1d3bb2a0157b33783cf277d3f1f1ec30757972bd5c2a97485567b0f9287ad59f49f9fdc2f3ad042e342e2852d3a811620328853a10245d36a73a112c
7
+ data.tar.gz: dc87e72420e7be2f16861fb6b5ead8355fd66e7ae52f0151997440d838ca011d707ee2b7abfa2ba46bff8dd7d1d2760611fa6c3914ad014216323072719a9a1b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  Please view this file on the master branch, otherwise it may be outdated
2
2
 
3
+ **Version 4.0.0**
4
+
5
+ **Warning**: This version introduces breaking changes to the way the gem handles the Redis connection.
6
+ Instead of providing the HOST, PORT and DB as separate options, now you should provide the full URL in the `redis_url` option.
7
+
8
+ This allows for more flexibility when using Redis, as it is now possible to use a password protected database.
9
+
10
+ Added a binary for experimenting with the gem or using it as a command line tool.
11
+
3
12
  **Version 3.4.0**
4
13
 
5
14
  Added new collections endpoints for toys and heirlooms.
data/Gemfile.lock CHANGED
@@ -1,24 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blizzard_api (3.4.3)
4
+ blizzard_api (4.0.0)
5
5
  redis (~> 4.1, >= 4.1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- dotenv (2.8.1)
12
- minitest (5.20.0)
13
- parallel (1.23.0)
14
- parser (3.2.2.4)
11
+ dotenv (3.1.0)
12
+ minitest (5.22.3)
13
+ parallel (1.24.0)
14
+ parser (3.3.1.0)
15
15
  ast (~> 2.4.1)
16
16
  racc
17
- racc (1.7.1)
17
+ racc (1.7.3)
18
18
  rainbow (3.1.1)
19
- rake (13.0.6)
19
+ rake (13.2.1)
20
20
  redis (4.8.1)
21
- regexp_parser (2.8.2)
21
+ regexp_parser (2.9.0)
22
22
  rexml (3.2.6)
23
23
  rubocop (0.93.1)
24
24
  parallel (~> 1.10)
@@ -29,22 +29,25 @@ GEM
29
29
  rubocop-ast (>= 0.6.0)
30
30
  ruby-progressbar (~> 1.7)
31
31
  unicode-display_width (>= 1.4.0, < 2.0)
32
- rubocop-ast (1.29.0)
33
- parser (>= 3.2.1.0)
32
+ rubocop-ast (1.31.2)
33
+ parser (>= 3.3.0.4)
34
+ rubocop-minitest (0.27.0)
35
+ rubocop (>= 0.90, < 2.0)
34
36
  ruby-progressbar (1.13.0)
35
37
  unicode-display_width (1.8.0)
36
- yard (0.9.34)
38
+ yard (0.9.36)
37
39
 
38
40
  PLATFORMS
39
41
  ruby
40
42
 
41
43
  DEPENDENCIES
42
44
  blizzard_api!
43
- dotenv
44
- minitest (~> 5.0)
45
- rake (~> 13.0)
46
- rubocop (~> 0.61)
47
- yard
45
+ dotenv (~> 3.1)
46
+ minitest (~> 5.22)
47
+ rake (~> 13.2)
48
+ rubocop (~> 0.93.1)
49
+ rubocop-minitest (~> 0.27.0)
50
+ yard (~> 0.9.36)
48
51
 
49
52
  BUNDLED WITH
50
- 2.2.17
53
+ 2.5.4
data/README.md CHANGED
@@ -25,8 +25,15 @@ gem 'blizzard_api'
25
25
  ```
26
26
 
27
27
  And then execute:
28
+ ```bash
29
+ $ bundle
30
+ ```
31
+
32
+ You can also install the gem and use as a standalone binary:
28
33
 
29
- $ bundle
34
+ ```bash
35
+ gem install blizzard_api
36
+ ```
30
37
 
31
38
  ## 2. Configuration
32
39
 
@@ -39,15 +46,84 @@ BlizzardApi.configure do |config|
39
46
  config.app_id = ENV['BNET_APPLICATION_ID']
40
47
  config.app_secret = ENV['BNET_APPLICATION_SECRET']
41
48
  config.region = 'us'
42
- config.use_cache = true
43
- config.redis_host = ENV['REDIS_HOST']
44
- config.redis_port = ENV['REDIS_PORT']
49
+ config.redis_url = 'redis://localhost:6379/0'
50
+ config.cache_access_token = true
45
51
  end
46
52
  ```
47
53
 
48
54
  It is highly recommended to use [redis](https://redis.io/) to cache all requests as it avoids unnecessary calls and speeds up your application.
49
55
 
50
- ## 3. Basic usage
56
+ ## 3. Using the shipped binary
57
+
58
+ This gem ships with a binary that allows you to perform requests to the api directly from the command line. Suppoerted arguments:
59
+
60
+ ## 3.1 Configuration
61
+
62
+ | Argument | Description |
63
+ |--------------------------|----------------------------------------------------------------------------------------------------------------------------|
64
+ | -a, --auth | A pair of application ID and secret created on the Blizzard API dev portal. Argument must be provided as APP_ID:APP_SECRET |
65
+ | -c, --cache | A valid Redis connection string. redis://user:password@host:port/db |
66
+ | -h, --help | Prints this help |
67
+ | -j, --json | Outputs the payload as JSON. |
68
+ | -J, --formatted-json | Outputs the payload as pretty formatted JSON. |
69
+ | -l, --locale | Locale to use when retrieving data. |
70
+ | -o, --output | Path to an output file. |
71
+ | -r, --region | Region to use for the API calls. Default is **us** |
72
+ | -t, --cache-access-token | Cache the access token in Redis |
73
+ | -v, --version | Prints the version |
74
+
75
+ Some arguments can be loaded from environment variables:
76
+
77
+ | Environment Variable | Description | Replaced argument |
78
+ |-------------------------|---------------------------------|-------------------|
79
+ | BNET_APPLICATION_ID | Blizzard API application ID | -a |
80
+ | BNET_APPLICATION_SECRET | Blizzard API application secret | -a |
81
+ | REGION | Blizzard API region | -r |
82
+ | BNET_REDIS_URL | Redis connection string | -c |
83
+ | BNET_CACHE_ACCESS_TOKEN | Cache the access token in Redis | -t |
84
+
85
+ **Note**: You can also use Dotenv to load the environment variables from a `.env` file as long as you have Dotenv installed
86
+ and the `.env` file is present in the same directory you are invoking the binary from.
87
+
88
+ ## 3.2. Command line usage
89
+
90
+ You can fetch API endpoints data by using the following format:
91
+
92
+ ```bash
93
+ blizzard_api <game namespace> <api endpoint> <endpoint method> [arguments]
94
+ ```
95
+
96
+ ## 3.3. Examples
97
+
98
+ ### 3.3.1. Using the binary to get a list of realms
99
+
100
+ ```bash
101
+ blizzard_api wow realm index
102
+ ````
103
+
104
+ ### 3.3.1. Using the binary to get a specific realm
105
+
106
+ Full payload:
107
+ ```bash
108
+ blizzard_api wow realm get 5909
109
+ ````
110
+
111
+ Full payload as formatted JSON:
112
+ ```bash
113
+ blizzard_api -J wow realm get 5909
114
+ ````
115
+
116
+ Full payload as formatted JSON to file:
117
+ ```bash
118
+ blizzard_api -Jo realm.json wow realm get 5909
119
+ ````
120
+
121
+ en-US only payload as formatted JSON:
122
+ ```bash
123
+ blizzard_api -Jl en_US wow realm get 5909
124
+ ````
125
+
126
+ ## 4. Basic usage
51
127
 
52
128
  You can now consume the api by instantiating a specific endpoint:
53
129
 
@@ -69,7 +145,7 @@ Most **game data** endpoints will have always 3 methods available `index`, `get`
69
145
  * `get` is used to get all information about a entry of the index returned data. It receives an id or slug as the first parameter, that depends on the endpoint.
70
146
  * `complete` is a complete information of all items listed in index. **This may perform various calls to the blizzard api** only use if you really need all information.
71
147
 
72
- ### 3.1 Searchable endpoints
148
+ ### 4.1 Searchable endpoints
73
149
 
74
150
  Some endpoints support search filters. To perform a search you can use the following formats:
75
151
 
@@ -108,7 +184,7 @@ realm_data = realm.search(1, 100) do |options|
108
184
  end
109
185
  ```
110
186
 
111
- ## 4. Available endpoints
187
+ ## 5. Available endpoints
112
188
 
113
189
  **Hint**: All methods support an additional optional hash parameter that allows you to override the following configurations for a single call:
114
190
 
@@ -120,7 +196,7 @@ end
120
196
  * **use_community_endpoint**: Some methods in game data still have an odl community version available.
121
197
  * **classic**: Set to true to query WoW Classic data, only works for some game data endpoints.
122
198
 
123
- ### 4.1. World of Warcraft endpoints
199
+ ### 5.1. World of Warcraft endpoints
124
200
 
125
201
  * [BlizzardApi::Wow.achievement](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Wow/Achievement)
126
202
  * [BlizzardApi::Wow.auction](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Wow/Auction)
@@ -162,7 +238,7 @@ end
162
238
  * [BlizzardApi::Wow.guild](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Wow/Guild)
163
239
  * [BlizzardApi::Wow.character_profile](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Wow/CharacterProfile)
164
240
 
165
- ### 4.2. Diablo III endpoints
241
+ ### 5.2. Diablo III endpoints
166
242
 
167
243
  * [BlizzardApi::Diablo.season](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Diablo/Season)
168
244
  * [BlizzardApi::Diablo.era](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Diablo/Era)
@@ -174,14 +250,14 @@ end
174
250
  * [BlizzardApi::Diablo.item](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Diablo/Item)
175
251
  * [BlizzardApi::Diablo.profile](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Diablo/Profile)
176
252
 
177
- ### 4.3. Hearthstone endpoints
253
+ ### 5.3. Hearthstone endpoints
178
254
 
179
255
  * [BlizzardApi::Hearthstone.card](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Hearthstone/Card)
180
256
  * [BlizzardApi::Hearthstone.back](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Hearthstone/Back)
181
257
  * [BlizzardApi::Hearthstone.deck](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Hearthstone/Deck)
182
258
  * [BlizzardApi::Hearthstone.metadata](https://rubydoc.info/gems/blizzard_api/BlizzardApi/Hearthstone/Metadata)
183
259
 
184
- ### 4.4. Starcraft II endpoints
260
+ ### 5.4. Starcraft II endpoints
185
261
 
186
262
  Every endpoint requiring a *region_id* parameter will accepts either the integer representation of the region described in the api docs or a symbol: `:US`, `:EU`, `:KO` or `:TW`
187
263
 
data/bin/blizzard_api ADDED
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'logger'
4
+ logger = Logger.new(STDOUT)
5
+
6
+ require 'bundler/setup'
7
+ require 'blizzard_api'
8
+ require 'irb'
9
+ require 'optparse'
10
+
11
+ begin
12
+ require 'dotenv/load'
13
+ rescue LoadError
14
+ logger.warn 'Dotenv gem not found. You must provide all arguments via the command line or system environment variables.'
15
+ end
16
+
17
+ options = {}
18
+ parser = OptionParser.new do |opts|
19
+ opts.banner = 'Interactive console for testing the BlizzardApi gem.'
20
+ opts.on('-a', '--auth AUTH', 'A pair of application ID and secret created on the Blizzard API dev portal. Argument must be provided as APP_ID:APP_SECRET') do |c|
21
+ ENV['BNET_APPLICATION_ID'], ENV['BNET_APPLICATION_SECRET'] = c.split(':')
22
+ end
23
+ opts.on('-c', '--cache REDIS_URL', 'A valid Redis connection string. redis://user:password@host:port/db', ) { |c| ENV['REDIS_URL'] = c }
24
+ opts.on('-h', '--help', 'Prints this help') { puts opts; exit }
25
+ opts.on('-j', '--json', 'Outputs the payload as JSON.') { options[:format] = 'json' }
26
+ opts.on('-J', '--formatted-json', 'Outputs the payload as pretty formatted JSON.') { options[:format] = 'json'; options[:pretty_print] = true }
27
+ opts.on('-l', '--locale LOCALE', 'Locale to use when retrieving data.') { |l| options[:locale] = l.to_sym }
28
+ opts.on('-o', '--output FILENAME', 'Path to an output file.') { |o| options[:output] = o }
29
+ opts.on('-r', '--region REGION', 'Region to use for the API calls. Default is us') { |r| ENV['REGION'] = r }
30
+ opts.on('-t', '--cache-access-token', 'Cache the access token in Redis') { ENV['CACHE_ACCESS_TOKEN]'] = 'true' }
31
+ opts.on('-v', '--version', 'Prints the version') { puts BlizzardApi::VERSION; exit }
32
+ end
33
+ parser.parse!
34
+
35
+ app_id = ENV.fetch('BNET_APPLICATION_ID', false)
36
+ app_secret = ENV.fetch('BNET_APPLICATION_SECRET', false)
37
+
38
+ if !app_id || !app_secret
39
+ logger.fatal 'You must provide an application ID and secret.'
40
+ exit 1
41
+ end
42
+
43
+ BlizzardApi.configure do |config|
44
+ config.app_id = app_id
45
+ config.app_secret = app_secret
46
+ config.region = ENV.fetch('REGION', 'us')
47
+ config.redis_url = ENV['REDIS_URL']
48
+ config.cache_access_token = ENV.fetch('CACHE_ACCESS_TOKEN', 'false').eql? 'true'
49
+ end
50
+
51
+ unless ARGV.length.positive?
52
+ IRB.start(__FILE__)
53
+ exit
54
+ end
55
+
56
+ class Runner
57
+ attr_reader :options
58
+
59
+ def initialize(api, endpoint, method, *args, **options)
60
+ @api = nested_class(BlizzardApi, api, 'Invalid API name. Valid APIs are: diablo, hearthstone, overwatch_league, starcraft and wow')
61
+ @endpoint = nested_class(@api, endpoint, 'Invalid endpoint name.')
62
+ @method = method
63
+ @args = parse_args args
64
+ @options = options
65
+ end
66
+
67
+ def run
68
+ data = consume_endpoint
69
+ if options[:output]
70
+ File.open(options[:output], 'w') { |f| f.write(data) }
71
+ else
72
+ puts data
73
+ end
74
+ end
75
+
76
+ private
77
+
78
+ def camelize(s)
79
+ s.split('_').map(&:capitalize).join
80
+ end
81
+
82
+ def nested_class(instance, class_name, msg)
83
+ class_name = camelize(class_name)
84
+ instance.const_get(class_name)
85
+ rescue NameError
86
+ raise StandardError, msg
87
+ end
88
+
89
+ def parse_args(args)
90
+ args.map do |arg|
91
+ begin
92
+ return arg.to_i if arg.match?(/^\d+$/)
93
+ return arg.to_sym if arg.match?(/^:[a-z_]+$/)
94
+ return arg.to_f if arg.match?(/^\d+\.\d+$/)
95
+ return arg.to_bool if arg.match?(/^(true|false)$/i)
96
+ if arg.match?(/^\{.*}$/)
97
+ result = arg.scan(/(\w+):\s+([^(;|})]+)/).each_with_object({}) do |(k,v), hash|
98
+ hash[k.to_sym] = v.strip
99
+ end
100
+ return [result]
101
+ end
102
+ arg
103
+ end
104
+ end
105
+ end
106
+
107
+ def consume_endpoint
108
+ opts = options.slice :locale
109
+ api_client = @endpoint.new
110
+ data = api_client.send(@method, *@args, **opts)
111
+ if options[:format].eql? 'json'
112
+ data = if options[:pretty_print]
113
+ JSON.pretty_generate data
114
+ else
115
+ JSON.generate data
116
+ end
117
+ end
118
+
119
+ data
120
+ end
121
+ end
122
+
123
+ runner = Runner.new(*ARGV, **options)
124
+ runner.run
data/bin/setup CHANGED
@@ -4,5 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/blizzard_api.gemspec CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'blizzard_api/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.required_ruby_version = '>= 2.7.2'
8
+ spec.required_ruby_version = '>= 3.0'
9
9
  spec.name = 'blizzard_api'
10
10
  spec.version = BlizzardApi::VERSION
11
11
  spec.authors = ['Francis Schiavo']
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  # to allow pushing to a single host or delete this section to allow pushing to any host.
20
20
  raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
21
21
 
22
- spec.metadata['homepage_uri'] = spec.homepage
23
22
  spec.metadata['source_code_uri'] = 'https://github.com/francis-schiavo/blizzard_api'
24
23
  spec.metadata['bug_tracker_uri'] = 'https://github.com/francis-schiavo/blizzard_api/issues'
25
24
  spec.metadata['changelog_uri'] = 'https://github.com/francis-schiavo/blizzard_api/blob/master/CHANGELOG.md'
@@ -28,17 +27,17 @@ Gem::Specification.new do |spec|
28
27
  # Specify which files should be added to the gem when it is released.
29
28
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
29
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
31
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|\..+|Rakefile)/) }
32
31
  end
33
- spec.bindir = 'exe'
34
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.executables = 'blizzard_api'
35
33
  spec.require_paths = ['lib']
36
34
 
37
35
  spec.add_runtime_dependency 'redis', '~> 4.1', '>= 4.1.0'
38
36
 
39
- spec.add_development_dependency 'dotenv'
40
- spec.add_development_dependency 'minitest', '~> 5.0'
41
- spec.add_development_dependency 'rake', '~> 13.0'
42
- spec.add_development_dependency 'rubocop', '~> 0.61'
43
- spec.add_development_dependency 'yard'
37
+ spec.add_development_dependency 'dotenv', '~> 3.1'
38
+ spec.add_development_dependency 'minitest', '~> 5.22'
39
+ spec.add_development_dependency 'rake', '~> 13.2'
40
+ spec.add_development_dependency 'rubocop', '~> 0.93.1'
41
+ spec.add_development_dependency 'rubocop-minitest', '~> 0.27.0'
42
+ spec.add_development_dependency 'yard', '~> 0.9.36'
44
43
  end
@@ -30,32 +30,10 @@ module BlizzardApi
30
30
  attr_accessor :mode
31
31
 
32
32
  ##
33
- # @!attribute use_cache
34
- # If true requests will be cached using a Redis server.
35
- # @see https://redis.io/
36
- # @return [Boolean] Application ID
37
- attr_accessor :use_cache
38
-
39
- ##
40
- # @!attribute redis_host
41
- # Redis host.
42
- # @see https://redis.io/
43
- # @return [String] Redis host
44
- attr_accessor :redis_host
45
-
46
- ##
47
- # @!attribute redis_port
48
- # Redis port.
49
- # @see https://redis.io/
50
- # @return [Integer] Redis port
51
- attr_accessor :redis_port
52
-
53
- ##
54
- # @!attribute redis_database
55
- # Redis databse.
56
- # @see https://redis.io/
57
- # @return [Integer] Redis database
58
- attr_accessor :redis_database
33
+ # @!attribute redis_url
34
+ # Redis connection string. Overrides redis_host, redis_port and redis_database.
35
+ # @see https://redis.io/
36
+ attr_accessor :redis_url
59
37
 
60
38
  ##
61
39
  # @!attribute cache_access_token
@@ -70,15 +48,13 @@ module BlizzardApi
70
48
  # @yield self
71
49
  #
72
50
  # @example
73
- # BlizzardApi.configure do |config|
74
- # config.app_id = ENV['BNET_APPLICATION_ID']
75
- # config.app_secret = ENV['BNET_APPLICATION_SECRET']
76
- # config.region = 'us'
77
- #
78
- # config.use_cache = true
79
- # config.redis_host = ENV['REDIS_HOST']
80
- # config.redis_port = ENV['REDIS_PORT']
81
- # end
51
+ # BlizzardApi.configure do |config|
52
+ # config.app_id = ENV['BNET_APPLICATION_ID']
53
+ # config.app_secret = ENV['BNET_APPLICATION_SECRET']
54
+ # config.region = 'us'
55
+ # config.redis_url = 'redis://localhost:6379/0'
56
+ # config.cache_access_token = true
57
+ # end
82
58
  def configure
83
59
  yield self
84
60
  end
@@ -86,8 +62,11 @@ module BlizzardApi
86
62
  ##
87
63
  # Initializes some default values for the main module
88
64
  def self.extended(base)
89
- base.redis_port = 1
90
65
  base.mode = :regular
91
66
  end
67
+
68
+ def use_cache?
69
+ @use_cache ||= !redis_url.nil?
70
+ end
92
71
  end
93
72
  end
@@ -177,11 +177,11 @@ module BlizzardApi
177
177
  end
178
178
 
179
179
  def save_in_cache(resource_url, data, ttl)
180
- BlizzardApi.redis_connection.setex resource_url, ttl, data if BlizzardApi.use_cache
180
+ BlizzardApi.redis_connection.setex resource_url, ttl, data if BlizzardApi.use_cache?
181
181
  end
182
182
 
183
183
  def find_in_cache(resource_url)
184
- return false unless BlizzardApi.use_cache
184
+ return false unless BlizzardApi.use_cache?
185
185
 
186
186
  BlizzardApi.redis_connection.get resource_url if BlizzardApi.redis_connection.exists? resource_url
187
187
  end
@@ -29,7 +29,7 @@ module BlizzardApi
29
29
  end
30
30
 
31
31
  def restore_access_token
32
- return false unless use_cache && cache_access_token
32
+ return false unless use_cache? && cache_access_token
33
33
 
34
34
  return false unless redis_connection.exists? REDIS_TOKEN_KEY
35
35
 
@@ -43,7 +43,7 @@ module BlizzardApi
43
43
  self.expires_at = Time.now + ttl
44
44
  self.access_token = token_data['access_token']
45
45
 
46
- redis_connection.setex REDIS_TOKEN_KEY, ttl, access_token if use_cache && cache_access_token
46
+ redis_connection.setex REDIS_TOKEN_KEY, ttl, access_token if use_cache? && cache_access_token
47
47
  end
48
48
  end
49
49
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module BlizzardApi
4
4
  # Gem version
5
- VERSION = '3.4.3'
5
+ VERSION = '4.0.0'
6
6
  end
data/lib/blizzard_api.rb CHANGED
@@ -19,8 +19,8 @@ module BlizzardApi
19
19
  extend Configuration
20
20
 
21
21
  def self.redis_connection
22
- return nil unless use_cache
22
+ return nil unless use_cache?
23
23
 
24
- @redis_connection ||= Redis.new(host: redis_host, port: redis_port, db: redis_database)
24
+ @redis_connection ||= Redis.new(url: BlizzardApi.redis_url)
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blizzard_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.3
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Schiavo
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-25 00:00:00.000000000 Z
11
+ date: 2024-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -34,90 +34,100 @@ dependencies:
34
34
  name: dotenv
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: '3.1'
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: '3.1'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '5.0'
53
+ version: '5.22'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '5.0'
60
+ version: '5.22'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '13.0'
67
+ version: '13.2'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '13.0'
74
+ version: '13.2'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rubocop
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.61'
81
+ version: 0.93.1
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0.61'
88
+ version: 0.93.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop-minitest
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.27.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.27.0
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: yard
91
105
  requirement: !ruby/object:Gem::Requirement
92
106
  requirements:
93
- - - ">="
107
+ - - "~>"
94
108
  - !ruby/object:Gem::Version
95
- version: '0'
109
+ version: 0.9.36
96
110
  type: :development
97
111
  prerelease: false
98
112
  version_requirements: !ruby/object:Gem::Requirement
99
113
  requirements:
100
- - - ">="
114
+ - - "~>"
101
115
  - !ruby/object:Gem::Version
102
- version: '0'
116
+ version: 0.9.36
103
117
  description: This is a simple interface to obtain data from Blizzard API
104
118
  email:
105
119
  - francis@schiavo.dev
106
- executables: []
120
+ executables:
121
+ - blizzard_api
107
122
  extensions: []
108
123
  extra_rdoc_files: []
109
124
  files:
110
- - ".github/workflows/ruby.yml"
111
- - ".gitignore"
112
- - ".rubocop.yml"
113
- - ".rubocop_todo.yml"
114
125
  - CHANGELOG.md
115
126
  - Gemfile
116
127
  - Gemfile.lock
117
128
  - LICENSE.txt
118
129
  - README.md
119
- - Rakefile
120
- - bin/console
130
+ - bin/blizzard_api
121
131
  - bin/setup
122
132
  - blizzard_api.gemspec
123
133
  - lib/blizzard_api.rb
@@ -210,7 +220,6 @@ homepage: https://github.com/francis-schiavo/blizzard_api
210
220
  licenses:
211
221
  - MIT
212
222
  metadata:
213
- homepage_uri: https://github.com/francis-schiavo/blizzard_api
214
223
  source_code_uri: https://github.com/francis-schiavo/blizzard_api
215
224
  bug_tracker_uri: https://github.com/francis-schiavo/blizzard_api/issues
216
225
  changelog_uri: https://github.com/francis-schiavo/blizzard_api/blob/master/CHANGELOG.md
@@ -223,14 +232,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
232
  requirements:
224
233
  - - ">="
225
234
  - !ruby/object:Gem::Version
226
- version: 2.7.2
235
+ version: '3.0'
227
236
  required_rubygems_version: !ruby/object:Gem::Requirement
228
237
  requirements:
229
238
  - - ">="
230
239
  - !ruby/object:Gem::Version
231
240
  version: '0'
232
241
  requirements: []
233
- rubygems_version: 3.3.7
242
+ rubygems_version: 3.5.3
234
243
  signing_key:
235
244
  specification_version: 4
236
245
  summary: Unofficial Ruby client for Blizzard Entertainment API
@@ -1,22 +0,0 @@
1
- name: Ruby
2
-
3
- on: push
4
-
5
- jobs:
6
- test:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v2
10
- - name: Set up Ruby
11
- uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
12
- with:
13
- ruby-version: 3.1
14
- - name: Install dependencies
15
- run: bundle install
16
- - name: Run tests
17
- run: bundle exec rake
18
- env:
19
- BNET_APPLICATION_ID: ${{ secrets.BNET_APPLICATION_ID }}
20
- BNET_APPLICATION_SECRET: ${{ secrets.BNET_APPLICATION_SECRET }}
21
- USE_CACHE: false
22
- IGNORE_CLASSIC_TESTS: true
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- .env
10
- .idea
11
- *.gem
12
- .directory
data/.rubocop.yml DELETED
@@ -1,18 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- Layout/LineLength:
4
- Max: 140
5
-
6
- Metrics/ModuleLength:
7
- Exclude:
8
- - 'lib/blizzard_api/wow.rb'
9
-
10
- Metrics/AbcSize:
11
- Max: 20
12
-
13
- AllCops:
14
- TargetRubyVersion: 2.7
15
- NewCops: enable
16
- Exclude:
17
- - 'vendor/**/*'
18
- - 'bin/**/*'
data/.rubocop_todo.yml DELETED
@@ -1,7 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2019-03-06 13:04:37 -0300 using RuboCop version 0.61.1.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rake/testtask'
5
-
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << 'test'
8
- t.libs << 'lib'
9
- t.test_files = FileList['test/**/*_test.rb']
10
- end
11
-
12
- task default: :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'blizzard/api'
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__)