Sha256: 006c2d3287b44f6e206b1c7d4ce4063947aecf9bb81c5d923e810f4f721ac6a9

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

class SinatraAppGenerator < RubiGen::Base
  DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
                              Config::CONFIG['ruby_install_name'])

  attr_reader :name

  def initialize(runtime_args, runtime_options = {})
    super
    usage if args.empty?
    @destination_root = File.expand_path(args.shift)
    @name = (args.shift || base_name).camelize
  end

  def template(m, filename)
    m.template "#{filename}.erb", filename
  end

  def manifest
    record do |m|
      # Ensure appropriate folder(s) exists
      m.directory ''
      BASEDIRS.each { |path| m.directory path }

      # root
      template m, "app.rb"
      template m, "config.ru"
      template m, "geminstaller.yml"
      template m, "Rakefile"

      # cucumber
      m.directory "features/support"
      m.directory "features/step_definitions"
      template m, "features/support/env.rb"
      template m, "features/support/paths.rb"
      template m, "features/step_definitions/webrat_steps.rb"

      # rspec
      m.directory "spec"
      template m, "spec/spec_helper.rb"

      # lib
      m.directory "lib"
      template m, "lib/rack_fix.rb"
    end
  end

  protected
    def banner
      <<-EOS
Creates a new Sinatra / Sequel / rspec / cucumber app.

USAGE: #{spec.name} directory_name [module_name]

EOS
    end

    # Installation skeleton.  Intermediate directories are automatically
    # created so don't sweat their absence here.
    BASEDIRS = %w(
      lib
      spec
    )
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
openhood-sinatra_app_gen-0.1.1 lib/generators/sinatra_app/sinatra_app_generator.rb
openhood-sinatra_app_gen-0.1.2 lib/generators/sinatra_app/sinatra_app_generator.rb
openhood-sinatra_app_gen-0.1.3 lib/generators/sinatra_app/sinatra_app_generator.rb
openhood-sinatra_app_gen-0.1.4 lib/generators/sinatra_app/sinatra_app_generator.rb
openhood-sinatra_app_gen-0.1.5 lib/generators/sinatra_app/sinatra_app_generator.rb