Module: Thor::Actions

Included in:
Rag, Rag::DSL
Defined in:
lib/rag/ext.rb

Defined Under Namespace

Classes: Directory2

Instance Method Summary collapse

Instance Method Details

#directory2(source, *args, &block) ⇒ Object



3
4
5
6
7
# File 'lib/rag/ext.rb', line 3

def directory2(source, *args, &block)
  config = args.last.is_a?(Hash) ? args.pop : {}
  destination = args.first || source
  action Directory2.new(self, source, destination || source, config, &block)
end

#template2(source, *args, &block) ⇒ Object

use tilt :scope => nil :locals => {} &block is for yield.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rag/ext.rb', line 13

def template2(source, *args, &block)
  config = args.last.is_a?(Hash) ? args.pop : {}
  destination = args.first || source.sub(/\.tt$/, '')
  template_options = {source_root: self.class.source_root}

  source = File.expand_path(find_in_source_paths(source.to_s))

  create_file destination, nil, config do
    Rag::Template.render(source, template_options, &block)
  end
end