Skip to content

Instantly share code, notes, and snippets.

@macmladen
Last active August 29, 2015 14:06
Show Gist options
  • Save macmladen/1fbb978ae60f1981956d to your computer and use it in GitHub Desktop.
Save macmladen/1fbb978ae60f1981956d to your computer and use it in GitHub Desktop.
Guard file sample. This may work for any project you just need to add/customize commands for your guards. It may help to generate guard init which will create samle file first and then merge with this one (not literally!). Under comments there are some samples to give you ideas what may be done and how. You will need guard gem and plugins you ne…
# A sample Guardfile based on Omega 4.x and init result
# More info at https://github.com/guard/guard#readme
# for this file to work you need some gem-s
# copy the following without hashtag to Gemfile:
# source 'https://rubygems.org'
#
# group :development do
#
# # Sass, Compass and extensions.
# gem 'sass' # Sass.
# gem 'compass' # Framework built on Sass.
# # ...and other gems you may need
# # Guard
# gem 'guard' # Guard event handler.
# gem 'guard-compass' # Compile on sass/scss change.
# gem 'guard-shell' # Run shell commands.
# gem 'guard-livereload' # Browser reload.
# gem 'yajl-ruby' # Faster JSON with LiveReload in the browser.
#
# end
# ...and run
# $ bundle install
notification :off
group :development do
# Guard::Compass
#
# You don't need to configure watchers for guard 'compass' declaration as they generated
# from your Compass configuration file. You might need to define the Compass working directory
# and point to the configuration file depending of your project structure.
#
# Available options:
#
# * working_directory: Define the Compass working directory, relative to the Guardfile directory
# * configuration_file: Path to the Compass configuration file, relative to :project_path
#
# Like usual, the Compass configuration path are relative to the :project_path
#
# guard 'compass', project_path: 'not_current_dir', configuration_file: 'path/to/my/compass_config.rb'
# Only run Compass if we have a config.rb file in place.
if File.exists?("config.rb")
# Compile on start.
puts `compass compile --time --quiet`
# https://github.com/guard/guard-compass
guard :compass do
watch(%r{.+\.s[ac]ss$})
end
end
## Uncomment this if you wish to clear the theme registry every time you
## change one of the relevant theme files.
# Add files and commands to this file, like the example:
# watch(%r{file/path}) { `command(s)` }
# e.g.
# watch(/(.*).txt/) {|m| `tail #{m[0]}` }
guard :shell do
puts 'Monitoring Drupal theme files.'
watch(%r{.+\.(php|inc|info)$}) { |m|
puts 'Change detected: ' + m[0]
`/full/path/to/drush/drush cache-clear theme-registry`
puts 'Cleared theme registry.'
}
end
# https://github.com/guard/guard-livereload.
# Ignore *.normalize.scss to prevent flashing content when re-rendering.
# e.g. Rails Assets Pipeline
# watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
guard :livereload do
watch(%r{^((?!\.normalize\.).)*\.(css|js)$})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment