Class: Dependabot::DependencyGroup

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/dependency_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, rules:, applies_to: "version-updates") ⇒ DependencyGroup

Returns a new instance of DependencyGroup.



36
37
38
39
40
41
42
# File 'lib/dependabot/dependency_group.rb', line 36

def initialize(name:, rules:, applies_to: "version-updates")
  @name = name
  # For backwards compatibility, if no applies_to is provided, default to "version-updates"
  @applies_to = T.let(applies_to || "version-updates", String)
  @rules = rules
  @dependencies = T.let([], T::Array[Dependabot::Dependency])
end

Instance Attribute Details

#applies_toObject (readonly)

Returns the value of attribute applies_to.



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

def applies_to
  @applies_to
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



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

def dependencies
  @dependencies
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#rulesObject (readonly)

Returns the value of attribute rules.



20
21
22
# File 'lib/dependabot/dependency_group.rb', line 20

def rules
  @rules
end

Instance Method Details

#contains?(dependency) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
# File 'lib/dependabot/dependency_group.rb', line 45

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



59
60
61
62
63
# File 'lib/dependabot/dependency_group.rb', line 59

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

#to_hObject



53
54
55
# File 'lib/dependabot/dependency_group.rb', line 53

def to_h
  { "name" => name }
end