Sha256: 9fd0e4aa7d510395ae1fe3052c0a3f4950cd9e4938feda49bd9204e0b6255c2c

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require "ro_commands/helpers/out"
module RoCommands
  class Navigate < Base

    desc "get_dir", ""

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


    desc 'get_project', 'get project path according name'

    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

    private

    def handle_drb_out
      #Out.out "result:#{result}   file:#{File.basename __FILE__} line:#{__LINE__}"
      Out.msgs.grep(%r{/\w+}).first
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ro_commands-0.0.1 lib/ro_commands/navigate.rb