Class: RoCommands::Navigate

Inherits:
Base
  • Object
show all
Defined in:
lib/ro_commands/navigate.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

#get_dir(name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ro_commands/navigate.rb', line 10

def get_dir(name)
  Find.find(File.join(ENV['HOME'], 'Dropbox')) do |f|
    if test(?d, f)
      if File.basename(f).match /^#{name}/
        Out.reset
        Out.out f
        return
      end
    end
  end
end

#get_project(name, lan = 'ruby') ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ro_commands/navigate.rb', line 25

def get_project(name, lan='ruby')

  if lan == 'ruby'
    projects = Dir[File.join ENV['PROJECTS'], '**']
  elsif lan == 'java'
    projects = Dir[File.join ENV['JAVA'], '**']
  end

  projects.each do |path|
    dir = File.basename path
    if dir == name
      Out.reset
      Out.out(path)
      return
    end
  end

  r = /^#{name.split('').join(".*")}.*/i
  projects.each do |path|
    dir = File.basename path
    if dir[r]
      Out.reset
      Out.out(path)
      return
    end
  end
end