Module: Patriot::Util::Script

Includes:
DateUtil
Included in:
Tool::BatchParser
Defined in:
lib/patriot/util/script.rb

Overview

a module to find target files

Instance Method Summary collapse

Methods included from DateUtil

#date_add, #date_add_year, #date_format, #date_sub, #date_sub_year, #date_to_month, #days_of_month, #days_of_month_until, #days_of_week, #hours, #month_add, #month_sub, #to_date_obj, #to_end_of_last_month, #to_end_of_month, #to_month, #to_start_of_month

Instance Method Details

#get_batch_files(path, date, opt = {}) ⇒ Array<String>

get target batch files from a given path

Parameters:

  • path (String)

    path to target directory

  • date (String)

    target date in ā€˜%Y-%m-%dā€™

  • opt (Hash) (defaults to: {})

Options Hash (opt):

  • :all (Boolean)

    force target all files

Returns:

  • (Array<String>)

    a list of target files



13
14
15
16
17
18
19
20
21
# File 'lib/patriot/util/script.rb', line 13

def get_batch_files(path, date, opt = {})
  return [path] if File.file?(path) && File.extname(path) == ".pbc" 
  files = []
  opt   = target_option(date, opt)
  files = Dir.glob("#{path}/**/*.pbc").find_all do |file|
    target_file?(file, opt)
  end
  return files
end