hem 1.0.1.beta1
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 +7 -0
- data/.editorconfig +10 -0
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +125 -0
- data/DoD.md +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +71 -0
- data/Guardfile +14 -0
- data/Hemfile +43 -0
- data/LICENSE +21 -0
- data/README.md +42 -0
- data/Rakefile +23 -0
- data/bin/hem +64 -0
- data/features/deps.feature +43 -0
- data/features/hem/basic.feature +43 -0
- data/features/hem/help.feature +16 -0
- data/features/hem/subcommands.feature +15 -0
- data/features/seed/plant.feature +64 -0
- data/features/step_definitions/env.rb +6 -0
- data/features/step_definitions/seed.rb +11 -0
- data/features/support/env.rb +6 -0
- data/hem.gemspec +47 -0
- data/lib/hem/asset_applicator.rb +33 -0
- data/lib/hem/asset_applicators/files.rb +5 -0
- data/lib/hem/asset_applicators/sqldump.rb +38 -0
- data/lib/hem/cli.rb +252 -0
- data/lib/hem/config/file.rb +22 -0
- data/lib/hem/config.rb +5 -0
- data/lib/hem/error_handlers/debug.rb +12 -0
- data/lib/hem/error_handlers/exit_code_map.rb +17 -0
- data/lib/hem/error_handlers/friendly.rb +58 -0
- data/lib/hem/errors.rb +89 -0
- data/lib/hem/help_formatter.rb +118 -0
- data/lib/hem/helper/file_locator.rb +44 -0
- data/lib/hem/helper/github.rb +10 -0
- data/lib/hem/helper/http_download.rb +41 -0
- data/lib/hem/helper/shell.rb +101 -0
- data/lib/hem/helper/vm_command.rb +30 -0
- data/lib/hem/lib/github/api.rb +48 -0
- data/lib/hem/lib/github/client.rb +52 -0
- data/lib/hem/lib/host_check/deps.rb +39 -0
- data/lib/hem/lib/host_check/git.rb +76 -0
- data/lib/hem/lib/host_check/ruby.rb +53 -0
- data/lib/hem/lib/host_check/vagrant.rb +45 -0
- data/lib/hem/lib/host_check.rb +34 -0
- data/lib/hem/lib/s3/local/file.rb +40 -0
- data/lib/hem/lib/s3/local/iohandler.rb +36 -0
- data/lib/hem/lib/s3/remote/file.rb +57 -0
- data/lib/hem/lib/s3/remote/iohandler.rb +38 -0
- data/lib/hem/lib/s3/sync.rb +134 -0
- data/lib/hem/lib/seed/project.rb +71 -0
- data/lib/hem/lib/seed/replacer.rb +56 -0
- data/lib/hem/lib/seed/seed.rb +111 -0
- data/lib/hem/lib/self_signed_cert_generator.rb +38 -0
- data/lib/hem/lib/vm/command.rb +131 -0
- data/lib/hem/lib/vm/inspector.rb +73 -0
- data/lib/hem/logging.rb +20 -0
- data/lib/hem/metadata.rb +42 -0
- data/lib/hem/null.rb +31 -0
- data/lib/hem/patches/deepstruct.rb +21 -0
- data/lib/hem/patches/rake.rb +101 -0
- data/lib/hem/patches/rubygems.rb +6 -0
- data/lib/hem/patches/slop.rb +69 -0
- data/lib/hem/paths.rb +96 -0
- data/lib/hem/tasks/assets.rb +92 -0
- data/lib/hem/tasks/config.rb +15 -0
- data/lib/hem/tasks/deps.rb +103 -0
- data/lib/hem/tasks/exec.rb +3 -0
- data/lib/hem/tasks/magento.rb +281 -0
- data/lib/hem/tasks/ops.rb +6 -0
- data/lib/hem/tasks/pr.rb +45 -0
- data/lib/hem/tasks/seed.rb +61 -0
- data/lib/hem/tasks/self.rb +45 -0
- data/lib/hem/tasks/shell_init.rb +25 -0
- data/lib/hem/tasks/system/completions.rb +76 -0
- data/lib/hem/tasks/system.rb +18 -0
- data/lib/hem/tasks/tools.rb +17 -0
- data/lib/hem/tasks/vm.rb +140 -0
- data/lib/hem/ui.rb +182 -0
- data/lib/hem/util.rb +76 -0
- data/lib/hem/version.rb +3 -0
- data/lib/hem.rb +72 -0
- data/lib/hobo/tasks/magento.rb +3 -0
- data/spec/hem/asset_applicator_spec.rb +30 -0
- data/spec/hem/cli_spec.rb +166 -0
- data/spec/hem/config/file_spec.rb +55 -0
- data/spec/hem/error_handlers/debug_spec.rb +43 -0
- data/spec/hem/error_handlers/friendly_spec.rb +97 -0
- data/spec/hem/error_spec.rb +0 -0
- data/spec/hem/help_formatter_spec.rb +162 -0
- data/spec/hem/helpers/file_locator_spec.rb +11 -0
- data/spec/hem/helpers/github_spec.rb +31 -0
- data/spec/hem/helpers/shell_spec.rb +22 -0
- data/spec/hem/helpers/vm_command_spec.rb +96 -0
- data/spec/hem/lib/github/api_spec.rb +92 -0
- data/spec/hem/lib/s3/sync_spec.rb +16 -0
- data/spec/hem/lib/seed/project_spec.rb +80 -0
- data/spec/hem/lib/seed/replacer_spec.rb +45 -0
- data/spec/hem/lib/seed/seed_spec.rb +127 -0
- data/spec/hem/logging_spec.rb +27 -0
- data/spec/hem/metadata_spec.rb +55 -0
- data/spec/hem/null_spec.rb +30 -0
- data/spec/hem/patches/rake_spec.rb +230 -0
- data/spec/hem/paths_spec.rb +75 -0
- data/spec/hem/ui_spec.rb +189 -0
- data/spec/hem/util_spec.rb +74 -0
- data/spec/spec_helper.rb +12 -0
- data/ssl/ca-bundle-s3.crt +3554 -0
- data/test_files/vagrant_fail/vagrant +2 -0
- metadata +339 -0
data/spec/hem/ui_spec.rb
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
|
|
2
|
+
describe Hem::Ui do
|
|
3
|
+
def test_ui opts = {}
|
|
4
|
+
opts = {
|
|
5
|
+
:answer => "",
|
|
6
|
+
:output => StringIO.new,
|
|
7
|
+
:error => StringIO.new,
|
|
8
|
+
:eof => false
|
|
9
|
+
}.merge(opts)
|
|
10
|
+
|
|
11
|
+
input = StringIO.new
|
|
12
|
+
input << opts[:answer]
|
|
13
|
+
input.rewind unless opts[:eof]
|
|
14
|
+
Hem.ui = ui = Hem::Ui.new(input, opts[:output], opts[:error])
|
|
15
|
+
ui.interactive = true
|
|
16
|
+
return ui
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
before do
|
|
20
|
+
HighLine.use_color = false
|
|
21
|
+
Hem.logger = Logger.new(nil)
|
|
22
|
+
Hem.logger.level = Logger::WARN
|
|
23
|
+
double(Hem.logger)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "initialization" do
|
|
27
|
+
it "should provide default color scheme"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "ask" do
|
|
31
|
+
it "should return default if in non-interactive mode" do
|
|
32
|
+
ui = test_ui()
|
|
33
|
+
ui.interactive = false
|
|
34
|
+
ui.ask("Question", :default => "default").should match "default"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should raise error if no default provided in non-interactive mode" do
|
|
38
|
+
ui = test_ui(:answer => "Answer\n")
|
|
39
|
+
ui.interactive = false
|
|
40
|
+
expect { ui.ask("Question") }.to raise_exception(Hem::NonInteractiveError)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should format prompt to include default if provided" do
|
|
44
|
+
output = StringIO.new
|
|
45
|
+
output.should_receive(:write).with(/Question \[default\]:/)
|
|
46
|
+
test_ui(:output => output).ask("Question", :default => "default")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should use default answer if given answer is empty" do
|
|
50
|
+
test_ui(:answer => "\n").ask("Question", :default => "default").should match "default"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should handle stdin EOF (Ctrl+d)" do
|
|
54
|
+
test_ui(:eof => true).ask("Question").should be_empty
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should always return an instance of String" do
|
|
58
|
+
test_ui(:answer => "Answer\n").ask("Question").should be_an_instance_of String
|
|
59
|
+
test_ui(:answer => "\n").ask("Question", :default => "").should be_an_instance_of String
|
|
60
|
+
test_ui(:answer => "\x04").ask("Question").should be_an_instance_of String
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should support hidden text for password inputs"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe "ask_choice" do
|
|
67
|
+
it "should return default if in non-interactive mode" do
|
|
68
|
+
ui = test_ui()
|
|
69
|
+
ui.interactive = false
|
|
70
|
+
ui.ask_choice("Question", ['default', 'non-default'], :default => "default").should match "default"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should raise error if no default provided in non-interactive mode" do
|
|
74
|
+
ui = test_ui(:answer => "Answer\n")
|
|
75
|
+
ui.interactive = false
|
|
76
|
+
expect { ui.ask_choice("Question", ['one', 'two']) }.to raise_exception(Hem::NonInteractiveError)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "should format prompt to include default if provided"
|
|
80
|
+
|
|
81
|
+
it "should give a choice prompt with each option in"
|
|
82
|
+
|
|
83
|
+
it "should convert a number choice to its value if given" do
|
|
84
|
+
test_ui(:answer => "2\n").ask_choice("Question", ['default', 'non-default'], :default => "default").should match "non-default"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should use default answer if given answer is empty" do
|
|
88
|
+
test_ui(:answer => "\n").ask_choice("Question", ['default', 'non-default'], :default => "default").should match "default"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should handle stdin EOF (Ctrl+d)" do
|
|
92
|
+
test_ui(:eof => true).ask_choice("Question", ['default', 'non-default']).should be_empty
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should always return an instance of String" do
|
|
96
|
+
test_ui(:answer => "Answer\n").ask_choice("Question", ['Answer']).should be_an_instance_of String
|
|
97
|
+
test_ui(:answer => "\n").ask_choice("Question", ['Answer'], :default => "").should be_an_instance_of String
|
|
98
|
+
test_ui(:answer => "\x04").ask_choice("Question", ['Answer']).should be_an_instance_of String
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe "color" do
|
|
103
|
+
it "should format message with ansi style" do
|
|
104
|
+
ui = test_ui
|
|
105
|
+
ui.use_color true
|
|
106
|
+
ui.color("test", :red).should match /\e\[31mtest\e\[0m/
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe "use_color" do
|
|
111
|
+
it "should set the use of color" do
|
|
112
|
+
ui = test_ui
|
|
113
|
+
ui.use_color true
|
|
114
|
+
ui.color("test", :red).should match /\e\[31mtest\e\[0m/
|
|
115
|
+
ui.use_color false
|
|
116
|
+
ui.color("test", :red).should match /^test$/
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
describe "color_scheme" do
|
|
121
|
+
it "should set the global color scheme if argument provided"
|
|
122
|
+
it "should return the global color scheme"
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
describe "debug" do
|
|
126
|
+
it "should send message to stdout" do
|
|
127
|
+
output = StringIO.new
|
|
128
|
+
output.should receive(:puts).with("test")
|
|
129
|
+
test_ui(:output => output).debug("test")
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it "should log to logger" do
|
|
133
|
+
Hem.logger.should_receive(:debug).with("test")
|
|
134
|
+
test_ui.debug("test")
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
describe "info" do
|
|
139
|
+
it "should send message to stdout" do
|
|
140
|
+
output = StringIO.new
|
|
141
|
+
output.should receive(:puts).with("test")
|
|
142
|
+
test_ui(:output => output).info("test")
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it "should log to logger" do
|
|
146
|
+
Hem.logger.should_receive(:debug).with("test")
|
|
147
|
+
test_ui.info("test")
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe "warning" do
|
|
152
|
+
it "should send message to stderr" do
|
|
153
|
+
error = StringIO.new
|
|
154
|
+
error.should receive(:puts).with("test")
|
|
155
|
+
test_ui(:error => error).warning("test")
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "should log to logger" do
|
|
159
|
+
Hem.logger.should_receive(:debug).with("test")
|
|
160
|
+
test_ui.warning("test")
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
describe "error" do
|
|
165
|
+
it "should send message to stderr" do
|
|
166
|
+
error = StringIO.new
|
|
167
|
+
error.should receive(:puts).with("test")
|
|
168
|
+
test_ui(:error => error).error("test")
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "should log to logger" do
|
|
172
|
+
Hem.logger.should_receive(:debug).with("test")
|
|
173
|
+
test_ui.error("test")
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
describe "success" do
|
|
178
|
+
it "should send message to stdout" do
|
|
179
|
+
output = StringIO.new
|
|
180
|
+
output.should receive(:puts).with("test")
|
|
181
|
+
test_ui(:output => output).success("test")
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it "should log to logger" do
|
|
185
|
+
Hem.logger.should_receive(:debug).with("test")
|
|
186
|
+
test_ui.success("test")
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
describe Hem do
|
|
3
|
+
describe "in_project?" do
|
|
4
|
+
it "should return true if project path detected" do
|
|
5
|
+
Hem.project_path = "test"
|
|
6
|
+
Hem.in_project?.should be true
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should return false if no project path detected" do
|
|
10
|
+
Hem.project_path = false
|
|
11
|
+
Hem.in_project?.should be false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "progress" do
|
|
16
|
+
def progress_mock file, increment, total, type
|
|
17
|
+
out = double(StringIO.new).as_null_object
|
|
18
|
+
out.stub(:tty?).and_return(true)
|
|
19
|
+
Hem.progress(file, increment, total, type, :throttle_rate => nil, :output => out)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
before do
|
|
23
|
+
Hem.project_bar_cache = {}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should create new progress bar if one does not exist" do
|
|
27
|
+
bar = progress_mock("test", 0, 10, :update)
|
|
28
|
+
bar.to_s.should match /^test.*0%/
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should force width to 79 if windows" do
|
|
32
|
+
Gem.should_receive(:win_platform?).and_return(true)
|
|
33
|
+
bar = progress_mock("test:79", 0, 10, :update)
|
|
34
|
+
bar.to_s.length.should eq 79
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should update progress bar if type :update" do
|
|
38
|
+
bar = progress_mock("test:update", 0, 10, :update)
|
|
39
|
+
bar.to_s.should match /^test:update.*0%/
|
|
40
|
+
|
|
41
|
+
Hem.progress("test:update", 1, 10, :update)
|
|
42
|
+
bar.to_s.should match /^test.update.*10%/
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should increment progress by specified amount if type :update" do
|
|
46
|
+
bar = progress_mock("test:increment", 0, 10, :update)
|
|
47
|
+
bar.to_s.should match /^test:increment.*0%/
|
|
48
|
+
|
|
49
|
+
Hem.progress("test:increment", 1, 10, :update)
|
|
50
|
+
bar.to_s.should match /^test:increment.*10%/
|
|
51
|
+
|
|
52
|
+
Hem.progress("test:increment", 1, 10, :update)
|
|
53
|
+
bar.to_s.should match /^test:increment.*20%/
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should finalize progress bar if type :finish" do
|
|
57
|
+
bar = progress_mock("test:finish", 0, 10, :update)
|
|
58
|
+
bar.to_s.should match /^test:finish.*0%/
|
|
59
|
+
Hem.progress("test:finish", 10, 10, :update)
|
|
60
|
+
Hem.progress("test:finish", 10, 10, :finish)
|
|
61
|
+
bar.to_s.should match /^test:finish.*100%.*Time/
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should set fixed format" do
|
|
65
|
+
bar = progress_mock("test:format", 1, 10, :update)
|
|
66
|
+
bar.to_s.should match /^test:format \[=+\s+\]\s+10%\s+ETA: 00:00:00/
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should use filename as title" do
|
|
70
|
+
bar = progress_mock("some/path/to/filename.ext", 1, 10, :update)
|
|
71
|
+
bar.to_s.should match /^filename\.ext/
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|