Sha256: 8b47e0953990eabd066128ffce66d8f8be7f744710f52218ad6c4ed24edf576c

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

class BrowserCmsGenerator < Rails::Generator::Base
  #We need to be able to define a different source root for each gem
  #So we'll just set the baseline source root to "/",
  #and append the appropriate path when we call file
  def source_root
    "/"
  end
  def manifest
    record do |m|
      
      #Cms.generator_paths is an Array of Arrays
      #Each Array has the root as the first element
      #and the array of "files" as the second element
      #Each element in files is actually a Dir.glob pattern string
      Cms.generator_paths.each do |src_root, files|
        copy_files m, src_root, files
      end
    end
  end
  def copy_files(m, src_root, files)
    dirs = []
    files.each do |d|
      Dir[File.join(src_root, d)].each do |f|
        if File.file?(f)
          dir = File.dirname(f.gsub("#{src_root}/",''))
          unless dirs.include?(dir)
            m.directory dir 
            dirs << dir
          end
          m.file f, f.gsub("#{src_root}/", "")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nate-browsercms-3.0.210 rails_generators/browser_cms/browser_cms_generator.rb
nate-browsercms-3.0.211 rails_generators/browser_cms/browser_cms_generator.rb