Class: Dependabot::Config::UpdateConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/config/update_config.rb

Overview

Configuration for a single ecosystem

Defined Under Namespace

Classes: CommitMessageOptions

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ignore_conditions: nil, commit_message_options: nil) ⇒ UpdateConfig

Returns a new instance of UpdateConfig.


10
11
12
13
# File 'lib/dependabot/config/update_config.rb', line 10

def initialize(ignore_conditions: nil, commit_message_options: nil)
  @ignore_conditions = ignore_conditions || []
  @commit_message_options = commit_message_options
end

Instance Attribute Details

#commit_message_optionsObject (readonly)

Returns the value of attribute commit_message_options.


9
10
11
# File 'lib/dependabot/config/update_config.rb', line 9

def commit_message_options
  @commit_message_options
end

#ignore_conditionsObject (readonly)

Returns the value of attribute ignore_conditions.


9
10
11
# File 'lib/dependabot/config/update_config.rb', line 9

def ignore_conditions
  @ignore_conditions
end

Class Method Details

.wildcard_match?(wildcard_string, candidate_string) ⇒ Boolean

Returns:

  • (Boolean)

27
28
29
30
31
32
33
34
35
# File 'lib/dependabot/config/update_config.rb', line 27

def self.wildcard_match?(wildcard_string, candidate_string)
  return false unless wildcard_string && candidate_string

  regex_string = "a#{wildcard_string.downcase}a".split("*").
                 map { |p| Regexp.quote(p) }.
                 join(".*").gsub(/^a|a$/, "")
  regex = /^#{regex_string}$/
  regex.match?(candidate_string.downcase)
end

Instance Method Details

#ignored_versions_for(dependency, security_updates_only: false) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dependabot/config/update_config.rb', line 15

def ignored_versions_for(dependency, security_updates_only: false)
  normalizer = name_normaliser_for(dependency)
  dep_name = normalizer.call(dependency.name)

  @ignore_conditions.
    select { |ic| self.class.wildcard_match?(normalizer.call(ic.dependency_name), dep_name) }.
    map { |ic| ic.ignored_versions(dependency, security_updates_only) }.
    flatten.
    compact.
    uniq
end