taketo 0.0.1 → 0.0.2

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 (40) hide show
  1. data/Gemfile +4 -4
  2. data/Gemfile.lock +11 -11
  3. data/LICENSE.txt +1 -1
  4. data/README.md +12 -4
  5. data/Rakefile +3 -6
  6. data/VERSION +1 -1
  7. data/bin/taketo +48 -27
  8. data/features/commands.feature +45 -0
  9. data/features/config_validation.feature +18 -0
  10. data/features/connect_to_server.feature +43 -1
  11. data/lib/taketo/commands/ssh_command.rb +6 -14
  12. data/lib/taketo/config_validator.rb +43 -0
  13. data/lib/taketo/constructs/command.rb +32 -0
  14. data/lib/taketo/constructs/config.rb +4 -2
  15. data/lib/taketo/constructs/environment.rb +5 -3
  16. data/lib/taketo/constructs/project.rb +4 -2
  17. data/lib/taketo/constructs/server.rb +28 -1
  18. data/lib/taketo/constructs_factory.rb +9 -0
  19. data/lib/taketo/dsl.rb +24 -24
  20. data/lib/taketo/support/key_error.rb +4 -0
  21. data/lib/taketo/support/named_nodes_collection.rb +26 -0
  22. data/lib/taketo/support.rb +2 -0
  23. data/lib/taketo/taketo_argv_parser.rb +48 -0
  24. data/lib/taketo.rb +2 -1
  25. data/spec/lib/{commands → taketo/commands}/ssh_command_spec.rb +8 -14
  26. data/spec/lib/taketo/config_validator_spec.rb +41 -0
  27. data/spec/lib/taketo/constructs/command_spec.rb +22 -0
  28. data/spec/lib/{constructs → taketo/constructs}/config_spec.rb +2 -2
  29. data/spec/lib/{constructs → taketo/constructs}/environment_spec.rb +2 -2
  30. data/spec/lib/{constructs → taketo/constructs}/project_spec.rb +2 -2
  31. data/spec/lib/taketo/constructs/server_spec.rb +84 -0
  32. data/spec/lib/{constructs_factory_spec.rb → taketo/constructs_factory_spec.rb} +14 -1
  33. data/spec/lib/{dsl_spec.rb → taketo/dsl_spec.rb} +45 -7
  34. data/spec/lib/{support → taketo/support}/eval_delegator_spec.rb +1 -1
  35. data/spec/lib/taketo/support/named_nodes_collection_spec.rb +29 -0
  36. data/spec/lib/taketo/taketo_argv_parser_spec.rb +92 -0
  37. data/spec/spec_helper.rb +8 -4
  38. data/spec/support/helpers/dsl_spec_helper.rb +11 -2
  39. metadata +25 -14
  40. data/spec/lib/constructs/server_spec.rb +0 -41
