Class: RikaCommand
- Inherits:
-
Object
- Object
- RikaCommand
- Defined in:
- lib/rika/cli/rika_command.rb
Overview
This command line application enables the parsing of documents on the command line. Syntax is:
rika [options] <file or url> [...file or url...]
Run with -h or –help option for more details.
Defaults to outputting both content (text) and metadata, but the -t and -m flags can be used to enable or suppress either. Supports output formats of JSON, Pretty JSON, YAML, Awesome Print, to_s, and inspect (see Formatters class).
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#help_text ⇒ Object
readonly
Returns the value of attribute help_text.
-
#metadata_formatter ⇒ Object
readonly
Returns the value of attribute metadata_formatter.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
-
#text_formatter ⇒ Object
readonly
Returns the value of attribute text_formatter.
Instance Method Summary collapse
-
#call ⇒ Object
Main method and entry point for this class’ work.
-
#initialize(args = ARGV) ⇒ RikaCommand
constructor
A new instance of RikaCommand.
Constructor Details
#initialize(args = ARGV) ⇒ RikaCommand
Returns a new instance of RikaCommand.
21 22 23 24 25 |
# File 'lib/rika/cli/rika_command.rb', line 21 def initialize(args = ARGV) # Dup the array in case it has been frozen. The array will be modified later when options are parsed # and removed, and when directories are removed, so this array should not be frozen. @args = args.dup end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
18 19 20 |
# File 'lib/rika/cli/rika_command.rb', line 18 def args @args end |
#help_text ⇒ Object (readonly)
Returns the value of attribute help_text.
18 19 20 |
# File 'lib/rika/cli/rika_command.rb', line 18 def help_text @help_text end |
#metadata_formatter ⇒ Object (readonly)
Returns the value of attribute metadata_formatter.
18 19 20 |
# File 'lib/rika/cli/rika_command.rb', line 18 def @metadata_formatter end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/rika/cli/rika_command.rb', line 18 def @options end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
18 19 20 |
# File 'lib/rika/cli/rika_command.rb', line 18 def targets @targets end |
#text_formatter ⇒ Object (readonly)
Returns the value of attribute text_formatter.
18 19 20 |
# File 'lib/rika/cli/rika_command.rb', line 18 def text_formatter @text_formatter end |
Instance Method Details
#call ⇒ Object
Main method and entry point for this class’ work.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rika/cli/rika_command.rb', line 28 def call prepare report_and_exit_if_no_targets_specified if [:as_array] puts result_array_output else targets.each do |target| result = Rika.parse(target, max_content_length: max_content_length, key_sort: [:key_sort]) puts single_document_output(target, result) end end nil end |