Class: Utilikilt::Scanner

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/utilikilt/scanner.rb

Constant Summary collapse

INPUT_TO_OUTPUT_EXT_MAP =
{
  'md' => 'html',
  'markdown' => 'html',
  'haml' => 'html',
  'sass' => 'css',
  'scss' => 'css',
  'coffee' => 'js'
}
TILT_OPTIONS =
{:cache => false}

Instance Method Summary collapse

Methods included from Loggable

#debug

Constructor Details

#initialize(opts) ⇒ Scanner

Returns a new instance of Scanner.



10
11
12
13
14
# File 'lib/utilikilt/scanner.rb', line 10

def initialize( opts )
  @input_base = Pathname.new( opts['input_dir'] ).expand_path
  @output_base = Pathname.new( opts['output_dir'] ).expand_path
  @files_processed = 0
end

Instance Method Details

#scanObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/utilikilt/scanner.rb', line 27

def scan
  @files_processed = 0
  input_file_glob = '*.{'+INPUT_TO_OUTPUT_EXT_MAP.keys.join(',')+'}'
  Pathname.glob(File.join( @input_base, "**", input_file_glob )).each do |input|
    debug{"checking #{input}"} 
    output = output_for_input(input)
    unless FileUtils.uptodate?( output, [input] ) 
      filter( input, output )
    end
  end

  log_files_processed
end