Class: Dependabot::DependencyGroup
- Inherits:
-
Object
- Object
- Dependabot::DependencyGroup
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/dependency_group.rb
Instance Attribute Summary collapse
-
#applies_to ⇒ Object
readonly
Returns the value of attribute applies_to.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#exclude_patterns ⇒ Object
readonly
Returns the value of attribute exclude_patterns.
-
#group_by ⇒ Object
readonly
Returns the value of attribute group_by.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#patterns ⇒ Object
readonly
Returns the value of attribute patterns.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#update_types ⇒ Object
readonly
Returns the value of attribute update_types.
Instance Method Summary collapse
- #contains?(dependency) ⇒ Boolean
- #group_by_dependency_name? ⇒ Boolean
-
#initialize(name:, rules:, applies_to: "version-updates") ⇒ DependencyGroup
constructor
A new instance of DependencyGroup.
- #to_config_yaml ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name:, rules:, applies_to: "version-updates") ⇒ DependencyGroup
Returns a new instance of DependencyGroup.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dependabot/dependency_group.rb', line 52 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 @group_by = T.let(string_rule(rules, "group-by"), T.nilable(String)) @patterns = T.let(string_array_rule(rules, "patterns"), T.nilable(T::Array[String])) @exclude_patterns = T.let(string_array_rule(rules, "exclude-patterns"), T.nilable(T::Array[String])) @update_types = T.let(string_array_rule(rules, "update-types"), T.nilable(T::Array[String])) @dependencies = T.let([], T::Array[Dependabot::Dependency]) end |
Instance Attribute Details
#applies_to ⇒ Object (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 |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
23 24 25 |
# File 'lib/dependabot/dependency_group.rb', line 23 def dependencies @dependencies end |
#exclude_patterns ⇒ Object (readonly)
Returns the value of attribute exclude_patterns.
39 40 41 |
# File 'lib/dependabot/dependency_group.rb', line 39 def exclude_patterns @exclude_patterns end |
#group_by ⇒ Object (readonly)
Returns the value of attribute group_by.
29 30 31 |
# File 'lib/dependabot/dependency_group.rb', line 29 def group_by @group_by end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/dependabot/dependency_group.rb', line 17 def name @name end |
#patterns ⇒ Object (readonly)
Returns the value of attribute patterns.
36 37 38 |
# File 'lib/dependabot/dependency_group.rb', line 36 def patterns @patterns end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
20 21 22 |
# File 'lib/dependabot/dependency_group.rb', line 20 def rules @rules end |
#update_types ⇒ Object (readonly)
Returns the value of attribute update_types.
42 43 44 |
# File 'lib/dependabot/dependency_group.rb', line 42 def update_types @update_types end |
Instance Method Details
#contains?(dependency) ⇒ Boolean
65 66 67 68 69 70 |
# File 'lib/dependabot/dependency_group.rb', line 65 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 |
#group_by_dependency_name? ⇒ Boolean
73 74 75 |
# File 'lib/dependabot/dependency_group.rb', line 73 def group_by_dependency_name? @group_by == "dependency-name" end |
#to_config_yaml ⇒ Object
84 85 86 87 88 |
# File 'lib/dependabot/dependency_group.rb', line 84 def to_config_yaml { "groups" => { name => rules } }.to_yaml.delete_prefix("---\n") end |
#to_h ⇒ Object
78 79 80 |
# File 'lib/dependabot/dependency_group.rb', line 78 def to_h { "name" => name } end |