class Guard::Rugular
Public Class Methods
new(opts = {})
click to toggle source
Calls superclass method
# File lib/rugular/tasks/server/guards/rugular.rb, line 11 def initialize(opts = {}) super(opts) end
Public Instance Methods
reload()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular.rb, line 24 def reload; true end
run_all()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular.rb, line 26 def run_all run_on_changes(Dir.glob('src/**/*').push('bower_components.yaml')) end
run_on_changes(paths)
click to toggle source
# File lib/rugular/tasks/server/guards/rugular.rb, line 30 def run_on_changes(paths) [*paths].each do |file| message = case File.extname(file) when '.coffee' then ::RugularCoffee.compile(file) when '.haml' then ::RugularHaml.compile(file) when '.yaml' then ::RugularBowerComponents.compile when '.png' then ::RugularAssets.copy_asset(file) when '.jpg' then ::RugularAssets.copy_asset(file) when '.ttf' then ::RugularAssets.copy_asset(file) when '.woff' then ::RugularAssets.copy_asset(file) else "Rugular does not know how to handle #{file}" end ::RugularIndexHtml.update_javascript_script_tags ::Guard::UI.info message end rescue StandardError => error handle_error_in_guard(error) end
run_on_removals(paths)
click to toggle source
# File lib/rugular/tasks/server/guards/rugular.rb, line 52 def run_on_removals(paths) [*paths].each do |file| ::Guard::UI.info "Guard received delete event for #{file}" message = case File.extname(file) when '.coffee' then ::RugularCoffee.delete(file) when '.haml' then ::RugularHaml.delete(file) when '.yaml' then fail "Please restore #{file}" when '.png' then ::RugularAssets.delete_asset(file) when '.jpg' then ::RugularAssets.delete_asset(file) when '.ttf' then ::RugularAssets.delete_asset(file) when '.woff' then ::RugularAssets.delete_asset(file) else "Rugular does not know how to handle #{file}" end ::RugularIndexHtml.update_javascript_script_tags ::Guard::UI.info message end rescue StandardError => error handle_error_in_guard(error) end
start()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular.rb, line 15 def start create_tmp_directory run_on_changes('src/index.haml') run_all end
stop()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular.rb, line 23 def stop; true end
Private Instance Methods
create_tmp_directory()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular.rb, line 78 def create_tmp_directory FileUtils.mkdir '.tmp' unless File.directory? '.tmp' end
handle_error_in_guard(error)
click to toggle source
# File lib/rugular/tasks/server/guards/rugular.rb, line 82 def handle_error_in_guard(error) ::Guard::UI.error error.message throw :task_has_failed end