kicker 2.1.0 → 2.2.0
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/.gitignore +10 -0
- data/.kick +37 -0
- data/README.rdoc +24 -21
- data/Rakefile +0 -1
- data/TODO.rdoc +4 -34
- data/VERSION +1 -0
- data/html/images/kikker.jpg +0 -0
- data/kicker.gemspec +106 -0
- data/lib/kicker.rb +46 -60
- data/lib/kicker/callback_chain.rb +4 -4
- data/lib/kicker/core_ext.rb +9 -1
- data/lib/kicker/growl.rb +54 -19
- data/lib/kicker/log_status_helper.rb +38 -0
- data/lib/kicker/options.rb +59 -34
- data/lib/kicker/recipes.rb +58 -0
- data/lib/kicker/recipes/could_not_handle_file.rb +5 -3
- data/lib/kicker/recipes/dot_kick.rb +17 -5
- data/lib/kicker/recipes/execute_cli_command.rb +1 -1
- data/lib/kicker/recipes/ignore.rb +8 -6
- data/lib/kicker/recipes/jstest.rb +7 -5
- data/lib/kicker/recipes/rails.rb +108 -43
- data/lib/kicker/recipes/ruby.rb +155 -0
- data/lib/kicker/utils.rb +36 -32
- data/test/callback_chain_test.rb +1 -1
- data/test/core_ext_test.rb +15 -5
- data/test/filesystem_change_test.rb +1 -1
- data/test/growl_test.rb +85 -0
- data/test/initialization_test.rb +25 -56
- data/test/log_status_helper_test.rb +56 -0
- data/test/options_test.rb +50 -12
- data/test/recipes/could_not_handle_file_test.rb +10 -0
- data/test/recipes/dot_kick_test.rb +1 -5
- data/test/recipes/execute_cli_command_test.rb +3 -3
- data/test/recipes/ignore_test.rb +1 -1
- data/test/recipes/jstest_test.rb +1 -1
- data/test/recipes/rails_test.rb +118 -18
- data/test/recipes/ruby_test.rb +154 -0
- data/test/recipes_test.rb +39 -0
- data/test/test_helper.rb +1 -1
- data/test/utils_test.rb +103 -48
- metadata +19 -6
- data/VERSION.yml +0 -4
- data/lib/kicker/validate.rb +0 -24
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module ReloadDotKick; end
|
4
|
+
|
5
|
+
describe "Kicker::Recipes" do
|
6
|
+
before do
|
7
|
+
@recipes = Kicker::Recipes
|
8
|
+
end
|
9
|
+
|
10
|
+
if File.exist?(File.expand_path('~/.kick'))
|
11
|
+
it "should add ~/.kick to the load path" do
|
12
|
+
$:.should.include File.expand_path('~/.kick')
|
13
|
+
end
|
14
|
+
else
|
15
|
+
puts "[!] ~/.kick does not exist, skipping an example."
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should load a recipe" do
|
19
|
+
expected_recipe = @recipes.recipes.first
|
20
|
+
expected_recipe.last.expects(:call)
|
21
|
+
recipe expected_recipe.first
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should define a recipe load callback" do
|
25
|
+
called = false
|
26
|
+
recipe('new_recipe') { called = true }
|
27
|
+
assert !called
|
28
|
+
recipe(:new_recipe)
|
29
|
+
assert called
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should raise if a recipe does not exist" do
|
33
|
+
begin
|
34
|
+
recipe :foobar
|
35
|
+
rescue LoadError => e
|
36
|
+
e.message.should == "Recipe `foobar' does not exist."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/test/test_helper.rb
CHANGED
data/test/utils_test.rb
CHANGED
@@ -1,83 +1,148 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
|
+
Kicker::Utils.send(:public, :did_execute_command)
|
4
|
+
|
3
5
|
describe "A Kicker instance, concerning its utility methods" do
|
4
6
|
before do
|
5
|
-
|
6
|
-
|
7
|
+
utils.stubs(:puts)
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
Kicker.silent = false
|
12
|
+
Kicker::Growl.use = true
|
7
13
|
end
|
8
14
|
|
9
15
|
it "should print a log entry with timestamp" do
|
10
16
|
now = Time.now
|
11
17
|
Time.stubs(:now).returns(now)
|
12
18
|
|
13
|
-
utils.expects(:puts).with("
|
19
|
+
utils.expects(:puts).with("#{now.strftime('%H:%M:%S')}.#{now.usec.to_s[0,2]} | the message")
|
20
|
+
utils.send(:log, 'the message')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should print a log entry with no timestamp in quiet mode' do
|
24
|
+
before = Kicker.quiet
|
25
|
+
|
26
|
+
utils.expects(:puts).with('the message')
|
27
|
+
|
28
|
+
Kicker.quiet = true
|
14
29
|
utils.send(:log, 'the message')
|
30
|
+
|
31
|
+
Kicker.quiet = before
|
15
32
|
end
|
16
33
|
|
17
34
|
it "should log the output of the command indented by 2 spaces and whether or not the command succeeded" do
|
35
|
+
Kicker::Growl.use = false
|
36
|
+
|
18
37
|
utils.stubs(:`).returns("line 1\nline 2")
|
19
38
|
|
20
|
-
utils.
|
21
|
-
utils.expects(:log).with('
|
22
|
-
utils.expects(:
|
23
|
-
utils.expects(:log).with('
|
39
|
+
utils.stubs(:last_command_succeeded?).returns(true)
|
40
|
+
utils.expects(:log).with('Executing: ls')
|
41
|
+
utils.expects(:puts).with("\nline 1\nline 2\n\n")
|
42
|
+
utils.expects(:log).with('Success')
|
24
43
|
utils.execute('ls')
|
25
44
|
|
26
45
|
utils.stubs(:last_command_succeeded?).returns(false)
|
27
46
|
utils.stubs(:last_command_status).returns(123)
|
28
|
-
utils.expects(:log).with('
|
29
|
-
utils.expects(:
|
30
|
-
utils.expects(:log).with('
|
31
|
-
utils.expects(:log).with('Command failed (123)')
|
47
|
+
utils.expects(:log).with('Executing: ls')
|
48
|
+
utils.expects(:puts).with("\nline 1\nline 2\n\n")
|
49
|
+
utils.expects(:log).with('Failed (123)')
|
32
50
|
utils.execute('ls')
|
33
51
|
end
|
34
52
|
|
35
|
-
it "should
|
36
|
-
utils.stubs(:log)
|
37
|
-
|
53
|
+
it "should growl a change occurred and the output" do
|
38
54
|
utils.stubs(:`).returns("line 1\nline 2")
|
39
|
-
|
40
|
-
|
41
|
-
OSX::NSWorkspace.sharedWorkspace.expects(:launchApplication).with('Terminal').times(2)
|
55
|
+
utils.stubs(:last_command_succeeded?).returns(true)
|
56
|
+
utils.stubs(:log)
|
42
57
|
|
43
|
-
Kicker.expects(:
|
44
|
-
Kicker.expects(:
|
58
|
+
Kicker::Growl.expects(:change_occured).with { |status| status.command == 'ls' }
|
59
|
+
Kicker::Growl.expects(:result).with { |status| status.output == "line 1\nline 2" }
|
45
60
|
utils.execute('ls')
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should not growl that a change occured in silent mode" do
|
64
|
+
Kicker.silent = true
|
65
|
+
utils.stubs(:did_execute_command)
|
46
66
|
|
47
|
-
utils.
|
48
|
-
|
49
|
-
Kicker.expects(:growl).with(Kicker::GROWL_NOTIFICATIONS[:change], 'Kicker: Change occured, executing command:', 'ls')
|
50
|
-
Kicker.expects(:growl).with(Kicker::GROWL_NOTIFICATIONS[:failed], 'Kicker: Command failed (123)', "line 1\nline 2").yields
|
67
|
+
utils.expects(:log)
|
68
|
+
Kicker::Growl.expects(:change_occured).never
|
51
69
|
utils.execute('ls')
|
52
70
|
end
|
53
71
|
|
54
|
-
it "should
|
55
|
-
|
72
|
+
it "should only log that is has succeeded in silent mode" do
|
73
|
+
Kicker.silent = true
|
74
|
+
Kicker::Growl.expects(:result).with { |status| status.output == "line 1\nline 2" }
|
56
75
|
|
57
|
-
|
58
|
-
|
59
|
-
Kicker.growl_command = 'ls -l'
|
76
|
+
status = Kicker::LogStatusHelper.new(nil, 'ls -l')
|
77
|
+
status.result("line 1\nline 2", true, 0)
|
60
78
|
|
61
|
-
utils.expects(:
|
62
|
-
|
79
|
+
utils.expects(:log).with("Success")
|
80
|
+
utils.did_execute_command(status)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should fully log that it has failed in silent mode" do
|
84
|
+
Kicker.silent = true
|
85
|
+
Kicker::Growl.expects(:result).with { |status| status.output == "line 1\nline 2" }
|
63
86
|
|
64
|
-
|
65
|
-
|
66
|
-
utils.execute('ls')
|
87
|
+
utils.expects(:puts).with("\nline 1\nline 2\n\n")
|
88
|
+
utils.expects(:log).with('Failed (123)')
|
67
89
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
utils.execute('ls')
|
90
|
+
status = Kicker::LogStatusHelper.new(nil, 'ls -l')
|
91
|
+
status.result("line 1\nline 2", false, 123)
|
92
|
+
|
93
|
+
utils.did_execute_command(status)
|
73
94
|
end
|
74
95
|
|
75
96
|
it "should store the last executed command" do
|
97
|
+
Kicker::Growl.use = false
|
76
98
|
utils.stubs(:log)
|
99
|
+
|
77
100
|
utils.execute('date')
|
78
101
|
utils.last_command.should == 'date'
|
79
102
|
end
|
80
103
|
|
104
|
+
it "should call the block given to execute when and yield the log status helper with status success" do
|
105
|
+
Kicker.silent = true
|
106
|
+
Kicker::Growl.use = false
|
107
|
+
utils.stubs(:last_command_succeeded?).returns(true)
|
108
|
+
|
109
|
+
utils.expects(:log).with('Start!')
|
110
|
+
utils.expects(:log).with('Done!')
|
111
|
+
|
112
|
+
utils.execute('ls -l') do |status|
|
113
|
+
if status.after?
|
114
|
+
if status.success?
|
115
|
+
'Done!'
|
116
|
+
else
|
117
|
+
'Ohnoes!'
|
118
|
+
end
|
119
|
+
elsif status.before?
|
120
|
+
'Start!'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should call the block given to execute when and yield the log status helper with status failed" do
|
126
|
+
Kicker.silent = true
|
127
|
+
Kicker::Growl.use = false
|
128
|
+
utils.stubs(:last_command_succeeded?).returns(false)
|
129
|
+
|
130
|
+
utils.expects(:log).with('Start!')
|
131
|
+
utils.expects(:log).with('Ohnoes!')
|
132
|
+
|
133
|
+
utils.execute('ls -l') do |status|
|
134
|
+
if status.after?
|
135
|
+
if status.success?
|
136
|
+
'Done!'
|
137
|
+
else
|
138
|
+
'Ohnoes!'
|
139
|
+
end
|
140
|
+
elsif status.before?
|
141
|
+
'Start!'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
81
146
|
private
|
82
147
|
|
83
148
|
def utils
|
@@ -105,16 +170,6 @@ describe "Kernel utility methods" do
|
|
105
170
|
last_command.should == 'abcde'
|
106
171
|
end
|
107
172
|
|
108
|
-
it "should call execute with the appropriate command to execute Ruby tests" do
|
109
|
-
utils.expects(:execute).with("ruby -r test/1.rb -r test/2.rb -e ''")
|
110
|
-
run_ruby_tests %w{ test/1.rb test/2.rb }
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should not execute anything if an empty array is given to run_ruby_tests" do
|
114
|
-
utils.expects(:execute).never
|
115
|
-
run_ruby_tests []
|
116
|
-
end
|
117
|
-
|
118
173
|
private
|
119
174
|
|
120
175
|
def utils
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kicker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Duran
|
@@ -9,45 +9,52 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-11-29 00:00:00 +01:00
|
13
|
+
default_executable: kicker
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description:
|
17
17
|
email: eloy.de.enige@gmail.com
|
18
18
|
executables:
|
19
19
|
- kicker
|
20
|
-
- kicker
|
21
20
|
extensions: []
|
22
21
|
|
23
22
|
extra_rdoc_files:
|
24
23
|
- LICENSE
|
25
24
|
- README.rdoc
|
26
25
|
files:
|
26
|
+
- .gitignore
|
27
|
+
- .kick
|
27
28
|
- LICENSE
|
28
29
|
- README.rdoc
|
29
30
|
- Rakefile
|
30
31
|
- TODO.rdoc
|
31
|
-
- VERSION
|
32
|
+
- VERSION
|
32
33
|
- bin/kicker
|
34
|
+
- html/images/kikker.jpg
|
35
|
+
- kicker.gemspec
|
33
36
|
- lib/kicker.rb
|
34
37
|
- lib/kicker/callback_chain.rb
|
35
38
|
- lib/kicker/core_ext.rb
|
36
39
|
- lib/kicker/growl.rb
|
40
|
+
- lib/kicker/log_status_helper.rb
|
37
41
|
- lib/kicker/options.rb
|
42
|
+
- lib/kicker/recipes.rb
|
38
43
|
- lib/kicker/recipes/could_not_handle_file.rb
|
39
44
|
- lib/kicker/recipes/dot_kick.rb
|
40
45
|
- lib/kicker/recipes/execute_cli_command.rb
|
41
46
|
- lib/kicker/recipes/ignore.rb
|
42
47
|
- lib/kicker/recipes/jstest.rb
|
43
48
|
- lib/kicker/recipes/rails.rb
|
49
|
+
- lib/kicker/recipes/ruby.rb
|
44
50
|
- lib/kicker/utils.rb
|
45
|
-
- lib/kicker/validate.rb
|
46
51
|
- test/callback_chain_test.rb
|
47
52
|
- test/core_ext_test.rb
|
48
53
|
- test/filesystem_change_test.rb
|
49
54
|
- test/fixtures/a_file_thats_reloaded.rb
|
55
|
+
- test/growl_test.rb
|
50
56
|
- test/initialization_test.rb
|
57
|
+
- test/log_status_helper_test.rb
|
51
58
|
- test/options_test.rb
|
52
59
|
- test/recipes/could_not_handle_file_test.rb
|
53
60
|
- test/recipes/dot_kick_test.rb
|
@@ -55,6 +62,8 @@ files:
|
|
55
62
|
- test/recipes/ignore_test.rb
|
56
63
|
- test/recipes/jstest_test.rb
|
57
64
|
- test/recipes/rails_test.rb
|
65
|
+
- test/recipes/ruby_test.rb
|
66
|
+
- test/recipes_test.rb
|
58
67
|
- test/test_helper.rb
|
59
68
|
- test/utils_test.rb
|
60
69
|
- vendor/growlnotifier/growl.rb
|
@@ -94,7 +103,9 @@ test_files:
|
|
94
103
|
- test/core_ext_test.rb
|
95
104
|
- test/filesystem_change_test.rb
|
96
105
|
- test/fixtures/a_file_thats_reloaded.rb
|
106
|
+
- test/growl_test.rb
|
97
107
|
- test/initialization_test.rb
|
108
|
+
- test/log_status_helper_test.rb
|
98
109
|
- test/options_test.rb
|
99
110
|
- test/recipes/could_not_handle_file_test.rb
|
100
111
|
- test/recipes/dot_kick_test.rb
|
@@ -102,5 +113,7 @@ test_files:
|
|
102
113
|
- test/recipes/ignore_test.rb
|
103
114
|
- test/recipes/jstest_test.rb
|
104
115
|
- test/recipes/rails_test.rb
|
116
|
+
- test/recipes/ruby_test.rb
|
117
|
+
- test/recipes_test.rb
|
105
118
|
- test/test_helper.rb
|
106
119
|
- test/utils_test.rb
|
data/VERSION.yml
DELETED
data/lib/kicker/validate.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
class Kicker
|
2
|
-
private
|
3
|
-
|
4
|
-
def validate_options!
|
5
|
-
validate_paths_and_command!
|
6
|
-
validate_paths_exist!
|
7
|
-
end
|
8
|
-
|
9
|
-
def validate_paths_and_command!
|
10
|
-
if process_chain.empty? && pre_process_chain.empty?
|
11
|
-
puts OPTION_PARSER_CALLBACK.call(nil).help
|
12
|
-
exit
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def validate_paths_exist!
|
17
|
-
@paths.each do |path|
|
18
|
-
unless File.exist?(path)
|
19
|
-
puts "The given path `#{path}' does not exist"
|
20
|
-
exit 1
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|