Class: RoCommands::FileActions

Inherits:
Base
  • Object
show all
Defined in:
lib/ro_commands/file_actions.rb

Instance Method Summary collapse

Methods inherited from Base

describe, method_added, meths, start, usage

Methods included from Bash

#_bash, #bash, #bash_lines, #bash_per, #bashc, err, #handle_path, out, status

Instance Method Details

#find(dir, keyword = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ro_commands/file_actions.rb', line 28

def find(dir, keyword=nil)
  Find.find(dir).each do |path|
    if keyword
      if path[/#{keyword}/]
        puts path
      end
    else
      puts path
    end
  end
end

#find_railscasts(video_name) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/ro_commands/file_actions.rb', line 42

def find_railscasts(video_name)
  Find.find('/media/zxr/New-Volume/TDDOWNLOAD/railscasts/').each do |path|
    if path[Regexp.new video_name]
      puts path
    end
  end
end

#grep(keyword, path = nil, options = {}) ⇒ Object



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

def grep(keyword, path=nil, options={})
  if options.is_a?(String)
    options = convert_options options
  end
  @keyword = keyword
  @path = path || Dir.pwd
  @options = options

  if @options[:verbose]
    @match_files = []
    _grep_verbose
    puts_match_files
  else
    _grep()
  end
end