Class: Expressir::Commands::Format

Inherits:
Base
  • Object
show all
Defined in:
lib/expressir/commands/format.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#exit_with_error, #initialize, #say

Constructor Details

This class inherits a constructor from Expressir::Commands::Base

Instance Method Details

#run(path) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/expressir/commands/format.rb', line 4

def run(path)
  repository = Expressir::Express::Parser.from_file(path)

  profile = options[:profile] || "iso"

  case profile.downcase
  when "elf"
    format_with_elf_profile(repository)
  when "iso"
    format_with_iso_profile(repository)
  else
    raise Expressir::InvalidOptionError.new(
      "profile",
      profile,
      valid_options: ["iso", "elf"],
    )
  end
end