Sha256: 4fdf3d9dd82d3929e744ec8dc5e45281f2d324f7fce3deef9bd1e6b5ef83910a

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require "ro_commands/helpers/out"
require_relative "base"
require "config/rorc"

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}/
            Out.reset
            Out.out 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

2 entries across 2 versions & 1 rubygems

Version Path
ro_commands-0.0.3 lib/ro_commands/navigate.rb
ro_commands-0.0.2 lib/ro_commands/navigate.rb