Class: Puppet::Module::Tool::Applications::Application
- Inherits:
-
Object
- Object
- Puppet::Module::Tool::Applications::Application
show all
- Includes:
- Utils::Interrogation
- Defined in:
- lib/puppet/module/tool/applications/application.rb
Direct Known Subclasses
Builder, Checksummer, Cleaner, Freezer, Generator, Installer, Registrar, Releaser, Searcher, Unpacker, Unreleaser
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#confirms?, #header, #prompt, #say, #subheader
Constructor Details
#initialize(options = {}) ⇒ Application
Returns a new instance of Application.
15
16
17
18
|
# File 'lib/puppet/module/tool/applications/application.rb', line 15
def initialize(options = {})
@options = options
Puppet::Module::Tool.prepare_settings(options)
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
13
14
15
|
# File 'lib/puppet/module/tool/applications/application.rb', line 13
def options
@options
end
|
Class Method Details
.run(*args) ⇒ Object
9
10
11
|
# File 'lib/puppet/module/tool/applications/application.rb', line 9
def self.run(*args)
new(*args).run
end
|
Instance Method Details
#discuss(response, success, failure) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/puppet/module/tool/applications/application.rb', line 28
def discuss(response, success, failure)
case response
when Net::HTTPOK, Net::HTTPCreated
say success
else
errors = PSON.parse(response.body)['error'] rescue "HTTP #{response.code}, #{response.body}"
say "#{failure} (#{errors})"
end
end
|
#load_modulefile! ⇒ Object
58
59
60
61
|
# File 'lib/puppet/module/tool/applications/application.rb', line 58
def load_modulefile!
@metadata = nil
metadata(true)
end
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/puppet/module/tool/applications/application.rb', line 38
def metadata(require_modulefile = false)
unless @metadata
unless @path
abort "Could not determine module path"
end
@metadata = Metadata.new
contents = ContentsDescription.new(@path)
contents.annotate(@metadata)
checksums = Checksums.new(@path)
checksums.annotate(@metadata)
modulefile_path = File.join(@path, 'Modulefile')
if File.file?(modulefile_path)
Modulefile.evaluate(@metadata, modulefile_path)
elsif require_modulefile
abort "No Modulefile found."
end
end
@metadata
end
|
#parse_filename! ⇒ Object
Use to extract and validate a module name and version from a filename Note: Must have @filename set to use this
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/puppet/module/tool/applications/application.rb', line 66
def parse_filename!
@release_name = File.basename(@filename,'.tar.gz')
match = /^(.*?)-(.*?)-(\d+\.\d+\.\d+.*?)$/.match(@release_name)
if match then
@username, @module_name, @version = match.captures
else
abort "Could not parse filename to obtain the username, module name and version. (#{@release_name})"
end
@full_name = [@username, @module_name].join('-')
unless @username && @module_name
abort "Username and Module name not provided"
end
if @version !~ /^(\d+)\.(\d+)\.(\d+)([a-zA-Z][a-zA-Z0-9-]*){0,1}$/ then
abort "Invalid version format: #{@version} (Semantic Versions are acceptable: http://semver.org)"
end
end
|
#repository ⇒ Object
20
21
22
|
# File 'lib/puppet/module/tool/applications/application.rb', line 20
def repository
@repository ||= Repository.new(Puppet.settings[:puppet_module_repository])
end
|
#run ⇒ Object
24
25
26
|
# File 'lib/puppet/module/tool/applications/application.rb', line 24
def run
raise NotImplementedError, "Should be implemented in child classes."
end
|