Class: GitExplorer::Explorer
- Inherits:
-
Thor
- Object
- Thor
- GitExplorer::Explorer
- Includes:
- GitExplorer, Thor::Actions
- Defined in:
- lib/git_explorer.rb
Defined Under Namespace
Classes: Line
Constant Summary collapse
- LOGGER =
Logger.new(STDOUT)
Constants included from GitExplorer
Instance Method Summary collapse
Methods included from GitExplorer
#extract_dir_name, #extract_light_status, #extract_path, #extract_status, #git_repository?, #git_status, #translate_color, #translate_status
Instance Method Details
#explore(root_dir = './') ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/git_explorer.rb', line 82 def explore(root_dir='./') if .light? run("ls #{root_dir} -l | awk '{if(NR>1)print}'", config={:capture=>true, :verbose=>false}) .split("\n") .map{|line| Line.new(line)} .map{|line| Line.new(line.full_line, '', git_repository?(extract_path(line.full_line, root_dir)))} .map{|line| Line.new(line.full_line, (extract_light_status(git_status(extract_path(line.full_line, root_dir))) if line.git_repository == true), line.git_repository)} .map{|line| say(="#{line.full_line} ") say(="#{'[' + line.state.branch + ']'} #{translate_status(line.state.status)} ", color=(translate_color(line.state.status))) if line.git_repository say(="\n") } else run("find #{root_dir} -type d -name .git", config={:capture=>true, :verbose=>false}) .split("\n") .map{|file| file >> extract_dir_name} .map{|dir| run("basename `git -C #{dir} rev-parse --show-toplevel`; git -C #{dir} status", config={:capture=>true, :verbose=>false})} .map{|status| status >> extract_status} .map{|status| say(="#{status.project_name} is #{status.status} on branch #{status.branch}\n#{status.files.map{|f| "\t#{f}\n"}.join}", color=(:red if status.status.equal?(:not_staged)))} end end |