Sha256: 0cdcefd982709ad8586fc60bc8fe08005be1b627db83b00d44f3872576b5f5ba

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require File.dirname(__FILE__) + '/generator_actions'
require File.dirname(__FILE__) + '/components/component_actions'
Dir[File.dirname(__FILE__) + "/{base_app,components}/**/*.rb"].each { |lib| require lib }

module SinatraMore
  class SkeletonGenerator < Thor::Group
    # Define the source template root
    def self.source_root; File.dirname(__FILE__); end

    # Include related modules
    include Thor::Actions
    include SinatraMore::GeneratorActions
    include SinatraMore::ComponentActions

    argument :name, :desc => "The name of your sinatra app"
    argument :path, :desc => "The path to create your app"

    # Definitions for the available customizable components
    component_option :orm,      "Database engine",    :aliases => '-d', :choices => [:sequel, :datamapper, :mongomapper, :activerecord]
    component_option :test,     "Testing framework",  :aliases => '-t', :choices => [:bacon, :shoulda, :rspec, :testspec, :riot]
    component_option :mock,     "Mocking library",    :aliases => '-m', :choices => [:mocha, :rr]
    component_option :script,   "Javascript library", :aliases => '-s', :choices => [:jquery, :prototype, :rightjs]
    component_option :renderer, "Template Engine",    :aliases => '-r', :choices => [:erb, :haml]

    # Copies over the base sinatra starting application
    def setup_skeleton
      self.destination_root = File.join(path, name)
      @class_name = name.classify
      directory("base_app/", self.destination_root)
      store_component_config('.components')
    end

    # For each component, retrieve a valid choice and then execute the associated generator
    def setup_components
      self.class.component_types.each do |comp|
        choice = resolve_valid_choice(comp)
        execute_component_setup(comp, choice)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinatra_more-0.3.0 generators/skeleton_generator.rb