senec 0.22.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec_status +61 -58
- data/.rubocop.yml +3 -0
- data/.ruby-lsp/Gemfile.lock +19 -19
- data/.ruby-lsp/last_updated +1 -0
- data/.ruby-lsp/main_lockfile_hash +1 -1
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +59 -24
- data/coverage/coverage.json +59 -24
- data/coverage/index.html +611 -213
- data/lib/senec/cloud/connection.rb +11 -16
- data/lib/senec/version.rb +1 -1
- data/pkg/senec-0.22.0.gem +0 -0
- metadata +3 -1
@@ -169,48 +169,43 @@ module Senec
|
|
169
169
|
response.headers['location'] || raise('No redirect location')
|
170
170
|
end
|
171
171
|
|
172
|
-
def ensure_token_valid
|
172
|
+
def ensure_token_valid!
|
173
173
|
authenticate! unless authenticated?
|
174
|
-
return
|
174
|
+
return unless oauth_token.expired?
|
175
175
|
|
176
176
|
self.oauth_token = oauth_token.refresh!
|
177
|
-
true
|
178
177
|
rescue StandardError => e
|
179
|
-
#
|
180
|
-
|
181
|
-
|
182
|
-
# :nocov:
|
178
|
+
warn "Token refresh failed: #{e.message}, trying to re-authenticate..."
|
179
|
+
|
180
|
+
authenticate!
|
183
181
|
end
|
184
182
|
|
185
|
-
def get(url
|
186
|
-
|
183
|
+
def get(url)
|
184
|
+
ensure_token_valid!
|
187
185
|
|
188
186
|
response = oauth_token.get(url)
|
189
|
-
return default unless response.status == 200
|
190
|
-
|
191
187
|
JSON.parse(response.body)
|
192
188
|
rescue StandardError => e
|
193
189
|
# :nocov:
|
194
190
|
warn "API error: #{e.message}"
|
195
|
-
|
191
|
+
nil
|
196
192
|
# :nocov:
|
197
193
|
end
|
198
194
|
|
199
|
-
def post(url, data
|
200
|
-
|
195
|
+
def post(url, data)
|
196
|
+
ensure_token_valid!
|
201
197
|
|
202
198
|
response = oauth_token.post(
|
203
199
|
url,
|
204
200
|
body: data.to_json,
|
205
201
|
headers: { 'Content-Type' => 'application/json' },
|
206
202
|
)
|
207
|
-
return default unless response.status == 200
|
208
203
|
|
209
204
|
JSON.parse(response.body)
|
210
205
|
rescue StandardError => e
|
211
206
|
# :nocov:
|
212
207
|
warn "API error: #{e.message}"
|
213
|
-
|
208
|
+
nil
|
214
209
|
# :nocov:
|
215
210
|
end
|
216
211
|
|
data/lib/senec/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: senec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.22.
|
4
|
+
version: 0.22.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Ledermann
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- ".ruby-lsp/.gitignore"
|
97
97
|
- ".ruby-lsp/Gemfile"
|
98
98
|
- ".ruby-lsp/Gemfile.lock"
|
99
|
+
- ".ruby-lsp/last_updated"
|
99
100
|
- ".ruby-lsp/main_lockfile_hash"
|
100
101
|
- ".ruby-lsp/needs_update"
|
101
102
|
- ".vscode/settings.json"
|
@@ -164,6 +165,7 @@ files:
|
|
164
165
|
- pkg/senec-0.2.0.gem
|
165
166
|
- pkg/senec-0.20.0.gem
|
166
167
|
- pkg/senec-0.21.0.gem
|
168
|
+
- pkg/senec-0.22.0.gem
|
167
169
|
- pkg/senec-0.3.0.gem
|
168
170
|
- pkg/senec-0.4.0.gem
|
169
171
|
- pkg/senec-0.5.0.gem
|