Module: Omnibus

Defined in:
lib/omnibus/logger.rb,
lib/omnibus.rb,
lib/omnibus/cli.rb,
lib/omnibus/ohai.rb,
lib/omnibus/util.rb,
lib/omnibus/config.rb,
lib/omnibus/builder.rb,
lib/omnibus/cleaner.rb,
lib/omnibus/fetcher.rb,
lib/omnibus/library.rb,
lib/omnibus/logging.rb,
lib/omnibus/package.rb,
lib/omnibus/project.rb,
lib/omnibus/reports.rb,
lib/omnibus/version.rb,
lib/omnibus/cli/base.rb,
lib/omnibus/manifest.rb,
lib/omnibus/metadata.rb,
lib/omnibus/packager.rb,
lib/omnibus/s3_cache.rb,
lib/omnibus/software.rb,
lib/omnibus/changelog.rb,
lib/omnibus/cli/cache.rb,
lib/omnibus/generator.rb,
lib/omnibus/git_cache.rb,
lib/omnibus/licensing.rb,
lib/omnibus/publisher.rb,
lib/omnibus/sugarable.rb,
lib/omnibus/compressor.rb,
lib/omnibus/digestable.rb,
lib/omnibus/exceptions.rb,
lib/omnibus/s3_helpers.rb,
lib/omnibus/templating.rb,
lib/omnibus/cli/publish.rb,
lib/omnibus/file_syncer.rb,
lib/omnibus/thread_pool.rb,
lib/omnibus/health_check.rb,
lib/omnibus/build_version.rb,
lib/omnibus/cli/changelog.rb,
lib/omnibus/manifest_diff.rb,
lib/omnibus/packagers/bff.rb,
lib/omnibus/packagers/deb.rb,
lib/omnibus/packagers/ips.rb,
lib/omnibus/packagers/msi.rb,
lib/omnibus/packagers/pkg.rb,
lib/omnibus/packagers/rpm.rb,
lib/omnibus/git_repository.rb,
lib/omnibus/manifest_entry.rb,
lib/omnibus/packagers/appx.rb,
lib/omnibus/packagers/base.rb,
lib/omnibus/compressors/dmg.rb,
lib/omnibus/compressors/tgz.rb,
lib/omnibus/instrumentation.rb,
lib/omnibus/compressors/base.rb,
lib/omnibus/compressors/null.rb,
lib/omnibus/download_helpers.rb,
lib/omnibus/packagers/pkgsrc.rb,
lib/omnibus/semantic_version.rb,
lib/omnibus/build_version_dsl.rb,
lib/omnibus/changelog_printer.rb,
lib/omnibus/null_argumentable.rb,
lib/omnibus/packagers/solaris.rb,
lib/omnibus/packagers/makeself.rb,
lib/omnibus/fetchers/git_fetcher.rb,
lib/omnibus/fetchers/net_fetcher.rb,
lib/omnibus/build_system_metadata.rb,
lib/omnibus/fetchers/file_fetcher.rb,
lib/omnibus/fetchers/null_fetcher.rb,
lib/omnibus/fetchers/path_fetcher.rb,
lib/omnibus/packagers/windows_base.rb,
lib/omnibus/publishers/s3_publisher.rb,
lib/omnibus/publishers/null_publisher.rb,
lib/omnibus/build_system_metadata/buildkite.rb,
lib/omnibus/publishers/artifactory_publisher.rb

Overview

Copyright 2012-2018 Chef Software, Inc.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: Command, Compressor, Digestable, DownloadHelpers, FileSyncer, Instrumentation, Logging, NullArgumentable, Packager, Reports, S3Helpers, Sugar, Sugarable, Templating, Util Classes: ArtifactoryPublisher, BuildSystemMetadata, BuildVersion, BuildVersionDSL, Builder, Buildkite, CLI, ChangeLog, ChangeLogPrinter, ChecksumMismatch, ChecksumMissing, Cleaner, CommandFailed, CommandTimeout, Config, EmptyManifestDiff, Error, FailedToSignWindowsPackage, Fetcher, FileFetcher, GemNotInstalled, Generator, GitCache, GitFetcher, GitRepository, HealthCheck, HealthCheckFailed, InsufficientSpecification, InternalSourceMissing, InvalidValue, InvalidVersion, Library, Licensing, LicensingError, Logger, Manifest, ManifestDiff, ManifestEntry, Metadata, MissingPatch, MissingProject, MissingRequiredAttribute, MissingSoftware, MissingTemplate, NetFetcher, NoPackageFile, NoPackageMetadataFile, NullFetcher, NullPublisher, Ohai, Package, PathFetcher, Project, ProjectAlreadyDirty, Publisher, S3Cache, S3Publisher, SemanticVersion, Software, ThreadPool, UnknownPlatform, UnknownPlatformVersion, UnresolvableGitReference

