# A sample Guardfile
# More info at https://github.com/guard/guard#readme

ignore(/\.orig$/)

notification :off

directories %w(config lib src public spec)

group :frontend do
  guard 'livereload' do
    watch(%r{app/views/.+\.(erb|haml|slim)$})
    watch(%r{app/helpers/.+\.rb})
    watch(%r{public/.+\.(css|js|html)})
    watch(%r{config/locales/.+\.yml})
    # Rails Assets Pipeline
    watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
  end
end

group :backend do

  guard :bundler do
    watch('Gemfile')
    # Uncomment next line if your Gemfile contains the `gemspec' command.
    # watch(/^.+\.gemspec/)
  end

  rspec_options = {
    failed_mode: :report,
    cmd: 'bundle exec rspec -t ~slow',
    run_all: {
      cmd: 'CI=true bundle exec rspec -t slow'
    }
  }

  guard :rspec, rspec_options do
    watch(/^lib\/web\.rb$/)  { "spec/lib/site_spec.rb" }
    watch(/^public\/.*\.html$/)  { "spec/lib/site_spec.rb" }

    watch(%r{^spec/.+_spec\.rb$})
    watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
      watch('spec/spec_helper.rb')  { "spec" }
  end

  jekyll_plus_options = {
    # serve: true,
    serve: true,
    silent: true,
    rack_config: 'config/config.ru',
    extensions: ['php', 'ico','htaccess']
  }

  guard "jekyll-plus", jekyll_plus_options do
    watch(/^src\/(.*\/)?(\.htaccess|favicon\.ico|500\.php|.*\.haml|.*\.scss)$/)
    #watch(/^src/)
  end
end
