Class: FileUtil
- Inherits:
-
Object
- Object
- FileUtil
- Defined in:
- lib/yadecli/util/file_util.rb
Overview
cli util
Class Method Summary collapse
- .git_current_branch(dir) ⇒ Object
-
.git_status(dir) ⇒ Object
git status.
-
.script_dir ⇒ Object
scripts dir.
- .script_path(script_name) ⇒ Object
Class Method Details
.git_current_branch(dir) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/yadecli/util/file_util.rb', line 28 def git_current_branch(dir) cmd = TTY::Command.new(output: Yadecli.LOGGER) out, err = cmd.run('git rev-parse --abbrev-ref HEAD', chdir: dir) out.chomp end |
.git_status(dir) ⇒ Object
git status
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/yadecli/util/file_util.rb', line 13 def git_status(dir) cmd = TTY::Command.new(output: Yadecli.LOGGER) out, err = cmd.run('git fetch', chdir: dir) out, err = cmd.run('git status -uno', chdir: dir) if out.include? 'Your branch is ahead' GitStatus::NEEDS_PUSH elsif out.include? 'Your branch is behind' GitStatus::NEEDS_PULL else GitStatus::UP_TO_DATE end end |
.script_dir ⇒ Object
scripts dir
36 37 38 39 40 |
# File 'lib/yadecli/util/file_util.rb', line 36 def script_dir script_dir = File.join(File.dirname(File.(__FILE__)), '../../../scripts') script_dir end |
.script_path(script_name) ⇒ Object
42 43 44 |
# File 'lib/yadecli/util/file_util.rb', line 42 def script_path(script_name) "#{script_dir}/#{script_name}" end |