Class: Avm::Tools::Runner::Files::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/tools/runner/files/format.rb

Instance Method Summary collapse

Instance Method Details

#formatter_optionsObject



25
26
27
28
29
# File 'lib/avm/tools/runner/files/format.rb', line 25

def formatter_options
  { ::Avm::Files::Formatter::OPTION_APPLY => parsed.apply?,
    ::Avm::Files::Formatter::OPTION_RECURSIVE => !parsed.no_recursive?,
    ::Avm::Files::Formatter::OPTION_VERBOSE => parsed.verbose? }
end

#gitObject



31
32
33
# File 'lib/avm/tools/runner/files/format.rb', line 31

def git
  @git ||= ::Avm::Launcher::Git::Base.new('.')
end

#git_dirty_filesObject



35
36
37
# File 'lib/avm/tools/runner/files/format.rb', line 35

def git_dirty_files
  git.dirty_files.map { |f| git.root_path.join(f.path) }.select(&:exist?).map(&:to_s)
end

#runObject



21
22
23
# File 'lib/avm/tools/runner/files/format.rb', line 21

def run
  ::Avm::Files::Formatter.new(source_paths, formatter_options).run
end

#source_pathsObject



39
40
41
42
43
44
45
# File 'lib/avm/tools/runner/files/format.rb', line 39

def source_paths
  if parsed.git_dirty?
    parsed.paths + git_dirty_files
  else
    parsed.paths.if_present(%w[.])
  end
end