Module: Puppet::Module::Tool

Extended by:
Utils::Settings
Defined in:
lib/puppet/module/tool.rb,
lib/puppet/module/tool.rb,
lib/puppet/module/tool/cache.rb,
lib/puppet/module/tool/utils.rb,
lib/puppet/module/tool/metadata.rb,
lib/puppet/module/tool/skeleton.rb,
lib/puppet/module/tool/checksums.rb,
lib/puppet/module/tool/utils/uri.rb,
lib/puppet/module/tool/dependency.rb,
lib/puppet/module/tool/modulefile.rb,
lib/puppet/module/tool/repository.rb,
lib/puppet/module/tool/applications.rb,
lib/puppet/module/tool/utils/interrogation.rb,
lib/puppet/module/tool/applications/builder.rb,
lib/puppet/module/tool/applications/cleaner.rb,
lib/puppet/module/tool/applications/freezer.rb,
lib/puppet/module/tool/contents_description.rb,
lib/puppet/module/tool/applications/releaser.rb,
lib/puppet/module/tool/applications/searcher.rb,
lib/puppet/module/tool/applications/unpacker.rb,
lib/puppet/module/tool/applications/generator.rb,
lib/puppet/module/tool/applications/installer.rb,
lib/puppet/module/tool/applications/registrar.rb,
lib/puppet/module/tool/applications/unreleaser.rb,
lib/puppet/module/tool/applications/application.rb,
lib/puppet/module/tool/applications/checksummer.rb

Defined Under Namespace

Modules: Applications, Utils Classes: CLI, Cache, Checksums, ContentsDescription, Dependency, Metadata, Modulefile, Repository, Skeleton

Constant Summary collapse

REPOSITORY_URL =

Default repository URL.

'http://forge.puppetlabs.com'
ARTIFACTS =

Directory names that should not be checksummed.

['pkg', /^\./, /^~/, /^#/, 'coverage']
FULL_NAME_PATTERN =
/\A([^-\/|.]+)[-|\/](.+)\z/

Class Method Summary collapse

Methods included from Utils::Settings

prepare_settings

Class Method Details

.artifact?(path) ⇒ Boolean

Is this a directory that shouldn’t be checksummed?

TODO: Should this be part of Checksums? TODO: Rename this method to reflect it’s purpose? TODO: Shouldn’t this be used when building packages too?

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
# File 'lib/puppet/module/tool.rb', line 20

def self.artifact?(path)
  case File.basename(path)
  when *ARTIFACTS
    true
  else
    false
  end
end

.changelog_filenameObject

Return the filename with the changelog.



67
68
69
# File 'lib/puppet/module/tool.rb', line 67

def self.changelog_filename
  return File.expand_path(File.join(self.root, 'CHANGES.markdown'))
end

.repositoryObject

Return Repository to fetch data from based on Puppet’s config file.



45
46
47
# File 'lib/puppet/module/tool.rb', line 45

def self.repository
  @repository ||= Repository.new(Puppet.settings[:puppet_module_repository])
end

.rootObject

Return Pathname for the directory this tool was installed into.



30
31
32
# File 'lib/puppet/module/tool.rb', line 30

def self.root
  @root ||= Pathname.new(File.expand_path(File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', '..')))
end

.usage_filenameObject

Return the filename with the usage documenation.



62
63
64
# File 'lib/puppet/module/tool.rb', line 62

def self.usage_filename
  return File.expand_path(File.join(self.root, 'README.markdown'))
end

.username_and_modname_from(full_name) ⇒ Object

Return the username and modname for a given full_name, or raise an ArgumentError if the argument isn’t parseable.



53
54
55
56
57
58
59
# File 'lib/puppet/module/tool.rb', line 53

def self.username_and_modname_from(full_name)
  if matcher = full_name.match(FULL_NAME_PATTERN)
    return matcher.captures
  else
    raise ArgumentError, "Not a valid full name: #{full_name}"
  end
end

.versionObject

Return the tool’s string version.



35
36
37
# File 'lib/puppet/module/tool.rb', line 35

def self.version
  @version ||= (root + 'VERSION').read
end

.working_dirObject

Return Pathname for this tool’s working directory.



40
41
42
# File 'lib/puppet/module/tool.rb', line 40

def self.working_dir
  @working_dir ||= Pathname.new(Puppet.settings[:puppet_module_working_dir])
end