oc 0.0.3 → 0.0.4
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/README.md +20 -9
- data/bin/oc +1 -2
- data/bin/oc.netrc +3 -0
- data/lib/oc/version.rb +1 -1
- data/lib/system/config.rb +9 -11
- data/lib/system/get.rb +3 -3
- data/lib/system/run/base.rb +3 -1
- data/lib/system/run/client.rb +3 -1
- data/lib/system/run/commands/info.rb +25 -0
- data/lib/system/run/run.rb +10 -10
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94a513a97b28baca3bad3b2eb2f14f4f3eb78448
|
4
|
+
data.tar.gz: d03e27fce3ca7dc61259815f67c8fa2ef7a2f371
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37b08b93b60961693685ab3306d3db80f3f4abe7e661ee86145adc82f3f297a8e726f44ee4c4e2451d0323e21804646122cd9d514ce30f3bb10075ce65b2d8f8
|
7
|
+
data.tar.gz: ee29fa536dfe90e254821171b180b5c63a4b368316e9f52471beed2e15eb44c672154d9762aa29e68d852dc5fe326d78d66f4087a1cedc50d3fa4ce106b6cf54
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Or install it yourself as:
|
|
17
17
|
$ gem install oc
|
18
18
|
|
19
19
|
## Droplets
|
20
|
-
|
20
|
+
<pre>
|
21
21
|
Droplet List
|
22
22
|
$ oc show [TRUE]
|
23
23
|
|
@@ -56,9 +56,9 @@ Or install it yourself as:
|
|
56
56
|
|
57
57
|
Rename Droplet
|
58
58
|
$ oc droplets rename [DROPLET_ID] [NEW_NAME]
|
59
|
-
|
59
|
+
</pre>
|
60
60
|
## SSH
|
61
|
-
|
61
|
+
<pre>
|
62
62
|
SSH Key List
|
63
63
|
$ oc ssh keys
|
64
64
|
|
@@ -73,19 +73,19 @@ Or install it yourself as:
|
|
73
73
|
|
74
74
|
Destroy SSH Key
|
75
75
|
$ oc ssh destroy [KEY_ID]
|
76
|
-
|
76
|
+
</pre>
|
77
77
|
## Regions
|
78
|
-
|
78
|
+
<pre>
|
79
79
|
Region List
|
80
80
|
$ oc regions
|
81
|
-
|
81
|
+
</pre>
|
82
82
|
## Sizes
|
83
|
-
|
83
|
+
<pre>
|
84
84
|
Size List
|
85
85
|
$ oc sizes
|
86
|
-
|
86
|
+
</pre>
|
87
87
|
## Images
|
88
|
-
|
88
|
+
<pre>
|
89
89
|
Show Images
|
90
90
|
$ co images [true]
|
91
91
|
|
@@ -97,6 +97,17 @@ Or install it yourself as:
|
|
97
97
|
|
98
98
|
Transfer Image
|
99
99
|
$ oc images transfer [IMAGE_ID] [REGION_ID]
|
100
|
+
</pre>
|
101
|
+
|
102
|
+
|
103
|
+
## Information
|
104
|
+
<pre>
|
105
|
+
Show API Key and Client ID
|
106
|
+
$ co info show
|
107
|
+
|
108
|
+
Change Information
|
109
|
+
$ co info change
|
110
|
+
</pre>
|
100
111
|
|
101
112
|
## Contributing
|
102
113
|
|
data/bin/oc
CHANGED
@@ -9,10 +9,9 @@ require "terminal-table"
|
|
9
9
|
bin_file = Pathname.new(__FILE__).realpath
|
10
10
|
$:.unshift File.expand_path("../../lib", bin_file)
|
11
11
|
|
12
|
-
config = Netrc.read
|
12
|
+
config = Netrc.read("oc.netrc")
|
13
13
|
|
14
14
|
if config["api.digitalocean.com"].nil?
|
15
|
-
puts "\n"
|
16
15
|
client_id = [(print 'Digital Ocean Client ID: '), STDIN.gets.rstrip][1]
|
17
16
|
api_key = [(print 'Digital Ocean API Key: '), STDIN.gets.rstrip][1]
|
18
17
|
config["api.digitalocean.com"] = client_id, api_key
|
data/bin/oc.netrc
ADDED
data/lib/oc/version.rb
CHANGED
data/lib/system/config.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
module Oc
|
2
2
|
class Config
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
3
|
+
def self.get(key)
|
4
|
+
config = Netrc.read("oc.netrc")
|
5
|
+
config = config["api.digitalocean.com"]
|
6
|
+
options = {
|
7
|
+
:client_id => config[0],
|
8
|
+
:api_key => config[1]
|
9
|
+
}
|
10
|
+
return options[:"#{key}"]
|
11
|
+
end
|
14
12
|
end
|
15
13
|
end
|
data/lib/system/get.rb
CHANGED
@@ -3,7 +3,7 @@ require "json"
|
|
3
3
|
module Oc
|
4
4
|
class Get
|
5
5
|
def self.get_json path,filter=nil
|
6
|
-
source = "https://api.digitalocean.com/#{path}/?client_id=#{Oc::Config.client_id}&api_key=#{Oc::Config.api_key}&filter=#{filter}"
|
6
|
+
source = "https://api.digitalocean.com/#{path}/?client_id=#{Oc::Config.get("client_id")}&api_key=#{Oc::Config.get("api_key")}&filter=#{filter}"
|
7
7
|
puts "I'm thinking, please wait..".blue
|
8
8
|
response = Net::HTTP.get_response(URI.parse(source))
|
9
9
|
data = response.body
|
@@ -18,7 +18,7 @@ module Oc
|
|
18
18
|
url += "/#{sub_path}"
|
19
19
|
end
|
20
20
|
|
21
|
-
url += "?client_id=#{Oc::Config.client_id}&api_key=#{Oc::Config.api_key}"
|
21
|
+
url += "?client_id=#{Oc::Config.get("client_id")}&api_key=#{Oc::Config.get("api_key")}"
|
22
22
|
|
23
23
|
parameter = ""
|
24
24
|
if parameters.length > 0
|
@@ -40,7 +40,7 @@ module Oc
|
|
40
40
|
|
41
41
|
def self.get_json_url url ,parameters=[]
|
42
42
|
|
43
|
-
url += "?client_id=#{Oc::Config.client_id}&api_key=#{Oc::Config.api_key}"
|
43
|
+
url += "?client_id=#{Oc::Config.get("client_id")}&api_key=#{Oc::Config.get("api_key")}"
|
44
44
|
|
45
45
|
parameter = ""
|
46
46
|
if parameters.length > 0
|
data/lib/system/run/base.rb
CHANGED
data/lib/system/run/client.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Oc::Run
|
2
|
+
class Info < Base
|
3
|
+
|
4
|
+
def show
|
5
|
+
puts "Client ID: #{Oc::Config.get("client_id")}".yellow
|
6
|
+
puts "API Key: #{Oc::Config.get("api_key")}".yellow
|
7
|
+
end
|
8
|
+
|
9
|
+
description "Change your API information"
|
10
|
+
def change(*args)
|
11
|
+
config = Netrc.read("oc.netrc")
|
12
|
+
client_id = [(print 'Digital Ocean Client ID: '), STDIN.gets.rstrip][1]
|
13
|
+
api_key = [(print 'Digital Ocean API Key: '), STDIN.gets.rstrip][1]
|
14
|
+
if client_id.empty? and api_key.empty?
|
15
|
+
puts "Please fill all fields".red
|
16
|
+
else
|
17
|
+
puts "#{client_id} - #{api_key}"
|
18
|
+
config["api.digitalocean.com"] = client_id, api_key
|
19
|
+
config.save
|
20
|
+
puts "Informations is changed".red
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/system/run/run.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'commander'
|
2
|
-
require 'commander/command'
|
3
|
-
require 'commander/import'
|
4
1
|
module Oc
|
5
2
|
module Run
|
6
3
|
autoload :Base, "system/run/base"
|
@@ -21,8 +18,6 @@ module Oc
|
|
21
18
|
|
22
19
|
def self.parse_command(ins = Commander::Runner::instance)
|
23
20
|
|
24
|
-
|
25
|
-
|
26
21
|
commands.each_pair do |name, opts|
|
27
22
|
name = Array(name)
|
28
23
|
names = [name.reverse.join('-'), name.join(' ')] if name.length > 1
|
@@ -35,19 +30,15 @@ module Oc
|
|
35
30
|
c.syntax = opts[:options][:syntax]
|
36
31
|
|
37
32
|
(options_metadata = Array(opts[:options][:meta])).each do |o|
|
38
|
-
option_data = [o[:switches], o[:type], o[:description]].compact.flatten(1)
|
33
|
+
option_data = [o[:switches], o[:type], o[:description], o[:optional]].compact.flatten(1)
|
39
34
|
c.option *option_data
|
40
35
|
o[:arg] = Commander::Runner.switch_to_sym(Array(o[:switches]).last)
|
41
36
|
|
42
37
|
end
|
43
38
|
|
44
|
-
|
45
|
-
|
46
39
|
c.when_called do |args, options|
|
47
40
|
object = opts[:class].new
|
48
41
|
object.options = options
|
49
|
-
|
50
|
-
|
51
42
|
run(object,opts[:method],args)
|
52
43
|
end
|
53
44
|
end
|
@@ -62,6 +53,15 @@ module Oc
|
|
62
53
|
end
|
63
54
|
|
64
55
|
|
56
|
+
protected
|
57
|
+
def self.hash_to_array(options)
|
58
|
+
return_data = []
|
59
|
+
options.each do |k,v|
|
60
|
+
return_data[k] = v
|
61
|
+
end
|
62
|
+
return return_data
|
63
|
+
end
|
64
|
+
|
65
65
|
def self.commands
|
66
66
|
@commands ||= {}
|
67
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sedat ÇİFTÇİ
|
@@ -99,6 +99,7 @@ email:
|
|
99
99
|
- iamcodegrab@gmail.com
|
100
100
|
executables:
|
101
101
|
- oc
|
102
|
+
- oc.netrc
|
102
103
|
extensions: []
|
103
104
|
extra_rdoc_files: []
|
104
105
|
files:
|
@@ -108,6 +109,7 @@ files:
|
|
108
109
|
- README.md
|
109
110
|
- Rakefile
|
110
111
|
- bin/oc
|
112
|
+
- bin/oc.netrc
|
111
113
|
- lib/oc.rb
|
112
114
|
- lib/oc/version.rb
|
113
115
|
- lib/system/config.rb
|
@@ -116,6 +118,7 @@ files:
|
|
116
118
|
- lib/system/run/client.rb
|
117
119
|
- lib/system/run/commands/droplets.rb
|
118
120
|
- lib/system/run/commands/images.rb
|
121
|
+
- lib/system/run/commands/info.rb
|
119
122
|
- lib/system/run/commands/regions.rb
|
120
123
|
- lib/system/run/commands/sizes.rb
|
121
124
|
- lib/system/run/commands/ssh.rb
|