taketo 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -2
- data/VERSION +1 -1
- data/bin/taketo +8 -1
- data/lib/taketo/config_validator.rb +1 -1
- data/lib/taketo/destination_matcher.rb +22 -0
- data/lib/taketo/destination_resolver.rb +2 -1
- data/spec/acceptance/completion_spec.rb +23 -0
- data/spec/acceptance/config_validation_spec.rb +2 -23
- data/spec/lib/taketo/config_validator_spec.rb +9 -16
- data/spec/lib/taketo/destination_matcher_spec.rb +26 -0
- data/spec/lib/taketo/destination_resolver_spec.rb +12 -1
- metadata +75 -85
data/README.md
CHANGED
@@ -141,9 +141,15 @@ Default configs are merged appropriately.
|
|
141
141
|
|
142
142
|
An SSH config file can be generated from taketo config. To do so, run ```taketo --generate-ssh-config```.
|
143
143
|
|
144
|
+
|
145
|
+
Taketo has autocompletion support for ZSH; completion file can be found at: scripts/zsh/completion/_taketo
|
146
|
+
|
144
147
|
The Changelog:
|
145
148
|
--------------
|
146
149
|
|
150
|
+
### v0.1.1 (04.12.2012) ###
|
151
|
+
* Add basic autocompletion support for ZSH, see scripts/zsh/completion
|
152
|
+
|
147
153
|
### v0.1.0 (04.12.2012) ###
|
148
154
|
* Servers can now be outside projects and environments (userful for standalone servers)
|
149
155
|
* SSH config is being generated both for hostnames and global aliases
|
@@ -213,6 +219,4 @@ The Changelog:
|
|
213
219
|
TO-DO:
|
214
220
|
------
|
215
221
|
|
216
|
-
* Define servers outside projects and environments
|
217
|
-
* Destination completion
|
218
222
|
* Command completion
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/bin/taketo
CHANGED
@@ -6,6 +6,7 @@ require 'taketo'
|
|
6
6
|
require 'taketo/constructs_factory'
|
7
7
|
require 'taketo/commands'
|
8
8
|
require 'taketo/destination_resolver'
|
9
|
+
require 'taketo/destination_matcher'
|
9
10
|
require 'optparse'
|
10
11
|
|
11
12
|
Signal.trap("SIGINT") do
|
@@ -61,6 +62,10 @@ def parse_options
|
|
61
62
|
options[:debug] = d
|
62
63
|
end
|
63
64
|
|
65
|
+
opts.on("--matches") do |m|
|
66
|
+
options[:matches] = m
|
67
|
+
end
|
68
|
+
|
64
69
|
end.parse!
|
65
70
|
|
66
71
|
options
|
@@ -96,7 +101,9 @@ begin
|
|
96
101
|
destination_path = ARGV.shift.to_s
|
97
102
|
resolver = DestinationResolver.new(config, destination_path)
|
98
103
|
|
99
|
-
if options.delete(:
|
104
|
+
if options.delete(:matches)
|
105
|
+
puts DestinationMatcher.new(resolver.servers).matches.join(" ")
|
106
|
+
elsif options.delete(:view)
|
100
107
|
node = resolver.get_node
|
101
108
|
traverser = ConfigTraverser.new(node)
|
102
109
|
config_printer = ConfigPrinterVisitor.new
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Taketo
|
2
|
+
class DestinationMatcher
|
3
|
+
def initialize(servers)
|
4
|
+
@servers = servers
|
5
|
+
end
|
6
|
+
|
7
|
+
def matches
|
8
|
+
(path_matches + global_alias_matches).uniq
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def path_matches
|
14
|
+
@servers.map(&:path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def global_alias_matches
|
18
|
+
@servers.map(&:global_alias).map(&:to_s).reject(&:empty?)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -58,7 +58,8 @@ module Taketo
|
|
58
58
|
when 1
|
59
59
|
results.first
|
60
60
|
else
|
61
|
-
|
61
|
+
exact_match = results.detect { |n| n.path == @path }
|
62
|
+
exact_match or raise AmbiguousDestinationError,
|
62
63
|
"There are multiple possible destinations: #{results.map(&:path).join(", ")}"
|
63
64
|
end
|
64
65
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'acceptance_spec_helper'
|
2
|
+
|
3
|
+
feature "Aids completion with matches" do
|
4
|
+
scenario "Show matching servers" do
|
5
|
+
create_config <<-CONFIG
|
6
|
+
project :foo do
|
7
|
+
server :s1 do
|
8
|
+
host '1.2.3.4'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
server :s10 do
|
13
|
+
host '2.3.4.5'
|
14
|
+
end
|
15
|
+
CONFIG
|
16
|
+
|
17
|
+
run "taketo s1 --matches"
|
18
|
+
exit_status.should be_success
|
19
|
+
stdout.should =~ %r{(foo:s1 s10|s10 foo:s1)}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -10,7 +10,7 @@ feature "Config validation" do
|
|
10
10
|
stderr.should include("There are no servers. Add some to your config (~/.taketo.rc.rb by default)")
|
11
11
|
end
|
12
12
|
|
13
|
-
scenario "Project has no
|
13
|
+
scenario "Project has no servers" do
|
14
14
|
create_config <<-CONFIG
|
15
15
|
project :foo do
|
16
16
|
end
|
@@ -26,28 +26,7 @@ feature "Config validation" do
|
|
26
26
|
|
27
27
|
run "taketo"
|
28
28
|
exit_status.should_not be_success
|
29
|
-
stderr.should include("Project foo: no
|
30
|
-
end
|
31
|
-
|
32
|
-
scenario "Environment has no servers" do
|
33
|
-
create_config <<-CONFIG
|
34
|
-
project :foo do
|
35
|
-
environment :bar do
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
project :bar do
|
40
|
-
environment :baz do
|
41
|
-
server :qux do
|
42
|
-
host '1.2.3.4'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
CONFIG
|
47
|
-
|
48
|
-
run "taketo"
|
49
|
-
exit_status.should_not be_success
|
50
|
-
stderr.should include("Environment foo:bar: no servers")
|
29
|
+
stderr.should include("Project foo: no servers")
|
51
30
|
end
|
52
31
|
|
53
32
|
scenario "Server has no host defined" do
|
@@ -18,22 +18,15 @@ end
|
|
18
18
|
describe "ConfigValidator::ConfigValidatorVisitor" do
|
19
19
|
subject(:visitor) { ConfigValidator::ConfigValidatorVisitor.new }
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
it "requires projects to have environments" do
|
31
|
-
project = stub(:Project, :has_environments? => false, :path => "my_project")
|
32
|
-
error_message = /my_project: no environments/
|
33
|
-
expect { visitor.visit_project(project) }.to raise_error ConfigError, error_message
|
34
|
-
|
35
|
-
project.stub(:has_environments? => true)
|
36
|
-
expect { visitor.visit_project(project) }.not_to raise_error ConfigError, error_message
|
21
|
+
{ :Config => nil, :Project => "my_project" }.each do |node_type, path|
|
22
|
+
it "requires #{node_type} to have servers" do
|
23
|
+
node = stub(node_type, :has_servers? => false, :path => path)
|
24
|
+
error_message = /#{path ? path + ": " : ""}no servers/
|
25
|
+
expect { visitor.send("visit_#{node_type.to_s.downcase}", node) }.to raise_error ConfigError, error_message
|
26
|
+
|
27
|
+
node.stub(:has_servers? => true)
|
28
|
+
expect { visitor.send("visit_#{node_type.to_s.downcase}", node) }.not_to raise_error ConfigError, error_message
|
29
|
+
end
|
37
30
|
end
|
38
31
|
|
39
32
|
it "requires environments to have servers" do
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/helpers/construct_spec_helper'
|
3
|
+
require 'taketo/support/named_nodes_collection'
|
4
|
+
require 'taketo/destination_matcher'
|
5
|
+
|
6
|
+
describe "DestinationMatcher" do
|
7
|
+
include ConstructsFixtures
|
8
|
+
|
9
|
+
let!(:server1) { s = server(:s1); s.global_alias = :foo_server_alias; s }
|
10
|
+
let!(:environment1) { environment(:bar, :servers => server1) }
|
11
|
+
let!(:project1) { project(:foo, :environments => environment1) }
|
12
|
+
|
13
|
+
let!(:server2) { server(:s2) }
|
14
|
+
|
15
|
+
let!(:config) { create_config(:projects => project1, :servers => server2) }
|
16
|
+
|
17
|
+
subject(:matcher) { Taketo::DestinationMatcher.new([server1, server2]) }
|
18
|
+
|
19
|
+
describe "#matches" do
|
20
|
+
it "returns list of all server paths" do
|
21
|
+
expect(matcher.matches).to match_array(%w(foo_server_alias foo:bar:s1 s2))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -21,7 +21,9 @@ describe "DestinationResolver" do
|
|
21
21
|
let(:environment3) { environment(:corge, :servers => [server3, server4]) }
|
22
22
|
let(:project3) { project(:quux, :environments => environment3) }
|
23
23
|
|
24
|
-
let(:
|
24
|
+
let(:server5) { server(:s5) }
|
25
|
+
let(:server6) { server(:s6) }
|
26
|
+
let(:environment4) { environment(:garply, :servers => [server5, server6]) }
|
25
27
|
let(:environment5) { environment(:waldo, :servers => server(:s7)) }
|
26
28
|
let(:project4) { project(:grault, :environments => [environment4, environment5]) }
|
27
29
|
|
@@ -127,6 +129,15 @@ describe "DestinationResolver" do
|
|
127
129
|
expect(resolver(config, "").resolve).to eq(server1)
|
128
130
|
end
|
129
131
|
end
|
132
|
+
|
133
|
+
context "when there is exact match and partial match" do
|
134
|
+
it "resolves to exact match" do
|
135
|
+
s1 = server(:server1)
|
136
|
+
s10 = server(:server10)
|
137
|
+
config = create_config(:servers => [s1, s10])
|
138
|
+
expect(resolver(config, "server1").resolve).to eq(s1)
|
139
|
+
end
|
140
|
+
end
|
130
141
|
end
|
131
142
|
|
132
143
|
context "when there is global matching server alias" do
|
metadata
CHANGED
@@ -1,91 +1,89 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: taketo
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Vladimir Yarotsky
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-12-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rspec
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 11
|
32
|
-
version: "2.11"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.11'
|
33
22
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rake
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.11'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
|
-
requirements:
|
34
|
+
requirements:
|
41
35
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
- 9
|
47
|
-
version: "0.9"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0.9'
|
48
38
|
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: simplecov
|
52
39
|
prerelease: false
|
53
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0.9'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: simplecov
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
54
49
|
none: false
|
55
|
-
requirements:
|
50
|
+
requirements:
|
56
51
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
- 6
|
62
|
-
version: "0.6"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.6'
|
63
54
|
type: :development
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: open4
|
67
55
|
prerelease: false
|
68
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.6'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: open4
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
69
65
|
none: false
|
70
|
-
requirements:
|
66
|
+
requirements:
|
71
67
|
- - ~>
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
segments:
|
75
|
-
- 1
|
76
|
-
- 3
|
77
|
-
version: "1.3"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.3'
|
78
70
|
type: :development
|
79
|
-
|
80
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.3'
|
78
|
+
description: ! " Taketo is an utility to aid quick access to often used servers
|
79
|
+
for web-developers.\n Taketo uses a config written in ruby using light DSL.\n
|
80
|
+
\ See http://github.com/v-yarotsky/taketo for additional instructions\n"
|
81
81
|
email: vladimir.yarotksy@gmail.com
|
82
|
-
executables:
|
82
|
+
executables:
|
83
83
|
- taketo
|
84
84
|
extensions: []
|
85
|
-
|
86
85
|
extra_rdoc_files: []
|
87
|
-
|
88
|
-
files:
|
86
|
+
files:
|
89
87
|
- bin/taketo
|
90
88
|
- lib/taketo/associated_nodes.rb
|
91
89
|
- lib/taketo/commands/ssh_command.rb
|
@@ -102,6 +100,7 @@ files:
|
|
102
100
|
- lib/taketo/constructs/server.rb
|
103
101
|
- lib/taketo/constructs.rb
|
104
102
|
- lib/taketo/constructs_factory.rb
|
103
|
+
- lib/taketo/destination_matcher.rb
|
105
104
|
- lib/taketo/destination_resolver.rb
|
106
105
|
- lib/taketo/dsl.rb
|
107
106
|
- lib/taketo/printer.rb
|
@@ -111,6 +110,7 @@ files:
|
|
111
110
|
- lib/taketo/support.rb
|
112
111
|
- lib/taketo.rb
|
113
112
|
- spec/acceptance/command_spec.rb
|
113
|
+
- spec/acceptance/completion_spec.rb
|
114
114
|
- spec/acceptance/config_dsl_spec.rb
|
115
115
|
- spec/acceptance/config_validation_spec.rb
|
116
116
|
- spec/acceptance/connect_to_server_spec.rb
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- spec/lib/taketo/constructs/project_spec.rb
|
134
134
|
- spec/lib/taketo/constructs/server_spec.rb
|
135
135
|
- spec/lib/taketo/constructs_factory_spec.rb
|
136
|
+
- spec/lib/taketo/destination_matcher_spec.rb
|
136
137
|
- spec/lib/taketo/destination_resolver_spec.rb
|
137
138
|
- spec/lib/taketo/dsl_spec.rb
|
138
139
|
- spec/lib/taketo/ssh_config_generator_visitor_spec.rb
|
@@ -150,40 +151,29 @@ files:
|
|
150
151
|
- README.md
|
151
152
|
- VERSION
|
152
153
|
homepage: http://github.com/v-yarotsky/taketo
|
153
|
-
licenses:
|
154
|
+
licenses:
|
154
155
|
- MIT
|
155
156
|
post_install_message:
|
156
157
|
rdoc_options: []
|
157
|
-
|
158
|
-
require_paths:
|
158
|
+
require_paths:
|
159
159
|
- lib
|
160
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
161
|
none: false
|
162
|
-
requirements:
|
163
|
-
- -
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
|
166
|
-
|
167
|
-
- 0
|
168
|
-
version: "0"
|
169
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
167
|
none: false
|
171
|
-
requirements:
|
172
|
-
- -
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
hash: 23
|
175
|
-
segments:
|
176
|
-
- 1
|
177
|
-
- 3
|
178
|
-
- 6
|
168
|
+
requirements:
|
169
|
+
- - ! '>='
|
170
|
+
- !ruby/object:Gem::Version
|
179
171
|
version: 1.3.6
|
180
172
|
requirements: []
|
181
|
-
|
182
173
|
rubyforge_project:
|
183
174
|
rubygems_version: 1.8.24
|
184
175
|
signing_key:
|
185
176
|
specification_version: 3
|
186
|
-
summary: A tiny helper utility to make access to servers eaiser for different projects
|
177
|
+
summary: A tiny helper utility to make access to servers eaiser for different projects
|
178
|
+
and environments
|
187
179
|
test_files: []
|
188
|
-
|
189
|
-
has_rdoc:
|