Class: Awestruct::CLI::Auto
- Inherits:
-
Object
- Object
- Awestruct::CLI::Auto
- Defined in:
- lib/awestruct/cli/auto.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Auto
constructor
A new instance of Auto.
- #run ⇒ Object
Constructor Details
#initialize(config) ⇒ Auto
Returns a new instance of Auto.
9 10 11 |
# File 'lib/awestruct/cli/auto.rb', line 9 def initialize(config) @config = config end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/awestruct/cli/auto.rb', line 13 def run() force_polling = ( RUBY_PLATFORM =~ /mingw/ ? true : false ) listener = Listen.to( @config.dir, :relative_paths=>true, :latency=>0.5, :force_polling=>force_polling ) listener.ignore( %r(\.awestruct) ) listener.ignore( %r(^#{File.basename( @config.tmp_dir )}) ) listener.ignore( %r(^#{File.basename( @config.output_dir )}) ) listener.change do |modified, added, removed| modified.each do |path| engine = ::Awestruct::Engine.instance unless ( path =~ %r(#{File.basename( engine.config.output_dir) }) || path =~ /.awestruct/ ) engine.generate_page_by_output_path( path ) end end end listener.start(false) end |