vito 0.0.2 → 0.0.4
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rvmrc +1 -0
- data/README.md +33 -7
- data/Rakefile +35 -0
- data/Vagrantfile +1 -1
- data/bin/vito +7 -2
- data/docs/manual.md +79 -0
- data/lib/samples/vito_for_rails.rb +14 -0
- data/lib/vito.rb +2 -2
- data/lib/vito/connection.rb +20 -27
- data/lib/vito/dsl/installation.rb +15 -0
- data/lib/vito/dsl/server.rb +17 -0
- data/lib/vito/dsl_file.rb +24 -0
- data/lib/vito/log.rb +7 -1
- data/lib/vito/operating_system.rb +1 -11
- data/lib/vito/operating_systems/ubuntu_10.rb +31 -0
- data/lib/vito/output.rb +21 -0
- data/lib/vito/recipe.rb +6 -3
- data/lib/vito/recipes/postgres.rb +104 -0
- data/lib/vito/recipes/rbenv.rb +10 -5
- data/lib/vito/shell_initializer.rb +7 -12
- data/lib/vito/version.rb +1 -1
- data/spec/acceptance/recipes/git_acceptance_spec.rb +20 -0
- data/spec/acceptance/recipes/postgres_acceptance_spec.rb +20 -0
- data/spec/acceptance/recipes/rbenv_acceptance_spec.rb +22 -0
- data/spec/acceptance/recipes/ruby_acceptance_spec.rb +24 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/vagrant.rb +34 -0
- data/spec/vito/connection_spec.rb +7 -4
- data/spec/vito/dsl/installation_spec.rb +17 -0
- data/spec/vito/dsl/server_spec.rb +0 -0
- data/spec/vito/dsl_file_spec.rb +37 -0
- data/spec/vito/log_spec.rb +10 -1
- data/spec/vito/operating_system_spec.rb +16 -0
- data/spec/vito/operating_systems/ubuntu_10_spec.rb +29 -0
- data/spec/vito/output_spec.rb +27 -5
- data/spec/vito/recipe_spec.rb +78 -0
- data/spec/vito/recipes/git_spec.rb +1 -1
- data/spec/vito/recipes/ruby_spec.rb +7 -35
- data/spec/vito/shell_initializer_spec.rb +10 -51
- data/vito.rb +3 -2
- metadata +33 -15
- data/lib/vito/installation.rb +0 -13
- data/lib/vito/logger.rb +0 -15
- data/lib/vito/recipes_configuration.rb +0 -11
- data/lib/vito/server.rb +0 -15
- data/lib/vito/ssh.rb +0 -62
- data/spec/contracts/vito/installation_contract.rb +0 -8
- data/spec/vito/installation_spec.rb +0 -25
- data/spec/vito/recipes_configuration_spec.rb +0 -7
- data/spec/vito/recipes_spec.rb +0 -9
data/spec/vito/log_spec.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
-
require "
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Vito::Log do
|
4
|
+
before do
|
5
|
+
@env = ENV["env"]
|
6
|
+
ENV["env"] = "development"
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
ENV["env"] = @env || ENV["env"]
|
11
|
+
end
|
12
|
+
|
4
13
|
describe "#some_method" do
|
5
14
|
it "returns true" do
|
6
15
|
STDOUT.should_receive(:puts).with("messagee")
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "vito/operating_system"
|
2
|
+
|
3
|
+
describe Vito::OperatingSystem do
|
4
|
+
subject { described_class.new(:connection) }
|
5
|
+
|
6
|
+
before do
|
7
|
+
stub_const("Vito::OperatingSystems::Ubuntu10", Class.new)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#os" do
|
11
|
+
it "instantiates Ubuntu 10" do
|
12
|
+
Vito::OperatingSystems::Ubuntu10.stub(:new).with(:connection) { :os }
|
13
|
+
subject.os.should == :os
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "vito/operating_systems/ubuntu_10"
|
2
|
+
|
3
|
+
describe Vito::OperatingSystems::Ubuntu10 do
|
4
|
+
let(:connection) { double }
|
5
|
+
|
6
|
+
subject { described_class.new(connection) }
|
7
|
+
|
8
|
+
describe "is?" do
|
9
|
+
context "correct OS" do
|
10
|
+
it "return true if ubuntu" do
|
11
|
+
subject.is?(:ubuntu).should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
it "return true if ubuntu 10" do
|
15
|
+
subject.is?(:ubuntu, "10").should be_true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "incorrect OS" do
|
20
|
+
it "return false if not ubuntu" do
|
21
|
+
subject.is?(:centos).should be_false
|
22
|
+
end
|
23
|
+
|
24
|
+
it "return false if ubuntu 11" do
|
25
|
+
subject.is?(:ubuntu, "11").should be_false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/vito/output_spec.rb
CHANGED
@@ -1,10 +1,32 @@
|
|
1
1
|
require "vito/output"
|
2
2
|
|
3
|
-
describe Vito::
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
describe Vito::ConnectionOutput do
|
4
|
+
let(:stdout) { double(read: :stdout_string) }
|
5
|
+
let(:stderr) { double(read: :stderr_string) }
|
6
|
+
let(:thread) { double(value: double(exitstatus: 0)) }
|
7
|
+
|
8
|
+
subject { described_class.new(nil, stdout, stderr, thread) }
|
9
|
+
|
10
|
+
describe "success?" do
|
11
|
+
it "returns true if exit status is successful" do
|
12
|
+
subject.success?.should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns false if exit status isn't successful" do
|
16
|
+
thread.stub_chain(:value, :exitstatus) { 128 }
|
17
|
+
subject.success?.should be_false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "result" do
|
22
|
+
it "returns stdout string in case of a successful command" do
|
23
|
+
subject.stub(:success?) { true }
|
24
|
+
subject.result.should == :stdout_string
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns stdout string in case of a successful command" do
|
28
|
+
subject.stub(:success?) { false }
|
29
|
+
subject.result.should == :stderr_string
|
8
30
|
end
|
9
31
|
end
|
10
32
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
class DummyRecipe < Vito::Recipe
|
4
|
+
end
|
5
|
+
|
6
|
+
describe DummyRecipe do
|
7
|
+
let(:operating_system) { double }
|
8
|
+
let(:options) { double }
|
9
|
+
let(:connection) { double }
|
10
|
+
|
11
|
+
subject { described_class.new(options, connection) }
|
12
|
+
|
13
|
+
describe "#run" do
|
14
|
+
it "raises an error if undefined" do
|
15
|
+
expect { subject.run }.to raise_error "DummyRecipe recipe needs to define a #run method"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#install_os_dependencies" do
|
20
|
+
it "installs operating system dependencies" do
|
21
|
+
dependencies = %w(build-essential openssl libreadline6
|
22
|
+
libreadline6-dev zlib1g zlib1g-dev libssl-dev
|
23
|
+
libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3
|
24
|
+
libxml2-dev libxslt1-dev autoconf libc6-dev
|
25
|
+
libncurses5-dev)
|
26
|
+
subject.stub(:os_dependencies) { dependencies }
|
27
|
+
|
28
|
+
operating_system.should_receive(:update_packages)
|
29
|
+
operating_system.should_receive(:install_dependencies).with(dependencies)
|
30
|
+
Vito::OperatingSystem.stub(:new).with(connection) { double(os: operating_system) }
|
31
|
+
|
32
|
+
subject.install_os_dependencies
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#depends_on_recipe" do
|
37
|
+
it "installs other recipes" do
|
38
|
+
Vito::Dsl::Installation
|
39
|
+
.stub(:new)
|
40
|
+
.with(:ruby, :options, connection)
|
41
|
+
.and_return(double(install: :installed))
|
42
|
+
|
43
|
+
subject.depends_on_recipe(:ruby, :options).should == :installed
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#run_command" do
|
48
|
+
it "runs a command in the server" do
|
49
|
+
connection.should_receive(:run).with(:command) { :result }
|
50
|
+
subject.run_command(:command).should == :result
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#query" do
|
55
|
+
it "runs a command in the server just querying some information" do
|
56
|
+
connection.should_receive(:query).with(:command) { :result }
|
57
|
+
subject.query(:command).should == :result
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#program_version" do
|
62
|
+
it "checks a given program's version" do
|
63
|
+
Vito::Utils::ProgramVersion
|
64
|
+
.stub(:new)
|
65
|
+
.with("ruby -c", connection)
|
66
|
+
.and_return(:truthy)
|
67
|
+
|
68
|
+
subject.program_version("ruby -c").should == :truthy
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#os" do
|
73
|
+
it "returns the current OS object" do
|
74
|
+
Vito::OperatingSystem.stub(:new).with(connection).and_return(double(os: :os))
|
75
|
+
subject.os.should == :os
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -1,51 +1,23 @@
|
|
1
|
-
require "
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Vito::Recipes::Ruby do
|
4
|
-
let(:
|
4
|
+
let(:options) { double("options").as_null_object }
|
5
|
+
let(:connection) { double("connection").as_null_object }
|
5
6
|
|
6
|
-
subject { Vito::Recipes::Ruby.new(
|
7
|
+
subject { Vito::Recipes::Ruby.new(options, connection) }
|
7
8
|
|
8
9
|
before do
|
9
|
-
|
10
|
-
|
11
|
-
stub_const("Vito::OperatingSystem", Object.new)
|
12
|
-
stub_const("Vito::Output", Object.new)
|
13
|
-
Vito::Output.stub(:write)
|
10
|
+
STDOUT.stub(:puts)
|
11
|
+
Vito::ConnectionOutput.stub(:write)
|
14
12
|
end
|
15
13
|
|
16
14
|
describe "#run" do
|
17
|
-
it "installs the operating system dependencies" do
|
18
|
-
subject.stub(:install_git)
|
19
|
-
subject.stub(:install_rbenv)
|
20
|
-
|
21
|
-
dependencies = %w( build-essential openssl libreadline6
|
22
|
-
libreadline6-dev zlib1g zlib1g-dev libssl-dev
|
23
|
-
libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3
|
24
|
-
libxml2-dev libxslt1-dev autoconf libc6-dev
|
25
|
-
libncurses5-dev)
|
26
|
-
operating_system = double
|
27
|
-
operating_system.should_receive(:install_dependencies).with(dependencies)
|
28
|
-
Vito::OperatingSystem.stub(:new).with(subject) { operating_system }
|
29
|
-
subject.run
|
30
|
-
end
|
31
|
-
|
32
|
-
it "installs git" do
|
33
|
-
subject.stub(:install_rbenv)
|
34
|
-
subject.stub(:install_os_dependencies)
|
35
|
-
|
36
|
-
git = double
|
37
|
-
git.should_receive(:run)
|
38
|
-
Vito::Recipes::Git.stub(:new).with(subject) { git }
|
39
|
-
subject.run
|
40
|
-
end
|
41
|
-
|
42
15
|
it "installs rbenv" do
|
43
|
-
subject.stub(:install_git)
|
44
16
|
subject.stub(:install_os_dependencies)
|
45
17
|
|
46
18
|
rbenv = double
|
47
19
|
rbenv.should_receive(:run)
|
48
|
-
Vito::Recipes::Rbenv.stub(:new).with(
|
20
|
+
Vito::Recipes::Rbenv.stub(:new).with(anything, connection) { rbenv }
|
49
21
|
subject.run
|
50
22
|
end
|
51
23
|
end
|
@@ -1,63 +1,22 @@
|
|
1
|
-
require "
|
2
|
-
require "contracts/vito/installation_contract"
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
3
|
describe Vito::ShellInitializer do
|
5
|
-
|
6
|
-
|
7
|
-
subject { Vito::ShellInitializer.new(["fixtures/vito.rb"]) }
|
4
|
+
subject { described_class.new(:argv) }
|
8
5
|
|
9
6
|
describe "#run" do
|
10
7
|
let(:recipes) { double }
|
8
|
+
let(:dsl) { double }
|
9
|
+
let(:file) { double }
|
11
10
|
|
12
11
|
before do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
describe "the execution starts" do
|
17
|
-
let(:ssh) { double }
|
18
|
-
let(:ssh_config) { double(ssh_host: :host, ssh_user: :user) }
|
19
|
-
|
20
|
-
it "connects to the SSH server" do
|
21
|
-
subject.stub(:config) { ssh_config }
|
22
|
-
subject.stub(:install_recipes)
|
23
|
-
subject.stub(:finish_execution)
|
24
|
-
Vito::Ssh.stub(:new).with(:host, :user) { ssh }
|
25
|
-
subject.run
|
26
|
-
subject.ssh.should == ssh
|
27
|
-
end
|
12
|
+
File.stub(:open).with("vito.rb") { file }
|
13
|
+
file.stub(:read) { :vitorb }
|
28
14
|
end
|
29
15
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
Vito::Installation.stub(:new).with(subject) { recipes }
|
36
|
-
recipes.should_receive(:install)
|
37
|
-
|
38
|
-
subject.run
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "the execution ends" do
|
43
|
-
let(:ssh) { double }
|
44
|
-
|
45
|
-
it "closes the SSH connection" do
|
46
|
-
subject.stub(:ssh) { ssh }
|
47
|
-
subject.stub(:install_recipes)
|
48
|
-
subject.stub(:open_ssh_connection)
|
49
|
-
|
50
|
-
ssh.should_receive(:close)
|
51
|
-
subject.run
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#config" do
|
57
|
-
it "returns a configuration object" do
|
58
|
-
stub_const("Vito::RecipesConfiguration", Object.new)
|
59
|
-
Vito::RecipesConfiguration.should_receive(:new) { :config }
|
60
|
-
subject.config.should == :config
|
16
|
+
it "uses ./vito.rb by default" do
|
17
|
+
dsl.should_receive(:run).with(:vitorb)
|
18
|
+
Vito::DslFile.stub(:new).with(:argv) { dsl }
|
19
|
+
subject.run
|
61
20
|
end
|
62
21
|
end
|
63
22
|
end
|
data/vito.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
server :ruby_server, :one do
|
2
|
-
|
2
|
+
# Vagrant box
|
3
|
+
connection :ssh, command: "ssh -i ~/.vagrant.d/insecure_private_key vagrant@localhost -p2222"
|
3
4
|
|
4
5
|
install :rbenv
|
5
6
|
install :git
|
6
7
|
install :ruby, version: "1.9.3-p125"
|
7
|
-
|
8
|
+
install :postgres
|
8
9
|
#install :tmux
|
9
10
|
#install :ruby_gem, :bundler
|
10
11
|
#install :passenger
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vito
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre de Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_support
|
@@ -64,39 +64,50 @@ extra_rdoc_files: []
|
|
64
64
|
files:
|
65
65
|
- .gitignore
|
66
66
|
- .rspec
|
67
|
+
- .rvmrc
|
67
68
|
- Gemfile
|
68
69
|
- LICENSE
|
69
70
|
- README.md
|
70
71
|
- Rakefile
|
71
72
|
- Vagrantfile
|
72
73
|
- bin/vito
|
74
|
+
- docs/manual.md
|
75
|
+
- lib/samples/vito_for_rails.rb
|
73
76
|
- lib/vito.rb
|
74
77
|
- lib/vito/connection.rb
|
75
|
-
- lib/vito/installation.rb
|
78
|
+
- lib/vito/dsl/installation.rb
|
79
|
+
- lib/vito/dsl/server.rb
|
80
|
+
- lib/vito/dsl_file.rb
|
76
81
|
- lib/vito/log.rb
|
77
|
-
- lib/vito/logger.rb
|
78
82
|
- lib/vito/operating_system.rb
|
83
|
+
- lib/vito/operating_systems/ubuntu_10.rb
|
84
|
+
- lib/vito/output.rb
|
79
85
|
- lib/vito/recipe.rb
|
80
86
|
- lib/vito/recipes/git.rb
|
87
|
+
- lib/vito/recipes/postgres.rb
|
81
88
|
- lib/vito/recipes/rbenv.rb
|
82
89
|
- lib/vito/recipes/ruby.rb
|
83
|
-
- lib/vito/recipes_configuration.rb
|
84
|
-
- lib/vito/server.rb
|
85
90
|
- lib/vito/shell_initializer.rb
|
86
|
-
- lib/vito/ssh.rb
|
87
91
|
- lib/vito/utils/program_version.rb
|
88
92
|
- lib/vito/version.rb
|
89
|
-
- spec/
|
93
|
+
- spec/acceptance/recipes/git_acceptance_spec.rb
|
94
|
+
- spec/acceptance/recipes/postgres_acceptance_spec.rb
|
95
|
+
- spec/acceptance/recipes/rbenv_acceptance_spec.rb
|
96
|
+
- spec/acceptance/recipes/ruby_acceptance_spec.rb
|
90
97
|
- spec/fixtures/vito.rb
|
91
98
|
- spec/spec_helper.rb
|
99
|
+
- spec/support/vagrant.rb
|
92
100
|
- spec/vito/connection_spec.rb
|
93
|
-
- spec/vito/installation_spec.rb
|
101
|
+
- spec/vito/dsl/installation_spec.rb
|
102
|
+
- spec/vito/dsl/server_spec.rb
|
103
|
+
- spec/vito/dsl_file_spec.rb
|
94
104
|
- spec/vito/log_spec.rb
|
105
|
+
- spec/vito/operating_system_spec.rb
|
106
|
+
- spec/vito/operating_systems/ubuntu_10_spec.rb
|
95
107
|
- spec/vito/output_spec.rb
|
108
|
+
- spec/vito/recipe_spec.rb
|
96
109
|
- spec/vito/recipes/git_spec.rb
|
97
110
|
- spec/vito/recipes/ruby_spec.rb
|
98
|
-
- spec/vito/recipes_configuration_spec.rb
|
99
|
-
- spec/vito/recipes_spec.rb
|
100
111
|
- spec/vito/shell_initializer_spec.rb
|
101
112
|
- spec/vito/utils/program_version_spec.rb
|
102
113
|
- vito.gemspec
|
@@ -126,16 +137,23 @@ signing_key:
|
|
126
137
|
specification_version: 4
|
127
138
|
summary: Install webserver environments automatically in an easier way
|
128
139
|
test_files:
|
129
|
-
- spec/
|
140
|
+
- spec/acceptance/recipes/git_acceptance_spec.rb
|
141
|
+
- spec/acceptance/recipes/postgres_acceptance_spec.rb
|
142
|
+
- spec/acceptance/recipes/rbenv_acceptance_spec.rb
|
143
|
+
- spec/acceptance/recipes/ruby_acceptance_spec.rb
|
130
144
|
- spec/fixtures/vito.rb
|
131
145
|
- spec/spec_helper.rb
|
146
|
+
- spec/support/vagrant.rb
|
132
147
|
- spec/vito/connection_spec.rb
|
133
|
-
- spec/vito/installation_spec.rb
|
148
|
+
- spec/vito/dsl/installation_spec.rb
|
149
|
+
- spec/vito/dsl/server_spec.rb
|
150
|
+
- spec/vito/dsl_file_spec.rb
|
134
151
|
- spec/vito/log_spec.rb
|
152
|
+
- spec/vito/operating_system_spec.rb
|
153
|
+
- spec/vito/operating_systems/ubuntu_10_spec.rb
|
135
154
|
- spec/vito/output_spec.rb
|
155
|
+
- spec/vito/recipe_spec.rb
|
136
156
|
- spec/vito/recipes/git_spec.rb
|
137
157
|
- spec/vito/recipes/ruby_spec.rb
|
138
|
-
- spec/vito/recipes_configuration_spec.rb
|
139
|
-
- spec/vito/recipes_spec.rb
|
140
158
|
- spec/vito/shell_initializer_spec.rb
|
141
159
|
- spec/vito/utils/program_version_spec.rb
|
data/lib/vito/installation.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module Vito
|
2
|
-
class Installation
|
3
|
-
def initialize(name, options, connection)
|
4
|
-
@name = name.to_s
|
5
|
-
@options = options
|
6
|
-
@connection = connection
|
7
|
-
end
|
8
|
-
|
9
|
-
def install
|
10
|
-
"Vito::Recipes::#{@name.camelize}".constantize.new(@options, @connection).run
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|