Class: Tocer::Runner
- Inherits:
-
Object
- Object
- Tocer::Runner
- Defined in:
- lib/tocer/runner.rb
Overview
Generates/updates Table of Contents for files in given path.
Instance Method Summary collapse
- #files ⇒ Object
-
#initialize(path = "", configuration: {}, writer: Writer) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
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
#files ⇒ Object
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 |
#run ⇒ Object
20 21 22 |
# File 'lib/tocer/runner.rb', line 20 def run files.each { |file| writer.new(file, label: configuration.fetch(:label)).write } end |