Class: FileSystem::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/skeleton_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, options = false) ⇒ Runner

Returns a new instance of Runner.



10
11
12
13
# File 'lib/skeleton_creator.rb', line 10

def initialize(filename, options = false)      
  @yml_content = YAML.load_file(filename)
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/skeleton_creator.rb', line 8

def options
  @options
end

#yml_contentObject

Returns the value of attribute yml_content.



8
9
10
# File 'lib/skeleton_creator.rb', line 8

def yml_content
  @yml_content
end

Instance Method Details

#run(root_dir, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/skeleton_creator.rb', line 15

def run(root_dir, options = {})  
  @options = options if !options.nil?      
  root = root_dir.gsub /~/, "#{ENV['HOME']}"
  yml_content.each do |key, value|
    if key == 'DIRECTORY'
      traverser = FileSystem::Traverser.new root, options
      traverser.traverse(value) do |file_node|
        file_node.create
      end
    end
  end
end