@@ -0,0 +1,92 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+ require 'taketo/taketo_argv_parser'
3
+ require 'taketo/support/named_nodes_collection'
4
+
5
+ include Taketo
6
+
7
+ describe "TaketoArgvParser" do
8
+ context "when project, environment and server specified" do
9
+ let(:server) { stub(:Server, :name => :baz) }
10
+
11
+ it "should return server if it exists" do
12
+ config = stub(:Config, :projects => list(
13
+ stub(:name => :foo, :environments => list(
14
+ stub(:name => :bar, :servers => list(
15
+ server
16
+ ))
17
+ ))
18
+ ))
19
+
20
+ parser(config, %w(foo bar baz)).parse.should == server
21
+ end
22
+
23
+ it "should raise error if server does not exist" do
24
+ config = stub(:Config, :projects => list())
25
+ expect do
26
+ parser(config, %w(foo bar baz)).parse
27
+ end.to raise_error ArgumentError, /exist/i
28
+ end
29
+ end
30
+
31
+ context "when there are two arguments" do
32
+ end
33
+
34
+ context "when there are no args" do
35
+ context "when there's one project" do
36
+ context "when there's one environment" do
37
+ context "when there's one server" do
38
+ let(:server) { stub(:Server) }
39
+
40
+ it "should execute command without asking project/environment/server" do
41
+ config = stub(:Config, :projects => list(
42
+ stub(:name => :foo, :environments => list(
43
+ stub(:name => :bar, :servers => list(
44
+ server
45
+ ))
46
+ ))
47
+ ))
48
+
49
+ parser(config, []).parse.should == server
50
+ end
51
+ end
52
+
53
+ context "when there are multiple servers" do
54
+ let(:server1) { stub(:Server, :name => :s1) }
55
+ let(:server2) { stub(:Server, :name => :s2) }
56
+
57
+ it "should ask for server if it's not specified" do
58
+ config = stub(:Config, :projects => list(
59
+ stub(:name => :foo, :environments => list(
60
+ stub(:name => :bar, :servers => list(
61
+ server1, server2
62
+ ))
63
+ ))
64
+ ))
65
+
66
+ expect do
67
+ parser(config, []).parse
68
+ end.to raise_error ArgumentError, /server/i
69
+
70
+ parser(config, ["s1"]).parse.should == server1
71
+ end
72
+ end
73
+ end
74
+
75
+ context "when there are multiple environments" do
76
+ context "when environment not specified" do
77
+ it "should ask for environment"
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ def parser(*args)
84
+ TaketoArgvParser.new(*args)
85
+ end
86
+
87
+ def list(*items)
88
+ Taketo::Support::NamedNodesCollection.new(items)
89
+ end
90
+
91
+ end
92
+
data/spec/spec_helper.rb CHANGED
@@ -3,15 +3,19 @@ require 'bundler/setup'
3
3
 
4
4
  if ENV['COVERAGE']
5
5
  require 'simplecov'
6
- SimpleCov.start
7
- end
6
+ SimpleCov.start do
7
+ add_filter "/spec/"
8
8
 
9
- $: << File.expand_path('../../lib', __FILE__)
9
+ add_filter do |f|
10
+ f.lines.count < 5
11
+ end
12
+ end
13
+ end
10
14
 
11
15
  require 'rspec'
12
16
  require 'rspec/autorun'
13
17
 
14
- require 'taketo/dsl'
18
+ $:.unshift File.expand_path('../../lib', __FILE__)
15
19
 
16
20
  Dir[File.dirname(__FILE__) + "/support/matchers/*.rb"].each {|f| require f}
17
21
 
@@ -1,6 +1,10 @@
1
1
  module DSLSpec
2
2
  class TestConstructsFactory
3
- attr_reader :config, :project, :environment, :server
3
+ attr_reader :config, :project, :environment, :server, :command
4
+
5
+ def create(type, *args)
6
+ send("create_#{type}", *args)
7
+ end
4
8
 
5
9
  def create_config
6
10
  @config ||= RSpec::Mocks::Mock.new(:Config).as_null_object
@@ -17,6 +21,10 @@ module DSLSpec
17
21
  def create_server(name = :foo)
18
22
  @server ||= RSpec::Mocks::Mock.new(:Server, :name => name).as_null_object
19
23
  end
24
+
25
+ def create_command(name = :the_cmd)
26
+ @command ||= RSpec::Mocks::Mock.new(:Command, :name => name).as_null_object
27
+ end
20
28
  end
21
29
 
22
30
  def factory
@@ -47,7 +55,8 @@ module DSLSpec
47
55
  :config => [:config],
48
56
  :project => [:config, :project],
49
57
  :environment => [:config, :project, :environment],
50
- :server => [:config, :project, :environment, :server]
58
+ :server => [:config, :project, :environment, :server],
59
+ :command => [:config, :project, :environment, :server, :command]
51
60
  }
52
61
 
53
62
  def scopes_hash.except(*keys)
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taketo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Vladimir Yarotsky
9
- - Maksim Yermalovich
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-06-13 00:00:00.000000000 Z
12
+ date: 2012-07-21 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rspec
@@ -19,7 +18,7 @@ dependencies:
19
18
  requirements:
20
19
  - - ~>
21
20
  - !ruby/object:Gem::Version
22
- version: '2.10'
21
+ version: '2.11'
23
22
  type: :development
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +26,7 @@ dependencies:
27
26
  requirements:
28
27
  - - ~>
29
28
  - !ruby/object:Gem::Version
30
- version: '2.10'
29
+ version: '2.11'
31
30
  - !ruby/object:Gem::Dependency
