hobo-inviqa 0.0.6 → 0.0.7.pre.rc1
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 +15 -0
- data/.editorconfig +10 -0
- data/Gemfile.lock +7 -3
- data/Guardfile +2 -2
- data/Hobofile +5 -1
- data/bin/hobo +12 -18
- data/hobo.gemspec +2 -0
- data/lib/hobo.rb +8 -1
- data/lib/hobo/cli.rb +14 -4
- data/lib/hobo/config/file.rb +1 -1
- data/lib/hobo/error_handlers/debug.rb +5 -2
- data/lib/hobo/error_handlers/exit_code_map.rb +16 -0
- data/lib/hobo/error_handlers/friendly.rb +13 -8
- data/lib/hobo/errors.rb +11 -1
- data/lib/hobo/helper/http_download.rb +41 -0
- data/lib/hobo/helper/shell.rb +21 -5
- data/lib/hobo/helper/vm_command.rb +127 -17
- data/lib/hobo/lib/host_check.rb +20 -6
- data/lib/hobo/lib/host_check/deps.rb +22 -4
- data/lib/hobo/lib/host_check/git.rb +41 -17
- data/lib/hobo/lib/host_check/ruby.rb +30 -20
- data/lib/hobo/lib/host_check/vagrant.rb +37 -6
- data/lib/hobo/lib/s3sync.rb +23 -40
- data/lib/hobo/lib/seed/project.rb +8 -1
- data/lib/hobo/lib/seed/seed.rb +15 -3
- data/lib/hobo/patches/slop.rb +21 -2
- data/lib/hobo/tasks/assets.rb +32 -20
- data/lib/hobo/tasks/config.rb +15 -0
- data/lib/hobo/tasks/deps.rb +29 -4
- data/lib/hobo/tasks/seed.rb +1 -1
- data/lib/hobo/tasks/system.rb +15 -0
- data/lib/hobo/tasks/system/completions.rb +76 -0
- data/lib/hobo/tasks/tools.rb +10 -6
- data/lib/hobo/tasks/vm.rb +74 -6
- data/lib/hobo/ui.rb +27 -10
- data/lib/hobo/util.rb +36 -2
- data/lib/hobo/version.rb +2 -2
- data/spec/hobo/asset_applicator_spec.rb +2 -2
- data/spec/hobo/cli_spec.rb +35 -24
- data/spec/hobo/config/file_spec.rb +1 -3
- data/spec/hobo/error_handlers/debug_spec.rb +39 -5
- data/spec/hobo/error_handlers/friendly_spec.rb +38 -21
- data/spec/hobo/help_formatter_spec.rb +3 -3
- data/spec/hobo/helpers/file_locator_spec.rb +2 -2
- data/spec/hobo/helpers/shell_spec.rb +2 -2
- data/spec/hobo/helpers/vm_command_spec.rb +36 -24
- data/spec/hobo/lib/s3sync_spec.rb +6 -3
- data/spec/hobo/lib/seed/project_spec.rb +2 -3
- data/spec/hobo/lib/seed/replacer_spec.rb +1 -2
- data/spec/hobo/lib/seed/seed_spec.rb +2 -3
- data/spec/hobo/logging_spec.rb +2 -2
- data/spec/hobo/metadata_spec.rb +2 -2
- data/spec/hobo/null_spec.rb +2 -2
- data/spec/hobo/paths_spec.rb +1 -2
- data/spec/hobo/ui_spec.rb +104 -20
- data/spec/hobo/util_spec.rb +75 -0
- data/spec/spec_helper.rb +1 -0
- metadata +43 -49
- data/lib/hobo/tasks/console.rb +0 -18
- data/lib/hobo/tasks/host.rb +0 -17
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'hobo/paths'
|
3
|
-
require 'hobo/config/file'
|
4
2
|
|
5
3
|
describe Hobo::Config::File do
|
6
4
|
before do
|
@@ -55,4 +53,4 @@ describe Hobo::Config::File do
|
|
55
53
|
expect { Hobo::Config::File.load("test.yaml") }.to raise_error(RuntimeError, "Invalid hobo configuration (test.yaml)")
|
56
54
|
end
|
57
55
|
end
|
58
|
-
end
|
56
|
+
end
|
@@ -1,10 +1,44 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hobo::ErrorHandlers::Debug do
|
4
|
+
before do
|
5
|
+
Hobo.ui = double(Hobo::Ui.new).as_null_object
|
6
|
+
end
|
7
|
+
|
8
|
+
def faked_exception(error_template)
|
9
|
+
error = nil
|
10
|
+
begin
|
11
|
+
raise error_template
|
12
|
+
rescue Exception => error
|
13
|
+
end
|
14
|
+
|
15
|
+
return error
|
16
|
+
end
|
17
|
+
|
4
18
|
describe "handle" do
|
5
|
-
it "should
|
6
|
-
|
7
|
-
|
19
|
+
it "should dump the error" do
|
20
|
+
error = nil
|
21
|
+
begin
|
22
|
+
raise Exception.new('error_message')
|
23
|
+
rescue Exception => error
|
24
|
+
end
|
25
|
+
|
26
|
+
Hobo.ui.should_receive(:error).with(/\(Exception\).*error_message.*debug_spec.rb.*/m)
|
27
|
+
Hobo::ErrorHandlers::Debug.new.handle(error)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return exit code according to exit_code_map" do
|
31
|
+
File.write("temp_log", "command output")
|
32
|
+
output = Struct.new(:path).new
|
33
|
+
output.path = "temp_log"
|
34
|
+
|
35
|
+
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Interrupt.new).should eq 1
|
36
|
+
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::ExternalCommandError.new("command", 128, output)).should eq 3
|
37
|
+
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::InvalidCommandOrOpt.new("command")).should eq 4
|
38
|
+
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::MissingArgumentsError.new("command", ["arg1"])).should eq 5
|
39
|
+
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::UserError.new("user error")).should eq 6
|
40
|
+
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Hobo::ProjectOnlyError.new).should eq 7
|
41
|
+
Hobo::ErrorHandlers::Debug.new.handle(faked_exception Exception.new "general").should eq 128
|
8
42
|
end
|
9
43
|
end
|
10
|
-
end
|
44
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'hobo/ui'
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Hobo::ErrorHandlers::Friendly do
|
5
4
|
before do
|
@@ -13,9 +12,19 @@ describe Hobo::ErrorHandlers::Friendly do
|
|
13
12
|
FakeFS.deactivate!
|
14
13
|
end
|
15
14
|
|
15
|
+
def faked_exception(error_template)
|
16
|
+
error = nil
|
17
|
+
begin
|
18
|
+
raise error_template
|
19
|
+
rescue Exception => error
|
20
|
+
end
|
21
|
+
|
22
|
+
return error
|
23
|
+
end
|
24
|
+
|
16
25
|
describe "handle" do
|
17
26
|
it "should display specialized error for Interrupt" do
|
18
|
-
error = Interrupt.new
|
27
|
+
error = faked_exception(Interrupt.new)
|
19
28
|
Hobo.ui.should_receive(:warning).with(/Caught Interrupt/)
|
20
29
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
21
30
|
end
|
@@ -24,7 +33,9 @@ describe Hobo::ErrorHandlers::Friendly do
|
|
24
33
|
File.write("temp_log", "command output")
|
25
34
|
output = Struct.new(:path).new
|
26
35
|
output.path = "temp_log"
|
27
|
-
|
36
|
+
|
37
|
+
error = faked_exception Hobo::ExternalCommandError.new("command", 128, output)
|
38
|
+
|
28
39
|
Hobo.ui.should_receive(:error).with(/The following external command appears to have failed \(exit status 128\)/)
|
29
40
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
30
41
|
end
|
@@ -33,49 +44,55 @@ describe Hobo::ErrorHandlers::Friendly do
|
|
33
44
|
File.write("temp_log", "command output")
|
34
45
|
output = Struct.new(:path).new
|
35
46
|
output.path = "temp_log"
|
36
|
-
|
47
|
+
|
48
|
+
error = faked_exception Hobo::ExternalCommandError.new("command", 128, output)
|
49
|
+
|
37
50
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
38
51
|
File.read(File.join(Dir.tmpdir, 'hobo_error.log')).should match "command output"
|
39
52
|
end
|
40
53
|
|
41
54
|
it "should display specialized error for invalid command or opt error" do
|
42
|
-
error = Hobo::InvalidCommandOrOpt.new("command")
|
55
|
+
error = faked_exception Hobo::InvalidCommandOrOpt.new("command")
|
43
56
|
Hobo.ui.should_receive(:error).with(/Invalid command or option specified: 'command'/)
|
44
57
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
45
58
|
end
|
46
59
|
|
47
60
|
it "should display specialized error for missing argument error" do
|
48
|
-
error = Hobo::MissingArgumentsError.new("command", ["arg1"])
|
61
|
+
error = faked_exception Hobo::MissingArgumentsError.new("command", ["arg1"])
|
49
62
|
Hobo.ui.should_receive(:error).with(/Not enough arguments for command/)
|
50
63
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
51
64
|
end
|
52
65
|
|
53
66
|
it "should display specialized error for user error" do
|
54
|
-
error = Hobo::UserError.new("user error")
|
67
|
+
error = faked_exception Hobo::UserError.new("user error")
|
55
68
|
Hobo.ui.should_receive(:error).with(/user error/)
|
56
69
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
57
70
|
end
|
58
71
|
|
59
72
|
it "should display generic error for other exception" do
|
60
|
-
error =
|
61
|
-
begin
|
62
|
-
raise Exception.new("general error")
|
63
|
-
rescue Exception => error
|
64
|
-
end
|
65
|
-
|
73
|
+
error = faked_exception Exception.new("general error")
|
66
74
|
Hobo.ui.should_receive(:error).with(/An unexpected error has occured/)
|
67
75
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
68
76
|
end
|
69
77
|
|
70
78
|
it "should write error backtrace to /tmp/hobo_error.log for other exception" do
|
71
|
-
error =
|
72
|
-
begin
|
73
|
-
raise Exception.new("general error")
|
74
|
-
rescue Exception => error
|
75
|
-
end
|
76
|
-
|
79
|
+
error = faked_exception Exception.new("general error")
|
77
80
|
Hobo::ErrorHandlers::Friendly.new.handle(error)
|
78
81
|
File.read(File.join(Dir.tmpdir, 'hobo_error.log')).should match /\(Exception\) general error/
|
79
82
|
end
|
83
|
+
|
84
|
+
it "should return exit code according to exit_code_map" do
|
85
|
+
File.write("temp_log", "command output")
|
86
|
+
output = Struct.new(:path).new
|
87
|
+
output.path = "temp_log"
|
88
|
+
|
89
|
+
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Interrupt.new).should eq 1
|
90
|
+
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::ExternalCommandError.new("command", 128, output)).should eq 3
|
91
|
+
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::InvalidCommandOrOpt.new("command")).should eq 4
|
92
|
+
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::MissingArgumentsError.new("command", ["arg1"])).should eq 5
|
93
|
+
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::UserError.new("user error")).should eq 6
|
94
|
+
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Hobo::ProjectOnlyError.new).should eq 7
|
95
|
+
Hobo::ErrorHandlers::Friendly.new.handle(faked_exception Exception.new "general").should eq 128
|
96
|
+
end
|
80
97
|
end
|
81
|
-
end
|
98
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hobo::HelpFormatter do
|
4
4
|
help = nil
|
@@ -38,8 +38,8 @@ describe Hobo::HelpFormatter do
|
|
38
38
|
|
39
39
|
help = Hobo::HelpFormatter.new slop
|
40
40
|
help.command_map = map
|
41
|
-
HighLine.use_color = false
|
42
41
|
Hobo.ui = Hobo::Ui.new
|
42
|
+
Hobo.ui.use_color false
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "help" do
|
@@ -160,4 +160,4 @@ describe Hobo::HelpFormatter do
|
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
163
|
-
end
|
163
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hobo::Helper do
|
4
4
|
describe "locate" do
|
@@ -8,4 +8,4 @@ describe Hobo::Helper do
|
|
8
8
|
it "should chdir to file path before yielding"
|
9
9
|
it "should yield once for each matching file"
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hobo::Helper do
|
4
4
|
describe "bundle_shell" do
|
@@ -18,4 +18,4 @@ describe Hobo::Helper do
|
|
18
18
|
it "should colour stderr output with red"
|
19
19
|
it "should set ENV args for command if specified with :env"
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
@@ -1,9 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'hobo/logging'
|
3
|
-
require 'hobo/ui'
|
4
|
-
require 'hobo/patches/deepstruct'
|
5
|
-
require 'hobo/helper/vm_command'
|
6
|
-
|
1
|
+
require 'spec_helper'
|
7
2
|
|
8
3
|
describe Hobo::Helper do
|
9
4
|
before do
|
@@ -12,29 +7,46 @@ describe Hobo::Helper do
|
|
12
7
|
:mysql => {
|
13
8
|
:username => "test_user",
|
14
9
|
:password => "test_pass"
|
10
|
+
},
|
11
|
+
:vm => {
|
12
|
+
:project_mount_path => '/'
|
15
13
|
}
|
16
14
|
})
|
15
|
+
|
16
|
+
Hobo.ui = Hobo::Ui.new
|
17
|
+
|
18
|
+
vmi_double = double(Hobo::Helper::VmInspector).as_null_object
|
19
|
+
vmi_double.should_receive(:ssh_config).and_return({
|
20
|
+
:ssh_host => 'fakehost',
|
21
|
+
:ssh_user => 'fakeuser',
|
22
|
+
:ssh_port => '999',
|
23
|
+
:ssh_identity => 'fakeidentity'
|
24
|
+
})
|
25
|
+
|
26
|
+
Hobo::Helper::VmCommand.class_eval do
|
27
|
+
class_variable_set '@@vm_inspector', vmi_double
|
28
|
+
end
|
17
29
|
end
|
18
30
|
|
19
31
|
describe "vm_command" do
|
20
32
|
it "should create a new vm command wrapper with specified command" do
|
21
|
-
vm_command("my_command").to_s.should match
|
33
|
+
vm_command("my_command", :pwd => '/').to_s.should match /-c my_command/
|
22
34
|
end
|
23
35
|
|
24
|
-
it "should default to using a psuedo tty" do
|
25
|
-
vm_command("my_command").to_s.
|
36
|
+
it "should default to not using a psuedo tty" do
|
37
|
+
vm_command("my_command", :pwd => '/').to_s.should_not match /\s-t\s/
|
26
38
|
end
|
27
39
|
|
28
|
-
it "should default to
|
29
|
-
vm_command("my_command").to_s.should match /
|
40
|
+
it "should default to ssh_config user" do
|
41
|
+
vm_command("my_command", :pwd => '/').to_s.should match /fakeuser@/
|
30
42
|
end
|
31
43
|
|
32
|
-
it "should default to
|
33
|
-
vm_command("my_command").to_s.should match /@
|
44
|
+
it "should default to ssh_config host name" do
|
45
|
+
vm_command("my_command", :pwd => '/').to_s.should match /@fakehost/
|
34
46
|
end
|
35
47
|
|
36
48
|
it "should not wrap piped commands with echo by default" do
|
37
|
-
c = vm_command("my_command")
|
49
|
+
c = vm_command("my_command", :pwd => '/')
|
38
50
|
c << "test"
|
39
51
|
c.to_s.should_not match /^echo test/
|
40
52
|
end
|
@@ -42,24 +54,24 @@ describe Hobo::Helper do
|
|
42
54
|
|
43
55
|
describe "vm_mysql" do
|
44
56
|
it "should use mysql command by default" do
|
45
|
-
vm_mysql.to_s.should match
|
57
|
+
vm_mysql(:pwd => '/').to_s.should match /-c mysql/
|
46
58
|
end
|
47
59
|
|
48
60
|
it "should use project config mysql username & password if set" do
|
49
|
-
vm_mysql.to_s.should match
|
61
|
+
vm_mysql(:pwd => '/').to_s.should match /-c mysql.*-utest_user.*-ptest_pass/
|
50
62
|
end
|
51
63
|
|
52
|
-
it "should
|
64
|
+
it "should not pass user / pass if project config mysql credentials not set" do
|
53
65
|
Hobo.project_config = DeepStruct.wrap({})
|
54
|
-
vm_mysql.to_s.should match
|
66
|
+
vm_mysql(:pwd => '/').to_s.should match /-c mysql'/
|
55
67
|
end
|
56
68
|
|
57
69
|
it "should allow specifying the database in options" do
|
58
|
-
vm_mysql(:db => "test_db").to_s.should match
|
70
|
+
vm_mysql(:pwd => '/', :db => "test_db").to_s.should match /-c mysql.*test_db'/
|
59
71
|
end
|
60
72
|
|
61
73
|
it "should enable auto echo of piped commands" do
|
62
|
-
c = vm_mysql
|
74
|
+
c = vm_mysql(:pwd => '/')
|
63
75
|
c << "SELECT 1"
|
64
76
|
c.to_s.should match /^echo SELECT\\ 1/
|
65
77
|
end
|
@@ -69,12 +81,12 @@ describe Hobo::Helper do
|
|
69
81
|
it "should execute the command using the shell helper" do
|
70
82
|
Hobo::Helper.class_eval do
|
71
83
|
alias :old_shell :shell
|
72
|
-
def shell command
|
73
|
-
command.should match /ssh.*
|
84
|
+
def shell command, opts
|
85
|
+
command.to_s.should match /ssh.* -c my_command/
|
74
86
|
end
|
75
87
|
end
|
76
88
|
|
77
|
-
vm_shell "my_command"
|
89
|
+
vm_shell "my_command", :pwd => '/'
|
78
90
|
|
79
91
|
Hobo::Helper.class_eval do
|
80
92
|
remove_method :shell
|
@@ -82,4 +94,4 @@ describe Hobo::Helper do
|
|
82
94
|
end
|
83
95
|
end
|
84
96
|
end
|
85
|
-
end
|
97
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
require 'hobo/lib/s3sync'
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Hobo::Lib::S3Sync do
|
4
|
+
before do
|
5
|
+
AWS.stub!
|
6
|
+
end
|
7
|
+
|
5
8
|
describe "sync" do
|
6
9
|
it "should synchronize s3 files to local"
|
7
10
|
it "should synchronize local files to s3"
|
@@ -10,4 +13,4 @@ describe Hobo::Lib::S3Sync do
|
|
10
13
|
it "should remove files that do not exist in source"
|
11
14
|
it "should update progress as files are transferred"
|
12
15
|
end
|
13
|
-
end
|
16
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'hobo'
|
3
2
|
|
4
3
|
describe Hobo::Lib::Seed::Project do
|
5
4
|
pwd = nil
|
@@ -12,7 +11,7 @@ describe Hobo::Lib::Seed::Project do
|
|
12
11
|
Dir.chdir tmp_dir
|
13
12
|
FileUtils.mkdir_p "project_path"
|
14
13
|
FileUtils.touch "project_path/test"
|
15
|
-
Hobo.ui = Hobo::Ui.
|
14
|
+
Hobo.ui = double(Hobo::Ui).as_null_object
|
16
15
|
default_config = {
|
17
16
|
:config_class => double(Hobo::Config::File).as_null_object,
|
18
17
|
:replacer => double(Hobo::Lib::Seed::Replacer.new).as_null_object
|
@@ -79,4 +78,4 @@ describe Hobo::Lib::Seed::Project do
|
|
79
78
|
it "should set hostname in config"
|
80
79
|
it "should set asset bucket in config"
|
81
80
|
end
|
82
|
-
end
|
81
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'hobo'
|
3
2
|
|
4
3
|
describe Hobo::Lib::Seed::Seed do
|
5
4
|
pwd = nil
|
@@ -9,7 +8,7 @@ describe Hobo::Lib::Seed::Seed do
|
|
9
8
|
tmp_dir = Dir.mktmpdir
|
10
9
|
pwd = Dir.pwd
|
11
10
|
Dir.chdir tmp_dir
|
12
|
-
Hobo.ui = Hobo::Ui.
|
11
|
+
Hobo.ui = double(Hobo::Ui).as_null_object
|
13
12
|
end
|
14
13
|
|
15
14
|
after do
|
@@ -91,4 +90,4 @@ describe Hobo::Lib::Seed::Seed do
|
|
91
90
|
seed.version.should eq `cd seeds/seed_4 && git rev-parse --short HEAD`.strip
|
92
91
|
end
|
93
92
|
end
|
94
|
-
end
|
93
|
+
end
|
data/spec/hobo/logging_spec.rb
CHANGED
data/spec/hobo/metadata_spec.rb
CHANGED