Class: Avm::Tools::Runner::Files::Format
- Inherits:
-
EacRubyUtils::Console::DocoptRunner
- Object
- EacRubyUtils::Console::DocoptRunner
- Avm::Tools::Runner::Files::Format
- Includes:
- EacRubyUtils::Console::Speaker
- Defined in:
- lib/avm/tools/runner/files/format.rb
Constant Summary collapse
- DOC =
<<~DOCOPT Format files. Usage: __PROGRAM__ [options] [<paths>...] __PROGRAM__ -h | --help Options: -h --help Show this screen. -a --apply Confirm changes. -n --no-recursive No recursive. -v --verbose Verbose -d --git-dirty Select Git dirty files to format. DOCOPT
Instance Method Summary collapse
- #formatter_options ⇒ Object
- #git ⇒ Object
- #git_dirty_files ⇒ Object
- #run ⇒ Object
- #source_paths ⇒ Object
Instance Method Details
#formatter_options ⇒ Object
34 35 36 37 |
# File 'lib/avm/tools/runner/files/format.rb', line 34 def { apply: .fetch('--apply'), recursive: !.fetch('--no-recursive'), verbose: .fetch('--verbose') } end |
#git ⇒ Object
39 40 41 |
# File 'lib/avm/tools/runner/files/format.rb', line 39 def git @git ||= ::EacLauncher::Git::Base.new('.') end |
#git_dirty_files ⇒ Object
43 44 45 |
# File 'lib/avm/tools/runner/files/format.rb', line 43 def git_dirty_files git.dirty_files.map { |f| git.root_path.join(f.path) }.select(&:exist?).map(&:to_s) end |
#run ⇒ Object
30 31 32 |
# File 'lib/avm/tools/runner/files/format.rb', line 30 def run ::Avm::Files::Formatter.new(source_paths, ).run end |
#source_paths ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/avm/tools/runner/files/format.rb', line 47 def source_paths if .fetch('--git-dirty') .fetch('<paths>') + git_dirty_files else .fetch('<paths>').if_present(%w[.]) end end |