Sha256: ffeb9286a5d76f87bd736f3dab64fba45209b7d70421cd7a41acb076f69c211f

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

#require 'guard/awestruct'

require 'listen'

module Awestruct
  module CLI
    class Auto

      def initialize(config)
        @config = config
      end

      def run()
        listener = Listen.to( @config.dir, :relative_paths=>true )
        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|
          puts "modified #{modified.inspect}"
          puts "added #{added.inspect}"
          puts "removed #{removed.inspect}"
          modified.each do |path|
            engine = ::Awestruct::Engine.instance
            puts "path -> #{path}"
            puts "bn -> #{File.basename( engine.config.output_dir )}"
            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

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
awestruct-0.4.2.x8 lib/awestruct/cli/auto.rb
awestruct-0.4.2.x7 lib/awestruct/cli/auto.rb