-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove monkey patched Parser and just extend the class
- Loading branch information
Showing
3 changed files
with
48 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Extend Lockfile to normalize module names from acme/mod to acme-mod | ||
module Librarian | ||
module Puppet | ||
class Lockfile < Librarian::Lockfile | ||
|
||
# Extend the parser to normalize module names in old .lock files, converting / to - | ||
class Parser < Librarian::Lockfile::Parser | ||
|
||
include Librarian::Puppet::Util | ||
|
||
def extract_and_parse_sources(lines) | ||
sources = super | ||
sources.each do |source| | ||
source[:manifests] = Hash[source[:manifests].map do |name,manifest| | ||
[normalize_name(name), manifest] | ||
end] | ||
end | ||
sources | ||
end | ||
|
||
def extract_and_parse_dependencies(lines, manifests_index) | ||
# when looking up in manifests_index normalize the name beforehand | ||
class << manifests_index | ||
include Librarian::Puppet::Util | ||
alias_method :old_lookup, :[] | ||
define_method(:[]) { |k| self.old_lookup(normalize_name(k)) } | ||
end | ||
super(lines, manifests_index) | ||
end | ||
|
||
end | ||
|
||
def load(string) | ||
Parser.new(environment).parse(string) | ||
end | ||
|
||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.