kylichuku-grate-handle 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/gh +13 -1
- data/grate-handle.gemspec +3 -2
- data/lib/cli_processor.rb +2 -4
- data/lib/exceptions.rb +1 -0
- data/lib/gogrid_manager.rb +13 -3
- data/lib/grate-handle.rb +2 -0
- data/spec/gogrid_manager_spec.rb +12 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/bin/gh
CHANGED
@@ -4,5 +4,17 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
4
4
|
|
5
5
|
require 'grate-handle'
|
6
6
|
|
7
|
-
|
7
|
+
Choice.options do
|
8
|
+
header ''
|
9
|
+
header 'Specific options:'
|
10
|
+
|
11
|
+
option :account do
|
12
|
+
short '-a'
|
13
|
+
long '--account=default'
|
14
|
+
desc 'An account name, specified in ~/.ghrc which will be used.'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
GrateHandle::CLIProcessor.new(ARGV, GoGridManager.new(Choice.choices[:account])).process
|
8
20
|
|
data/grate-handle.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{grate-handle}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kirill Ishanov"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-09-05}
|
13
13
|
s.default_executable = %q{gh}
|
14
14
|
s.description = %q{ Grate Handle is a small gem which simplifies the with GoGrid's API from ruby code. Also ships with a CLI tool called 'gh' which allows to perform most of the actions from http://my.gogrid.com but using true Unix CLI way. }
|
15
15
|
s.email = %q{kirill.ishanov@gmail.com}
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"bin/gh",
|
31
31
|
"grate-handle.gemspec",
|
32
32
|
"lib/cli_processor.rb",
|
33
|
+
"lib/exceptions.rb",
|
33
34
|
"lib/gogrid_client.rb",
|
34
35
|
"lib/gogrid_manager.rb",
|
35
36
|
"lib/grate-handle.rb",
|
data/lib/cli_processor.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'gogrid_manager'
|
2
|
-
|
3
1
|
module GrateHandle
|
4
2
|
class CLIProcessor
|
5
3
|
#{{{1 Initialization and accessors
|
@@ -14,7 +12,7 @@ module GrateHandle
|
|
14
12
|
#}}}
|
15
13
|
#{{{1 Ugly Options processing
|
16
14
|
def process
|
17
|
-
case @args.shift
|
15
|
+
case @args.shift
|
18
16
|
when 'list' then list_action
|
19
17
|
when 'help', nil then print_usage
|
20
18
|
else @out.puts "unknown action"
|
@@ -22,7 +20,7 @@ module GrateHandle
|
|
22
20
|
end
|
23
21
|
|
24
22
|
def list_action
|
25
|
-
case @args.shift
|
23
|
+
case @args.shift
|
26
24
|
when 'servers' then print_servers
|
27
25
|
when 'images' then print_images
|
28
26
|
when 'ips' then print_ips
|
data/lib/exceptions.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
class ConfigError < StandardError; end
|
data/lib/gogrid_manager.rb
CHANGED
@@ -18,9 +18,19 @@ module GrateHandle
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def from_config(account=nil)
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
all_configs = YAML::load(File.read(path_to_config))
|
22
|
+
config_for_given_acc = all_configs.select { |c| c['account'] == account }
|
23
|
+
|
24
|
+
raise ConfigError, "Account #{account} is not specified in ~/.ghrc" if (account && config_for_given_acc.empty?)
|
25
|
+
|
26
|
+
config_to_use = account ? config_for_given_acc.first : all_configs.first
|
27
|
+
from_params(config_to_use['apikey'], config_to_use['secret'])
|
28
|
+
end
|
29
|
+
|
30
|
+
def path_to_config
|
31
|
+
path = File.expand_path('~/.ghrc')
|
32
|
+
raise ConfigError, "Cannot find file with grate-handle settings (#{path})" unless File.exist?(path)
|
33
|
+
path
|
24
34
|
end
|
25
35
|
|
26
36
|
def from_params(apikey, secret)
|
data/lib/grate-handle.rb
CHANGED
data/spec/gogrid_manager_spec.rb
CHANGED
@@ -26,6 +26,18 @@ describe GoGridManager do
|
|
26
26
|
manager = GoGridManager.new("acc2", nil)
|
27
27
|
end
|
28
28
|
|
29
|
+
it "should raise ConfigException if there is no such account" do
|
30
|
+
lambda {
|
31
|
+
GoGridManager.new('non-existent-account', nil)
|
32
|
+
}.should raise_error(ConfigError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should raise ConfigException if ~/.ghrc doesn't exist" do
|
36
|
+
stub(File).exist? { false }
|
37
|
+
lambda {
|
38
|
+
GoGridManager.new('acc', nil)
|
39
|
+
}.should raise_error(ConfigError)
|
40
|
+
end
|
29
41
|
end
|
30
42
|
|
31
43
|
def config_data
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kylichuku-grate-handle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Ishanov
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-05 00:00:00 -07:00
|
13
13
|
default_executable: gh
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- bin/gh
|
64
64
|
- grate-handle.gemspec
|
65
65
|
- lib/cli_processor.rb
|
66
|
+
- lib/exceptions.rb
|
66
67
|
- lib/gogrid_client.rb
|
67
68
|
- lib/gogrid_manager.rb
|
68
69
|
- lib/grate-handle.rb
|
@@ -76,7 +77,6 @@ files:
|
|
76
77
|
- spec/spec_helper.rb
|
77
78
|
has_rdoc: false
|
78
79
|
homepage: http://github.com/kylichuku/grate-handle
|
79
|
-
licenses:
|
80
80
|
post_install_message:
|
81
81
|
rdoc_options:
|
82
82
|
- --charset=UTF-8
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
requirements: []
|
98
98
|
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.
|
100
|
+
rubygems_version: 1.2.0
|
101
101
|
signing_key:
|
102
102
|
specification_version: 3
|
103
103
|
summary: A ruby library and a CLI client to GoGrid API
|