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 = {}) ⇒ Runner

Returns a new instance of Runner.



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

def initialize(filename, options = {})      
  @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

#root_dirObject (readonly)

Returns the value of attribute root_dir.



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

def root_dir
  @root_dir
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(dir, options = {}) ⇒ Object



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

def run(dir, options = {})  
  return run_list(dir, options) if dir.respond_to? :each

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