Sha256: a6b52f5fc0423f938fd0729a3771061f6a66112d8217e8e3f2814123a6d20856

Contents?: true

Size: 1.02 KB

Versions: 15

Compression:

Stored size: 1.02 KB

Contents

require "active_support"

class CoherentBaseGenerator < RubiGen::Base
  
  def copy_template_folder(m, path=nil)
    path = path ? "#{path}/" : ""
    prefix_regex= Regexp.new("^#{Regexp.escape(source_root)}/(.*)$")
    all_files= Dir.glob("#{source_root}/**/*").select { |filepath| File.file?(filepath) }

    all_files.map! { |filepath| prefix_regex.match(filepath)[1] }

    b= binding
    
    all_folders= all_files.map { |filepath|
      File.dirname(filepath).gsub(/@(\w+)@/) { |match|
        begin
          eval($1, b)
        rescue
          "@#{$1}@"
        end
      }
    }
    all_folders.uniq.each { |folder| m.directory "#{path}#{folder}" }

    all_files.each { |filepath|
      output_path= filepath.gsub(/\.erb$/, '').gsub(/@(\w+)@/) { |match|
        begin
          eval($1, b)
        rescue
          "@#{$1}@"
        end
      }
      output_path= "#{path}#{output_path}"
      if (filepath[/\.erb$/])
        m.template filepath, output_path
      else
        m.file filepath, output_path
      end
    }
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
coherent-0.6.10 lib/coherent.rb
coherent-0.6.9 lib/coherent.rb
coherent-0.6.8 lib/coherent.rb
coherent-0.6.7 lib/coherent.rb
coherent-0.6.6 lib/coherent.rb
coherent-0.6.5 lib/coherent.rb
coherent-0.6.4 lib/coherent.rb
coherent-0.6.2 lib/coherent.rb
coherent-0.6.1 lib/coherent.rb
coherent-0.6.0 lib/coherent.rb
coherent-0.4.3 lib/coherent.rb
coherent-0.4.2 lib/coherent.rb
coherent-0.4.1 lib/coherent.rb
coherent-0.4.0 lib/coherent.rb
coherent-0.3.0 lib/coherent.rb