Sha256: cd56f4a788a277e553e64dc87535f38f789cf73b9df4d1b82dc9d3e0f8776c0c
Contents?: true
Size: 719 Bytes
Versions: 6
Compression:
Stored size: 719 Bytes
Contents
# frozen_string_literal: true require "pathname" module Tocer # Generates/updates Table of Contents for files in given path. class Runner def initialize path = ".", configuration: {}, writer: Writer @path = Pathname path @configuration = configuration @writer = writer end def files return [] unless path.exist? && path.directory? && !whitelist.empty? Pathname.glob(%(#{path}/{#{whitelist.join ","}})).select(&:file?) end def run files.each { |file| writer.new(file, label: configuration.fetch(:label)).write } end private attr_reader :path, :configuration, :writer def whitelist Array configuration[:whitelist] end end end
Version data entries
6 entries across 6 versions & 1 rubygems