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
- #cache_path ⇒ Object
- #fetch_dependencies(name, version, version_uri) ⇒ Object
- #fetch_version(name, version_uri) ⇒ 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.
157 158 159 160 161 |
# File 'lib/librarian/puppet/source/forge.rb', line 157 def initialize(environment, uri, = {}) self.environment = environment @uri = uri @cache_path = nil end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
153 154 155 |
# File 'lib/librarian/puppet/source/forge.rb', line 153 def environment @environment end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
155 156 157 |
# File 'lib/librarian/puppet/source/forge.rb', line 155 def uri @uri end |
Class Method Details
.from_lock_options(environment, options) ⇒ Object
138 139 140 |
# File 'lib/librarian/puppet/source/forge.rb', line 138 def (environment, ) new(environment, [:remote], .reject { |k, v| k == :remote }) end |
.from_spec_args(environment, uri, options) ⇒ Object
142 143 144 145 146 147 148 149 150 |
# File 'lib/librarian/puppet/source/forge.rb', line 142 def from_spec_args(environment, uri, ) = [] = .keys - unless .empty? raise Error, "unrecognised options: #{.join(", ")}" end new(environment, uri, ) end |
.lock_name ⇒ Object
134 135 136 |
# File 'lib/librarian/puppet/source/forge.rb', line 134 def lock_name LOCK_NAME end |
Instance Method Details
#==(other) ⇒ Object
167 168 169 170 171 |
# File 'lib/librarian/puppet/source/forge.rb', line 167 def ==(other) other && self.class == other.class && self.uri == other.uri end |
#cache_path ⇒ Object
206 207 208 209 210 211 |
# File 'lib/librarian/puppet/source/forge.rb', line 206 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
226 227 228 229 230 |
# File 'lib/librarian/puppet/source/forge.rb', line 226 def fetch_dependencies(name, version, version_uri) repo(name).dependencies(version).map do |k, v| Dependency.new(k, v, nil) end end |
#fetch_version(name, version_uri) ⇒ Object
217 218 219 220 221 222 223 224 |
# File 'lib/librarian/puppet/source/forge.rb', line 217 def fetch_version(name, version_uri) versions = repo(name).versions if versions.include? version_uri version_uri else versions.first end end |
#install!(manifest) ⇒ Object
188 189 190 191 192 193 194 195 196 197 |
# File 'lib/librarian/puppet/source/forge.rb', line 188 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
213 214 215 |
# File 'lib/librarian/puppet/source/forge.rb', line 213 def install_path(name) environment.install_path.join(name.split('/').last) end |
#manifest(name, version, dependencies) ⇒ Object
199 200 201 202 203 204 |
# File 'lib/librarian/puppet/source/forge.rb', line 199 def manifest(name, version, dependencies) manifest = Manifest.new(self, name) manifest.version = version manifest.dependencies = dependencies manifest end |
#manifests(name) ⇒ Object
232 233 234 |
# File 'lib/librarian/puppet/source/forge.rb', line 232 def manifests(name) repo(name).manifests end |
#pinned? ⇒ Boolean
181 182 183 |
# File 'lib/librarian/puppet/source/forge.rb', line 181 def pinned? false end |
#to_lock_options ⇒ Object
177 178 179 |
# File 'lib/librarian/puppet/source/forge.rb', line 177 def {:remote => uri} end |
#to_s ⇒ Object
163 164 165 |
# File 'lib/librarian/puppet/source/forge.rb', line 163 def to_s uri end |
#to_spec_args ⇒ Object
173 174 175 |
# File 'lib/librarian/puppet/source/forge.rb', line 173 def to_spec_args [uri, {}] end |
#unpin! ⇒ Object
185 186 |
# File 'lib/librarian/puppet/source/forge.rb', line 185 def unpin! end |