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: Reviewer.arguments.tags.raw, keywords: Reviewer.arguments.keywords.for_tags) ⇒ self

Generates an instace 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: (defaults to: Reviewer.arguments.tags.raw)

    Reviewer.arguments.tags.raw [Array<String>] tag arguments provided directly via the -t or –tags flag on the command line.

  • keywords: (defaults to: Reviewer.arguments.keywords.for_tags)

    Reviewer.arguments.keywords [Array, String] keywords that can potentially be translated to a list of tags based on the tags used in the configuration file



26
27
28
29
# File 'lib/reviewer/arguments/tags.rb', line 26

def initialize(provided: Reviewer.arguments.tags.raw, keywords: Reviewer.arguments.keywords.for_tags)
  @provided = Array(provided)
  @keywords = Array(keywords)
end

Instance Attribute Details

#keywordsObject

Returns the value of attribute keywords.



7
8
9
# File 'lib/reviewer/arguments/tags.rb', line 7

def keywords
  @keywords
end

#providedObject Also known as: raw

Returns the value of attribute provided.



7
8
9
# File 'lib/reviewer/arguments/tags.rb', line 7

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



34
35
36
# File 'lib/reviewer/arguments/tags.rb', line 34

def to_a
  tag_list
end

#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



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

def to_s
  to_a.join(',')
end