Sha256: 7231c90cad7070bb529137f46aa381b0fcc77673756f20c4e92f92e7bf157d94

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

module Deano
  class AppGenerator < Deano::NameCommand

    def self.command
      "generate:app"
    end

    def self.help
      "app_name"
    end

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

    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

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
deano-1.2.1 lib/deano/commands/app_generator_command.rb
deano-1.2.0 lib/deano/commands/app_generator_command.rb
deano-1.1.3 lib/deano/commands/app_generator_command.rb
deano-1.1.2 lib/deano/commands/app_generator_command.rb
deano-1.1.1 lib/deano/commands/app_generator_command.rb
deano-1.1.0 lib/deano/commands/app_generator_command.rb
deano-1.0.0 lib/deano/commands/app_generator_command.rb