class Dustcart::DSL

DSL for instruction file

Attributes

dump_base[R]

Public Class Methods

new() click to toggle source
# File lib/dustcart/dsl.rb, line 6
def initialize
end

Public Instance Methods

load(path) click to toggle source
# File lib/dustcart/dsl.rb, line 9
def load(path)
  load_from(path)
end

Private Instance Methods

cleanup(target) click to toggle source
# File lib/dustcart/dsl.rb, line 45
def cleanup(target)
  raise "target(#{target}) is not available." unless [:all, :except_latest].include?(target)

  Dir.glob("#{dump_base}/*").each do |file|
    next if target == :except_latest && file.start_with?(temp_dir)
    FileUtils.rm_rf(file)
  end
end
dump_site(path) click to toggle source
# File lib/dustcart/dsl.rb, line 19
def dump_site(path)
  raise 'dump_site has already set.' if @_temp_dir

  @dump_base = path.chomp('/')
  time_str = Time.now.strftime('%Y%m%d%H%M%S')
  @_temp_dir = "#{@dump_base}/#{time_str}"
end
group(*args, &block) click to toggle source
# File lib/dustcart/dsl.rb, line 35
def group(*args, &block)
  size = args.size
  raise ArgumentError, "wrong number of arguments (#{size} for 1)" unless size == 1

  method = args.first

  group = Group.new(method, temp_dir)
  group.instance_eval(&block)
end
load_from(path) click to toggle source
# File lib/dustcart/dsl.rb, line 15
def load_from(path)
  instance_eval(File.read(path), path) if path
end
temp_dir() click to toggle source
# File lib/dustcart/dsl.rb, line 27
def temp_dir
  return @_temp_dir if @_temp_dir

  @dump_base = '/tmp/dustcart'
  time_str = Time.now.strftime('%Y%m%d%H%M%S')
  @_temp_dir = "#{@dump_base}/#{time_str}"
end