32
31
  name: rake
33
32
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +85,8 @@ files:
86
85
  - bin/taketo
87
86
  - lib/taketo/commands/ssh_command.rb
88
87
  - lib/taketo/commands.rb
88
+ - lib/taketo/config_validator.rb
89
+ - lib/taketo/constructs/command.rb
89
90
  - lib/taketo/constructs/config.rb
90
91
  - lib/taketo/constructs/environment.rb
91
92
  - lib/taketo/constructs/project.rb
@@ -94,21 +95,30 @@ files:
94
95
  - lib/taketo/constructs_factory.rb
95
96
  - lib/taketo/dsl.rb
96
97
  - lib/taketo/support/eval_delegator.rb
98
+ - lib/taketo/support/key_error.rb
99
+ - lib/taketo/support/named_nodes_collection.rb
97
100
  - lib/taketo/support.rb
101
+ - lib/taketo/taketo_argv_parser.rb
98
102
  - lib/taketo.rb
99
103
  - spec/integration/dsl_integration_spec.rb
100
- - spec/lib/commands/ssh_command_spec.rb
101
- - spec/lib/constructs/config_spec.rb
102
- - spec/lib/constructs/environment_spec.rb
103
- - spec/lib/constructs/project_spec.rb
104
- - spec/lib/constructs/server_spec.rb
105
- - spec/lib/constructs_factory_spec.rb
106
- - spec/lib/dsl_spec.rb
107
- - spec/lib/support/eval_delegator_spec.rb
104
+ - spec/lib/taketo/commands/ssh_command_spec.rb
105
+ - spec/lib/taketo/config_validator_spec.rb
106
+ - spec/lib/taketo/constructs/command_spec.rb
107
+ - spec/lib/taketo/constructs/config_spec.rb
108
+ - spec/lib/taketo/constructs/environment_spec.rb
109
+ - spec/lib/taketo/constructs/project_spec.rb
110
+ - spec/lib/taketo/constructs/server_spec.rb
111
+ - spec/lib/taketo/constructs_factory_spec.rb
112
+ - spec/lib/taketo/dsl_spec.rb
113
+ - spec/lib/taketo/support/eval_delegator_spec.rb
114
+ - spec/lib/taketo/support/named_nodes_collection_spec.rb
115
+ - spec/lib/taketo/taketo_argv_parser_spec.rb
108
116
  - spec/spec_helper.rb
109
117
  - spec/support/helpers/dsl_spec_helper.rb
110
118
  - spec/support/matchers/be_appropriate_construct_matcher.rb
111
119
  - spec/support/matchers/enclose_scope_matcher.rb
120
+ - features/commands.feature
121
+ - features/config_validation.feature
112
122
  - features/connect_to_server.feature
113
123
  - features/step_definitions/main_steps.rb
114
124
  - features/support/env.rb
@@ -139,9 +149,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
149
  version: 1.3.6
140
150
  requirements: []
141
151
  rubyforge_project:
142
- rubygems_version: 1.8.21
152
+ rubygems_version: 1.8.24
143
153
  signing_key:
144
154
  specification_version: 3
145
155
  summary: A tiny helper utility to make access to servers eaiser for different projects
146
156
  and environments
147
157
  test_files: []
158
+ has_rdoc:
@@ -1,41 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require 'taketo/constructs/server'
3
- require 'stringio'
4
-
5
- include Taketo
6
-
7
- describe "Server" do
8
- let(:server) { Taketo::Constructs::Server.new(:foo) }
9
-
10
- it "should have name" do
11
- server.name.should == :foo
12
- end
13
-
14
- it "should set host" do
15
- server.host = "foo"
16
- server.host.should == "foo"
17
- end
18
-
19
- it "should set port" do
20
- server.port = "foo"
21
- server.port.should == "foo"
22
- end
23
-
24
- it "should set username" do
25
- server.username = "foo"
26
- server.username.should == "foo"
27
- end
28
-
29
- it "should set default_location" do
30
- server.default_location = "foo"
31
- server.default_location.should == "foo"
32
- end
33
-
34
- it "should set environment" do
35
- environment = stub(:Environment)
36
- server.environment = environment
37
- server.environment.should == environment
38
- end
39
- end
40
-
41
-