class Copypasta::ContentsDSL

Attributes

contents[R]
directory[R]

Public Class Methods

new(contents, directory) click to toggle source
# File lib/copypasta/contents_dsl.rb, line 6
def initialize(contents, directory)
  raise "contents must be a Copypasta::Contents" \
    unless contents.is_a?(Copypasta::Contents)

  raise "#{directory} doesn't exist." unless Dir.exist?(directory)

  @contents = contents
  @directory = directory
end

Public Instance Methods

copy(filename, source: nil, only_if: nil) click to toggle source
# File lib/copypasta/contents_dsl.rb, line 20
def copy(filename, source: nil, only_if: nil)
  contents.entries << Copypasta::Entry::Copy.new(filename, directory: @directory, source: source, only_if: only_if).freeze
end
create_even_if_empty!() click to toggle source
# File lib/copypasta/contents_dsl.rb, line 16
def create_even_if_empty!
  contents.force_create = true
end
download(filename, source: nil, only_if: nil) click to toggle source
# File lib/copypasta/contents_dsl.rb, line 28
def download(filename, source: nil, only_if: nil)
  contents.entries << Copypasta::Entry::Download.new(filename, source: source, only_if: only_if).freeze
end
erb(filename, source: nil, locals: {}, only_if: nil) click to toggle source
# File lib/copypasta/contents_dsl.rb, line 24
def erb(filename, source: nil, locals: {}, only_if: nil)
  contents.entries << Copypasta::Entry::ERB.new(filename, directory: @directory, source: source, locals: locals, only_if: only_if).freeze
end
literal(filename, data:, only_if: nil) click to toggle source
# File lib/copypasta/contents_dsl.rb, line 32
def literal(filename, data:, only_if: nil)
  contents.entries << Copypasta::Entry::Literal.new(filename, data: data, only_if: only_if).freeze
end