Module: CookbookOmnifetch
- Defined in:
- lib/cookbook-omnifetch.rb,
lib/cookbook-omnifetch/git.rb,
lib/cookbook-omnifetch/base.rb,
lib/cookbook-omnifetch/path.rb,
lib/cookbook-omnifetch/github.rb,
lib/cookbook-omnifetch/version.rb,
lib/cookbook-omnifetch/exceptions.rb,
lib/cookbook-omnifetch/integration.rb,
lib/cookbook-omnifetch/artifactserver.rb
Defined Under Namespace
Classes: AbstractFunction, ArtifactserverLocation, BaseLocation, CookbookValidationFailure, GitCommandError, GitError, GitLocation, GitNotInstalled, GithubLocation, Integration, MismatchedCookbookName, MissingConfiguration, NotACookbook, NullValue, OmnifetchError, PathLocation
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.cache_path ⇒ String
Returns the filepath to the location where data will be cached.
-
.cached_cookbook_class ⇒ #from_path
Returns an Object (generally a class, but not required) that respsonds to #from_path and returns an object representing the cookbook.
-
.configure {|String| ... } ⇒ Object
Yields the Integration object which configures Dependency Injection classes for the library.
-
.cookbook?(path) ⇒ Boolean
Returns true or false if the given path contains a Chef Cookbook.
-
.init(dependency, options = {}) ⇒ ~BaseLocation?
Create a new instance of a Location class given dependency and options.
-
.integration ⇒ String
Returns the Integration object which configures Dependency Injection classes for the library.
-
.shell_out_class ⇒ #shell_out
Returns an Object (generally a class or module, but that’s not required) that responds to the #shell_out method to run an external command.
-
.storage_path ⇒ Pathname
Returns a pathname object representing the location where cookbooks are cached.
-
.which(executable) ⇒ String?
Location an executable in the current user’s $PATH.
Class Method Details
.cache_path ⇒ String
Returns the filepath to the location where data will be cached.
70 71 72 |
# File 'lib/cookbook-omnifetch.rb', line 70 def self.cache_path integration.cache_path end |
.cached_cookbook_class ⇒ #from_path
Returns an Object (generally a class, but not required) that respsonds to #from_path and returns an object representing the cookbook. In berkshelf, this would be a Berkshelf::CachedCookbook (inherits from Ridley::Chef::Cookbook). The object returned by ‘cached_cookbook_class.from_path(path)` is expected to respond to #version and #cookbook_name
94 95 96 |
# File 'lib/cookbook-omnifetch.rb', line 94 def self.cached_cookbook_class integration.cached_cookbook_class end |
.configure {|String| ... } ⇒ Object
Yields the Integration object which configures Dependency Injection classes for the library.
64 65 66 |
# File 'lib/cookbook-omnifetch.rb', line 64 def self.configure yield integration end |
.cookbook?(path) ⇒ Boolean
Returns true or false if the given path contains a Chef Cookbook
115 116 117 |
# File 'lib/cookbook-omnifetch.rb', line 115 def self.cookbook?(path) File.exists?(File.join(path, "metadata.json")) || File.exists?(File.join(path, "metadata.rb")) end |
.init(dependency, options = {}) ⇒ ~BaseLocation?
Create a new instance of a Location class given dependency and options. The type of class is determined by the values in the given options Hash.
If you do not provide an option with a matching location id, nil is returned.
30 31 32 33 34 35 36 |
# File 'lib/cookbook-omnifetch.rb', line 30 def self.init(dependency, = {}) if klass = () klass.new(dependency, ) else nil end end |
.integration ⇒ String
Returns the Integration object which configures Dependency Injection classes for the library.
56 57 58 |
# File 'lib/cookbook-omnifetch.rb', line 56 def self.integration @integration ||= Integration.new end |
.shell_out_class ⇒ #shell_out
Returns an Object (generally a class or module, but that’s not required) that responds to the #shell_out method to run an external command. The shell_out method accepts a single string for the command to run, and returns an object that responds to #success?, #stdout and #stderr.
Note that this shell_out method should not raise errors automatically.
82 83 84 |
# File 'lib/cookbook-omnifetch.rb', line 82 def self.shell_out_class integration.shell_out_class end |
.storage_path ⇒ Pathname
Returns a pathname object representing the location where cookbooks are cached.
NOTE: In the original berks code, this is generally accessed via Berkshelf.cookbook_store.storage_path
105 106 107 |
# File 'lib/cookbook-omnifetch.rb', line 105 def self.storage_path integration.storage_path end |
.which(executable) ⇒ String?
Location an executable in the current user’s $PATH
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cookbook-omnifetch.rb', line 42 def self.which(executable) if File.file?(executable) && File.executable?(executable) executable elsif ENV['PATH'] path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p| File.executable?(File.join(p, executable)) end path && File.(executable, path) end end |