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

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

Defined Under Namespace

Classes: Repo

Constant Summary collapse

LOCK_NAME =
'GITHUBTARBALL'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#clean_uri, #cp_r, #debug, #info, #normalize_name, #warn

Constructor Details

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

Returns a new instance of GitHubTarball.



37
38
39
40
41
# File 'lib/librarian/puppet/source/githubtarball.rb', line 37

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

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



33
34
35
# File 'lib/librarian/puppet/source/githubtarball.rb', line 33

def environment
  @environment
end

#uriObject (readonly)

Returns the value of attribute uri.



35
36
37
# File 'lib/librarian/puppet/source/githubtarball.rb', line 35

def uri
  @uri
end

Class Method Details

.from_lock_options(environment, options) ⇒ Object



18
19
20
# File 'lib/librarian/puppet/source/githubtarball.rb', line 18

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

.from_spec_args(environment, uri, options) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/librarian/puppet/source/githubtarball.rb', line 22

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



14
15
16
# File 'lib/librarian/puppet/source/githubtarball.rb', line 14

def lock_name
  LOCK_NAME
end

Instance Method Details

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



47
48
49
50
51
# File 'lib/librarian/puppet/source/githubtarball.rb', line 47

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

#cache_pathObject



94
95
96
97
98
# File 'lib/librarian/puppet/source/githubtarball.rb', line 94

def cache_path
  @cache_path ||= begin
    environment.cache_path.join("source/puppet/githubtarball/#{uri.host}#{uri.path}")
  end
end

#fetch_dependencies(name, version, version_uri) ⇒ Object



113
114
115
# File 'lib/librarian/puppet/source/githubtarball.rb', line 113

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

#fetch_version(name, version_uri) ⇒ Object



104
105
106
107
108
109
110
111
# File 'lib/librarian/puppet/source/githubtarball.rb', line 104

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

#hashObject



55
56
57
# File 'lib/librarian/puppet/source/githubtarball.rb', line 55

def hash
  self.to_s.hash
end

#install!(manifest) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/librarian/puppet/source/githubtarball.rb', line 74

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



100
101
102
# File 'lib/librarian/puppet/source/githubtarball.rb', line 100

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

#manifest(name, version, dependencies) ⇒ Object



87
88
89
90
91
92
# File 'lib/librarian/puppet/source/githubtarball.rb', line 87

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

#manifests(name) ⇒ Object



117
118
119
# File 'lib/librarian/puppet/source/githubtarball.rb', line 117

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

#pinned?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/librarian/puppet/source/githubtarball.rb', line 67

def pinned?
  false
end

#to_lock_optionsObject



63
64
65
# File 'lib/librarian/puppet/source/githubtarball.rb', line 63

def to_lock_options
  {:remote => clean_uri(uri).to_s}
end

#to_sObject



43
44
45
# File 'lib/librarian/puppet/source/githubtarball.rb', line 43

def to_s
  clean_uri(uri).to_s
end

#to_spec_argsObject



59
60
61
# File 'lib/librarian/puppet/source/githubtarball.rb', line 59

def to_spec_args
  [clean_uri(uri).to_s, {}]
end

#unpin!Object



71
72
# File 'lib/librarian/puppet/source/githubtarball.rb', line 71

def unpin!
end