2012-09-08 23:27:41 -04:00
|
|
|
require 'guard/guard'
|
|
|
|
|
|
|
|
module ::Guard
|
|
|
|
class Bacon < Guard
|
|
|
|
def run_all
|
2012-11-15 00:37:37 -05:00
|
|
|
system "rake spec"
|
2012-09-08 23:27:41 -04:00
|
|
|
puts
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_on_changes(paths)
|
2012-12-09 21:18:26 -05:00
|
|
|
paths.delete('some_lib')
|
2012-12-13 12:34:17 -05:00
|
|
|
puts "Running: #{paths.join ' '}"
|
2012-12-09 21:18:26 -05:00
|
|
|
if paths.size.zero?
|
2013-01-08 15:59:40 -05:00
|
|
|
warn 'Running all tests'
|
2012-12-11 10:05:03 -05:00
|
|
|
system 'rake recspec'
|
2012-12-09 21:18:26 -05:00
|
|
|
else
|
|
|
|
paths.each do |path|
|
2012-12-07 10:43:17 -05:00
|
|
|
warn "Running #{path}"
|
2012-12-09 21:18:26 -05:00
|
|
|
system "rake spec run=#{path}" or return
|
|
|
|
warn "\e[32;1mNice!!\e[0m Now running all specs, just to be sure."
|
|
|
|
run_all
|
|
|
|
end
|
2012-09-08 23:27:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
guard 'bacon' do
|
2012-11-15 00:37:37 -05:00
|
|
|
def deduce_spec_from(token)
|
2012-12-09 21:18:26 -05:00
|
|
|
%W(
|
|
|
|
spec/#{token}_spec.rb
|
|
|
|
spec/pry_#{token}_spec.rb
|
|
|
|
spec/commands/#{token}_spec.rb
|
|
|
|
).each do |e|
|
|
|
|
return e if File.exists? e
|
|
|
|
end
|
|
|
|
nil
|
2012-09-17 03:12:40 -04:00
|
|
|
end
|
|
|
|
|
2012-12-09 21:18:26 -05:00
|
|
|
Dir['lib/pry/**/*.rb'].each do |rb|
|
2012-09-17 03:12:40 -04:00
|
|
|
rb[%r(lib/pry/(.+)\.rb$)]
|
2012-12-09 21:18:26 -05:00
|
|
|
spec_rb = deduce_spec_from($1)
|
|
|
|
if spec_rb
|
|
|
|
# run as 'bundle exec guard -d' to see these.
|
|
|
|
::Guard::UI.debug "'#{rb}' maps to '#{spec_rb}'"
|
2012-09-17 03:12:40 -04:00
|
|
|
else
|
2012-12-09 21:18:26 -05:00
|
|
|
::Guard::UI.debug "No map, so run all for: '#{rb}'"
|
2012-09-17 03:12:40 -04:00
|
|
|
end
|
2012-12-09 21:18:26 -05:00
|
|
|
next unless spec_rb
|
|
|
|
watch(rb) do |m| spec_rb end
|
2012-09-17 03:12:40 -04:00
|
|
|
end
|
2012-09-08 23:27:41 -04:00
|
|
|
|
2012-12-09 21:18:26 -05:00
|
|
|
watch(%r{^lib/.+\.rb$}) do |m|
|
|
|
|
return if deduce_spec_from(m[0])
|
|
|
|
'some_lib'
|
|
|
|
end
|
2012-09-08 23:27:41 -04:00
|
|
|
|
2012-12-09 21:18:26 -05:00
|
|
|
watch(%r{^spec/.+\.rb$}) do |m| m end
|
2012-09-08 23:27:41 -04:00
|
|
|
end
|
|
|
|
|
2012-09-17 03:12:40 -04:00
|
|
|
# vim:ft=ruby
|