Class: Tocer::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/tocer/runner.rb

Overview

Generates/updates Table of Contents for files in given path.

Instance Method Summary collapse

Constructor Details

#initialize(path = "", configuration: {}, writer: Writer) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
12
# File 'lib/tocer/runner.rb', line 8

def initialize path = "", configuration: {}, writer: Writer
  @path = Pathname path
  @configuration = configuration
  @writer = writer
end

Instance Method Details

#filesObject



14
15
16
17
18
# File 'lib/tocer/runner.rb', line 14

def files
  return [] unless path.exist?
  glob = whitelist.empty? ? %(#{path}/**/*) : %(#{path}/**/*{#{whitelist.join ","}})
  Pathname.glob(glob).select(&:file?)
end

#runObject



20
21
22
# File 'lib/tocer/runner.rb', line 20

def run
  files.each { |file| writer.new(file, label: configuration.fetch(:label)).write }
end