red_drop 0.1.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1db5773a0cd7ddbb2bc91980a382ad55df83d61698e9bce86c528234c05142e
4
- data.tar.gz: d4452d721f41d8970e08154a346c97857318ff50eb0f224fdc996ee968918c60
3
+ metadata.gz: 0e8d4807cbe21026e6016b4405af8c01927d7b4fcdf3db1fdaa554bd29010922
4
+ data.tar.gz: 575f53939c2f7226da78fa1b7a11dade5a271839c0384c0cc359aaf065a7fcab
5
5
  SHA512:
6
- metadata.gz: 4272b8cc7994a7588988df318ccee25fe11b787eca07944bacde902f95a60b8f2d3d390431c6ea95cdf1d24f20397ec7fd925045a039829dccff9c3cb1be821d
7
- data.tar.gz: 613353c97c01c208b4a1980019f8499dc9e7f7061e064cce6df20be3d99d63d6e94738d5866fa6a5be717257383c2e1088005623f2e3701e0ee6d06fbbb72745
6
+ metadata.gz: 682a2b88b20d60249cade64720125d7a38c6f2208f23dd64cf4cbd761503250c9f1822bb8419bb553cbdaeef023a310f571f6e857fa5643f3fab7140fd900a66
7
+ data.tar.gz: 6507c953860a854f34aa475a4adaaf01d5b8b928c40d25888333a87622e9e80d602ecb1ba5644be4052e763a1a3f41f6ef034ea564387ad0e3aeccd938696704
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- red_drop (0.1.0)
4
+ red_drop (0.3.0)
5
5
  droplet_kit (~> 3.18)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # RedDrop
1
+ # red_drop
2
+
3
+ Simple cli for automating droplet management with sane defaults baked in.
2
4
 
3
5
  ## Installation
4
6
 
@@ -12,7 +14,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
12
14
 
13
15
  ## Usage
14
16
 
15
- require "red_drop"
17
+ $ red_drop
16
18
 
17
19
  ## Development
18
20
 
@@ -20,22 +22,21 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
20
22
 
21
23
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
22
24
 
23
- ### Todos
24
-
25
- - Research making gem executable
26
- - Research TDD and minitest vs rspec
27
- - refactor status module to match delete module droplets var structure
28
- - maybe convert delete module droplets array to hash with array index as key to avoid accidental deletions
29
- - refactor delete while loop to match that of red_drop.rb
30
- - refactor auth to use Faraday which is used by DropletKit
31
- - refactor status to get ip address of runnning droplets
32
- - Research having delete get status before executing
33
- - use cloud_init to automate server config for SSH, ufw, docker
34
-
35
25
  ## Contributing
36
26
 
37
27
  Bug reports and pull requests are welcome on GitHub at https://github.com/sergio-ortiz/red_drop.
38
28
 
29
+ ### Todos
30
+
31
+ - Research: TDD whether its w/ minitest or rspec
32
+ - Refactor: status module to match delete module droplets data structure
33
+ - Research: converting delete module droplets array to hash to avoid accidental deletions
34
+ - Refactor: delete module while loop to match that of red_drop.rb
35
+ - Research: Faraday, used by DropletKit, to replace built-in HTTP client library
36
+ - Research: status module to get ip address of runnning droplets
37
+ - Research: delete module to get droplet status before executing
38
+ - Research: using cloud_init to automate server config for SSH, ufw, docker
39
+
39
40
  ## License
40
41
 
41
42
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/exe/red_drop ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "red_drop"
4
+
5
+ RedDrop.new.start
@@ -1,5 +1,9 @@
1
- module Create
2
- def create
1
+ class Create
2
+ def initialize(client)
3
+ @client = client
4
+ end
5
+
6
+ def execute
3
7
  puts "loading... \n\n"
4
8
 
