Class: Guard::Rugular
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Rugular
- Defined in:
- lib/rugular/tasks/server/guards/rugular.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Rugular
constructor
A new instance of Rugular.
- #reload ⇒ Object
- #run_all ⇒ Object
- #run_on_changes(paths) ⇒ Object
- #run_on_removals(paths) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Rugular
Returns a new instance of Rugular.
11 12 13 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 11 def initialize(opts = {}) super(opts) end |
Instance Method Details
#reload ⇒ Object
24 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 24 def reload; true end |
#run_all ⇒ Object
26 27 28 |
# 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) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 30 def run_on_changes(paths) [*paths].each do |file| = 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. ::Guard::UI.info end rescue StandardError => error handle_error_in_guard(error) end |
#run_on_removals(paths) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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}" = 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. ::Guard::UI.info end rescue StandardError => error handle_error_in_guard(error) end |
#start ⇒ Object
15 16 17 18 19 20 21 |
# 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 ⇒ Object
23 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 23 def stop; true end |