kicker 3.0.0 → 4.0.0.p1
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/COPYING +20 -0
- data/README.rdoc +0 -150
- data/bin/kicker +1 -3
- data/lib/kicker.rb +16 -117
- data/lib/kicker/cli.rb +130 -0
- data/lib/kicker/core_ext/array.rb +40 -0
- data/lib/kicker/debug.rb +5 -0
- data/lib/kicker/deprecated.rb +14 -0
- data/lib/kicker/formatter.rb +15 -0
- data/lib/kicker/option_parser.rb +37 -0
- data/lib/kicker/recipe/ignore.rb +2 -0
- data/lib/kicker/recipe/peck.rb +54 -0
- data/lib/kicker/recipe/reload.rb +0 -0
- data/lib/kicker/{recipes → recipe}/ruby.rb +10 -10
- data/lib/kicker/script.rb +77 -0
- data/lib/kicker/version.rb +2 -2
- data/lib/kicker/watcher.rb +113 -0
- metadata +32 -120
- data/LICENSE +0 -54
- data/lib/kicker/callback_chain.rb +0 -95
- data/lib/kicker/core_ext.rb +0 -38
- data/lib/kicker/fsevents.rb +0 -36
- data/lib/kicker/job.rb +0 -57
- data/lib/kicker/notification.rb +0 -31
- data/lib/kicker/options.rb +0 -96
- data/lib/kicker/recipes.rb +0 -98
- data/lib/kicker/recipes/could_not_handle_file.rb +0 -7
- data/lib/kicker/recipes/dot_kick.rb +0 -47
- data/lib/kicker/recipes/execute_cli_command.rb +0 -9
- data/lib/kicker/recipes/ignore.rb +0 -41
- data/lib/kicker/recipes/jstest.rb +0 -10
- data/lib/kicker/recipes/rails.rb +0 -109
- data/lib/kicker/utils.rb +0 -127
@@ -1,47 +0,0 @@
|
|
1
|
-
module ReloadDotKick #:nodoc
|
2
|
-
class << self
|
3
|
-
def save_state
|
4
|
-
@features_before_dot_kick = $LOADED_FEATURES.dup
|
5
|
-
@chains_before_dot_kick = Kicker.full_chain.map { |c| c.dup }
|
6
|
-
end
|
7
|
-
|
8
|
-
def call(files)
|
9
|
-
reset! if files.delete('.kick')
|
10
|
-
end
|
11
|
-
|
12
|
-
def use?
|
13
|
-
File.exist?('.kick')
|
14
|
-
end
|
15
|
-
|
16
|
-
def load!
|
17
|
-
load '.kick'
|
18
|
-
end
|
19
|
-
|
20
|
-
def reset!
|
21
|
-
remove_loaded_features!
|
22
|
-
reset_chains!
|
23
|
-
load!
|
24
|
-
end
|
25
|
-
|
26
|
-
def reset_chains!
|
27
|
-
Kicker.full_chain = nil
|
28
|
-
|
29
|
-
chains = @chains_before_dot_kick.map { |c| c.dup }
|
30
|
-
Kicker.pre_process_chain, Kicker.process_chain, Kicker.post_process_chain = *chains
|
31
|
-
end
|
32
|
-
|
33
|
-
def remove_loaded_features!
|
34
|
-
($LOADED_FEATURES - @features_before_dot_kick).each do |feat|
|
35
|
-
$LOADED_FEATURES.delete(feat)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
if ReloadDotKick.use?
|
42
|
-
startup do
|
43
|
-
pre_process ReloadDotKick
|
44
|
-
ReloadDotKick.save_state
|
45
|
-
ReloadDotKick.load!
|
46
|
-
end
|
47
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# A recipe which removes files from the files array, thus “ignoring” them.
|
2
|
-
#
|
3
|
-
# By default ignores logs, tmp, and svn and git files.
|
4
|
-
#
|
5
|
-
# See Kernel#ignore for info on how to ignore files.
|
6
|
-
module Ignore
|
7
|
-
def self.call(files) #:nodoc:
|
8
|
-
files.reject! { |file| ignores.any? { |ignore| file =~ ignore } }
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.ignores #:nodoc:
|
12
|
-
@ignores ||= []
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.ignore(regexp_or_string) #:nodoc:
|
16
|
-
ignores << (regexp_or_string.is_a?(Regexp) ? regexp_or_string : /^#{regexp_or_string}$/)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module Kernel
|
21
|
-
# Adds +regexp_or_string+ as an ignore rule.
|
22
|
-
#
|
23
|
-
# require 'ignore'
|
24
|
-
#
|
25
|
-
# ignore /^data\//
|
26
|
-
# ignore 'Rakefile'
|
27
|
-
#
|
28
|
-
# <em>Only available if the `ignore' recipe is required.</em>
|
29
|
-
def ignore(regexp_or_string)
|
30
|
-
Ignore.ignore(regexp_or_string)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
recipe :ignore do
|
35
|
-
pre_process Ignore
|
36
|
-
|
37
|
-
ignore("tmp")
|
38
|
-
ignore(/\w+\.log/)
|
39
|
-
ignore(/\.(svn|git)\//)
|
40
|
-
ignore("svn-commit.tmp")
|
41
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
recipe :jstest do
|
2
|
-
process do |files|
|
3
|
-
test_files = files.take_and_map do |file|
|
4
|
-
if file =~ %r{^(test|public)/javascripts/(\w+?)(_test)*\.(js|html)$}
|
5
|
-
"test/javascripts/#{$2}_test.html"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
execute "jstest #{test_files.join(' ')}" unless test_files.empty?
|
9
|
-
end
|
10
|
-
end
|
data/lib/kicker/recipes/rails.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
recipe :ruby
|
2
|
-
|
3
|
-
class Kicker::Recipes::Rails < Kicker::Recipes::Ruby
|
4
|
-
class << self
|
5
|
-
# Call these options on the Ruby class which takes the cli options.
|
6
|
-
%w{ test_type runner_bin test_cases_root test_options }.each do |delegate|
|
7
|
-
define_method(delegate) { Kicker::Recipes::Ruby.send(delegate) }
|
8
|
-
end
|
9
|
-
|
10
|
-
# Maps +type+, for instance `models', to a test directory.
|
11
|
-
def type_to_test_dir(type)
|
12
|
-
if test_type == 'test'
|
13
|
-
case type
|
14
|
-
when "models"
|
15
|
-
"unit"
|
16
|
-
when "concerns"
|
17
|
-
"unit/concerns"
|
18
|
-
when "controllers", "views"
|
19
|
-
"functional"
|
20
|
-
when "helpers"
|
21
|
-
"unit/helpers"
|
22
|
-
end
|
23
|
-
elsif test_type == 'spec'
|
24
|
-
case type
|
25
|
-
when "models"
|
26
|
-
"models"
|
27
|
-
when "concerns"
|
28
|
-
"models/concerns"
|
29
|
-
when "controllers", "views"
|
30
|
-
"controllers"
|
31
|
-
when "helpers"
|
32
|
-
"helpers"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Returns an array consiting of all controller tests.
|
38
|
-
def all_controller_tests
|
39
|
-
if test_type == 'test'
|
40
|
-
Dir.glob("#{test_cases_root}/functional/**/*_test.rb")
|
41
|
-
else
|
42
|
-
Dir.glob("#{test_cases_root}/controllers/**/*_spec.rb")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Returns an array of all tests related to the given model.
|
48
|
-
def tests_for_model(model)
|
49
|
-
if test_type == 'test'
|
50
|
-
%W{
|
51
|
-
unit/#{ActiveSupport::Inflector.singularize(model)}
|
52
|
-
unit/helpers/#{ActiveSupport::Inflector.pluralize(model)}_helper
|
53
|
-
functional/#{ActiveSupport::Inflector.pluralize(model)}_controller
|
54
|
-
}
|
55
|
-
else
|
56
|
-
%W{
|
57
|
-
models/#{ActiveSupport::Inflector.singularize(model)}
|
58
|
-
helpers/#{ActiveSupport::Inflector.pluralize(model)}_helper
|
59
|
-
controllers/#{ActiveSupport::Inflector.pluralize(model)}_controller
|
60
|
-
}
|
61
|
-
end.map { |f| test_file f }
|
62
|
-
end
|
63
|
-
|
64
|
-
def handle!
|
65
|
-
@tests.concat(@files.take_and_map do |file|
|
66
|
-
case file
|
67
|
-
# Run all functional tests when routes.rb is saved
|
68
|
-
when 'config/routes.rb'
|
69
|
-
Kicker::Recipes::Rails.all_controller_tests
|
70
|
-
|
71
|
-
# Match lib/*
|
72
|
-
when /^(lib\/.+)\.rb$/
|
73
|
-
test_file($1)
|
74
|
-
|
75
|
-
# Map fixtures to their related tests
|
76
|
-
when %r{^#{test_cases_root}/fixtures/(\w+)\.yml$}
|
77
|
-
tests_for_model($1)
|
78
|
-
|
79
|
-
# Match any file in app/ and map it to a test file
|
80
|
-
when %r{^app/(\w+)([\w/]*)/([\w\.]+)\.\w+$}
|
81
|
-
type, namespace, file = $1, $2, $3
|
82
|
-
|
83
|
-
if dir = Kicker::Recipes::Rails.type_to_test_dir(type)
|
84
|
-
if type == "views"
|
85
|
-
namespace = namespace.split('/')[1..-1]
|
86
|
-
file = "#{namespace.pop}_controller"
|
87
|
-
end
|
88
|
-
|
89
|
-
test_file File.join(dir, namespace, file)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end)
|
93
|
-
|
94
|
-
# And let the Ruby handler match other stuff.
|
95
|
-
super
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
recipe :rails do
|
100
|
-
require 'rubygems' rescue LoadError
|
101
|
-
require 'active_support/inflector'
|
102
|
-
|
103
|
-
process Kicker::Recipes::Rails
|
104
|
-
|
105
|
-
# When changing the schema, prepare the test database.
|
106
|
-
process do |files|
|
107
|
-
execute 'rake db:test:prepare' if files.delete('db/schema.rb')
|
108
|
-
end
|
109
|
-
end
|
data/lib/kicker/utils.rb
DELETED
@@ -1,127 +0,0 @@
|
|
1
|
-
require 'shellwords' if RUBY_VERSION >= "1.9"
|
2
|
-
|
3
|
-
class Kicker
|
4
|
-
module Utils #:nodoc:
|
5
|
-
extend self
|
6
|
-
|
7
|
-
attr_accessor :should_clear_screen
|
8
|
-
alias_method :should_clear_screen?, :should_clear_screen
|
9
|
-
|
10
|
-
def perform_work(command_or_options)
|
11
|
-
if command_or_options.is_a?(Hash)
|
12
|
-
options = command_or_options
|
13
|
-
elsif command_or_options.is_a?(String)
|
14
|
-
options = { :command => command_or_options }
|
15
|
-
else
|
16
|
-
raise ArgumentError, "Should be a string or a hash."
|
17
|
-
end
|
18
|
-
job = Job.new(options)
|
19
|
-
will_execute_command(job)
|
20
|
-
yield job
|
21
|
-
did_execute_command(job)
|
22
|
-
job
|
23
|
-
end
|
24
|
-
|
25
|
-
def execute(command_or_options)
|
26
|
-
perform_work(command_or_options) do |job|
|
27
|
-
_execute(job)
|
28
|
-
yield job if block_given?
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def log(message)
|
33
|
-
if Kicker.quiet
|
34
|
-
puts message
|
35
|
-
else
|
36
|
-
now = Time.now
|
37
|
-
puts "#{now.strftime('%H:%M:%S')}.#{now.usec.to_s[0,2]} | #{message}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def clear_console!
|
42
|
-
puts(CLEAR) if Kicker.clear_console?
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
CLEAR = "\e[H\e[2J"
|
48
|
-
|
49
|
-
def _execute(job)
|
50
|
-
silent = Kicker.silent?
|
51
|
-
unless silent
|
52
|
-
puts
|
53
|
-
sync_before, $stdout.sync = $stdout.sync, true
|
54
|
-
end
|
55
|
-
output = ""
|
56
|
-
popen(job.command) do |io|
|
57
|
-
while str = io.read(1)
|
58
|
-
output << str
|
59
|
-
$stdout.print str unless silent
|
60
|
-
end
|
61
|
-
end
|
62
|
-
job.output = output.strip
|
63
|
-
job.exit_code = $?.exitstatus
|
64
|
-
job
|
65
|
-
ensure
|
66
|
-
unless silent
|
67
|
-
$stdout.sync = sync_before
|
68
|
-
puts("\n\n")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def popen(command, &block)
|
73
|
-
if RUBY_VERSION >= "1.9"
|
74
|
-
args = Shellwords.shellsplit(command)
|
75
|
-
args << { :err => [:child, :out] }
|
76
|
-
IO.popen(args, &block)
|
77
|
-
else
|
78
|
-
IO.popen("#{command} 2>&1", &block)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def will_execute_command(job)
|
83
|
-
puts(CLEAR) if Kicker.clear_console? && should_clear_screen?
|
84
|
-
@should_clear_screen = false
|
85
|
-
|
86
|
-
if message = job.print_before
|
87
|
-
log(message)
|
88
|
-
end
|
89
|
-
|
90
|
-
if notification = job.notify_before
|
91
|
-
Notification.notify(notification)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def did_execute_command(job)
|
96
|
-
if message = job.print_after
|
97
|
-
puts(message)
|
98
|
-
end
|
99
|
-
|
100
|
-
log(job.success? ? "Success" : "Failed (#{job.exit_code})")
|
101
|
-
|
102
|
-
if notification = job.notify_after
|
103
|
-
Notification.notify(notification)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
module Kernel
|
110
|
-
# Prints a +message+ with timestamp to stdout.
|
111
|
-
def log(message)
|
112
|
-
Kicker::Utils.log(message)
|
113
|
-
end
|
114
|
-
|
115
|
-
# When you perform some work (like shelling out a command to run without
|
116
|
-
# using +execute+) you need to call this method, with a block in which you
|
117
|
-
# perform your work, which will take care of logging the work appropriately.
|
118
|
-
def perform_work(command, &block)
|
119
|
-
Kicker::Utils.perform_work(command, &block)
|
120
|
-
end
|
121
|
-
|
122
|
-
# Executes the +command+, logs the output, and optionally sends user
|
123
|
-
# notifications on Mac OS X (10.8 or higher).
|
124
|
-
def execute(command, &block)
|
125
|
-
Kicker::Utils.execute(command, &block)
|
126
|
-
end
|
127
|
-
end
|