Sha256: a0bdb43c2621cff9607d7bef78c2aa227a685354a6971e59e584fc59a57724e4

Contents?: true

Size: 1.05 KB

Versions: 20

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

# Options used when comparing catalogs - set ignored changes.
# @param parser [OptionParser object] The OptionParser argument
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:ignore) do
  has_weight 130

  def parse(parser, options)
    descriptive_text = 'More resources to ignore in format type[title]'
    parser.on('--ignore "Type1[Title1],Type2[Title2],..."', Array, descriptive_text) do |res|
      options[:ignore] ||= []
      res.each do |item|
        if item =~ /\A(.+?)\[(.+)\](.+)/
          h = { type: Regexp.last_match(1), title: Regexp.last_match(2) }
          h[:attr] = Regexp.last_match(3).gsub(/(\\f|::)/, "\f")
          options[:ignore] << h
        elsif item =~ /^(.+?)\[(.+)\]$/
          options[:ignore] << { type: Regexp.last_match(1), title: Regexp.last_match(2) }
        else
          raise ArgumentError, "Ignore #{item} must be in Type[Title] or Type[Title]::Attribute format!"
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
octocatalog-diff-2.3.1 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-2.3.0 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-2.1.0 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-2.0.0 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.6.0 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.5.4 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.5.3 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.5.2 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.5.1 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.5.0 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.4.1 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.4.0 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.3.0 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.2.0 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.1.0 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.0.4 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.0.3 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.0.2 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.0.1 lib/octocatalog-diff/cli/options/ignore.rb
octocatalog-diff-1.0.0 lib/octocatalog-diff/cli/options/ignore.rb