antbird 0.0.5 → 0.0.6

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: 05cfc127c437bdff01a5becf578bfd439055b2ade100d75bf403d2d1ab1fe7f1
4
- data.tar.gz: 1bd9ee41bd5a56c2f3e9ec0e59fbfc5bec6ec75770a4f8b627a5e6692972346a
3
+ metadata.gz: 95d22cfe4e068e067929b6473a071f50c64cf50995a03b7621ac052093d19211
4
+ data.tar.gz: 0df5fbbfca2db06550df0dc222910de067225760c70ce2dad3705d579719f6d3
5
5
  SHA512:
6
- metadata.gz: 5913a6be7b0814a37a1b9b85b77bd751254f7ff80f6cdc40d6f4491b181302ca3c806066b11ff71bd9b65abd62424e1fc0b3c55663573dc29932f66b24117bc9
7
- data.tar.gz: 6b726071026b88cabc4e4ffbfb455fd75fe99e2e868e9751faba296228890b21672f84b6435c24e5adf29ad3e03422781280ab90dd207a789bbac23f8bc0ea34
6
+ metadata.gz: 539b9a124240ca48400d10d3561900702f9414e45e3d1327ca97bc6d29ecd8a7fe5a0ca25541ca761e2941be036abbc54fed79167c7401c3f56df7059cbb3105
7
+ data.tar.gz: 655a9ec1fdcdcf0454b7030011d1f34dbe37fc74bca0abe07ae39c56b89239db787c2411ae1bc4c38a35e98de1504f61f57edadd1c0b6bb1dd58c22ee05576b7
@@ -18,14 +18,9 @@ module Antbird
18
18
  @url = url
19
19
 
20
20
  @scope = scope.transform_keys(&:to_sym)
21
- @version = version || fetch_version
21
+ @version = version
22
22
 
23
23
  @api_specs = {}
24
-
25
- class_version = @version.split('.')[0,2].join('_')
26
-
27
- require "antbird/rest_api/rest_api_v#{class_version}"
28
- extend Antbird::RestApi.const_get "RestApiV#{class_version}"
29
24
  end
30
25
  attr_reader :scope, :url, :version
31
26
  attr_reader :read_timeout, :open_timeout
@@ -181,5 +176,29 @@ module Antbird
181
176
  def fetch_version
182
177
  connection.get('/').body.dig('version', 'number')
183
178
  end
179
+
180
+ def ensure_api_spec_loaded
181
+ return if api_specs_loaded?
182
+
183
+ @version ||= fetch_version
184
+ class_version = @version.split('.')[0, 2].join('_')
185
+ require "antbird/rest_api/rest_api_v#{class_version}"
186
+ extend Antbird::RestApi.const_get "RestApiV#{class_version}"
187
+
188
+ @api_specs_loaded = true
189
+ end
190
+
191
+ def api_specs_loaded?
192
+ !!@api_specs_loaded
193
+ end
194
+
195
+ def method_missing(name, *args, &block)
196
+ return super if api_specs_loaded?
197
+
198
+ ensure_api_spec_loaded
199
+
200
+ return super unless respond_to?(name)
201
+ __send__(name, *args, &block)
202
+ end
184
203
  end
185
204
  end
@@ -1,3 +1,3 @@
1
1
  module Antbird
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: antbird
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - fukayatsu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-13 00:00:00.000000000 Z
11
+ date: 2018-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday