Class: Dependabot::DependencyGroup

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, rules:) ⇒ DependencyGroup

Returns a new instance of DependencyGroup.



15
16
17
18
19
20
# File 'lib/dependabot/dependency_group.rb', line 15

def initialize(name:, rules:)
  @name = name
  @rules = rules
  @dependencies = []
  @handled_dependencies = Set.new
end

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



13
14
15
# File 'lib/dependabot/dependency_group.rb', line 13

def dependencies
  @dependencies
end

#handled_dependenciesObject (readonly)

Returns the value of attribute handled_dependencies.



13
14
15
# File 'lib/dependabot/dependency_group.rb', line 13

def handled_dependencies
  @handled_dependencies
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/dependabot/dependency_group.rb', line 13

def name
  @name
end

#rulesObject (readonly)

Returns the value of attribute rules.



13
14
15
# File 'lib/dependabot/dependency_group.rb', line 13

def rules
  @rules
end

Instance Method Details

#add_all_to_handledObject



26
27
28
# File 'lib/dependabot/dependency_group.rb', line 26

def add_all_to_handled
  @handled_dependencies += dependencies.map(&:name)
end

#add_to_handled(*dependencies) ⇒ Object



22
23
24
# File 'lib/dependabot/dependency_group.rb', line 22

def add_to_handled(*dependencies)
  @handled_dependencies += dependencies.map(&:name)
end

#contains?(dependency) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
# File 'lib/dependabot/dependency_group.rb', line 30

def contains?(dependency)
  return true if @dependencies.include?(dependency)
  return false if matches_excluded_pattern?(dependency.name)

  matches_pattern?(dependency.name) && matches_dependency_type?(dependency)
end

#to_config_yamlObject

Provides a debug utility to view the group as it appears in the config file.



42
43
44
45
46
# File 'lib/dependabot/dependency_group.rb', line 42

def to_config_yaml
  {
    "groups" => { name => rules }
  }.to_yaml.delete_prefix("---\n")
end

#to_hObject



37
38
39
# File 'lib/dependabot/dependency_group.rb', line 37

def to_h
  { "name" => name }
end