redfish_client 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -0
- data/.rubocop.yml +4 -0
- data/lib/redfish_client/resource.rb +24 -11
- data/lib/redfish_client/version.rb +1 -1
- data/redfish_client.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 207554e7443e5ebe22eb6f2c76561697a52ff0bdc133cfa21eeb56537100cfe6
|
4
|
+
data.tar.gz: 0433356121c5f822036f311aa9ae679d01f067b9ecc9789574b3b476b542b540
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2ddcc580f63812be3b07ffed4da2cc5cffb01b52b44c7030b8388fc87fdcc6054ba32b3855ee94247ab500e1f3d69c5547e2544c9aff7b4a7ac7ff3f18a4a17
|
7
|
+
data.tar.gz: 541d959834877c466f432962b250d9d02f98ce783ac6e38f3584e636a0a2271e6f3bb4520f0bd49e3991a2d8ec90b02e19ba2a2c2ee41804aa5a89283d704def
|
data/.codeclimate.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -64,20 +64,32 @@ module RedfishClient
|
|
64
64
|
# Members array. This means that `res["Members"][3]` can be shortened into
|
65
65
|
# `res[3]`.
|
66
66
|
#
|
67
|
-
#
|
68
|
-
# raise `KeyError`. Accessing invalid index will raise `IndexError`.
|
67
|
+
# Indexing non-collection resource key will # raise `KeyError`.
|
69
68
|
#
|
70
69
|
# @param attr [String, Integer] key or index for accessing data
|
71
|
-
# @return associated value
|
70
|
+
# @return associated value or `nil` if attr is missing
|
72
71
|
def [](attr)
|
73
72
|
if attr.is_a?(Integer)
|
74
73
|
raise(KeyError, "Not a collection.") unless key?("Members")
|
75
|
-
cache("Members")
|
74
|
+
cache("Members")[attr]
|
76
75
|
else
|
77
76
|
cache(attr)
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
80
|
+
# Safely access nested resource content.
|
81
|
+
#
|
82
|
+
# This function is an equivalent of safe navigation operator that can be
|
83
|
+
# used with arbitrary keys.
|
84
|
+
#
|
85
|
+
# Calling `res.dig("a", "b", "c")` is equivalent to `res.a&.b&.c` and
|
86
|
+
# `res["a"] && res["a"]["b"] && res["a"]["b"]["c"]`.
|
87
|
+
# @params keys [Array<Symbol, String>] sequence of keys to access
|
88
|
+
# @return associated value or `nil` if any key is missing
|
89
|
+
def dig(*keys)
|
90
|
+
keys.reduce(self) { |a, k| a.nil? ? nil : a[k] }
|
91
|
+
end
|
92
|
+
|
81
93
|
# Test if resource contains required key.
|
82
94
|
#
|
83
95
|
# @param name [String, Symbol] key name to test
|
@@ -88,12 +100,9 @@ module RedfishClient
|
|
88
100
|
|
89
101
|
# Convenience access for resource data.
|
90
102
|
#
|
91
|
-
# Calling `resource.Value` is exactly the same as `resource["Value"]`.
|
92
|
-
|
93
|
-
|
94
|
-
def method_missing(symbol, *args, &block)
|
95
|
-
name = symbol.to_s
|
96
|
-
key?(name) ? self[name] : super
|
103
|
+
# Calling `resource.Value` is exactly the same as `resource["Value"]`.
|
104
|
+
def method_missing(symbol, *_args, &_block)
|
105
|
+
self[symbol.to_s]
|
97
106
|
end
|
98
107
|
|
99
108
|
def respond_to_missing?(symbol, include_private = false)
|
@@ -187,10 +196,12 @@ module RedfishClient
|
|
187
196
|
end
|
188
197
|
|
189
198
|
def cache(name)
|
190
|
-
@cache[name] ||= build_resource(@content
|
199
|
+
@cache[name] ||= build_resource(@content[name])
|
191
200
|
end
|
192
201
|
|
193
202
|
def build_resource(data)
|
203
|
+
return nil if data.nil?
|
204
|
+
|
194
205
|
case data
|
195
206
|
when Hash then build_hash_resource(data)
|
196
207
|
when Array then data.collect { |d| build_resource(d) }
|
@@ -204,6 +215,8 @@ module RedfishClient
|
|
204
215
|
else
|
205
216
|
Resource.new(@connector, content: data)
|
206
217
|
end
|
218
|
+
rescue NoResource
|
219
|
+
nil
|
207
220
|
end
|
208
221
|
end
|
209
222
|
end
|
data/redfish_client.gemspec
CHANGED
@@ -36,6 +36,6 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency "rspec", ">= 3.7"
|
37
37
|
spec.add_development_dependency "simplecov"
|
38
38
|
spec.add_development_dependency "yard"
|
39
|
-
spec.add_development_dependency "rubocop"
|
39
|
+
spec.add_development_dependency "rubocop", "~> 0.54.0"
|
40
40
|
spec.add_development_dependency "pry"
|
41
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redfish_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tadej Borovšak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: rubocop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.54.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.54.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: pry
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|