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.
12 13 14 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 12 def initialize(opts = {}) super(opts) end |
Instance Method Details
#reload ⇒ Object
25 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 25 def reload; true end |
#run_all ⇒ Object
27 28 29 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 27 def run_all run_on_changes(Dir.glob('src/**/*').push('bower_components.yaml')) end |
#run_on_changes(paths) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 31 def run_on_changes(paths) [*paths].each do |file| = case File.extname(file) when '.es6' then ::RugularES6.compile(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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 54 def run_on_removals(paths) [*paths].each do |file| ::Guard::UI.info "Guard received delete event for #{file}" = case File.extname(file) when '.es6' then ::RugularES6.delete(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
16 17 18 19 20 21 22 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 16 def start create_tmp_directory run_on_changes('src/index.haml') run_all end |
#stop ⇒ Object
24 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 24 def stop; true end |