class Guard::Strainer::Runner

Attributes

cabinet[R]

Public Class Methods

new(options) click to toggle source
# File lib/guard/strainer/runner.rb, line 6
def initialize(options)
  @options = options
  @cabinet = {}
end

Public Instance Methods

run!(paths = []) click to toggle source
# File lib/guard/strainer/runner.rb, line 11
def run!(paths = [])
  cookbooks = paths.map{|path| find_cookbook_name(path)}
  runner = runner_for_cookbooks(cookbooks)

  UI.info "Straining: #{cookbooks.join(',')}"
  runner.run!
end
run_all!() click to toggle source
# File lib/guard/strainer/runner.rb, line 19
def run_all!
  paths = Dir[File.join('**', 'metadata.rb')].sort
  run!(paths)
end

Protected Instance Methods

find_cookbook_name(path) click to toggle source
# File lib/guard/strainer/runner.rb, line 25
def find_cookbook_name(path)
  current_path = Pathname.new(File.dirname(path))
  cookbook = nil

  until current_path == ::Guard::Dsl.options["guardfile_path"] do
    if File.exist?(File.join(current_path, 'metadata.rb'))
      cookbook = current_path.basename
      break
    else
      current_path = current_path.parent
    end
  end

  cookbook
end
runner_for_cookbooks(cookbooks) click to toggle source
# File lib/guard/strainer/runner.rb, line 41
def runner_for_cookbooks(cookbooks)
  @cabinet.fetch(cookbooks) do |books|
    ::Strainer::Runner.new(books, @options.merge({strainer_file: File.join(File.dirname(::Guard::Dsl.options["guardfile_path"]), ::Strainer::Strainerfile::DEFAULT_FILENAME)}))
  end
end