1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/Guardfile

63 lines
1.3 KiB
Text
Raw Normal View History

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)
paths.delete('some_lib')
puts "Running: #{paths.join ' '}"
if paths.size.zero?
warn 'Running all tests'
system 'rake recspec'
else
paths.each do |path|
warn "Running #{path}"
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)
%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
end
Dir['lib/pry/**/*.rb'].each do |rb|
rb[%r(lib/pry/(.+)\.rb$)]
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}'"
else
::Guard::UI.debug "No map, so run all for: '#{rb}'"
end
next unless spec_rb
watch(rb) do |m| spec_rb end
end
2012-09-08 23:27:41 -04: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
watch(%r{^spec/.+\.rb$}) do |m| m end
2012-09-08 23:27:41 -04:00
end
# vim:ft=ruby