Class: Thor::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/thor/tree.rb,
lib/thor/tree/file.rb,
lib/thor/tree/writer.rb,
lib/thor/tree/version.rb,
lib/thor/tree/directory.rb

Defined Under Namespace

Classes: Directory, File, Writer

Constant Summary collapse

VERSION =
'0.2.1'

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Tree

Returns a new instance of Tree.



13
14
15
# File 'lib/thor/tree.rb', line 13

def initialize(file)
  @options = YAML.load_file(Path(file).expand, safe: true).symbolize_keys!
end

Instance Method Details

#set_template_variable(key, value) ⇒ Object



17
18
19
# File 'lib/thor/tree.rb', line 17

def set_template_variable(key, value)
  Tree::File.set_template_variable key, value
end

#writeObject



21
22
23
24
25
26
27
28
29
# File 'lib/thor/tree.rb', line 21

def write
  source_paths.each do |path|
    Tree::File.source_paths << path
  end

  Tree::Writer.new([], {}, destination_root: options[:destination_root]).tap do |w|
    w.write options[:content]
  end
end