Class: SimpleTemplater::DSL

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/simple-templater/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FileUtils

cp_f

Constructor Details

#initialize(generator) ⇒ DSL

Returns a new instance of DSL.



10
11
12
13
# File 'lib/simple-templater/dsl.rb', line 10

def initialize(generator)
  @generator = generator
  @context   = generator.context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



9
10
11
# File 'lib/simple-templater/dsl.rb', line 9

def context
  @context
end

#generatorObject (readonly)

Returns the value of attribute generator.



9
10
11
# File 'lib/simple-templater/dsl.rb', line 9

def generator
  @generator
end

Instance Method Details

#file(name, &block) ⇒ Object



19
20
21
# File 'lib/simple-templater/dsl.rb', line 19

def file(name, &block)
  File.open(name, "w", &block)
end

#hook(&block) ⇒ Object



23
24
25
# File 'lib/simple-templater/dsl.rb', line 23

def hook(&block)
  block.call(self.generator, self.context)
end

#make_executable(path) ⇒ Object



15
16
17
# File 'lib/simple-templater/dsl.rb', line 15

def make_executable(path)
  sh "chmod +x '#{path}'"
end