Module: CommandUtil
- Defined in:
- lib/command_util.rb
Overview
Make commands ################################
Instance Method Summary collapse
Instance Method Details
#dir_commands(dir) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/command_util.rb', line 28 def dir_commands dir dir=File. dir cmds=config['directories'].keys.map do |dest| next if dest=='_rm' path=File.join(dir,dest) if File.exists?(path) if !File.directory?(path) Trollop::die "#{path} already exists, and isn't a directory" else nil end else CreateCommand.new dest,dir end end cmds.compact end |
#file_commands(dir) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/command_util.rb', line 18 def file_commands dir dir=File. dir cmds=Dir[File.join(dir, '*')].map do |filename| nil if File.directory? filename make_file_command(File.basename(filename)) end cmds.compact.map { |c| c.path=dir ; c } end |
#make_file_command(filename) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/command_util.rb', line 6 def make_file_command filename dest=destination_for filename return nil unless dest if dest=="_rm" RemoveCommand.new filename else MoveCommand.new filename, dest end end |