module MotherBrain

Author

Daniel DeLeo (<dan@opscode.com>)

Copyright

Copyright © 2010 Opscode, Inc.

License

Apache License, Version 2.0

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.

Retrieved on 1/28/2014 @ 24dc69a9a97e82a6e4207de68d6dcc664178249b Source: github.com/opscode/chef/blob/24dc69a9a97e82a6e4207de68d6dcc664178249b/lib/chef/run_list/run_list_item.rb

Constants

VERSION

Attributes

ui[W]

Public Class Methods

app_root() click to toggle source

Path to the root directory of the motherbrain application

@return [Pathname]

# File lib/motherbrain.rb, line 76
def app_root
  @app_root ||= Pathname.new(File.expand_path('../', File.dirname(__FILE__)))
end
expand_procs(procs) click to toggle source

Takes an array of procs or a an array of arrays of procs and calls them returning their evaluated values in an array at the same depth.

@example

procs = [
  -> { :one },
  -> { :two },
  [
    -> { :nested },
    [
      -> { :deep_nested }
    ]
  ]
]

expand_procs(procs) => [
  :one,
  :two,
  [
    :nested,
    [
      :deep_nested
    ]
  ]
]

@param [Array<Proc>, Array<Array<Proc>>] procs

an array of nested arrays and procs

@return [Array]

an array of nested arrays and their evaluated values
# File lib/motherbrain.rb, line 138
def expand_procs(procs)
  procs.map! do |l_proc|
    if l_proc.is_a?(Array)
      expand_procs(l_proc)
    else
      l_proc.call
    end
  end
end
log()
Alias for: logger
logger() click to toggle source

@return [Logger]

# File lib/motherbrain.rb, line 88
def logger
  MB::Logging.logger
end
Also aliased as: log
require_or_exit(library, message = nil) click to toggle source
# File lib/motherbrain.rb, line 148
def require_or_exit(library, message = nil)
  begin
    require library
  rescue LoadError
    message ||=
      "#{library} was not found. Please add it to your Gemfile, " +
      "and then run `bundle install`."
    raise PrerequisiteNotInstalled, message
  end
end
scripts() click to toggle source

Path to the scripts directory

@return [Pathname]

# File lib/motherbrain.rb, line 83
def scripts
  app_root.join('scripts')
end
set_logger(obj) click to toggle source

@param [Logger, nil] obj

@return [Logger]

# File lib/motherbrain.rb, line 96
def set_logger(obj)
  MB::Logging.set_logger(obj)
end
testing?() click to toggle source

Is motherbrain executing in test mode?

@return [Boolean]

# File lib/motherbrain.rb, line 103
def testing?
  ENV['RUBY_ENV'] == 'test'
end