taketo 0.0.10 → 0.1.0

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.
Files changed (51) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +14 -30
  3. data/README.md +4 -0
  4. data/Rakefile +4 -8
  5. data/VERSION +1 -1
  6. data/bin/taketo +5 -5
  7. data/lib/taketo/config_printer_visitor.rb +6 -22
  8. data/lib/taketo/config_traverser.rb +4 -33
  9. data/lib/taketo/config_validator.rb +1 -1
  10. data/lib/taketo/config_visitor.rb +15 -1
  11. data/lib/taketo/constructs/base_construct.rb +30 -6
  12. data/lib/taketo/constructs/config.rb +5 -0
  13. data/lib/taketo/constructs/environment.rb +6 -3
  14. data/lib/taketo/constructs/project.rb +3 -3
  15. data/lib/taketo/constructs/server.rb +3 -4
  16. data/lib/taketo/constructs.rb +6 -1
  17. data/lib/taketo/destination_resolver.rb +37 -52
  18. data/lib/taketo/dsl.rb +6 -3
  19. data/lib/taketo/printer.rb +29 -0
  20. data/lib/taketo/ssh_config_generator_visitor.rb +8 -22
  21. data/spec/acceptance/command_spec.rb +20 -0
  22. data/spec/acceptance/config_dsl_spec.rb +277 -0
  23. data/spec/acceptance/config_validation_spec.rb +109 -0
  24. data/spec/acceptance/connect_to_server_spec.rb +60 -0
  25. data/spec/acceptance/error_handling_spec.rb +31 -0
  26. data/spec/acceptance/generate_ssh_config_spec.rb +44 -0
  27. data/spec/acceptance/help_spec.rb +74 -0
  28. data/spec/acceptance/location_spec.rb +21 -0
  29. data/spec/acceptance_spec_helper.rb +71 -0
  30. data/spec/lib/taketo/config_traverser_spec.rb +20 -33
  31. data/spec/lib/taketo/config_validator_spec.rb +4 -4
  32. data/spec/lib/taketo/config_visitor_spec.rb +0 -4
  33. data/spec/lib/taketo/constructs/base_construct_spec.rb +37 -5
  34. data/spec/lib/taketo/constructs/environment_spec.rb +1 -1
  35. data/spec/lib/taketo/constructs/project_spec.rb +0 -6
  36. data/spec/lib/taketo/constructs/server_spec.rb +1 -3
  37. data/spec/lib/taketo/destination_resolver_spec.rb +21 -54
  38. data/spec/lib/taketo/dsl_spec.rb +46 -44
  39. data/spec/spec_helper.rb +1 -1
  40. data/spec/support/helpers/construct_spec_helper.rb +29 -0
  41. metadata +94 -82
  42. data/features/commands.feature +0 -36
  43. data/features/config.feature +0 -177
  44. data/features/config_validation.feature +0 -43
  45. data/features/connect_to_server.feature +0 -87
  46. data/features/default_server_config.feature +0 -41
  47. data/features/error_handling.feature +0 -29
  48. data/features/generate_ssh_config.feature +0 -44
  49. data/features/help.feature +0 -76
  50. data/features/step_definitions/main_steps.rb +0 -16
  51. data/features/support/env.rb +0 -14
metadata CHANGED
@@ -1,89 +1,91 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: taketo
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.10
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Vladimir Yarotsky
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-11-17 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-12-04 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: rspec
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '2.11'
22
- type: :development
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
- requirements:
25
+ requirements:
27
26
  - - ~>
28
- - !ruby/object:Gem::Version
29
- version: '2.11'
30
- - !ruby/object:Gem::Dependency
31
- name: rake
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '0.9'
27
+ - !ruby/object:Gem::Version
28
+ hash: 21
29
+ segments:
30
+ - 2
31
+ - 11
32
+ version: "2.11"
38
33
  type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rake
39
37
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
40
+ requirements:
43
41
  - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '0.9'
46
- - !ruby/object:Gem::Dependency
47
- name: aruba
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '0.4'
42
+ - !ruby/object:Gem::Version
43
+ hash: 25
44
+ segments:
45
+ - 0
46
+ - 9
47
+ version: "0.9"
54
48
  type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '0.4'
