veslo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -0
- data/TODO +2 -0
- data/VERSION +1 -1
- data/lib/veslo.rb +31 -19
- data/spec/fixtures/config.yaml +3 -0
- data/spec/veslo_spec.rb +25 -4
- data/veslo.gemspec +8 -5
- metadata +95 -135
- data/README.rdoc +0 -19
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# veslo
|
2
|
+
|
3
|
+
_veslo (ru)_ -- paddle
|
4
|
+
|
5
|
+
veslo is a command-line interface for the [Noah](https://github.com/lusis/Noah) server.
|
6
|
+
|
7
|
+
The first version implement getting and saving configuration entities:
|
8
|
+
|
9
|
+
veslo configurations get config.yml
|
10
|
+
|
11
|
+
The default output is to STDOUT, so you can pipe it wherever you want, for example:
|
12
|
+
|
13
|
+
veslo configurations get config.yml > current_production_config.yml
|
14
|
+
|
15
|
+
The put command accepts two arguments: the config name on the server and the local config file to upload (or STDIN) _TODO_
|
16
|
+
|
17
|
+
veslo configurations put config.yml my_new_config.yml
|
18
|
+
|
19
|
+
The server to use is either configured via the **~/.noah/veslo.rb** file, or passed in the **-s** paramater.
|
20
|
+
|
21
|
+
# Contributing to veslo
|
22
|
+
|
23
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
24
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
25
|
+
* Fork the project
|
26
|
+
* Start a feature/bugfix branch
|
27
|
+
* Commit and push until you are happy with your contribution
|
28
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
29
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
30
|
+
|
31
|
+
# Copyright
|
32
|
+
|
33
|
+
Copyright (c) 2011 Dimitri Krassovski / Wix.com. See LICENSE.txt for
|
34
|
+
further details.
|
35
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/veslo.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'mixlib/cli'
|
3
3
|
require 'rest_client'
|
4
|
+
require 'json'
|
4
5
|
|
5
6
|
class Veslo
|
6
7
|
include Mixlib::CLI
|
7
|
-
|
8
|
-
|
8
|
+
SUPPORTED_METHODS = ["put", "get"]
|
9
|
+
SUPPORTED_RESOURCES = ["configurations"]
|
9
10
|
|
10
11
|
option :server_url,
|
11
12
|
:short => "-s SERVER",
|
@@ -16,14 +17,15 @@ class Veslo
|
|
16
17
|
argv = parse_options(arguments)
|
17
18
|
@server = RestClient::Resource.new(config[:server_url], :headers => {:accept => "application/octet"})
|
18
19
|
parse_commands(argv)
|
19
|
-
|
20
|
+
send(:"resource_#{@method}")
|
20
21
|
end
|
21
22
|
|
22
23
|
def parse_commands(commands)
|
23
|
-
raise ArgumentError.new("Not the right ammount of arguments")
|
24
|
+
raise ArgumentError.new("Not the right ammount of arguments") unless (3..4).include?(commands.size)
|
24
25
|
@resource = commands.shift
|
25
26
|
@method = commands.shift
|
26
27
|
@name = commands.shift
|
28
|
+
@file = commands.shift
|
27
29
|
validate_input
|
28
30
|
end
|
29
31
|
|
@@ -32,20 +34,30 @@ class Veslo
|
|
32
34
|
raise NotImplementedError.new("resource #{@resource} not supported") unless SUPPORTED_RESOURCES.include?(@resource)
|
33
35
|
end
|
34
36
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
return 2
|
48
|
-
end
|
37
|
+
def resource_get
|
38
|
+
result = @server["#{@resource}/#{@name}"].get
|
39
|
+
$stdout.puts result.to_str
|
40
|
+
return 0
|
41
|
+
rescue RestClient::ExceptionWithResponse => e
|
42
|
+
case e.response.code
|
43
|
+
when 404
|
44
|
+
$stderr.puts("Requested resource not found")
|
45
|
+
return 1
|
46
|
+
else
|
47
|
+
$stderr.puts("Request failed with status: #{e.response.code}")
|
48
|
+
return 2
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
|
+
def resource_put
|
53
|
+
raise NotImplementedError, "No STDIN yet" unless @file
|
54
|
+
file_content = File.open(@file, 'r').read
|
55
|
+
put_data = "{\"format\":\"app/octet\", \"body\":#{file_content.to_json}}"
|
56
|
+
result = @server["#{@resource}/#{@name}"].put(put_data)
|
57
|
+
$stdout.puts "Config uploaded"
|
58
|
+
return 0
|
59
|
+
rescue Errno::ENOENT
|
60
|
+
$stderr.puts "File not found: #{@file}"
|
61
|
+
return 3
|
62
|
+
end
|
63
|
+
end
|
data/spec/veslo_spec.rb
CHANGED
@@ -23,12 +23,16 @@ describe "Veslo", "parsing arguments" do
|
|
23
23
|
lambda{@veslo.parse_commands(["configurations", "get", "chix"])}.should_not raise_error(ArgumentError)
|
24
24
|
end
|
25
25
|
|
26
|
+
it "should accept 4 well-formed arguments" do
|
27
|
+
lambda{@veslo.parse_commands(["configurations", "put", "chix", "chix.yml"])}.should_not raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
|
26
30
|
it "should not accept less than 3 arguments" do
|
27
31
|
lambda{@veslo.parse_commands(["foo", "bar"])}.should raise_error(ArgumentError)
|
28
32
|
end
|
29
33
|
|
30
|
-
it "should not accept more than
|
31
|
-
lambda{@veslo.parse_commands(["foo", "bar", "baz", "foobar"])}.should raise_error(ArgumentError)
|
34
|
+
it "should not accept more than 4 arguments" do
|
35
|
+
lambda{@veslo.parse_commands(["foo", "bar", "baz", "foobar", "foobaz"])}.should raise_error(ArgumentError)
|
32
36
|
end
|
33
37
|
|
34
38
|
it "should not accept unknown methods" do
|
@@ -47,7 +51,8 @@ describe "Veslo", "interacting with server" do
|
|
47
51
|
@get_existing_argv = @base_argv + ["get", "existing"]
|
48
52
|
@get_missing_argv = @base_argv + ["get", "missing"]
|
49
53
|
@get_error_argv = @base_argv + ["get", "error"]
|
50
|
-
|
54
|
+
@put_new_argv = @base_argv + ["put", "creating", "spec/fixtures/config.yaml"]
|
55
|
+
@put_missing_argv = @base_argv + ["put", "config_name", "nofile.yml"]
|
51
56
|
FakeWeb.allow_net_connect = false
|
52
57
|
FakeWeb.register_uri(:get, "http://example.com/configurations/existing", :body => "Hello World!")
|
53
58
|
FakeWeb.register_uri(:get, "http://example.com/configurations/missing", :body => "Nothing to be found 'round here", :status => ["404", "Not Found"])
|
@@ -76,4 +81,20 @@ describe "Veslo", "interacting with server" do
|
|
76
81
|
end
|
77
82
|
@output.should == "Request failed with status: 500\n"
|
78
83
|
end
|
79
|
-
|
84
|
+
|
85
|
+
it "should not upload a missing file" do
|
86
|
+
@output = capture(:stderr) do
|
87
|
+
@veslo.run!(*@put_missing_argv)
|
88
|
+
end
|
89
|
+
@output.should == "File not found: nofile.yml\n"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should upload a config" do
|
93
|
+
@output = capture(:stdout) do
|
94
|
+
@veslo.run!(*@put_new_argv)
|
95
|
+
end
|
96
|
+
@output.should == "Config uploaded\n"
|
97
|
+
FakeWeb.last_request.method.should == "PUT"
|
98
|
+
FakeWeb.last_request.body.should == "{\"format\":\"app/octet\", \"body\":\"foo:\\n bar: baz\\n foobar: foobaz\\n\"}"
|
99
|
+
end
|
100
|
+
end
|
data/veslo.gemspec
CHANGED
@@ -5,17 +5,18 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "veslo"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dimitri Krassovski"]
|
12
|
-
s.date = "2011-12-
|
12
|
+
s.date = "2011-12-06"
|
13
13
|
s.description = "Command line utility to manage Noah configurations"
|
14
14
|
s.email = "dimitri@wix.com"
|
15
15
|
s.executables = ["veslo", "veslo"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE.txt",
|
18
|
-
"README.
|
18
|
+
"README.md",
|
19
|
+
"TODO"
|
19
20
|
]
|
20
21
|
s.files = [
|
21
22
|
".document",
|
@@ -23,11 +24,13 @@ Gem::Specification.new do |s|
|
|
23
24
|
"Gemfile",
|
24
25
|
"Gemfile.lock",
|
25
26
|
"LICENSE.txt",
|
26
|
-
"README.
|
27
|
+
"README.md",
|
27
28
|
"Rakefile",
|
29
|
+
"TODO",
|
28
30
|
"VERSION",
|
29
31
|
"bin/veslo",
|
30
32
|
"lib/veslo.rb",
|
33
|
+
"spec/fixtures/config.yaml",
|
31
34
|
"spec/spec_helper.rb",
|
32
35
|
"spec/veslo_spec.rb",
|
33
36
|
"veslo.gemspec"
|
@@ -35,7 +38,7 @@ Gem::Specification.new do |s|
|
|
35
38
|
s.homepage = "http://github.com/Wixpress/veslo"
|
36
39
|
s.licenses = ["MIT"]
|
37
40
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = "1.8.
|
41
|
+
s.rubygems_version = "1.8.12"
|
39
42
|
s.summary = "Command line Noah client"
|
40
43
|
|
41
44
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,195 +1,155 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: veslo
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 0.0.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Dimitri Krassovski
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
-
none: false
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
hash: 3
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
version: "0"
|
30
|
-
version_requirements: *id001
|
12
|
+
date: 2011-12-06 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
31
15
|
name: mixlib-cli
|
32
|
-
|
33
|
-
type: :runtime
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70250054294280 !ruby/object:Gem::Requirement
|
36
17
|
none: false
|
37
|
-
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
|
41
|
-
segments:
|
42
|
-
- 0
|
43
|
-
version: "0"
|
44
|
-
version_requirements: *id002
|
45
|
-
name: rest-client
|
46
|
-
prerelease: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
47
22
|
type: :runtime
|
48
|
-
|
49
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70250054294280
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rest-client
|
27
|
+
requirement: &70250054293000 !ruby/object:Gem::Requirement
|
50
28
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
55
|
-
|
56
|
-
- 0
|
57
|
-
version: "0"
|
58
|
-
version_requirements: *id003
|
59
|
-
name: rdoc
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
60
34
|
prerelease: false
|
61
|
-
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
|
35
|
+
version_requirements: *70250054293000
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rdoc
|
38
|
+
requirement: &70250054292200 !ruby/object:Gem::Requirement
|
64
39
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
69
|
-
|
70
|
-
- 0
|
71
|
-
version: "0"
|
72
|
-
version_requirements: *id004
|
73
|
-
name: fakeweb
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
74
45
|
prerelease: false
|
46
|
+
version_requirements: *70250054292200
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: fakeweb
|
49
|
+
requirement: &70250054291580 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
75
55
|
type: :development
|
76
|
-
|
77
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70250054291580
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &70250054290900 !ruby/object:Gem::Requirement
|
78
61
|
none: false
|
79
|
-
requirements:
|
62
|
+
requirements:
|
80
63
|
- - ~>
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
hash: 3
|
83
|
-
segments:
|
84
|
-
- 2
|
85
|
-
- 3
|
86
|
-
- 0
|
64
|
+
- !ruby/object:Gem::Version
|
87
65
|
version: 2.3.0
|
88
|
-
version_requirements: *id005
|
89
|
-
name: rspec
|
90
|
-
prerelease: false
|
91
66
|
type: :development
|
92
|
-
|
93
|
-
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70250054290900
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: &70250054290320 !ruby/object:Gem::Requirement
|
94
72
|
none: false
|
95
|
-
requirements:
|
73
|
+
requirements:
|
96
74
|
- - ~>
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
hash: 23
|
99
|
-
segments:
|
100
|
-
- 1
|
101
|
-
- 0
|
102
|
-
- 0
|
75
|
+
- !ruby/object:Gem::Version
|
103
76
|
version: 1.0.0
|
104
|
-
version_requirements: *id006
|
105
|
-
name: bundler
|
106
|
-
prerelease: false
|
107
77
|
type: :development
|
108
|
-
|
109
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70250054290320
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: jeweler
|
82
|
+
requirement: &70250054289720 !ruby/object:Gem::Requirement
|
110
83
|
none: false
|
111
|
-
requirements:
|
84
|
+
requirements:
|
112
85
|
- - ~>
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
hash: 7
|
115
|
-
segments:
|
116
|
-
- 1
|
117
|
-
- 6
|
118
|
-
- 4
|
86
|
+
- !ruby/object:Gem::Version
|
119
87
|
version: 1.6.4
|
120
|
-
version_requirements: *id007
|
121
|
-
name: jeweler
|
122
|
-
prerelease: false
|
123
88
|
type: :development
|
124
|
-
- !ruby/object:Gem::Dependency
|
125
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
126
|
-
none: false
|
127
|
-
requirements:
|
128
|
-
- - ">="
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
hash: 3
|
131
|
-
segments:
|
132
|
-
- 0
|
133
|
-
version: "0"
|
134
|
-
version_requirements: *id008
|
135
|
-
name: rcov
|
136
89
|
prerelease: false
|
90
|
+
version_requirements: *70250054289720
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: rcov
|
93
|
+
requirement: &70250054272700 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
137
99
|
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70250054272700
|
138
102
|
description: Command line utility to manage Noah configurations
|
139
103
|
email: dimitri@wix.com
|
140
|
-
executables:
|
104
|
+
executables:
|
141
105
|
- veslo
|
142
106
|
extensions: []
|
143
|
-
|
144
|
-
extra_rdoc_files:
|
107
|
+
extra_rdoc_files:
|
145
108
|
- LICENSE.txt
|
146
|
-
- README.
|
147
|
-
|
109
|
+
- README.md
|
110
|
+
- TODO
|
111
|
+
files:
|
148
112
|
- .document
|
149
113
|
- .rspec
|
150
114
|
- Gemfile
|
151
115
|
- Gemfile.lock
|
152
116
|
- LICENSE.txt
|
153
|
-
- README.
|
117
|
+
- README.md
|
154
118
|
- Rakefile
|
119
|
+
- TODO
|
155
120
|
- VERSION
|
156
121
|
- bin/veslo
|
157
122
|
- lib/veslo.rb
|
123
|
+
- spec/fixtures/config.yaml
|
158
124
|
- spec/spec_helper.rb
|
159
125
|
- spec/veslo_spec.rb
|
160
126
|
- veslo.gemspec
|
161
127
|
homepage: http://github.com/Wixpress/veslo
|
162
|
-
licenses:
|
128
|
+
licenses:
|
163
129
|
- MIT
|
164
130
|
post_install_message:
|
165
131
|
rdoc_options: []
|
166
|
-
|
167
|
-
require_paths:
|
132
|
+
require_paths:
|
168
133
|
- lib
|
169
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
135
|
none: false
|
171
|
-
requirements:
|
172
|
-
- -
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
|
175
|
-
segments:
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
segments:
|
176
141
|
- 0
|
177
|
-
|
178
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
hash: 477080292991891829
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
144
|
none: false
|
180
|
-
requirements:
|
181
|
-
- -
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
|
184
|
-
segments:
|
185
|
-
- 0
|
186
|
-
version: "0"
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
187
149
|
requirements: []
|
188
|
-
|
189
150
|
rubyforge_project:
|
190
|
-
rubygems_version: 1.8.
|
151
|
+
rubygems_version: 1.8.12
|
191
152
|
signing_key:
|
192
153
|
specification_version: 3
|
193
154
|
summary: Command line Noah client
|
194
155
|
test_files: []
|
195
|
-
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= veslo
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to veslo
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
-
* Fork the project
|
10
|
-
* Start a feature/bugfix branch
|
11
|
-
* Commit and push until you are happy with your contribution
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2011 Dimitri Krassovski. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|