hobo-inviqa 0.0.4 → 0.0.6
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.
- data/Gemfile.lock +27 -6
- data/README.md +1 -10
- data/bin/hobo +20 -0
- data/features/hobo/help.feature +5 -1
- data/hobo.gemspec +4 -0
- data/lib/hobo.rb +17 -14
- data/lib/hobo/asset_applicator.rb +16 -0
- data/lib/hobo/cli.rb +40 -20
- data/lib/hobo/config.rb +5 -0
- data/lib/hobo/config/file.rb +3 -1
- data/lib/hobo/errors.rb +8 -1
- data/lib/hobo/help_formatter.rb +8 -1
- data/lib/hobo/helper/file_locator.rb +8 -5
- data/lib/hobo/helper/shell.rb +12 -4
- data/lib/hobo/helper/vm_command.rb +67 -0
- data/lib/hobo/lib/host_check.rb +23 -0
- data/lib/hobo/lib/host_check/deps.rb +21 -0
- data/lib/hobo/lib/host_check/git.rb +52 -0
- data/lib/hobo/lib/host_check/ruby.rb +42 -0
- data/lib/hobo/lib/host_check/vagrant.rb +15 -0
- data/lib/hobo/lib/s3sync.rb +233 -0
- data/lib/hobo/lib/seed/project.rb +12 -0
- data/lib/hobo/lib/seed/seed.rb +19 -0
- data/lib/hobo/logging.rb +22 -0
- data/lib/hobo/metadata.rb +7 -1
- data/lib/hobo/null.rb +31 -0
- data/lib/hobo/patches/deepstruct.rb +23 -0
- data/lib/hobo/patches/rake.rb +14 -1
- data/lib/hobo/patches/slop.rb +11 -1
- data/lib/hobo/paths.rb +8 -3
- data/lib/hobo/tasks/assets.rb +96 -0
- data/lib/hobo/tasks/console.rb +18 -0
- data/lib/hobo/tasks/debug.rb +2 -2
- data/lib/hobo/tasks/deps.rb +1 -1
- data/lib/hobo/tasks/host.rb +17 -0
- data/lib/hobo/tasks/vm.rb +2 -2
- data/lib/hobo/ui.rb +21 -16
- data/lib/hobo/version.rb +1 -1
- data/spec/hobo/asset_applicator_spec.rb +31 -0
- data/spec/hobo/cli_spec.rb +115 -97
- data/spec/hobo/config/file_spec.rb +13 -3
- data/spec/hobo/help_formatter_spec.rb +50 -18
- data/spec/hobo/helpers/file_locator_spec.rb +5 -1
- data/spec/hobo/helpers/shell_spec.rb +15 -1
- data/spec/hobo/helpers/vm_command_spec.rb +85 -0
- data/spec/hobo/lib/s3sync_spec.rb +13 -0
- data/spec/hobo/lib/seed/project_spec.rb +7 -8
- data/spec/hobo/lib/seed/seed_spec.rb +3 -4
- data/spec/hobo/logging_spec.rb +28 -0
- data/spec/hobo/metadata_spec.rb +10 -0
- data/spec/hobo/null_spec.rb +31 -0
- data/spec/hobo/paths_spec.rb +6 -6
- data/spec/hobo/ui_spec.rb +4 -0
- metadata +93 -6
- data/features/vm.feature +0 -0
data/lib/hobo/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'hobo/asset_applicator'
|
2
|
+
|
3
|
+
describe Hobo::AssetApplicatorRegistry do
|
4
|
+
describe "asset_applicators accessor" do
|
5
|
+
it "should initialize registry if none exists" do
|
6
|
+
Hobo.asset_applicators = nil
|
7
|
+
Hobo.asset_applicators.should be_an_instance_of Hobo::AssetApplicatorRegistry
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return registry if exists" do
|
11
|
+
Hobo.asset_applicators.register "test" do
|
12
|
+
"test"
|
13
|
+
end
|
14
|
+
|
15
|
+
Hobo.asset_applicators["test"].should be_an_instance_of Proc
|
16
|
+
Hobo.asset_applicators["test"].call.should match "test"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "register" do
|
21
|
+
it "should store passed block with pattern" do
|
22
|
+
registry = Hobo::AssetApplicatorRegistry.new
|
23
|
+
registry.register "abc" do
|
24
|
+
"block"
|
25
|
+
end
|
26
|
+
|
27
|
+
registry["abc"].should be_an_instance_of Proc
|
28
|
+
registry["abc"].call.should match "block"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/hobo/cli_spec.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
1
2
|
require 'rake'
|
2
|
-
|
3
|
-
require 'hobo/metadata'
|
4
|
-
require 'hobo/patches/rake'
|
5
|
-
require 'hobo/patches/slop'
|
6
|
-
|
7
|
-
require 'hobo/errors'
|
8
|
-
require 'hobo/cli'
|
9
|
-
|
3
|
+
require 'hobo'
|
10
4
|
|
11
5
|
describe Hobo::Cli do
|
12
6
|
cli = nil
|
13
7
|
help = nil
|
8
|
+
hobofile = nil
|
14
9
|
|
15
10
|
before do
|
16
11
|
Rake::Task.tasks.each do |task|
|
@@ -19,117 +14,140 @@ describe Hobo::Cli do
|
|
19
14
|
Hobo.ui = double(Hobo::Ui).as_null_object
|
20
15
|
help = double(Hobo::HelpFormatter).as_null_object
|
21
16
|
cli = Hobo::Cli.new help: help
|
17
|
+
|
18
|
+
hobofile = File.read(File.join(File.dirname(__FILE__), '../../Hobofile'))
|
19
|
+
|
20
|
+
Hobo.project_path = nil
|
21
|
+
FakeFS.activate!
|
22
|
+
|
23
|
+
File.write('Hobofile', hobofile)
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
Rake::Task["test:non-interactive"].should_not be nil
|
28
|
-
end
|
26
|
+
after do
|
27
|
+
FakeFS::FileSystem.clear
|
28
|
+
FakeFS.deactivate!
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
cli.start ["test", "subcommand"]
|
35
|
-
end
|
31
|
+
it "should load the hobofile if present" do
|
32
|
+
cli.start []
|
33
|
+
Rake::Task["test:non-interactive"].should_not be nil
|
36
34
|
end
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
36
|
+
it "should load the user hobofile if present" do
|
37
|
+
FileUtils.mkdir_p(File.dirname(Hobo.user_hobofile_path))
|
38
|
+
File.write(Hobo.user_hobofile_path, "namespace :user do\ntask :user do\nend\nend")
|
39
|
+
cli.start []
|
40
|
+
Rake::Task["user:user"].should_not be nil
|
41
|
+
end
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
it "should load project config if present" do
|
44
|
+
FileUtils.mkdir_p("tools/hobo/")
|
45
|
+
File.write("tools/hobo/config.yaml", YAML::dump({ :project => "project_config" }))
|
46
|
+
cli.start []
|
47
|
+
Hobo.project_config.project.should match "project_config"
|
48
|
+
end
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
it "should load user config if present" do
|
51
|
+
FileUtils.mkdir_p(Hobo.config_path)
|
52
|
+
File.write(Hobo.user_config_file, YAML::dump({ :user => "user_config" }))
|
53
|
+
cli.start []
|
54
|
+
Hobo.user_config.user.should match "user_config"
|
55
|
+
end
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
map["test:metadata"].options.length.should be 2
|
65
|
-
expect(map["test:metadata"].options.map(&:short)).to eq [ 'o', 'h' ]
|
66
|
-
expect(map["test:metadata"].options.map(&:long)).to eq [ 'option', 'help' ]
|
67
|
-
expect(map["test:metadata"].options.map(&:description)).to eq [ 'Option description', 'Display help' ]
|
68
|
-
end
|
57
|
+
it "should set command map on help formatter" do
|
58
|
+
help.should_recieve('command_map=')
|
59
|
+
cli.start ["test", "subcommand"]
|
60
|
+
end
|
69
61
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
62
|
+
it "should propagate description metadata" do
|
63
|
+
map = nil
|
64
|
+
allow(help).to receive("command_map=") { |i| map = i }
|
65
|
+
cli.start []
|
66
|
+
map["test:metadata"].description.should match "description"
|
76
67
|
end
|
77
68
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
69
|
+
it "should propagate long description metadata" do
|
70
|
+
map = nil
|
71
|
+
allow(help).to receive("command_map=") { |i| map = i }
|
72
|
+
cli.start []
|
73
|
+
map["test:metadata"].long_description.should match "long description"
|
83
74
|
end
|
84
75
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
76
|
+
it "should propagate arg list metadata" do
|
77
|
+
map = nil
|
78
|
+
allow(help).to receive("command_map=") { |i| map = i }
|
79
|
+
cli.start []
|
80
|
+
expect(map["test:metadata"].arg_list).to eq [ :arg ]
|
81
|
+
end
|
90
82
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
83
|
+
it "should propagate option metadata" do
|
84
|
+
map = nil
|
85
|
+
allow(help).to receive("command_map=") { |i| map = i }
|
86
|
+
cli.start []
|
87
|
+
map["test:metadata"].options.length.should be 2
|
88
|
+
expect(map["test:metadata"].options.map(&:short)).to eq [ 'o', 'h' ]
|
89
|
+
expect(map["test:metadata"].options.map(&:long)).to eq [ 'option', 'help' ]
|
90
|
+
expect(map["test:metadata"].options.map(&:description)).to eq [ 'Option description', 'Display help' ]
|
91
|
+
end
|
95
92
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
93
|
+
it "should propagate hidden metadata" do
|
94
|
+
map = nil
|
95
|
+
allow(help).to receive("command_map=") { |i| map = i }
|
96
|
+
cli.start []
|
97
|
+
map["test:metadata"].hidden.should be true
|
98
|
+
end
|
100
99
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
100
|
+
it "should set non-interactive mode in ui if --non-interactive" do
|
101
|
+
Hobo.ui.should_receive('interactive=').with(false)
|
102
|
+
cli.start(['--non-interactive'])
|
103
|
+
end
|
105
104
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
it "should show help if no args or opts passed" do
|
106
|
+
help.should_receive(:help)
|
107
|
+
cli.start([])
|
108
|
+
end
|
110
109
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
110
|
+
it "should show help for --help" do
|
111
|
+
help.should_receive(:help)
|
112
|
+
cli.start ["--help"]
|
113
|
+
end
|
115
114
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
it "should execute a top level command" do
|
116
|
+
Hobo.ui.should_recieve(:info).with("top level")
|
117
|
+
cli.start ["top-level"]
|
118
|
+
end
|
120
119
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
120
|
+
it "should execute a subcommand" do
|
121
|
+
Hobo.ui.should_recieve(:info).with("Subcommand test")
|
122
|
+
cli.start ["test", "subcommand"]
|
123
|
+
end
|
125
124
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
125
|
+
it "should show help for a namespace" do
|
126
|
+
help.should_receive(:help).with(all: nil, target: "test")
|
127
|
+
cli.start ["test"]
|
128
|
+
end
|
130
129
|
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
it "should show command help for --help" do
|
131
|
+
help.should_receive(:help).with(all: nil, target: "test:subcommand")
|
132
|
+
cli.start ["test", "subcommand", "--help"]
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should propagate --all option to help" do
|
136
|
+
help.should_receive(:help).with(all: true, target: "test")
|
137
|
+
cli.start ["test", "--all"]
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should propagate command opts to command" do
|
141
|
+
Hobo.ui.should_receive(:info).with("1234")
|
142
|
+
cli.start ["test", "option-test", "--testing=1234"]
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should propagate arguments to command" do
|
146
|
+
Hobo.ui.should_receive(:info).with("1234")
|
147
|
+
cli.start ["test", "argument-test", "1234"]
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should raise an exception if not enough arguments were passed" do
|
151
|
+
expect { cli.start(["test", "metadata"]) }.to raise_error Hobo::MissingArgumentsError
|
134
152
|
end
|
135
153
|
end
|
@@ -28,16 +28,26 @@ describe Hobo::Config::File do
|
|
28
28
|
Hobo::Config::File.save "test.yaml", fake_config
|
29
29
|
File.read("test.yaml").should match /string: string/
|
30
30
|
end
|
31
|
+
|
32
|
+
it "should automatically unwrap deepstruct" do
|
33
|
+
Hobo::Config::File.save "test.yaml", DeepStruct.wrap(fake_config)
|
34
|
+
File.read("test.yaml").should match /string: string/
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
describe "load" do
|
39
|
+
it "should wrap loaded config with DeepStruct::HashWrapper" do
|
40
|
+
Hobo::Config::File.save "test.yaml", fake_config
|
41
|
+
Hobo::Config::File.load("test.yaml").should be_an_instance_of DeepStruct::HashWrapper
|
42
|
+
end
|
43
|
+
|
34
44
|
it "should load config hash from file" do
|
35
45
|
Hobo::Config::File.save "test.yaml", fake_config
|
36
|
-
fake_config().should eq Hobo::Config::File.load("test.yaml")
|
46
|
+
fake_config().should eq Hobo::Config::File.load("test.yaml").unwrap
|
37
47
|
end
|
38
48
|
|
39
|
-
it "should return empty
|
40
|
-
Hobo::Config::File.load("test.yaml").should eq({})
|
49
|
+
it "should return empty config if file does not exist" do
|
50
|
+
Hobo::Config::File.load("test.yaml").unwrap.should eq({})
|
41
51
|
end
|
42
52
|
|
43
53
|
it "should raise error if file can't be parsed" do
|
@@ -12,7 +12,7 @@ describe Hobo::HelpFormatter do
|
|
12
12
|
|
13
13
|
map["test"] = command "test" do
|
14
14
|
description "Testing1"
|
15
|
-
opt "-t", "--test", "Test description"
|
15
|
+
opt "-t", "--test", "Test description", :invertable => true
|
16
16
|
opt "-x", "--longer-option", "Longer option"
|
17
17
|
|
18
18
|
map["test:test"] = command "test" do
|
@@ -21,6 +21,18 @@ describe Hobo::HelpFormatter do
|
|
21
21
|
opt "-a=", "--a-test=", "Arg with value"
|
22
22
|
opt "-b=", "--b-test=", "Arg with optional value", argument: :optional
|
23
23
|
end
|
24
|
+
|
25
|
+
map["test:long_desc"] = command "long_desc" do
|
26
|
+
long_description "This is a long_desc"
|
27
|
+
end
|
28
|
+
|
29
|
+
map["test:desc"] = command "desc" do
|
30
|
+
description "This is a desc"
|
31
|
+
end
|
32
|
+
|
33
|
+
map["test:no_desc"] = command "no_desc" do
|
34
|
+
description nil
|
35
|
+
end
|
24
36
|
end
|
25
37
|
end
|
26
38
|
|
@@ -67,6 +79,10 @@ describe Hobo::HelpFormatter do
|
|
67
79
|
len = "--longer-option".length - "--test".length + 4 # ALIGN_PAD
|
68
80
|
help.help(target: "test").should match /\s+-t, --test\s{#{len}}Test description/
|
69
81
|
end
|
82
|
+
|
83
|
+
it "should include invertable note if option is invertable" do
|
84
|
+
help.help(target: "test").should match /--test.*\(Disable with --no-test\)/
|
85
|
+
end
|
70
86
|
end
|
71
87
|
|
72
88
|
describe "command format" do
|
@@ -104,28 +120,44 @@ describe Hobo::HelpFormatter do
|
|
104
120
|
end
|
105
121
|
|
106
122
|
describe "command" do
|
107
|
-
it "should include long command description if set"
|
108
|
-
|
109
|
-
|
110
|
-
it "should include usage"
|
111
|
-
it "should include global options"
|
112
|
-
it "should include command options"
|
113
|
-
it "shoult not include -h command option"
|
114
|
-
end
|
123
|
+
it "should include long command description if set" do
|
124
|
+
help.help(target: "test:long_desc").should match /^\s+This is a long_desc/
|
125
|
+
end
|
115
126
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
127
|
+
it "should fall back to short command description if long description not set" do
|
128
|
+
help.help(target: "test:desc").should match /^\s+This is a desc/
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should not display extra blank lines if no description set" do
|
132
|
+
help.help(target: "test:no_desc").should match /^Usage/m
|
133
|
+
end
|
121
134
|
|
122
|
-
|
123
|
-
|
135
|
+
it "should include usage" do
|
136
|
+
help.help(target: "test:no_desc").should match /Usage:/
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should include global options" do
|
140
|
+
help.help(target: "test:test").should match /^Global options:/
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should include command options" do
|
144
|
+
help.help(target: "test:test").should match /^Command options:/
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should not include -h command option" do
|
148
|
+
help.help(target: "test:test").should_not match /Command options:.*--help/m
|
149
|
+
end
|
124
150
|
end
|
125
151
|
|
152
|
+
|
126
153
|
describe "filtering" do
|
127
|
-
it "should not show commands that do not have descriptions"
|
128
|
-
|
154
|
+
it "should not show commands that do not have descriptions" do
|
155
|
+
help.help(target: "test").should_not match /Commands:.*no_desc/m
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should show commands that do not have descriptions if :all is set" do
|
159
|
+
help.help(target: "test", all: true).should match /Commands:.*no_desc/m
|
160
|
+
end
|
129
161
|
end
|
130
162
|
end
|
131
163
|
end
|
@@ -2,6 +2,10 @@ require 'hobo/helper/file_locator'
|
|
2
2
|
|
3
3
|
describe Hobo::Helper do
|
4
4
|
describe "locate" do
|
5
|
-
it "should
|
5
|
+
it "should yield filename and path for matches"
|
6
|
+
it "should match files in git"
|
7
|
+
it "should fallback to files not in git if no matches from git"
|
8
|
+
it "should chdir to file path before yielding"
|
9
|
+
it "should yield once for each matching file"
|
6
10
|
end
|
7
11
|
end
|
@@ -1,7 +1,21 @@
|
|
1
1
|
require 'hobo/helper/shell'
|
2
2
|
|
3
3
|
describe Hobo::Helper do
|
4
|
+
describe "bundle_shell" do
|
5
|
+
it "should execute command with bundle exec if bundle present"
|
6
|
+
it "should execte command normally if no bundle present"
|
7
|
+
end
|
8
|
+
|
4
9
|
describe "shell" do
|
5
|
-
it "should
|
10
|
+
it "should run the specified external command"
|
11
|
+
it "should return captured output if :capture specified"
|
12
|
+
it "should display output if :realtime specified"
|
13
|
+
it "should indent output if :realtime and :indent specified"
|
14
|
+
it "should apply block to each line if block passed"
|
15
|
+
it "should not display lines for which the filter block returned nil"
|
16
|
+
it "should buffer all command output in a temporary file"
|
17
|
+
it "should throw Hobo::ExternalCommandError on non-zero exit code"
|
18
|
+
it "should colour stderr output with red"
|
19
|
+
it "should set ENV args for command if specified with :env"
|
6
20
|
end
|
7
21
|
end
|