red_drop 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -3
- data/exe/red_drop +1 -1
- data/lib/red_drop/auth.rb +12 -11
- data/lib/red_drop/create.rb +0 -0
- data/lib/red_drop/delete.rb +0 -0
- data/lib/red_drop/status.rb +0 -0
- data/lib/red_drop/version.rb +1 -1
- data/lib/red_drop.rb +12 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d28d88532deca7906c0a221dea00ed41441a10327fe2b0f8645683fd3212051
|
4
|
+
data.tar.gz: 4092ed01f7810eb0f9f44862422a55a7d6657ca8dfc2b91baf1ad5353a40d18f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b3924b1f24754a170c46b7f09bf6fcc35e5ab079999f6f448ed7bdd6fbe23e7e94613aa7df2413a20c99ea8d17f796620018cd71db3df18fadd03d800eb9e55
|
7
|
+
data.tar.gz: bf86b6c9813d0e560f5d9b89ab7dc4d66dc5d6a6fe58a1167ce2f06d90ca0532bde3f685d100567fa1fb2dadeb3ea4a7b311e77e710a0cd32f1abd0a1ca3b1aa
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,11 +28,10 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/sergio
|
|
28
28
|
|
29
29
|
### Todos
|
30
30
|
|
31
|
-
- Research: TDD whether its w/ minitest or rspec
|
32
31
|
- Refactor: status module to match delete module droplets data structure
|
33
|
-
- Research: converting delete module droplets array to hash to avoid accidental deletions
|
34
32
|
- Refactor: delete module while loop to match that of red_drop.rb
|
35
|
-
- Research:
|
33
|
+
- Research: TDD whether its w/ minitest or rspec
|
34
|
+
- Research: converting delete module droplets array to hash to avoid accidental deletions
|
36
35
|
- Research: status module to get ip address of runnning droplets
|
37
36
|
- Research: delete module to get droplet status before executing
|
38
37
|
- Research: using cloud_init to automate server config for SSH, ufw, docker
|
data/exe/red_drop
CHANGED
data/lib/red_drop/auth.rb
CHANGED
@@ -1,27 +1,28 @@
|
|
1
|
-
require "
|
1
|
+
require "faraday"
|
2
2
|
|
3
3
|
class Auth
|
4
4
|
def initialize
|
5
|
+
puts "loading..."
|
6
|
+
|
5
7
|
file = File.open("secret.txt", "a+")
|
6
8
|
@secret = file.read
|
7
9
|
file.close
|
8
10
|
|
9
|
-
|
10
|
-
@
|
11
|
-
|
12
|
-
|
13
|
-
@req["Authorization"] = "Bearer #{@secret}"
|
14
|
-
@res = @http.request(@req)
|
11
|
+
@faraday = Faraday.new("https://api.digitalocean.com/v2/droplets")
|
12
|
+
@res = @faraday.get do |req|
|
13
|
+
req.headers["Authorization"] = "Bearer #{@secret}"
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def token
|
18
|
-
while @secret.empty? or not @res.
|
19
|
-
puts "
|
18
|
+
while @secret.empty? or not @res.success?
|
19
|
+
puts "\nThere in no valid API token in memory,\nplease enter a valid API token."
|
20
20
|
@secret = gets.chomp
|
21
21
|
File.write("secret.txt", @secret)
|
22
22
|
|
23
|
-
@
|
24
|
-
|
23
|
+
@res = @faraday.get do |req|
|
24
|
+
req.headers["Authorization"] = "Bearer #{@secret}"
|
25
|
+
end
|
25
26
|
end
|
26
27
|
@secret
|
27
28
|
end
|
data/lib/red_drop/create.rb
CHANGED
File without changes
|
data/lib/red_drop/delete.rb
CHANGED
File without changes
|
data/lib/red_drop/status.rb
CHANGED
File without changes
|
data/lib/red_drop/version.rb
CHANGED
data/lib/red_drop.rb
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
require "red_drop/auth"
|
2
|
-
require
|
2
|
+
require "droplet_kit"
|
3
3
|
require "red_drop/create"
|
4
4
|
require "red_drop/status"
|
5
5
|
require "red_drop/delete"
|
6
6
|
|
7
7
|
class RedDrop
|
8
|
-
|
8
|
+
def initialize
|
9
|
+
client = DropletKit::Client.new(access_token: Auth.new.token)
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
@task_menu = {
|
12
|
+
"create" => Create.new(client),
|
13
|
+
"status" => Status.new(client),
|
14
|
+
"delete" => Delete.new(client)
|
15
|
+
}
|
16
|
+
end
|
15
17
|
|
16
|
-
def
|
18
|
+
def begin
|
17
19
|
input = nil
|
18
20
|
|
19
21
|
until input.eql? "exit"
|
20
|
-
puts "\nEnter from task menu below.\n#{
|
22
|
+
puts "\nEnter from task menu below.\n#{@task_menu.keys << "exit"}\n\n"
|
21
23
|
|
22
24
|
input = gets.chomp
|
23
25
|
|
24
|
-
|
26
|
+
@task_menu[input].execute if @task_menu.has_key? input
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: red_drop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Ortiz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest-reporters
|