Class: Puppet::ModuleTool::Applications::Application Private
- Includes:
- Util::Colors
- Defined in:
- lib/puppet/module_tool/applications/application.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Constant Summary
Constants included from Util::Colors
Util::Colors::BG_BLUE, Util::Colors::BG_CYAN, Util::Colors::BG_GREEN, Util::Colors::BG_HBLUE, Util::Colors::BG_HCYAN, Util::Colors::BG_HGREEN, Util::Colors::BG_HMAGENTA, Util::Colors::BG_HRED, Util::Colors::BG_HWHITE, Util::Colors::BG_HYELLOW, Util::Colors::BG_MAGENTA, Util::Colors::BG_RED, Util::Colors::BG_WHITE, Util::Colors::BG_YELLOW, Util::Colors::BLACK, Util::Colors::BLUE, Util::Colors::CYAN, Util::Colors::Colormap, Util::Colors::GREEN, Util::Colors::HBLACK, Util::Colors::HBLUE, Util::Colors::HCYAN, Util::Colors::HGREEN, Util::Colors::HMAGENTA, Util::Colors::HRED, Util::Colors::HWHITE, Util::Colors::HYELLOW, Util::Colors::MAGENTA, Util::Colors::RED, Util::Colors::RESET, Util::Colors::WHITE, Util::Colors::YELLOW
Instance Attribute Summary collapse
- #options ⇒ Object private
Class Method Summary collapse
- .run(*args) ⇒ Object private
Instance Method Summary collapse
- #discuss(response, success, failure) ⇒ Object private
-
#initialize(options = {}) ⇒ Application
constructor
private
A new instance of Application.
- #load_metadata! ⇒ Object private
- #metadata(require_metadata = false) ⇒ Object private
- #parse_filename(filename) ⇒ Object private
- #run ⇒ Object private
Methods included from Util::Colors
#colorize, #console_color, #html_color
Constructor Details
#initialize(options = {}) ⇒ Application
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Application.
17 18 19 |
# File 'lib/puppet/module_tool/applications/application.rb', line 17 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/puppet/module_tool/applications/application.rb', line 15 def @options end |
Class Method Details
.run(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/puppet/module_tool/applications/application.rb', line 11 def self.run(*args) new(*args).run end |
Instance Method Details
#discuss(response, success, failure) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet/module_tool/applications/application.rb', line 25 def discuss(response, success, failure) case response when Net::HTTPOK, Net::HTTPCreated Puppet.notice success else errors = Puppet::Util::Json.load(response.body)['error'] rescue "HTTP #{response.code}, #{response.body}" Puppet.warning "#{failure} (#{errors})" end end |
#load_metadata! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 69 |
# File 'lib/puppet/module_tool/applications/application.rb', line 66 def @metadata = nil (true) end |
#metadata(require_metadata = false) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/puppet/module_tool/applications/application.rb', line 35 def ( = false) return @metadata if @metadata @metadata = Puppet::ModuleTool::Metadata.new unless @path raise ArgumentError, _("Could not determine module path") end if && !Puppet::ModuleTool.is_module_root?(@path) raise ArgumentError, _("Unable to find metadata.json in module root at %{path} See https://puppet.com/docs/puppet/latest/modules_publishing.html for required file format.") % { path: @path } end = File.join(@path, 'metadata.json') if File.file?() File.open() do |f| begin @metadata.update(Puppet::Util::Json.load(f)) rescue Puppet::Util::Json::ParseError => ex raise ArgumentError, _("Could not parse JSON %{metadata_path}") % { metadata_path: }, ex.backtrace end end end if File.file?(File.join(@path, 'Modulefile')) Puppet.warning _("A Modulefile was found in the root directory of the module. This file will be ignored and can safely be removed.") end return @metadata end |
#parse_filename(filename) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/puppet/module_tool/applications/application.rb', line 71 def parse_filename(filename) match = /^((.*?)-(.*?))-(\d+\.\d+\.\d+.*?)$/.match(File.basename(filename, '.tar.gz')) if match module_name, , shortname, version = match.captures else raise ArgumentError, _("Could not parse filename to obtain the username, module name and version. (%{release_name})") % { release_name: @release_name } end unless SemanticPuppet::Version.valid?(version) raise ArgumentError, _("Invalid version format: %{version} (Semantic Versions are acceptable: http://semver.org)") % { version: version } end return { :module_name => module_name, :author => , :dir_name => shortname, :version => version } end |
#run ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/puppet/module_tool/applications/application.rb', line 21 def run raise NotImplementedError, "Should be implemented in child classes." end |