Module: Jeny::Command::Support

Included in:
Generate, Snippets
Defined in:
lib/jeny/command/support.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.simplify_path(path) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/jeny/command/support.rb', line 5

def simplify_path(path)
  if path.to_s.start_with?(Path.pwd.to_s)
    path.relative_to(Path.pwd)
  else
    path
  end
end

Instance Method Details

#edit_changed_files(changed) ⇒ Object



14
15
16
17
18
19
# File 'lib/jeny/command/support.rb', line 14

def edit_changed_files(changed)
  to_open = changed
    .select{|pair| config.should_be_edited?(*pair) }
    .map{|pair| simplify_path(pair.first) }
  config.open_editor(to_open) unless to_open.empty?
end