Constant Summary collapse

DEFAULT_CONFIG =

The path to the default configuration file.

Returns:

  • (String)
"omnibus.rb".freeze
VERSION =
"9.0.24".freeze

Class Method Summary collapse

Class Method Details

.load_configuration(file) ⇒ void

This method returns an undefined value.

Load in an Omnibus configuration file. Values will be merged with and override the defaults defined in Config.

Parameters:

  • file (String)

    path to a configuration file to load



162
163
164
# File 'lib/omnibus.rb', line 162

def load_configuration(file)
  Config.load(file)
end

.loggerLogger

The logger for this Omnibus instance.

Examples:

Omnibus.logger.debug { 'This is a message!' }

Returns:



130
131
132
# File 'lib/omnibus.rb', line 130

def logger
  @logger ||= Logger.new
end

.logger=(logger) ⇒ 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.

Programatically set the logger for Omnibus.

Parameters:



141
142
143
# File 'lib/omnibus.rb', line 141

def logger=(logger)
  @logger = logger
end

.possible_paths_for(path) ⇒ Array<String>

The list of directories to search for the given path. These paths are returned **in order** of specificity.

Parameters:

  • path (String)

    the subpath to search for

Returns:

  • (Array<String>)


243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/omnibus.rb', line 243

def possible_paths_for(path)
  possible_paths[path] ||= [
    paths_from_project_root,
    paths_from_local_software_dirs,
    paths_from_software_gems,
  ].flatten.inject([]) do |array, directory|
    destination = File.join(directory, path)

    if File.directory?(destination)
      array << destination
    end

    array
  end
end

.project(name) ⇒ Project

Load the Project instance with the given name.

Parameters:

  • name (String)

    the name of the project to get

Returns:



203
204
205
# File 'lib/omnibus.rb', line 203

def project(name)
  Project.load(name)
end

.project_path(name) ⇒ String?

The preferred filepath to a project with the given name on disk.

Returns:

  • (String, nil)


221
222
223
# File 'lib/omnibus.rb', line 221

def project_path(name)
  project_map[name.to_s]
end

.projectsArray<:Project>

All Project instances that have been loaded.

Returns:

  • (Array<:Project>)


189
190
191
192
193
# File 'lib/omnibus.rb', line 189

def projects
  project_map.map do |name, _|
    Project.load(name)
  end
end

.reset!(include_logger = false) ⇒ void

This method returns an undefined value.

Reset the current Omnibus configuration. This is primary an internal API used in testing, but it can also be useful when Omnibus is used as a library.

Note - this persists the Logger object by default.

Parameters:

  • include_logger (true, false) (defaults to: false)

    whether the logger object should be cleared as well



107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/omnibus.rb', line 107

def reset!(include_logger = false)
  instance_variables.each do |instance_variable|
    unless include_logger
      next if instance_variable == :@logger
    end

    remove_instance_variable(instance_variable)
  end

  Config.reset!
  # Clear caches on Project and Software
  Project.reset!
  Software.reset!
end

.software_path(name) ⇒ String?

The preferred filepath to a software with the given name on disk.

Returns:

  • (String, nil)


230
231
232
# File 'lib/omnibus.rb', line 230

def software_path(name)
  software_map[name.to_s]
end

.source_rootPathname

The source root is the path to the root directory of the ‘omnibus` gem.

Returns:

  • (Pathname)


212
213
214
# File 'lib/omnibus.rb', line 212

def source_root
  @source_root ||= Pathname.new(File.expand_path("..", __dir__))
end

.uiThor::Shell

The UI class for Omnibus.

Returns:

  • (Thor::Shell)


150
151
152
# File 'lib/omnibus.rb', line 150

def ui
  @ui ||= Thor::Base.shell.new
end

.which(executable) ⇒ String?

Locate an executable in the current $PATH.

Returns:

  • (String, nil)

    the path to the executable, or nil if not present



172
173
174
175
176
177
178
179
180
181
182
# File 'lib/omnibus.rb', line 172

def which(executable)
  if File.file?(executable) && File.executable?(executable)
    executable
  elsif ENV["PATH"]
    path = ENV["PATH"].split(File::PATH_SEPARATOR).find do |path|
      File.executable?(File.join(path, executable))
    end

    path && File.expand_path(executable, path)
  end
end