Class: YardJunk::Janitor::YardOptions
- Inherits:
-
Object
- Object
- YardJunk::Janitor::YardOptions
- Defined in:
- lib/yard-junk/janitor/yard_options.rb
Overview
Allows to properly parse ‘.yardopts` or other option file YARD supports and gracefully replace or remove some of options.
Defined Under Namespace
Classes: Internal
Instance Attribute Summary collapse
-
#extra_files ⇒ Object
readonly
Returns the value of attribute extra_files.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ YardOptions
constructor
A new instance of YardOptions.
- #remove_option(long, short = nil) ⇒ Object
- #set_files(*files) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ YardOptions
Returns a new instance of YardOptions.
10 11 12 13 14 15 16 |
# File 'lib/yard-junk/janitor/yard_options.rb', line 10 def initialize internal = Internal.new internal.parse_arguments @options = internal.option_args @files = internal.files @extra_files = internal..files end |
Instance Attribute Details
#extra_files ⇒ Object (readonly)
Returns the value of attribute extra_files.
8 9 10 |
# File 'lib/yard-junk/janitor/yard_options.rb', line 8 def extra_files @extra_files end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
8 9 10 |
# File 'lib/yard-junk/janitor/yard_options.rb', line 8 def files @files end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/yard-junk/janitor/yard_options.rb', line 8 def @options end |
Instance Method Details
#remove_option(long, short = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/yard-junk/janitor/yard_options.rb', line 24 def remove_option(long, short = nil) [short, long].compact.each do |o| i = @options.index(o) next unless i @options.delete_at(i) @options.delete_at(i) unless @options[i].start_with?('-') # it was argument end self end |
#set_files(*files) ⇒ Object
18 19 20 21 22 |
# File 'lib/yard-junk/janitor/yard_options.rb', line 18 def set_files(*files) # TODO: REALLY fragile :( @files, @extra_files = files.partition { |f| f =~ /\.(rb|c|cxx|cpp|rake)/ } self end |
#to_a ⇒ Object
35 36 37 38 |
# File 'lib/yard-junk/janitor/yard_options.rb', line 35 def to_a (@options + @files) .tap { |res| res.push('-', *@extra_files) unless @extra_files.empty? } end |