kicker 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kicker.rb +1 -1
- data/lib/kicker/growl.rb +4 -9
- data/lib/kicker/recipes/rails.rb +1 -1
- data/lib/kicker/recipes/ruby.rb +2 -18
- data/lib/kicker/utils.rb +48 -23
- data/lib/kicker/version.rb +1 -1
- metadata +3 -3
- data/lib/kicker/log_status_helper.rb +0 -38
data/lib/kicker.rb
CHANGED
@@ -5,7 +5,6 @@ require 'kicker/fsevents'
|
|
5
5
|
require 'kicker/callback_chain'
|
6
6
|
require 'kicker/core_ext'
|
7
7
|
require 'kicker/growl'
|
8
|
-
require 'kicker/log_status_helper'
|
9
8
|
require 'kicker/options'
|
10
9
|
require 'kicker/utils'
|
11
10
|
require 'kicker/recipes'
|
@@ -83,6 +82,7 @@ class Kicker #:nodoc:
|
|
83
82
|
|
84
83
|
def process(events)
|
85
84
|
unless (files = changed_files(events)).empty?
|
85
|
+
Utils.should_clear_screen = true
|
86
86
|
full_chain.call(files)
|
87
87
|
finished_processing!
|
88
88
|
end
|
data/lib/kicker/growl.rb
CHANGED
@@ -49,11 +49,7 @@ begin
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def change_occured(status)
|
52
|
-
growl(notifications[:change], 'Kicker: Executing', status.
|
53
|
-
end
|
54
|
-
|
55
|
-
def command_callback
|
56
|
-
lambda { system(command) } if command
|
52
|
+
growl(notifications[:change], 'Kicker: Executing', status.command)
|
57
53
|
end
|
58
54
|
|
59
55
|
def result(status)
|
@@ -61,14 +57,13 @@ begin
|
|
61
57
|
end
|
62
58
|
|
63
59
|
def succeeded(status)
|
64
|
-
|
65
|
-
|
66
|
-
growl(notifications[:succeeded], "Kicker: Success", body, &callback)
|
60
|
+
body = Kicker.silent? ? '' : status.output
|
61
|
+
growl(notifications[:succeeded], "Kicker: Success", body, &DEFAULT_CALLBACK)
|
67
62
|
end
|
68
63
|
|
69
64
|
def failed(status)
|
70
65
|
message = "Kicker: Failed (#{status.exit_code})"
|
71
|
-
body =
|
66
|
+
body = Kicker.silent? ? '' : status.output
|
72
67
|
growl(notifications[:failed], message, body, &DEFAULT_CALLBACK)
|
73
68
|
end
|
74
69
|
end
|
data/lib/kicker/recipes/rails.rb
CHANGED
data/lib/kicker/recipes/ruby.rb
CHANGED
@@ -73,16 +73,8 @@ class Kicker::Recipes::Ruby
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# Runs the given tests with `ruby' as unit-test tests.
|
76
|
-
#
|
77
|
-
# If you want to adjust the logging, stdout and growl, override this, call
|
78
|
-
# test_runner_command with the tests to get the command and call execute
|
79
|
-
# with the custom logging block.
|
80
76
|
def run_with_test_runner(tests)
|
81
|
-
execute(test_runner_command(tests))
|
82
|
-
if status.after? && status.growl?
|
83
|
-
status.output.split("\n").last
|
84
|
-
end
|
85
|
-
end
|
77
|
+
execute(test_runner_command(tests))
|
86
78
|
end
|
87
79
|
|
88
80
|
def spec_runner_command(tests)
|
@@ -90,16 +82,8 @@ class Kicker::Recipes::Ruby
|
|
90
82
|
end
|
91
83
|
|
92
84
|
# Runs the given tests with `spec' as RSpec tests.
|
93
|
-
#
|
94
|
-
# If you want to adjust the logging, stdout and growl, override this, call
|
95
|
-
# spec_runner_command with the tests to get the command and call execute
|
96
|
-
# with the custom logging block.
|
97
85
|
def run_with_spec_runner(tests)
|
98
|
-
execute(spec_runner_command(tests))
|
99
|
-
if status.after? && status.growl?
|
100
|
-
status.output.split("\n").last
|
101
|
-
end
|
102
|
-
end
|
86
|
+
execute(spec_runner_command(tests))
|
103
87
|
end
|
104
88
|
end
|
105
89
|
|
data/lib/kicker/utils.rb
CHANGED
@@ -1,22 +1,38 @@
|
|
1
1
|
require 'shellwords' if RUBY_VERSION >= "1.9"
|
2
2
|
|
3
3
|
class Kicker
|
4
|
+
Status = Struct.new(:command, :exit_code, :output) do
|
5
|
+
def success?
|
6
|
+
exit_code == 0
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
module Utils #:nodoc:
|
5
11
|
extend self
|
6
|
-
|
7
|
-
|
12
|
+
|
13
|
+
attr_accessor :should_clear_screen
|
14
|
+
alias_method :should_clear_screen?, :should_clear_screen
|
15
|
+
|
16
|
+
def perform_work(command)
|
8
17
|
@last_command = command
|
9
|
-
status =
|
18
|
+
status = Status.new(command, 0, '')
|
10
19
|
will_execute_command(status)
|
11
|
-
|
12
|
-
status.result(output, last_command_succeeded?, last_command_status)
|
20
|
+
yield status
|
13
21
|
did_execute_command(status)
|
22
|
+
status
|
14
23
|
end
|
15
|
-
|
24
|
+
|
25
|
+
def execute(command)
|
26
|
+
perform_work(command) do |status|
|
27
|
+
_execute(status)
|
28
|
+
yield status if block_given?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
16
32
|
def last_command
|
17
33
|
@last_command
|
18
34
|
end
|
19
|
-
|
35
|
+
|
20
36
|
def log(message)
|
21
37
|
if Kicker.quiet
|
22
38
|
puts message
|
@@ -31,27 +47,33 @@ class Kicker
|
|
31
47
|
end
|
32
48
|
|
33
49
|
def last_command_status
|
34
|
-
$?.
|
50
|
+
$?.exitstatus
|
35
51
|
end
|
36
|
-
|
52
|
+
|
53
|
+
def clear_console!
|
54
|
+
puts(CLEAR) if Kicker.clear_console?
|
55
|
+
end
|
56
|
+
|
37
57
|
private
|
38
|
-
|
58
|
+
|
39
59
|
CLEAR = "\e[H\e[2J"
|
40
60
|
|
41
|
-
def _execute(
|
61
|
+
def _execute(status)
|
42
62
|
silent = Kicker.silent?
|
43
63
|
unless silent
|
44
64
|
puts
|
45
65
|
sync_before, $stdout.sync = $stdout.sync, true
|
46
66
|
end
|
47
67
|
output = ""
|
48
|
-
popen(command) do |io|
|
68
|
+
popen(status.command) do |io|
|
49
69
|
while str = io.read(1)
|
50
70
|
output << str
|
51
71
|
$stdout.print str unless silent
|
52
72
|
end
|
53
73
|
end
|
54
|
-
output
|
74
|
+
status.output = output.strip
|
75
|
+
status.exit_code = last_command_status
|
76
|
+
status
|
55
77
|
ensure
|
56
78
|
unless silent
|
57
79
|
$stdout.sync = sync_before
|
@@ -70,20 +92,16 @@ class Kicker
|
|
70
92
|
end
|
71
93
|
|
72
94
|
def will_execute_command(status)
|
73
|
-
puts(CLEAR) if Kicker.clear_console?
|
74
|
-
|
75
|
-
|
95
|
+
puts(CLEAR) if Kicker.clear_console? && should_clear_screen?
|
96
|
+
@should_clear_screen = false
|
97
|
+
|
98
|
+
log "Executing: #{status.command}"
|
76
99
|
Kicker::Growl.change_occured(status) if Kicker::Growl.use? && !Kicker.silent?
|
77
100
|
end
|
78
101
|
|
79
102
|
def did_execute_command(status)
|
80
|
-
if
|
81
|
-
|
82
|
-
else
|
83
|
-
puts("\n#{status.output.strip}\n\n") if Kicker.silent? && !status.success?
|
84
|
-
log(status.success? ? "Success" : "Failed (#{status.exit_code})")
|
85
|
-
end
|
86
|
-
|
103
|
+
puts("\n#{status.output}\n\n") if Kicker.silent? && !status.success?
|
104
|
+
log(status.success? ? "Success" : "Failed (#{status.exit_code})")
|
87
105
|
Kicker::Growl.result(status) if Kicker::Growl.use?
|
88
106
|
end
|
89
107
|
end
|
@@ -95,6 +113,13 @@ module Kernel
|
|
95
113
|
Kicker::Utils.log(message)
|
96
114
|
end
|
97
115
|
|
116
|
+
# When you perform some work (like shelling out a command to run without
|
117
|
+
# using +execute+) you need to call this method, with a block in which you
|
118
|
+
# perform your work, which will take care of logging the work appropriately.
|
119
|
+
def perform_work(command, &block)
|
120
|
+
Kicker::Utils.perform_work(command, &block)
|
121
|
+
end
|
122
|
+
|
98
123
|
# Executes the +command+, logs the output, and optionally growls.
|
99
124
|
def execute(command, &block)
|
100
125
|
Kicker::Utils.execute(command, &block)
|
data/lib/kicker/version.rb
CHANGED
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.6.
|
4
|
+
version: 2.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: listen
|
@@ -140,7 +140,6 @@ files:
|
|
140
140
|
- lib/kicker/core_ext.rb
|
141
141
|
- lib/kicker/fsevents.rb
|
142
142
|
- lib/kicker/growl.rb
|
143
|
-
- lib/kicker/log_status_helper.rb
|
144
143
|
- lib/kicker/options.rb
|
145
144
|
- lib/kicker/recipes/could_not_handle_file.rb
|
146
145
|
- lib/kicker/recipes/dot_kick.rb
|
@@ -184,3 +183,4 @@ signing_key:
|
|
184
183
|
specification_version: 3
|
185
184
|
summary: A lean, agnostic, flexible file-change watcher.
|
186
185
|
test_files: []
|
186
|
+
has_rdoc:
|
@@ -1,38 +0,0 @@
|
|
1
|
-
class Kicker
|
2
|
-
class LogStatusHelper
|
3
|
-
attr_reader :command, :output, :exit_code
|
4
|
-
|
5
|
-
def initialize(proc, command)
|
6
|
-
@proc, @command, @output, @success = proc, command
|
7
|
-
end
|
8
|
-
|
9
|
-
def result(output, success, exit_code)
|
10
|
-
@output, @success, @exit_code = output, success, exit_code
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(logger_type)
|
14
|
-
@logger_type = logger_type
|
15
|
-
@proc.call(self) if @proc
|
16
|
-
end
|
17
|
-
|
18
|
-
def stdout?
|
19
|
-
@logger_type == :stdout
|
20
|
-
end
|
21
|
-
|
22
|
-
def growl?
|
23
|
-
@logger_type == :growl
|
24
|
-
end
|
25
|
-
|
26
|
-
def before?
|
27
|
-
@output.nil?
|
28
|
-
end
|
29
|
-
|
30
|
-
def after?
|
31
|
-
!before?
|
32
|
-
end
|
33
|
-
|
34
|
-
def success?
|
35
|
-
@success
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|