Sha256: d6ebe364133b37cf25a07a1c52caffff76fd433c5ae94f484a81bfbb13e7a23a

Contents?: true

Size: 1.07 KB

Versions: 33

Compression:

Stored size: 1.07 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
          relative_dest_file_name = f.gsub("#{src_root}/", "")
          m.file Cms.scrub_path(f), relative_dest_file_name
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 10 rubygems

Version Path
SFEley-browsercms-3.0.2 rails_generators/browser_cms/browser_cms_generator.rb
buzzware-browsercms-3.0.2 rails_generators/browser_cms/browser_cms_generator.rb
coredumplings-browsercms-3.0.0 rails_generators/browser_cms/browser_cms_generator.rb
we5-browsercms-3.0.1.1 rails_generators/browser_cms/browser_cms_generator.rb
webficient-browsercms-3.0.1 rails_generators/browser_cms/browser_cms_generator.rb
webficient-browsercms-3.0.2 rails_generators/browser_cms/browser_cms_generator.rb
webficient-browsercms-3.0.3 rails_generators/browser_cms/browser_cms_generator.rb
webficient-browsercms-3.0.4 rails_generators/browser_cms/browser_cms_generator.rb
browsercms-3.1.5 rails_generators/browser_cms/browser_cms_generator.rb
browsercms-3.1.4 rails_generators/browser_cms/browser_cms_generator.rb
browsercms-3.1.3 rails_generators/browser_cms/browser_cms_generator.rb
bf4-browsercms-3.1.0 rails_generators/browser_cms/browser_cms_generator.rb
drujensen-browsercms-3.2.0 rails_generators/browser_cms/browser_cms_generator.rb
browsercmsi-3.1.2 rails_generators/browser_cms/browser_cms_generator.rb
browsercms-3.1.2 rails_generators/browser_cms/browser_cms_generator.rb
browsercms-3.1.1 rails_generators/browser_cms/browser_cms_generator.rb
browsercmsi-3.1.1 rails_generators/browser_cms/browser_cms_generator.rb
browsercmsi-3.1.0 rails_generators/browser_cms/browser_cms_generator.rb
browsercms-3.1.0 rails_generators/browser_cms/browser_cms_generator.rb
we5-browsercms-3.1.0 rails_generators/browser_cms/browser_cms_generator.rb