red_drop 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b12a527dc9ff28ec0c9e792c104101b901b026b7fe6193d60515ea3f7f977a2
4
- data.tar.gz: c77538eb9f87ce0a5f28d6ae031aa3cf369f447f9bf225065e1688e36b9cef6b
3
+ metadata.gz: 650b690e863fa3223fa8111c28f1105f644107396b006614980e6394096d8f59
4
+ data.tar.gz: 23a050d37eb35151c4c91fb08a98d98a074d897e4aab159610bf157ec1bbe183
5
5
  SHA512:
6
- metadata.gz: d7868499fc8db147cef82c8cbe18a3d8e245cc799249080f35ba342ae89e58e3a33812ce9946cfeb38d914d55ef96bb44b74ee3c5cd1255083ce1fd5c7c2a1ee
7
- data.tar.gz: 9e5968363a8c458fcfad17e621a10909680894ea9fcc4360a109e10fef09c88e7a36e54a98c7f860762fbaa52dc74b27e8be9aa627c878dc9bbc4f3d27c0a6c3
6
+ metadata.gz: e24b7f0d8a9f898a75f79aef5e3e6a448ea8a58880c430a4b386361e84e10bab1493be6d56a1b60a6311eab83b7bf1420e55b94e5d883a6bfaa7608831894682
7
+ data.tar.gz: 14c7800731c053b00a2d2562dbb5b4e2ab4688551ec0c85068f3907abe100773642fee970fb3d6b69f371ab0c62757679c7606aaac0ebd45b201a208673dd631
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- red_drop (0.2.0)
4
+ red_drop (0.3.1)
5
5
  droplet_kit (~> 3.18)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # red_drop
2
2
 
3
- is the seed of a grander vision of server automation with ruby.
3
+ Simple cli for automating droplet management with sane defaults baked in.
4
4
 
5
5
  ## Installation
6
6
 
@@ -14,7 +14,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
14
 
15
15
  ## Usage
16
16
 
17
- require "red_drop"
17
+ $ red_drop
18
18
 
19
19
  ## Development
20
20
 
@@ -22,22 +22,20 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
22
22
 
23
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).
24
24
 
25
+ ## Contributing
26
+
27
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sergio-ortiz/red_drop.
28
+
25
29
  ### Todos
26
30
 
27
- - Research: making gem executable
28
- - Research: TDD and minitest vs rspec
29
- - Refactor: status module to match delete module droplets var structure
30
- - Research: converting delete module droplets array to hash with array index as key to avoid accidental deletions
31
- - Refactor: delete while loop to match that of red_drop.rb
32
- - Refactor: auth to use Faraday which is used by DropletKit
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
33
36
  - Research: status module to get ip address of runnning droplets
34
- - Research: having delete module get status before executing
37
+ - Research: delete module to get droplet status before executing
35
38
  - Research: using cloud_init to automate server config for SSH, ufw, docker
36
- - Research: should I use duck typing
37
-
38
- ## Contributing
39
-
40
- Bug reports and pull requests are welcome on GitHub at https://github.com/sergio-ortiz/red_drop.
41
39
 
42
40
  ## License
43
41
 
data/exe/red_drop CHANGED
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "red_drop"
4
+
5
+ RedDrop.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.2.0"
3
+ class RedDrop
4
+ VERSION = "0.3.1"
5
5
  end
data/lib/red_drop.rb CHANGED
@@ -1,27 +1,27 @@
1
1
  require "red_drop/auth"
2
- auth = Auth.new
3
- token = auth.token
4
-
5
2
  require 'droplet_kit'
6
- client = DropletKit::Client.new(access_token: token)
3
+ require "red_drop/create"
4
+ require "red_drop/status"
5
+ require "red_drop/delete"
7
6
 
8
- require "red_drop/droplet_wizard"
7
+ class RedDrop
8
+ client = DropletKit::Client.new(access_token: Auth.new.token)
9
9
 
10
- droplet_wizard = DropletWizard.new(client)
10
+ @@task_menu = {
11
+ "create" => Create.new(client),
12
+ "status" => Status.new(client),
13
+ "delete" => Delete.new(client)
14
+ }
11
15
 
12
- command = nil
16
+ def self.start
17
+ input = nil
13
18
 
14
- while not command === "quit"
15
- puts "\nWhat would you like to do?\n['status', 'create', 'delete', 'quit']\n\n"
19
+ until input.eql? "exit"
20
+ puts "\nEnter from task menu below.\n#{@@task_menu.keys << "exit"}\n\n"
16
21
 
17
- command = gets.chomp
22
+ input = gets.chomp
18
23
 
19
- case command
20
- when "create"
21
- droplet_wizard.create
22
- when "status"
23
- droplet_wizard.status
24
- when "delete"
25
- droplet_wizard.delete
24
+ @@task_menu[input].execute if @@task_menu.has_key? input
25
+ end
26
26
  end
27
27
  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.2.0
4
+ version: 0.3.1
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-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest-reporters
@@ -58,7 +58,6 @@ files:
58
58
  - lib/red_drop/auth.rb
59
59
  - lib/red_drop/create.rb
60
60
  - lib/red_drop/delete.rb
61
- - lib/red_drop/droplet_wizard.rb
62
61
  - lib/red_drop/status.rb
63
62
  - lib/red_drop/version.rb
64
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