Class: Guard::Asciidoctor
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Asciidoctor
- Defined in:
- lib/guard/asciidoctor.rb,
lib/guard/asciidoctor/notifier.rb
Defined Under Namespace
Classes: Notifier
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Asciidoctor
constructor
Initializes a Guard plugin.
-
#reload ⇒ Object
Called when ‘reload|r|z + enter` is pressed.
-
#run_all ⇒ Object
Called when just
enteris pressed This method should be principally used for long action like running all specs/tests/… - #run_on_changes(paths) ⇒ Object
-
#start ⇒ Object
Called once when Guard starts.
-
#stop ⇒ Object
Called when ‘stop|quit|exit|s|q|e + enter` is pressed (when Guard quits).
Constructor Details
#initialize(options = {}) ⇒ Asciidoctor
Initializes a Guard plugin. Don’t do any work here, especially as Guard plugins get initialized even if they are not in an active group!
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/guard/asciidoctor.rb', line 17 def initialize( = {}) @patterns = [] opts = { notifications: true, helper_modules: [] }.merge() super(opts) end |
Instance Method Details
#reload ⇒ Object
Called when ‘reload|r|z + enter` is pressed. This method should be mainly used for “reload” (really!) actions like reloading passenger/spork/bundler/…
54 55 56 57 |
# File 'lib/guard/asciidoctor.rb', line 54 def reload Compat::UI.info "method reload" run_all end |
#run_all ⇒ Object
Called when just enter is pressed This method should be principally used for long action like running all specs/tests/…
65 66 67 68 |
# File 'lib/guard/asciidoctor.rb', line 65 def run_all Compat::UI.info "run all" run_on_changes(Compat.matching_files(self, Dir.glob(File.join('**', '*.*')))) end |
#run_on_changes(paths) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/guard/asciidoctor.rb', line 71 def run_on_changes(paths) paths.each do |file| output_paths = _output_paths(file) compiled_asciidoc = compile_asciidoc(file) output_paths.each do |output_file| FileUtils.mkdir_p File.dirname(output_file) File.open(output_file, 'w') { |f| f.write(compiled_asciidoc) } end = "Successfully compiled asciidoc!\n" += "# #{file} -> #{output_paths.join(', ')}".gsub("#{::Bundler.root}/", '') Compat::UI.info Notifier.notify(true, ) if [:notifications] end end |
#start ⇒ Object
Called once when Guard starts. Please override initialize method to init stuff.
33 34 35 36 |
# File 'lib/guard/asciidoctor.rb', line 33 def start Compat::UI.info "method start" run_all #if options[:run_at_start] end |
#stop ⇒ Object
Called when ‘stop|quit|exit|s|q|e + enter` is pressed (when Guard quits).
43 44 45 46 |
# File 'lib/guard/asciidoctor.rb', line 43 def stop Compat::UI.info "method stop" true end |