Sha256: 657f797c4f46fe747f3d5fb29fe9c03f228cfc7e4a1dd9eb0695dd9e363af580

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

require 'yaml'
require 'active_support/all'
require "maprename/renamer"

module Maprename
  class App
    def initialize(config_file)
      @config = YAML.load(IO.read(config_file)).with_indifferent_access
    end

    def run!(opts)
      input_files.each do |file|
        file = File.join(@config[:input][:directory], file)
        Maprename::Renamer.new(file, @config).rename!(opts)
      end
    end

    def input_files
      files = Dir.children(@config[:input][:directory]).grep(Regexp.new(@config[:input][:pattern]))
      debug 'Matched input files:'
      debug files.map { |f| '  %s' % f}
      files
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
maprename-0.1.2 lib/maprename/app.rb
maprename-0.1.1 lib/maprename/app.rb