Module: Lipsiadmin::Generator::Commands::Base

Included in:
Create, Destroy
Defined in:
lib/generator.rb

Overview

:nodoc:

Constant Summary collapse

PROTECTED_DIRS =
["app/controllers/",
"app/views/",
"config/",
"app/helpers/",
"app/models/",
"config/",
"lib/",
"app/views/layouts/",
"public/images/",
"public/javascripts/",
"public/stylesheet/"]

Instance Method Summary collapse

Instance Method Details

#create_all(relative_source, relative_destination) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/generator.rb', line 53

def create_all(relative_source, relative_destination)
  directories = []
  with_source_in(relative_source) do |full, rel|
    if File.directory?(source_path(full))
      directory File.join(relative_destination, rel)
      directories << File.join(relative_destination, rel)
    else
      file full, File.join(relative_destination, rel)
    end
  end
  # Need to do this for remove all directories
  directories.each { |d| directory(d) unless PROTECTED_DIRS.include?(d) }
end

#with_source_in(path) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/generator.rb', line 42

def with_source_in(path)
  root = source_path(path)
  Find.find(root) do |f|
    Find.prune if File.basename(f) == ".svn"
    Find.prune if File.basename(f) == ".DS_Store"
    full_path = f[(source_root.length)..-1]
    rel_path = f[(root.length)..-1]
    yield full_path, rel_path
  end
end