Class: Librarian::Puppet::Source::GitHubTarball

Inherits:
Object
  • Object
show all
Defined in:
lib/librarian/puppet/source/githubtarball.rb

Defined Under Namespace

Classes: Repo

Constant Summary collapse

LOCK_NAME =
'GITHUBTARBALL'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, uri, options = {}) ⇒ GitHubTarball

Returns a new instance of GitHubTarball.



171
172
173
174
175
# File 'lib/librarian/puppet/source/githubtarball.rb', line 171

def initialize(environment, uri, options = {})
  self.environment = environment
  @uri = uri
  @cache_path = nil
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



167
168
169
# File 'lib/librarian/puppet/source/githubtarball.rb', line 167

def environment
  @environment
end

#uriObject (readonly)

Returns the value of attribute uri.



169
170
171
# File 'lib/librarian/puppet/source/githubtarball.rb', line 169

def uri
  @uri
end

Class Method Details

.from_lock_options(environment, options) ⇒ Object



152
153
154
# File 'lib/librarian/puppet/source/githubtarball.rb', line 152

def from_lock_options(environment, options)
  new(environment, options[:remote], options.reject { |k, v| k == :remote })
end

.from_spec_args(environment, uri, options) ⇒ Object



156
157
158
159
160
161
162
163
164
# File 'lib/librarian/puppet/source/githubtarball.rb', line 156

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_nameObject



148
149
150
# File 'lib/librarian/puppet/source/githubtarball.rb', line 148

def lock_name
  LOCK_NAME
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



181
182
183
184
185
# File 'lib/librarian/puppet/source/githubtarball.rb', line 181

def ==(other)
  other &&
  self.class == other.class &&
  self.uri == other.uri
end

#cache_pathObject



226
227
228
229
230
231
# File 'lib/librarian/puppet/source/githubtarball.rb', line 226

def cache_path
  @cache_path ||= begin
    dir = Digest::MD5.hexdigest(uri)
    environment.cache_path.join("source/puppet/githubtarball/#{dir}")
  end
end

#fetch_dependencies(name, version, version_uri) ⇒ Object



246
247
248
# File 'lib/librarian/puppet/source/githubtarball.rb', line 246

def fetch_dependencies(name, version, version_uri)
  {}
end

#fetch_version(name, version_uri) ⇒ Object



237
238
239
240
241
242
243
244
# File 'lib/librarian/puppet/source/githubtarball.rb', line 237

def fetch_version(name, version_uri)
  versions = repo(name).versions
  if versions.include? version_uri
    version_uri
  else
    versions.first
  end
end

#hashObject



189
190
191
# File 'lib/librarian/puppet/source/githubtarball.rb', line 189

def hash
  self.to_s.hash
end

#install!(manifest) ⇒ Object



208
209
210
211
212
213
214
215
216
217
# File 'lib/librarian/puppet/source/githubtarball.rb', line 208

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



233
234
235
# File 'lib/librarian/puppet/source/githubtarball.rb', line 233

def install_path(name)
  environment.install_path.join(name.split('/').last)
end

#manifest(name, version, dependencies) ⇒ Object



219
220
221
222
223
224
# File 'lib/librarian/puppet/source/githubtarball.rb', line 219

def manifest(name, version, dependencies)
  manifest = Manifest.new(self, name)
  manifest.version = version
  manifest.dependencies = dependencies
  manifest
end

#manifests(name) ⇒ Object



250
251
252
# File 'lib/librarian/puppet/source/githubtarball.rb', line 250

def manifests(name)
  repo(name).manifests
end

#pinned?Boolean

Returns:

  • (Boolean)


201
202
203
# File 'lib/librarian/puppet/source/githubtarball.rb', line 201

def pinned?
  false
end

#to_lock_optionsObject



197
198
199
# File 'lib/librarian/puppet/source/githubtarball.rb', line 197

def to_lock_options
  {:remote => uri}
end

#to_sObject



177
178
179
# File 'lib/librarian/puppet/source/githubtarball.rb', line 177

def to_s
  uri
end

#to_spec_argsObject



193
194
195
# File 'lib/librarian/puppet/source/githubtarball.rb', line 193

def to_spec_args
  [uri, {}]
end

#unpin!Object



205
206
# File 'lib/librarian/puppet/source/githubtarball.rb', line 205

def unpin!
end