Sha256: b2ab59471ce82f3ad38a8b63b00d1d2aab4bf5507d9d4b74cc31b7fee44f4708

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'ruboss4ruby/configuration'

module Merb::Generators
  class RubossControllerGenerator < Generator
    include Ruboss::Configuration
    
    def initialize(*args)
      super
      @project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
    end

    def project_name
      @project_name
    end

    def flex_project_name
      @flex_project_name
    end

    def base_folder
      @base_folder
    end
    
    def base_package
      @base_package
    end
    
    def command_controller_name
      @command_controller_name
    end
    
    def model_names
      list_as_files("app/flex/#{base_folder}/models")
    end
    
    def command_names
      list_as_files("app/flex/#{base_folder}/commands")
    end

    def self.source_root
      File.join(File.dirname(__FILE__), 'templates', 'ruboss_controller')
    end
    
    template :controller do
      source('controller.as.erb')
      destination(File.join('app', 'flex', base_folder, 'controllers', "#{command_controller_name}.as"))
    end

    desc <<-DESC
      Generates the main Ruboss Flex application controller.
      Typically app/flex/<yourappname>/controllers/<YourAppName>Controller.as, 
      e.g. app/flex/pomodo/controllers/PomodoController.as
    
      It pulls out all available models and commands from respective
      folders and makes sure they'll be pulled into the Flex application
      at runtime.
    DESC
  end
  
  add :ruboss_controller, RubossControllerGenerator
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruboss4ruby-1.0.2 merb_generators/ruboss_controller.rb