Class: Dependabot::Config::File
- Inherits:
-
Object
- Object
- Dependabot::Config::File
- 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
-
.parse(config) ⇒ Object
Parse the YAML config file.
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.
12 13 14 15 |
# File 'lib/dependabot/config/file.rb', line 12 def initialize(updates:, registries: nil) @updates = updates || [] @registries = registries || [] end |
Instance Attribute Details
#registries ⇒ Object (readonly)
Returns the value of attribute registries.
10 11 12 |
# File 'lib/dependabot/config/file.rb', line 10 def registries @registries end |
#updates ⇒ Object (readonly)
Returns the value of attribute updates.
10 11 12 |
# File 'lib/dependabot/config/file.rb', line 10 def updates @updates end |
Class Method Details
.parse(config) ⇒ Object
Parse the YAML config file
31 32 33 34 35 36 37 |
# File 'lib/dependabot/config/file.rb', line 31 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
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dependabot/config/file.rb', line 17 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 Dependabot::Config::UpdateConfig.new( ignore_conditions: ignore_conditions(cfg), commit_message_options: (cfg) ) end |