5
9
  droplet = DropletKit::Droplet.new(name: 'drop', region: 'nyc1', size: 's-1vcpu-512mb-10gb', image: 'ubuntu-22-04-x64')
@@ -1,5 +1,9 @@
1
- module Delete
2
- def delete
1
+ class Delete
2
+ def initialize(client)
3
+ @client = client
4
+ end
5
+
6
+ def execute
3
7
  puts "loading... \n\n"
4
8
 
5
9
  droplets = @client.droplets.all.map { |droplet| droplet.to_h }
@@ -1,5 +1,9 @@
1
- module Status
2
- def status
1
+ class Status
2
+ def initialize(client)
3
+ @client = client
4
+ end
5
+
6
+ def execute
3
7
  puts "loading... \n\n"
4
8
 
5
9
  droplets = @client.droplets.all.map { |droplet| { "droplet_id" => droplet.id, "status" => droplet.status } }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module RedDrop
4
- VERSION = "0.1.0"
3
+ class RedDrop
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/red_drop.rb CHANGED
@@ -1,29 +1,29 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require "red_drop/auth"
4
- auth = Auth.new
5
- token = auth.token
6
-
7
2
  require 'droplet_kit'
8
- client = DropletKit::Client.new(access_token: token)
9
-
10
- require "red_drop/droplet_wizard"
11
-
12
- droplet_wizard = DropletWizard.new(client)
3
+ require "red_drop/create"
4
+ require "red_drop/status"
5
+ require "red_drop/delete"
6
+
7
+ class RedDrop
8
+ def initialize
9
+ client = DropletKit::Client.new(access_token: Auth.new.token)
10
+
11
+ @task_menu = {
12
+ "create" => Create.new(client),
13
+ "status" => Status.new(client),
14
+ "delete" => Delete.new(client)
15
+ }
16
+ end
13
17
 
14
- command = nil
18
+ def start
19
+ input = nil
15
20
 
16
- while not command === "quit"
17
- puts "\nWhat would you like to do?\n['status', 'create', 'delete', 'quit']\n\n"
21
+ until input.eql? "exit"
22
+ puts "\nEnter from task menu below.\n#{@task_menu.keys << "exit"}\n\n"
18
23
 
19
- command = gets.chomp
24
+ input = gets.chomp
20
25
 
21
- case command
22
- when "create"
23
- droplet_wizard.create
24
- when "status"
25
- droplet_wizard.status
26
- when "delete"
27
- droplet_wizard.delete
26
+ @task_menu[input].execute if @task_menu.has_key? input
27
+ end
28
28
  end
29
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.1.0
4
+ version: 0.3.0
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-01 00:00:00.000000000 Z
11
+ date: 2022-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest-reporters
@@ -42,7 +42,8 @@ description: A cli wriiten in ruby for executing automated droplet tasks with sa
42
42
  configurations baked in.
43
43
  email:
44
44
  - ortiz.sergio0303@gmail.com
45
- executables: []
45
+ executables:
46
+ - red_drop
46
47
  extensions: []
47
48
  extra_rdoc_files: []
48
49
  files:
@@ -52,11 +53,11 @@ files:
52
53
  - LICENSE.txt
53
54
  - README.md
54
55
  - Rakefile
56
+ - exe/red_drop
55
57
  - lib/red_drop.rb
56
58
  - lib/red_drop/auth.rb
57
59
  - lib/red_drop/create.rb
58
60
  - lib/red_drop/delete.rb
59
- - lib/red_drop/droplet_wizard.rb
60
61
  - lib/red_drop/status.rb
61
62
  - lib/red_drop/version.rb
62
63
  - red_drop.gemspec
@@ -1,14 +0,0 @@
1
- require_relative "create"
2
- require_relative "status"
3
- require_relative "delete"
4
-
5
-
6
- class DropletWizard
7
- def initialize(client)
8
- @client = client
9
- end
10
-
11
- include Create
12
- include Status
13
- include Delete
14
- end