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
20 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 20 def reload; true end |
#run_all ⇒ Object
22 23 24 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 22 def run_all run_on_changes(Dir.glob("src/**/*")) end |
#run_on_changes(paths) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 26 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 ::RugularVendorAndBowerComponents.compile when '.png' then ::RugularAssets.copy_image(file) when '.jpg' then ::RugularAssets.copy_image(file) when '.ttf' then ::RugularAssets.copy_font(file) when '.woff' then ::RugularAssets.copy_font(file) else next 'Rugular does not know how to handle this file' end ::RugularIndexHtml. ::Guard::UI.info end rescue StandardError => error handle_error_in_guard(error) end |
#run_on_removals(paths) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 47 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 '.png' then ::RugularAssets.delete_image(file) when '.jpg' then ::RugularAssets.delete_image(file) when '.ttf' then ::RugularAssets.delete_font(file) when '.woff' then ::RugularAssets.delete_font(file) when '.yaml' then fail 'what are you doing? trying to break rugular?!' else next 'Rugular does not know how to handle this file' end ::RugularIndexHtml. ::Guard::UI.info end rescue StandardError => error handle_error_in_guard(error) end |
#start ⇒ Object
15 16 17 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 15 def start ::RugularHaml.compile('src/index.haml') end |
#stop ⇒ Object
19 |
# File 'lib/rugular/tasks/server/guards/rugular.rb', line 19 def stop; true end |