module Peony::Configure

Public Instance Methods

find_in_directories(paths, name, file_only) click to toggle source
# File lib/peony/configure.rb, line 75
def find_in_directories(paths, name, file_only)
  templates = []
  paths.each do|path|
    templates += Dir[File.expand_path(name, path)].reject{|filename| file_only && File.directory?(filename)}
  end
  templates
end
find_recipes(name, file_only=true) click to toggle source
# File lib/peony/configure.rb, line 71
def find_recipes(name, file_only=true)
  find_in_directories(recipes_paths, name, file_only)
end
find_templates(name, file_only=true) click to toggle source
# File lib/peony/configure.rb, line 63
def find_templates(name, file_only=true)
  find_in_directories(template_paths, name, file_only)
end
method_missing(method, *args, &blk) click to toggle source

### method_missing Hook to get settings. See settings for an explanation.

Returns things.

Calls superclass method
# File lib/peony/configure.rb, line 89
def method_missing(method, *args, &blk)
  if settings.respond_to? method, true
    settings.__send__(method, *args, &blk)
  else
    super
  end
end
recipes_paths() click to toggle source
# File lib/peony/configure.rb, line 67
def recipes_paths
  ["#{Dir.pwd}/recipes", File.expand_path('../../recipes', __dir__)]
end
scope(name) { || ... } click to toggle source
# File lib/peony/configure.rb, line 43
def scope(name)
  settings.with_scope(name.to_sym) do
    yield
  end
end
set(key, *args, &block) click to toggle source

### set Sets settings. Sets given symbol ‘key` to value in `value`.

Returns the value.

set :domain, 'kickflip.me'
# File lib/peony/configure.rb, line 11
def set(key, *args, &block)
  settings.send :"#{key}=", *args, &block
end
set_default(key, *args, &block) click to toggle source

### set_default Sets default settings. Sets given symbol ‘key` to value in `value` only if the key isn’t set yet.

Returns the value.

set_default :term_mode, :pretty
set :term_mode, :system
settings.term_mode.should == :system

set :term_mode, :system
set_default :term_mode, :pretty
settings.term_mode.should == :system
# File lib/peony/configure.rb, line 28
def set_default(key, *args, &block)
  set(key, *args, block) unless settings.send(:local?, key.to_sym)
end
settings() click to toggle source

### settings Accesses the settings hash.

set :domain, 'kickflip.me'

settings.domain  #=> 'kickflip.me'
domain           #=> 'kickflip.me'
# File lib/peony/configure.rb, line 39
def settings
  @settings ||= Settings.new
end
template_paths() click to toggle source
# File lib/peony/configure.rb, line 59
def template_paths
  ["#{Dir.pwd}/templates", File.expand_path('../../templates', __dir__)]
end
travel(scope, &block) click to toggle source
# File lib/peony/configure.rb, line 49
def travel(scope, &block)
  say "scope: #{scope.name}", :yellow
  scope.each do |_k, _|
    block.call scope, _k
  end
  scope.children.each do|_name, _scope|
    travel(_scope, &block)
  end
end