class Sinatra::AppGenerator

Public Class Methods

command() click to toggle source
# File lib/sinatra/commands/app_generator_command.rb, line 4
def self.command
  "generate:app"
end
help() click to toggle source
# File lib/sinatra/commands/app_generator_command.rb, line 8
def self.help
  "app_name"
end

Public Instance Methods

call() click to toggle source
# File lib/sinatra/commands/app_generator_command.rb, line 16
    def call
      # mkdir self.underscored, verbose: true
      %w{apps spec/apps}.each do |dir|
        Dir[template_path("**", "*")].each do |f|
          if File.directory?(f)
            FileUtils.mkdir_p clean_string(f), verbose: true
          else
            FileUtils.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
      File.open(app_path("assets", "javascripts", "#{self.underscored}.js.coffee"), 'w') do |file|
        file.puts ""
      end
      File.open(app_path("assets", "stylesheets", "#{self.underscored}.css.scss"), 'w') do |file|
        file.puts ""
      end
      File.open(app_path("config.ru"), "a") do |file|
        file.puts <<-EOF
  map "/#{self.underscored}" do
    run #{self.classified}
  end
        EOF
      end

    end
classified() click to toggle source
# File lib/sinatra/commands/app_generator_command.rb, line 12
def classified
  "#{self.name.classify}App"
end