62
- - !ruby/object:Gem::Dependency
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
63
51
  name: simplecov
64
- requirement: !ruby/object:Gem::Requirement
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
65
54
  none: false
66
- requirements:
55
+ requirements:
67
56
  - - ~>
68
- - !ruby/object:Gem::Version
69
- version: '0.6'
57
+ - !ruby/object:Gem::Version
58
+ hash: 7
59
+ segments:
60
+ - 0
61
+ - 6
62
+ version: "0.6"
70
63
  type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: open4
71
67
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
73
69
  none: false
74
- requirements:
70
+ requirements:
75
71
  - - ~>
76
- - !ruby/object:Gem::Version
77
- version: '0.6'
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"
72
+ - !ruby/object:Gem::Version
73
+ hash: 9
74
+ segments:
75
+ - 1
76
+ - 3
77
+ version: "1.3"
78
+ type: :development
79
+ version_requirements: *id004
80
+ description: " Taketo is an utility to aid quick access to often used servers for web-developers.\n Taketo uses a config written in ruby using light DSL.\n 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
+
85
86
  extra_rdoc_files: []
86
- files:
87
+
88
+ files:
87
89
  - bin/taketo
88
90
  - lib/taketo/associated_nodes.rb
89
91
  - lib/taketo/commands/ssh_command.rb
@@ -102,11 +104,21 @@ files:
102
104
  - lib/taketo/constructs_factory.rb
103
105
  - lib/taketo/destination_resolver.rb
104
106
  - lib/taketo/dsl.rb
107
+ - lib/taketo/printer.rb
105
108
  - lib/taketo/ssh_config_generator_visitor.rb
106
109
  - lib/taketo/support/key_error.rb
107
110
  - lib/taketo/support/named_nodes_collection.rb
108
111
  - lib/taketo/support.rb
109
112
  - lib/taketo.rb
113
+ - spec/acceptance/command_spec.rb
114
+ - spec/acceptance/config_dsl_spec.rb
115
+ - spec/acceptance/config_validation_spec.rb
116
+ - spec/acceptance/connect_to_server_spec.rb
117
+ - spec/acceptance/error_handling_spec.rb
118
+ - spec/acceptance/generate_ssh_config_spec.rb
119
+ - spec/acceptance/help_spec.rb
120
+ - spec/acceptance/location_spec.rb
121
+ - spec/acceptance_spec_helper.rb
110
122
  - spec/integration/dsl_integration_spec.rb
111
123
  - spec/lib/taketo/associated_nodes_spec.rb
112
124
  - spec/lib/taketo/commands/ssh_command_spec.rb
@@ -131,16 +143,6 @@ files:
131
143
  - spec/support/matchers/be_appropriate_construct_matcher.rb
132
144
  - spec/support/matchers/enclose_scope_matcher.rb
133
145
  - spec/support/matchers/have_accessor_matcher.rb
134
- - features/commands.feature
135
- - features/config.feature
136
- - features/config_validation.feature
137
- - features/connect_to_server.feature
138
- - features/default_server_config.feature
139
- - features/error_handling.feature
140
- - features/generate_ssh_config.feature
141
- - features/help.feature
142
- - features/step_definitions/main_steps.rb
143
- - features/support/env.rb
144
146
  - Gemfile
145
147
  - Gemfile.lock
146
148
  - Rakefile
@@ -148,30 +150,40 @@ files:
148
150
  - README.md
149
151
  - VERSION
150
152
  homepage: http://github.com/v-yarotsky/taketo
151
- licenses:
153
+ licenses:
152
154
  - MIT
153
155
  post_install_message:
154
156
  rdoc_options: []
155
- require_paths:
157
+
158
+ require_paths:
156
159
  - lib
157
- required_ruby_version: !ruby/object:Gem::Requirement
160
+ required_ruby_version: !ruby/object:Gem::Requirement
158
161
  none: false
159
- requirements:
160
- - - ! '>='
161
- - !ruby/object:Gem::Version
162
- version: '0'
163
- required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ hash: 3
166
+ segments:
167
+ - 0
168
+ version: "0"
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
170
  none: false
165
- requirements:
166
- - - ! '>='
167
- - !ruby/object:Gem::Version
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ hash: 23
175
+ segments:
176
+ - 1
177
+ - 3
178
+ - 6
168
179
  version: 1.3.6
