Sha256: 37ae8417e82ede9ca504f50e2b2c7e11cb3cf4b074663cf90d3e24f3c664464c

Contents?: true

Size: 1015 Bytes

Versions: 1

Compression:

Stored size: 1015 Bytes

Contents

require "gator/generator"
require "gator/project"

module Gator
  class AS3Generator < Gator::Generator
    include Thor::Actions
    include Gator::Project

    register_generator "as3", "generate as3 CLASS_NAME", "Creates a class."

    def self.source_root
      File.dirname __FILE__
    end

    desc "as3 klass CLASS_NAME", "Creates an AS3 Class"
    def klass(class_name)
      src = project.path(:src,:main,:as3)
      @package_name, @class_name = split_class_name(class_name)
      src = File.join( src, @package_name.split(".").join(File::SEPARATOR) ) unless @package_name == ""
      template "ClassTemplate.as.tt", File.join( src, "#{@class_name}.as")
    end

    no_tasks {

      def package_name
        @package_name
      end

      def class_name
        @class_name
      end

    }

    protected

    def split_class_name(class_name)
      pieces = class_name.split "."
      class_name = pieces.pop
      package_name = pieces.join "."
      return package_name, class_name
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gator-0.0.11.pre lib/gator/generators/as3_generator.rb