Class: PuppetLibrary::Forge::GitRepository
- Inherits:
-
Abstract
show all
- Defined in:
- lib/puppet_library/forge/git_repository.rb
Overview
A forge for serving modules from a Git repository
Usage:
forge = PuppetLibrary::Forge::GitRepository.configure do
source "http://example.com/mymodule.git"
include_tags /[0-9.]+/
end
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Abstract
#collect_dependencies_versions, #get_module_buffer, #get_module_metadata, #get_module_metadata_with_dependencies, #retrieve_all_metadata, #retrieve_metadata, #search_modules
#debug, #info, #logger, #logs, #warn
Constructor Details
#initialize(git, version_tag_regex) ⇒ GitRepository
59
60
61
62
63
64
65
|
# File 'lib/puppet_library/forge/git_repository.rb', line 59
def initialize(git, version_tag_regex)
super(self)
@version_tag_regex = version_tag_regex
@git = git
@metadata_cache = PuppetLibrary::Http::Cache::InMemory.new(60)
@tags_cache = PuppetLibrary::Http::Cache::InMemory.new(60)
end
|
Class Method Details
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/puppet_library/forge/git_repository.rb', line 41
def self.configure(&block)
config_api = PuppetLibrary::Util::ConfigApi.for(GitRepository) do
required :source, "path or URL"
required :include_tags, "regex" do |value|
value.tap do |value|
raise "not a regex" unless value.is_a? Regexp
end
end
end
config = config_api.configure(&block)
cache_dir = PuppetLibrary::Util::TempDir.new("git-repo-cache")
git = PuppetLibrary::Util::Git.new(config.get_source, cache_dir)
GitRepository.new(git, config.get_include_tags)
end
|
Instance Method Details
#clear_cache ⇒ Object
71
72
73
|
# File 'lib/puppet_library/forge/git_repository.rb', line 71
def clear_cache
@git.clear_cache!
end
|
90
91
92
93
94
|
# File 'lib/puppet_library/forge/git_repository.rb', line 90
def get_all_metadata
tags.map do |tag|
metadata_for_tag(tag)
end
end
|
96
97
98
99
100
101
102
|
# File 'lib/puppet_library/forge/git_repository.rb', line 96
def get_metadata(author, module_name)
metadata = get_all_metadata
metadata.select do |m|
m["author"] == author
m["name"] == "#{author}-#{module_name}"
end
end
|
#get_module(author, name, version) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/puppet_library/forge/git_repository.rb', line 75
def get_module(author, name, version)
return nil unless tags.include? tag_for(version)
metadata = metadata_for(version)
return nil unless metadata["name"] == "#{author}-#{name}"
with_tag_for(version) do |tag_path|
PuppetLibrary::Archive::Archiver.archive_dir(tag_path, "#{metadata["name"]}-#{version}") do |archive|
archive.add_file("metadata.json", 0644) do |entry|
entry.write metadata.to_json
end
end
end
end
|
#prime ⇒ Object
67
68
69
|
# File 'lib/puppet_library/forge/git_repository.rb', line 67
def prime
@git.update_cache!
end
|