Class: Reviewer::Arguments::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/arguments/tags.rb

Overview

Handles the logic of translating tag arguments

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provided: [], keywords: []) ⇒ self

Generates an instance of parsed tags from the provided arguments by merging tag arguments

that were provided via either flags or keywords

Examples:

Using keywords: ‘rvw ruby` (assuming a ’ruby’ tag is defined)

Reviewer::Arguments::Tags.new.to_a # => ['ruby']

Using the -t flag: ‘rvw -t ruby`

Reviewer::Arguments::Tags.new.to_a # => ['ruby']

Using the --tags flag: ‘rvw -t ruby,css`

Reviewer::Arguments::Tags.new.to_a # => ['css', 'ruby']

Parameters:

  • provided (Array<String>) (defaults to: [])

    tag arguments provided directly via the -t or –tags flag on the command line.

  • keywords (Array, String) (defaults to: [])

    keywords that can potentially be translated to a list of tags based on the tags used in the configuration file



30
31
32
33
# File 'lib/reviewer/arguments/tags.rb', line 30

def initialize(provided: [], keywords: [])
  @provided = Array(provided)
  @keywords = Array(keywords)
end

Instance Attribute Details

#keywordsObject

Returns the value of attribute keywords.



11
# File 'lib/reviewer/arguments/tags.rb', line 11

attr_reader :provided, :keywords

#providedArray<String> Also known as: raw

Returns tags explicitly provided via -t or –tags flag.

Returns:

  • (Array<String>)

    tags explicitly provided via -t or –tags flag



11
12
13
# File 'lib/reviewer/arguments/tags.rb', line 11

def provided
  @provided
end

Instance Method Details

#to_aArray<String>

Provides the full list of tags values derived from the command-line arguments

Returns:

  • (Array<String>)

    full collection of the tag arguments as a string



38
# File 'lib/reviewer/arguments/tags.rb', line 38

def to_a = tag_list

#to_hHash Also known as: inspect

Summary of the state of the tag arguments

Returns:

  • (Hash)

    represents the summary of the tag values parsed from the command-line



48
49
50
51
52
53
# File 'lib/reviewer/arguments/tags.rb', line 48

def to_h
  {
    provided: provided.sort,
    from_keywords: keywords.sort
  }
end

#to_sString

Provides the full list of tag values derived from the command-line arguments

Returns:

  • (String)

    comma-separated string of the derived tag values



43
# File 'lib/reviewer/arguments/tags.rb', line 43

def to_s = to_a.join(',')