Class: Librarian::Puppet::Source::Forge
- Inherits:
-
Object
- Object
- Librarian::Puppet::Source::Forge
- Defined in:
- lib/librarian/puppet/source/forge.rb
Defined Under Namespace
Classes: Repo
Constant Summary collapse
- LOCK_NAME =
'FORGE'
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
- .from_lock_options(environment, options) ⇒ Object
- .from_spec_args(environment, uri, options) ⇒ Object
- .lock_name ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #cache_path ⇒ Object
- #fetch_dependencies(name, version, version_uri) ⇒ Object
- #fetch_version(name, version_uri) ⇒ Object
- #hash ⇒ Object
-
#initialize(environment, uri, options = {}) ⇒ Forge
constructor
A new instance of Forge.
- #install!(manifest) ⇒ Object
- #install_path(name) ⇒ Object
- #manifest(name, version, dependencies) ⇒ Object
- #manifests(name) ⇒ Object
- #pinned? ⇒ Boolean
- #to_lock_options ⇒ Object
- #to_s ⇒ Object
- #to_spec_args ⇒ Object
- #unpin! ⇒ Object
Constructor Details
#initialize(environment, uri, options = {}) ⇒ Forge
Returns a new instance of Forge.
196 197 198 199 200 |
# File 'lib/librarian/puppet/source/forge.rb', line 196 def initialize(environment, uri, = {}) self.environment = environment @uri = uri @cache_path = nil end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
192 193 194 |
# File 'lib/librarian/puppet/source/forge.rb', line 192 def environment @environment end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
194 195 196 |
# File 'lib/librarian/puppet/source/forge.rb', line 194 def uri @uri end |
Class Method Details
.from_lock_options(environment, options) ⇒ Object
177 178 179 |
# File 'lib/librarian/puppet/source/forge.rb', line 177 def (environment, ) new(environment, [:remote], .reject { |k, v| k == :remote }) end |
.from_spec_args(environment, uri, options) ⇒ Object
181 182 183 184 185 186 187 188 189 |
# File 'lib/librarian/puppet/source/forge.rb', line 181 def from_spec_args(environment, uri, ) = [] = .keys - unless .empty? raise Error, "unrecognised options: #{.join(", ")}" end new(environment, uri, ) end |
.lock_name ⇒ Object
173 174 175 |
# File 'lib/librarian/puppet/source/forge.rb', line 173 def lock_name LOCK_NAME end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
206 207 208 209 210 |
# File 'lib/librarian/puppet/source/forge.rb', line 206 def ==(other) other && self.class == other.class && self.uri == other.uri end |
#cache_path ⇒ Object
251 252 253 254 255 256 |
# File 'lib/librarian/puppet/source/forge.rb', line 251 def cache_path @cache_path ||= begin dir = Digest::MD5.hexdigest(uri) environment.cache_path.join("source/puppet/forge/#{dir}") end end |
#fetch_dependencies(name, version, version_uri) ⇒ Object
271 272 273 274 275 276 |
# File 'lib/librarian/puppet/source/forge.rb', line 271 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
262 263 264 265 266 267 268 269 |
# File 'lib/librarian/puppet/source/forge.rb', line 262 def fetch_version(name, version_uri) versions = repo(name).versions if versions.include? version_uri version_uri else versions.first end end |
#hash ⇒ Object
214 215 216 |
# File 'lib/librarian/puppet/source/forge.rb', line 214 def hash self.to_s.hash end |
#install!(manifest) ⇒ Object
233 234 235 236 237 238 239 240 241 242 |
# File 'lib/librarian/puppet/source/forge.rb', line 233 def install!(manifest) manifest.source == self or raise ArgumentError 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
258 259 260 |
# File 'lib/librarian/puppet/source/forge.rb', line 258 def install_path(name) environment.install_path.join(name.split('/').last) end |
#manifest(name, version, dependencies) ⇒ Object
244 245 246 247 248 249 |
# File 'lib/librarian/puppet/source/forge.rb', line 244 def manifest(name, version, dependencies) manifest = Manifest.new(self, name) manifest.version = version manifest.dependencies = dependencies manifest end |
#manifests(name) ⇒ Object
278 279 280 |
# File 'lib/librarian/puppet/source/forge.rb', line 278 def manifests(name) repo(name).manifests end |
#pinned? ⇒ Boolean
226 227 228 |
# File 'lib/librarian/puppet/source/forge.rb', line 226 def pinned? false end |
#to_lock_options ⇒ Object
222 223 224 |
# File 'lib/librarian/puppet/source/forge.rb', line 222 def {:remote => uri} end |
#to_s ⇒ Object
202 203 204 |
# File 'lib/librarian/puppet/source/forge.rb', line 202 def to_s uri end |
#to_spec_args ⇒ Object
218 219 220 |
# File 'lib/librarian/puppet/source/forge.rb', line 218 def to_spec_args [uri, {}] end |
#unpin! ⇒ Object
230 231 |
# File 'lib/librarian/puppet/source/forge.rb', line 230 def unpin! end |