-
Notifications
You must be signed in to change notification settings - Fork 7
/
Guardfile
68 lines (57 loc) · 2.55 KB
/
Guardfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# More info at https://github.com/guard/guard#readme
require 'active_support/inflector'
guard :shell do
# Some problems with this approach (double reloading of livereload):
# - http://stackoverflow.com/questions/28136107/guard-gem-pause-file-modification-within-guardfile-for-execution-of-a-block
# - http://stackoverflow.com/questions/28136122/guard-gem-run-some-code-at-startup-or-shutdown
# watch %r{app/\w+/(.+\.(html|rb)).*} do |m|
# n m[0], 'Changed'
# `i18n-tasks add-missing -v 'TRANSLATE: %{value}'`
# end
# watch 'Gemfile.lock' do |m|
# `spring reload`
# end
end
guard :livereload, port: 35729 do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/(helpers|inputs)/.+\.rb})
watch('config/routes.rb')
watch(%r{public/.+\.(css|js|html)})
watch(%r{config/locales/.+\.yml})
watch('app/models/ability.rb')
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(sass|coffee|css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
end
# TODO: Why is bundle exec needed? More infos here: http://stackoverflow.com/questions/22555324 and https://github.com/rails/spring/issues/277
guard :rspec, cmd: 'bin/rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/features/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch('app/models/ability.rb') { "spec/models/user_spec.rb" }
# TODO: Rename to features!
# Turnip features and steps
watch(%r{^spec/features/(.+)\.feature$})
# Reload factory girl, see http://urgetopunt.com/2011/10/01/guard-factory-girl.html
watch(%r{^spec/factories/(.+)\.rb$}) do |m|
[ "spec/models/#{m[1].singularize}_spec.rb",
"spec/controllers/#{m[1]}_controller_spec.rb"
]
end
end
guard :bundler do
watch('Gemfile')
# Uncomment next line if your Gemfile contains the `gemspec' command.
# watch(/^.+\.gemspec/)
end
guard :migrate, cmd: 'spring rake',
run_on_start: false do
watch(%r{^db/migrate/(\d+).+\.rb})
watch('db/seeds.rb')
end