codepicnic 0.1.6 → 0.1.7
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/lib/codepicnic/console.rb +0 -4
- data/lib/codepicnic/version.rb +1 -1
- data/lib/codepicnic.rb +5 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d61063c8c66256efcca66cf3916fa3c3d1b8150
|
4
|
+
data.tar.gz: 5aac244cc7cbe31d8dea7316805426d831f646cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 144c391b95c92696f9d1eaf80d955475fb566982cf0ea409ee3abe30a7011e17e8664ce7146490c16d58dffe6558bccf9005e74ccd83703816b0286855c2db23
|
7
|
+
data.tar.gz: 60f8920907bed1b72f3f9dc68bbfa93584b75974fd2584c57ece7723fd1832a5285180ac8911be895180c1570a1b459a83be65e64903b57a6b5f78c6f47a79f1
|
data/lib/codepicnic/console.rb
CHANGED
@@ -4,10 +4,6 @@ module CodePicnic
|
|
4
4
|
|
5
5
|
@api_url = "https://codepicnic.com/api/consoles"
|
6
6
|
|
7
|
-
class << self
|
8
|
-
attr_accessor :api_url
|
9
|
-
end
|
10
|
-
|
11
7
|
attr_accessor :id, :name, :container_name, :container_type, :custom_image, :created_at, :permalink, :url, :is_headless
|
12
8
|
|
13
9
|
def initialize(opts={})
|
data/lib/codepicnic/version.rb
CHANGED
data/lib/codepicnic.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'rest_client'
|
3
3
|
require 'codepicnic/api_request'
|
4
|
+
require 'codepicnic/token'
|
4
5
|
require 'codepicnic/request'
|
5
6
|
require 'codepicnic/console'
|
6
7
|
require 'codepicnic/version'
|
7
8
|
|
8
9
|
module CodePicnic
|
9
10
|
|
10
|
-
@api_url = "https://codepicnic.com/oauth/token"
|
11
|
-
|
12
11
|
class << self
|
13
|
-
attr_accessor :
|
12
|
+
attr_accessor :client_id, :client_secret, :token
|
14
13
|
|
15
14
|
def token
|
16
15
|
@token ||= get_token
|
16
|
+
refresh_token if @token.expired?
|
17
|
+
@token.access_token
|
17
18
|
end
|
18
19
|
|
19
20
|
def refresh_token
|
@@ -21,12 +22,7 @@ module CodePicnic
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def get_token
|
24
|
-
|
25
|
-
grant_type: "client_credentials",
|
26
|
-
client_id: @client_id,
|
27
|
-
client_secret: @client_secret
|
28
|
-
}
|
29
|
-
JSON.parse(response)["access_token"]
|
25
|
+
Token.new(@client_id, @client_secret)
|
30
26
|
end
|
31
27
|
|
32
28
|
end
|