Module: TouchP

Defined in:
lib/touch_p.rb,
lib/touch_p/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.exeObject



4
5
6
7
# File 'lib/touch_p.rb', line 4

def self.exe
  return if !is_valid?(ARGV)
  touch_p(ARGV)
end

.touch_p(argv) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/touch_p.rb', line 9

def self.touch_p(argv)
  argv.each do |file_path|
    if file_path.include?("/")
      dir = extract_dir(file_path)
      begin
        FileUtils.mkdir_p(dir)
      rescue Errno::EEXIST
      end
    end
  end

  begin
    FileUtils.touch(argv)
  rescue => exception
    puts exception
  end
end