Class: Librarian::Puppet::Source::Forge
- Inherits:
-
Object
- Object
- Librarian::Puppet::Source::Forge
show all
- Includes:
- Util
- Defined in:
- lib/librarian/puppet/source/forge.rb,
lib/librarian/puppet/source/forge/repo.rb,
lib/librarian/puppet/source/forge/repo_v1.rb,
lib/librarian/puppet/source/forge/repo_v3.rb
Defined Under Namespace
Classes: Repo, RepoV1, RepoV3
Constant Summary
collapse
- LOCK_NAME =
'FORGE'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Util
#clean_uri, #cp_r, #debug, #info, #normalize_name, #organization_name, #warn
Constructor Details
#initialize(environment, uri, options = {}) ⇒ Forge
Returns a new instance of Forge.
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/librarian/puppet/source/forge.rb', line 53
def initialize(environment, uri, options = {})
self.environment = environment
if uri =~ %r{^http(s)?://forge\.puppetlabs\.com}
uri = "https://forgeapi.puppetlabs.com"
warn { "Replacing Puppet Forge API URL to use v3 #{uri}. You should update your Puppetfile" }
end
@uri = URI::parse(uri)
@cache_path = nil
end
|
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
49
50
51
|
# File 'lib/librarian/puppet/source/forge.rb', line 49
def environment
@environment
end
|
#uri ⇒ Object
Returns the value of attribute uri.
51
52
53
|
# File 'lib/librarian/puppet/source/forge.rb', line 51
def uri
@uri
end
|
Class Method Details
.client_api_version ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/librarian/puppet/source/forge.rb', line 33
def client_api_version()
version = 1
pe_version = Librarian::Puppet.puppet_version.match(/\(Puppet Enterprise (.+)\)/)
if Librarian::Puppet::puppet_gem_version >= Gem::Version.create('3.6.0.a')
version = 3
elsif pe_version and Gem::Version.create(pe_version[1].strip) >= Gem::Version.create('3.2.0')
version = 3
end
return version
end
|
.from_lock_options(environment, options) ⇒ Object
19
20
21
|
# File 'lib/librarian/puppet/source/forge.rb', line 19
def from_lock_options(environment, options)
new(environment, options[:remote], options.reject { |k, v| k == :remote })
end
|
.from_spec_args(environment, uri, options) ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/librarian/puppet/source/forge.rb', line 23
def from_spec_args(environment, uri, options)
recognised_options = []
unrecognised_options = options.keys - recognised_options
unless unrecognised_options.empty?
raise Error, "unrecognised options: #{unrecognised_options.join(", ")}"
end
new(environment, uri, options)
end
|
.lock_name ⇒ Object
15
16
17
|
# File 'lib/librarian/puppet/source/forge.rb', line 15
def lock_name
LOCK_NAME
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
69
70
71
72
73
|
# File 'lib/librarian/puppet/source/forge.rb', line 69
def ==(other)
other &&
self.class == other.class &&
self.uri == other.uri
end
|
#cache_path ⇒ Object
116
117
118
119
120
121
|
# File 'lib/librarian/puppet/source/forge.rb', line 116
def cache_path
@cache_path ||= begin
dir = "#{uri.host}#{uri.path}".gsub(/[^0-9a-z\-_]/i, '_')
environment.cache_path.join("source/puppet/forge/#{dir}")
end
end
|
#fetch_dependencies(name, version, version_uri) ⇒ Object
136
137
138
139
140
141
|
# File 'lib/librarian/puppet/source/forge.rb', line 136
def fetch_dependencies(name, version, version_uri)
repo(name).dependencies(version).map do |k, v|
v = Requirement.new(v).gem_requirement
Dependency.new(k, v, nil)
end
end
|
#fetch_version(name, version_uri) ⇒ Object
127
128
129
130
131
132
133
134
|
# File 'lib/librarian/puppet/source/forge.rb', line 127
def fetch_version(name, version_uri)
versions = repo(name).versions
if versions.include? version_uri
version_uri
else
versions.first
end
end
|
#hash ⇒ Object
77
78
79
|
# File 'lib/librarian/puppet/source/forge.rb', line 77
def hash
self.to_s.hash
end
|
#install!(manifest) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/librarian/puppet/source/forge.rb', line 96
def install!(manifest)
manifest.source == self or raise ArgumentError
debug { "Installing #{manifest}" }
name = manifest.name
version = manifest.version
install_path = install_path(name)
repo = repo(name)
repo.install_version! version, install_path
end
|
#install_path(name) ⇒ Object
123
124
125
|
# File 'lib/librarian/puppet/source/forge.rb', line 123
def install_path(name)
environment.install_path.join(organization_name(name))
end
|
#manifest(name, version, dependencies) ⇒ Object
109
110
111
112
113
114
|
# File 'lib/librarian/puppet/source/forge.rb', line 109
def manifest(name, version, dependencies)
manifest = Manifest.new(self, name)
manifest.version = version
manifest.dependencies = dependencies
manifest
end
|
#manifests(name) ⇒ Object
143
144
145
|
# File 'lib/librarian/puppet/source/forge.rb', line 143
def manifests(name)
repo(name).manifests
end
|
#pinned? ⇒ Boolean
89
90
91
|
# File 'lib/librarian/puppet/source/forge.rb', line 89
def pinned?
false
end
|
#to_lock_options ⇒ Object
85
86
87
|
# File 'lib/librarian/puppet/source/forge.rb', line 85
def to_lock_options
{:remote => clean_uri(uri).to_s}
end
|
#to_s ⇒ Object
65
66
67
|
# File 'lib/librarian/puppet/source/forge.rb', line 65
def to_s
clean_uri(uri).to_s
end
|
#to_spec_args ⇒ Object
81
82
83
|
# File 'lib/librarian/puppet/source/forge.rb', line 81
def to_spec_args
[clean_uri(uri).to_s, {}]
end
|
#unpin! ⇒ Object
93
94
|
# File 'lib/librarian/puppet/source/forge.rb', line 93
def unpin!
end
|