Sha256: b65d76d6fab883ff9b361579e27a1590cdee854c8309cc14ea39a34fb4422d5c

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

require 'maven/gwt/layout'
require 'thor/group'
require 'thor/actions'

module Maven
  module Gwt
    class Generator < Thor::Group
      include Thor::Actions

      source_root( File.join( File.dirname( __FILE__ ), 'templates' ) )

      def layout
        @layout ||= Layout.new
      end

      def base_package
        @base_package ||= @java_package + '.client'
      end
      
      def basedir
        @basedir ||= File.join( layout.java_root, *@java_package.split( /\./ ) )
      end
      
      def clientdir
        @clientdir ||= File.join( basedir, 'client' )
      end
      
      def application_name
        @application_name ||= File.basename( @basedir )
      end

      def application_class_name
        @application_name ||= camelize( application_name )
      end

      def camelize( str )
        str.split( "_" ).collect { |s| s.capitalize }.join
      end

      def setup( java_package, app_name = nil )
        @java_package = java_package
        @application_name = app_name
        template( 'Module.gwt.xml',
                  "#{basedir}/#{application_class_name}.gwt.xml" )
        template( 'ModuleDevelopment.gwt.xml',
                  "#{basedir}/#{application_class_name}Development.gwt.xml" )
        template( 'EntryPoint.java', 
                  "#{clientdir}/#{application_class_name}EntryPoint.java" )
        template( 'Application.java', 
                  "#{clientdir}/#{application_class_name}Application.java" )
        template( 'Application.ui.xml', 
                  "#{clientdir}/#{application_class_name}Application.ui.xml" )
        template( 'index.html',
                  'public/index.html' )
        template( 'gwt.css',
                  "public/#{application_name}.css" )
        
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gwt-run-0.1.0 lib/maven/gwt/generator.rb~