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
# File 'lib/dependabot/dependency_group.rb', line 15

def initialize(name:, rules:)
  @name = name
  @rules = rules
  @dependencies = []
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

#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

#contains?(dependency) ⇒ Boolean

Returns:

  • (Boolean)


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

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.



33
34
35
36
37
# File 'lib/dependabot/dependency_group.rb', line 33

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

#to_hObject



28
29
30
# File 'lib/dependabot/dependency_group.rb', line 28

def to_h
  { "name" => name }
end