Sha256: ef2097341a4954e75550769dd70271f7af4f86136109650c896835d1bf291fa7

Contents?: true

Size: 776 Bytes

Versions: 2

Compression:

Stored size: 776 Bytes

Contents

module Sinatra
  class NewProjectGenerator < Sinatra::NameCommand

    def self.command
      "new"
    end

    def self.help
      "name"
    end

    def initialize(*args)
      super
      @app_dir = File.expand_path(File.join(pwd, self.underscored))
    end

    def classified
      "#{self.name.classify}App"
    end

    def call
      mkdir self.underscored, verbose: true
      Dir[File.expand_path(File.join("**", "*"), Sinatra.template_dir)].each do |f|
        if File.directory?(f)
          mkdir_p clean_string(f), verbose: true
        else
          mkdir_p clean_string(File.dirname(f)), verbose: true
          File.open(clean_string(f), 'w') do |file|
            file.puts clean_string(File.read(f))
          end
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sinatra-template-1.2.0 lib/sinatra/commands/new_project_generator_command.rb
sinatra-template-1.1.0 lib/sinatra/commands/new_project_generator_command.rb