Sha256: 898bca5fd47d9ded24daec63e58ac2281a03cb5aa169b90cf3b961f37b742474

Contents?: true

Size: 928 Bytes

Versions: 8

Compression:

Stored size: 928 Bytes

Contents

module Sharp
  class Generator
    include FileUtils

    attr_accessor :name, :source_dir, :output_dir

    def initialize(name)
      @name = name
    end

    def source_dir
      @source_dir ||= File.expand_path(File.join('../../../template'), __FILE__)
    end

    def output_dir
      @output_dir ||= File.expand_path(name)
    end

    def generate
      cp_r source_dir, output_dir
      configs.each do |config, data|
        open(File.join(output_dir, 'config', "#{config}.yml"), 'w') do |file|
          file << data.to_yaml.sub(/\A---\n/,'')
        end
      end
    end

    def configs
      {
        #:database => %w[development test production].inject({}) do |cfg, env|
          #cfg[env] = {
            #'adapter' => 'mysql2',
            #'database' => "#{@name}_#{env}",
            #'host' => 'localhost',
            #'user' => 'root'
          #}
          #cfg
        #end
      }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sharp-0.3.7 lib/sharp/generator.rb
sharp-0.3.6 lib/sharp/generator.rb
sharp-0.3.5 lib/sharp/generator.rb
sharp-0.3.4 lib/sharp/generator.rb
sharp-0.3.3 lib/sharp/generator.rb
sharp-0.3.2 lib/sharp/generator.rb
sharp-0.3.1 lib/sharp/generator.rb
sharp-0.3.0 lib/sharp/generator.rb