Sha256: 8983f26c929e5a33667e341af073132ea74593d370a73c43f9754dbf06c7ad3e

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module Gator
  module AS3
    class ClassTestGenerator < Task
      include Gator::Project

      define :on => Gator::AS3::TestGeneratorCollection, :as => "klass",
             :usage => "generate as3 test klass CLASS_NAME", :description => "Creates AS3 class test."

      argument :classname

      def self.source_root
        File.dirname __FILE__
      end

      def generate
        src = project.path(:src, :test, :as3)
        @package_name, @class_name = split_class_name(classname)
        @class_name += "Test"
        src = File.join(src, @package_name.split(".").join(File::SEPARATOR)) unless @package_name == ""
        template "ClassTemplate.as.tt", File.join(src, "#{@class_name}.as")

        invoke Gator::AS3::GeneratorCollection, "klass"
      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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gator-0.0.14.pre lib/gator/generators/as3/test/class_test_generator.rb