Class: Dependabot::Config::File
- Inherits:
-
Object
- Object
- Dependabot::Config::File
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/config/file.rb
Overview
Configuration for the repository, a parsed dependabot.yaml.
Instance Attribute Summary collapse
-
#registries ⇒ Object
readonly
Returns the value of attribute registries.
-
#updates ⇒ Object
readonly
Returns the value of attribute updates.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(updates:, registries: nil) ⇒ File
constructor
A new instance of File.
- #update_config(package_manager, directory: nil, target_branch: nil) ⇒ Object
Constructor Details
#initialize(updates:, registries: nil) ⇒ File
Returns a new instance of File.
26 27 28 29 |
# File 'lib/dependabot/config/file.rb', line 26 def initialize(updates:, registries: nil) @updates = T.let(updates || [], T::Array[T::Hash[Symbol, String]]) @registries = T.let(registries || {}, T::Hash[Symbol, T::Hash[Symbol, String]]) end |
Instance Attribute Details
#registries ⇒ Object (readonly)
Returns the value of attribute registries.
17 18 19 |
# File 'lib/dependabot/config/file.rb', line 17 def registries @registries end |
#updates ⇒ Object (readonly)
Returns the value of attribute updates.
14 15 16 |
# File 'lib/dependabot/config/file.rb', line 14 def updates @updates end |
Class Method Details
.parse(config) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/dependabot/config/file.rb', line 50 def self.parse(config) parsed = YAML.safe_load(config, symbolize_names: true) version = parsed[:version] raise InvalidConfigError, "invalid version #{version}" if version && version != 2 File.new(updates: parsed[:updates], registries: parsed[:registries]) end |
Instance Method Details
#update_config(package_manager, directory: nil, target_branch: nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dependabot/config/file.rb', line 35 def update_config(package_manager, directory: nil, target_branch: nil) dir = directory || "/" package_ecosystem = PACKAGE_MANAGER_LOOKUP.invert.fetch(package_manager) cfg = updates.find do |u| u[:"package-ecosystem"] == package_ecosystem && u[:directory] == dir && (target_branch.nil? || u[:"target-branch"] == target_branch) end UpdateConfig.new( ignore_conditions: ignore_conditions(cfg), commit_message_options: (cfg) ) end |