Class: Brutal::CommandLineArgumentsParser
- Inherits:
-
Object
- Object
- Brutal::CommandLineArgumentsParser
- Defined in:
- lib/brutal/command_line_arguments_parser.rb
Overview
Accept an arbitrary number of arguments passed from the command-line.
Constant Summary collapse
- MANIFEST_FILENAME_PATTERN =
::File.join("**", Manifest::File::Name::SUFFIX_PATTERN)
- CURRENT_DIRECTORY_CONTEXT =
"."
- GEM_NAME =
"brutal"
- HELP_OPTION =
"--help"
- VERSION_OPTION =
"--version"
- RUBY_FORMAT_OPTION =
"--format=ruby"
- DEFAULT_FORMAT_OPTION =
RUBY_FORMAT_OPTION
- FORMAT_OPTIONS =
{ RUBY_FORMAT_OPTION => :Ruby }.freeze
- DEFAULT_FORMAT =
FORMAT_OPTIONS.fetch(DEFAULT_FORMAT_OPTION)
- DEFAULT_FORMATS =
[DEFAULT_FORMAT].freeze
Instance Attribute Summary collapse
-
#pathnames ⇒ Object
readonly
Returns the value of attribute pathnames.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(*args) ⇒ CommandLineArgumentsParser
constructor
A new instance of CommandLineArgumentsParser.
Constructor Details
#initialize(*args) ⇒ CommandLineArgumentsParser
Returns a new instance of CommandLineArgumentsParser.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/brutal/command_line_arguments_parser.rb', line 27 def initialize(*args) args.each do |arg| help! if arg == HELP_OPTION version! if arg == VERSION_OPTION end @formats = [] @pathnames = [] args << CURRENT_DIRECTORY_CONTEXT unless any_path_given?(*args) args.each { |arg| parse!(arg) } end |
Instance Attribute Details
#pathnames ⇒ Object (readonly)
Returns the value of attribute pathnames.
25 26 27 |
# File 'lib/brutal/command_line_arguments_parser.rb', line 25 def pathnames @pathnames end |
Instance Method Details
#call ⇒ Object
40 41 42 |
# File 'lib/brutal/command_line_arguments_parser.rb', line 40 def call [formats, pathnames] end |