169
180
  requirements: []
181
+
170
182
  rubyforge_project:
171
183
  rubygems_version: 1.8.24
172
184
  signing_key:
173
185
  specification_version: 3
174
- summary: A tiny helper utility to make access to servers eaiser for different projects
175
- and environments
186
+ summary: A tiny helper utility to make access to servers eaiser for different projects and environments
176
187
  test_files: []
188
+
177
189
  has_rdoc:
@@ -1,36 +0,0 @@
1
- Feature:
2
- In order to be able to quickly run commands on my servers
3
- As a developer
4
- I want to have ability to create command shortcuts via config
5
- or specify command directly
6
-
7
- Background:
8
- When I have the following config
9
- """
10
- project :slots do
11
- environment :staging do
12
- server do
13
- host "1.2.3.4"
14
- location "/var/apps/slots"
15
- command :console do
16
- execute "rails c"
17
- end
18
- end
19
- end
20
- end
21
- """
22
-
23
- Scenario: Run explicit command
24
- When I run taketo --dry-run --command "TERM=xterm-256color bash"
25
- Then the output should contain
26
- """
27
- ssh -t 1.2.3.4 "cd /var/apps/slots; RAILS_ENV=staging TERM=xterm-256color bash"
28
- """
29
-
30
- Scenario: Run command defined in config
31
- When I run taketo --dry-run --command console slots:staging
32
- Then the output should contain
33
- """
34
- ssh -t 1.2.3.4 "cd /var/apps/slots; RAILS_ENV=staging rails c"
35
- """
36
-
@@ -1,177 +0,0 @@
1
- Feature: taketo config
2
- In order to get rid of routineous ssh command calls
3
- As a user
4
- I want to be able configure taketo
5
-
6
- Scenario: Shared server configs
7
- When I have the following config
8
- """
9
- shared_server_config :sc1 do
10
- port 9999 #can contain any server config options
11
- end
12
-
13
- shared_server_config :sc2 do
14
- location "/var/qux"
15
- end
16
-
17
- project :slots do
18
- environment :staging do
19
- server(:s1) { host "1.2.3.4"; include_shared_server_config(:sc1, :sc2) }
20
- end
21
- end
22
- """
23
- And I run taketo slots:staging:s1 --dry-run
24
- Then the output should contain
25
- """
26
- ssh -t -p 9999 1.2.3.4 "cd /var/qux; RAILS_ENV=staging bash"
27
- """
28
-
29
- Scenario: Shared server configs with arguments
30
- When I have the following config
31
- """
32
- shared_server_config :sc_args1 do |port_num|
33
- port port_num
34
- end
35
-
36
- shared_server_config :sc_args2 do |projects_root_folder, project_folder|
37
- location File.join(projects_root_folder, project_folder)
38
- end
39
-
40
- project :slots do
41
- environment :staging do
42
- server(:s1) do
43
- host "1.2.3.4"
44
- include_shared_server_config(:sc_args1 => 9999, :sc_args2 => ['/var', 'qux'])
45
- end
46
- end
47
- end
48
- """
49
- And I run taketo slots:staging:s1 --dry-run
50
- Then the output should contain
51
- """
52
- ssh -t -p 9999 1.2.3.4 "cd /var/qux; RAILS_ENV=staging bash"
53
- """
54
-
55
- Scenario: Set environment variables
56
- When I have the following config
57
- """
58
- project :slots do
59
- environment :staging do
60
- server do
61
- host "1.2.3.4"
62
- location "/var/apps/slots"
63
- env :FOO => "the value"
64
- end
65
- end
66
- end
67
- """
68
- And I run taketo --dry-run
69
- Then the output should contain
70
- """
71
- RAILS_ENV=staging
72
- """
73
- And the output should contain
74
- """
75
- FOO=the\ value
76
- """
77
-
78
- Scenario: Reopen config scopes
79
- When I have the following config
80
- """
81
- project :slots do
82
- environment :staging do
83
- server do
84
- host "1.2.3.4"
85
- end
86
- end
87
- end
88
-
89
- project :slots do
90
- environment :staging do
91
- server do
92
- env :FOO => "bar"
93
- end
94
- end
95
- end
96
- """
97
- And I run taketo slots:staging --dry-run
98
- Then the output should match /ssh -t 1\.2\.3\.4 "(RAILS_ENV=staging FOO=bar|FOO=bar RAILS_ENV=staging) bash"/
99
-
100
- Scenario: Unique server alias
101
- When I have the following config
102
- """
103
- project :slots do
104
- environment :staging do
105
- server :s1 do
106
- host "1.2.3.4"
107
- end
108
- server :s2 do
109
- global_alias :ss2
110
- host "2.3.4.5"
111
- end
112
- end
113
- end
114
- """
115
- And I run taketo ss2 --dry-run
116
- Then the output should contain
117
- """
118
- ssh -t 2.3.4.5 "RAILS_ENV=staging bash"
119
- """
120
-
121
- Scenario: Override default location specified for server
122
- When I have the following config
123
- """
124
- project :slots do
125
- environment :staging do
126
- server do
127
- location '/var/foo'
128
- host "1.2.3.4"
129
- end
130
- end
131
- end
132
- """
133
- When I run taketo --dry-run --directory /var/www slots:staging
134
- Then the output should contain
135
- """
136
- ssh -t 1.2.3.4 "cd /var/www; RAILS_ENV=staging bash"
137
- """
138
-
139
- Scenario: Default server command
140
- When I have the following config
141
- """
142
- project :slots do
143
- environment :staging do
144
- server do
145
- host "1.2.3.4"
146
-
147
- default_command :tmux
148
-
149
- command :tmux do
150
- execute "tmux attach || tmux new-session"
151
- end
152
- end
153
- end
154
- end
155
- """
156
- When I run taketo --dry-run slots:staging
157
- Then the output should contain
158
- """
159
- ssh -t 1.2.3.4 "RAILS_ENV=staging tmux attach || tmux new-session"
160
- """
161
- When I have the following config
162
- """
163
- project :slots do
164
- environment :staging do
165
- server do
166
- host "1.2.3.4"
167
- default_command "do_something"
168
- end
169
- end
170
- end
171
- """
172
- When I run taketo --dry-run slots:staging
173
- Then the output should contain
174
- """
175
- ssh -t 1.2.3.4 "RAILS_ENV=staging do_something"
176
- """
177
-
@@ -1,43 +0,0 @@
1
- Feature:
2
- In order to be able to use the piece of software
3
- As a user
4
- I want to be guided if there are any errors in my configuration
5
-
6
- Scenario Outline: Config validation
7
- When I have the following config
8
- """
9
- <config>
10
- """
11
- And I run taketo
12
- Then the stderr should contain "<error>"
13
-
14
- Examples:
15
- | config | error |
16
- | | There are no projects. Add some to your config (~/.taketo.rc.rb by default) |
17
- | project(:foo) {} | Project foo: no environments |
18
- | project(:foo) { environment(:bar) {} } | Environment foo:bar: no servers |
19
- | project(:foo) { environment(:bar) { server {} }} | Server foo:bar:default: host is not defined |
20
-
21
- Scenario: Global server alias clash
22
- When I have the following config
23
- """
24
- project(:foo) { environment(:bar) {
25
- server(:s1) { host '1.2.3.4'; global_alias :a1 }
26
- server(:s2) { host '2.3.4.5'; global_alias :a1 }
27
- }}
28
- """
29
- And I run taketo
30
- Then the stderr should contain "Server foo:bar:s2: global alias 'a1' has already been taken by server foo:bar:s1"
31
-
32
- Scenario: Bad command
33
- When I have the following config
34
- """
35
- project(:foo) { environment(:bar) {
36
- server(:s1) { host '1.2.3.4'
37
- command(:foo) {}
38
- }
39
- }}
40
- """
41
- And I run taketo
42
- Then the stderr should contain "Don't know what to execute on command foo"
43
-
@@ -1,87 +0,0 @@
1
- Feature:
2
- In order to be able to access my servers quickly
3
- As a developer
4
- I want to have a nifty little utility
5
- configurable with simple DSL
6
-
7
- Scenario: SSH to server
8
- When I have the following config
9
- """
10
- project :slots do
11
- environment :staging do
12
- server :s1 do
13
- host "1.2.3.4"
14
- user "deployer"
15
- location "/var/apps/slots"
16
- end
17
-
18
- server :s2 do
19
- host "2.3.4.5"
20
- end
21
- end
22
- end
23
-
24
- """
25
- And I run taketo --dry-run slots:staging:s1
26
- Then the output should contain
27
- """
28
- ssh -t deployer@1.2.3.4 "cd /var/apps/slots; RAILS_ENV=staging bash"
29
- """
30
-
31
- Scenario: SSH to the only server
32
- When I have the following config
33
- """
34
- project :slots do
35
- environment :staging do
36
- server do
37
- host "1.2.3.4"
38
- location "/var/apps/slots"
39
- end
40
- end
41
- end
42
- """
43
- And I run taketo --dry-run
44
- Then the output should contain
45
- """
46
- ssh -t 1.2.3.4 "cd /var/apps/slots; RAILS_ENV=staging bash"
47
- """
48
-
49
- Scenario: Default destination
50
- When I have the following config
51
- """
52
- default_destination "slots:staging:s2"
53
- project :slots do
54
- environment :staging do
55
- server :s1 do
56
- host "1.2.3.4"
57
- end
58
- server :s2 do
59
- host "2.3.4.5"
60
- end
61
- end
62
- end
63
- """
64
- And I run taketo --dry-run
65
- Then the output should contain
66
- """
67
- ssh -t 2.3.4.5 "RAILS_ENV=staging bash"
68
- """
69
-
70
- Scenario: SSH key file
71
- When I have the following config
72
- """
73
- project :slots do
74
- environment :staging do
75
- server do
76
- identity_file "/home/gor/.ssh/foo bar"
77
- host "2.3.4.5"
78
- end
79
- end
80
- end
81
- """
82
- And I run taketo --dry-run
83
- Then the output should contain
84
- """
85
- ssh -t -i /home/gor/.ssh/foo\ bar 2.3.4.5 "RAILS_ENV=staging bash"
86
- """
87
-
@@ -1,41 +0,0 @@
1
- Feature: taketo config's default server config
2
- In order to reduce duplication
3
- As a taketo user
4
- I want to be able set default configs for servers in particular scopes
5
-
6
- Background:
7
- When I have the following config
8
- """
9
- default_server_config do
10
- env :FOO => 'bar'
11
- end
12
-
13
- project :slots do
14
- default_server_config do
15
- location '/mnt/apps'
16
- end
17
-
18
- environment :staging do
19
- server :s1 do
20
- host "1.2.3.4"
21
- end
22
- end
23
- end
24
-
25
- project :shoes do
26
- environment :production do
27
- server do
28
- host "2.3.4.5"
29
- end
30
- end
31
- end
32
- """
33
-
34
- Scenario: Global default server config
35
- When I run taketo shoes --dry-run
36
- Then the output should match /ssh -t 2\.3\.4\.5 "(RAILS_ENV=production FOO=bar|FOO=bar RAILS_ENV=production) bash"/
37
-
38
- Scenario: Project default server config
39
- When I run taketo slots --dry-run
40
- Then the output should match /ssh -t 1\.2\.3\.4 "cd .mnt.apps; (RAILS_ENV=staging FOO=bar|FOO=bar RAILS_ENV=staging) bash"/
41
-
@@ -1,29 +0,0 @@
1
- Feature:
2
- To be able to troubleshoot my config issues quickly
3
- As a user
4
- I want to see meaningful errors when I accidentally specify bad location
5
-
6
- Background:
7
- When I have the following config
8
- """
9
- default_destination "slots:staging:s2"
10
- project :slots do
11
- environment :staging do
12
- server :s1 do
13
- host "1.2.3.4"
14
- end
15
- server :s2 do
16
- host "2.3.4.5"
17
- end
18
- end
19
- end
20
- """
21
-
22
- Scenario: Non-existent location
23
- And I run taketo slots:staging:qqq --dry-run
24
- Then the stderr should contain "server qqq not found for environment staging"
25
-
26
- Scenario: Ambiguous location
27
- And I run taketo slots:staging --dry-run
28
- Then the stderr should contain "There are multiple servers for environment staging: s1, s2"
29
-