skill-assessment-app/Guardfile

94 lines
3.1 KiB
Plaintext
Raw Normal View History

# frozen_string_literal: true
2016-07-26 10:38:00 -05:00
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
2016-08-18 18:22:57 -05:00
guard 'livereload' do
2016-09-01 14:49:13 -05:00
extensions = {
css: :css,
scss: :css,
sass: :css,
js: :js,
coffee: :js,
html: :html,
png: :png,
gif: :gif,
jpg: :jpg,
jpeg: :jpeg,
# less: :less, # uncomment if you want LESS stylesheets done in browser
}
2016-08-18 18:22:57 -05:00
2016-09-01 14:49:13 -05:00
rails_view_exts = %w(erb haml slim)
2016-08-18 18:22:57 -05:00
2016-09-01 14:49:13 -05:00
# file types LiveReload may optimize refresh for
compiled_exts = extensions.values.uniq
watch(%r{public/.+\.(#{compiled_exts * '|'})})
2016-09-01 14:49:13 -05:00
extensions.each do |ext, type|
watch(%r{
(?:app|vendor)
(?:/assets/\w+/(?<path>[^.]+) # path+base without extension
(?<ext>\.#{ext})) # matching extension (must be first encountered)
(?:\.\w+|$) # other extensions
}x) do |m|
path = m[1]
"/assets/#{path}.#{type}"
end
end
2016-09-01 14:49:13 -05:00
# file needing a full reload of the page anyway
watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$})
watch(%r{app/(helpers|controllers)/.+\.rb})
watch(%r{config/locales/.+\.yml})
end
2016-09-02 17:51:35 -05:00
guard :minitest, spring: "bin/rails test", all_after_pass: true do
2016-09-14 17:05:37 -05:00
watch(%r{^app/(.+)\.rb$}) { |m| ["test/#{m[1]}", "test/#{m[1]}_test.rb"] }
2016-09-01 14:49:13 -05:00
watch(%r{^app/controllers/(admin|application)_controller\.rb$}) { 'test/controllers' }
watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' }
watch(%r{^test/.+_test\.rb$})
# run controller/integration test when touching the router or erb files
2016-08-16 12:08:42 -05:00
watch(%r{^app/views/((?!_mailer).)*([^/]+)\.erb$}) { ["test/controllers", "test/integration"] }
watch(%r{^config/routes.rb}) { ["test/controllers", "test/integration"] }
2016-08-16 12:08:42 -05:00
# run mailers/integration test when touching mailer erb files
watch(%r{^app/views/(.*_mailer/)?([^/]+)\.erb$}) { ["test/mailers", "test/integration"] }
2016-07-26 10:38:00 -05:00
end
2016-09-01 14:49:13 -05:00
# ESLint
guard :shell, all_on_start: true do
watch %r{app/assets/javascripts/*/.*} do |file|
2016-09-02 17:51:35 -05:00
system %(echo "ESLint:\033[32m #{file[0]}\033[0m")
2016-09-01 14:49:13 -05:00
system %(eslint #{file[0]})
end
end
2016-09-19 09:10:22 -05:00
guard :rubocop, cli: %w(-D -S) do
watch(/.rubocop.yml/)
2016-07-26 10:38:00 -05:00
watch(/.+\.rb$/)
watch(/Rakefile/)
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
2016-09-19 09:10:22 -05:00
guard 'brakeman', run_on_start: true, quiet: true do
watch(%r{^app/.+\.(erb|haml|rhtml|rb)$})
watch(%r{^config/.+\.rb$})
watch(%r{^lib/.+\.rb$})
watch('Gemfile')
end