commit 70b9d9193016dfef14ac09010aaa93043c3511a1 Author: Greg Jastrab Date: Tue Dec 2 15:50:24 2008 -0500 Initial PureMVCGen gem code in place. diff --git a/History.txt b/History.txt new file mode 100644 index 0000000..5785ff7 --- /dev/null +++ b/History.txt @@ -0,0 +1,6 @@ +=== 1.0.0 / 2008-12-02 + +* 1 major enhancement + + * Birthday! + diff --git a/Manifest.txt b/Manifest.txt new file mode 100644 index 0000000..96fb52e --- /dev/null +++ b/Manifest.txt @@ -0,0 +1,21 @@ +History.txt +Manifest.txt +README.txt +Rakefile +bin/puremvc-gen +conf/build.xml +conf/config/pmvcgen.log.properties +conf/config/pmvcgen.properties +conf/example/author.properties +conf/example/proj.properties +conf/templates/.DS_Store +conf/templates/Event.tpl +conf/templates/standard/Application.tpl +conf/templates/standard/Facade.tpl +conf/templates/standard/MacroCommand.tpl +conf/templates/standard/Mediator.tpl +conf/templates/standard/Proxy.tpl +conf/templates/standard/SimpleCommand.tpl +lib/pure_m_v_c_gen.rb +lib/pure_m_v_c_gen/version.rb +test/test_pure_m_v_c_gen.rb diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..6819d21 --- /dev/null +++ b/README.txt @@ -0,0 +1,48 @@ += PureMVCGen + +* FIX (url) + +== DESCRIPTION: + +FIX (describe your package) + +== FEATURES/PROBLEMS: + +* FIX (list of features or problems) + +== SYNOPSIS: + + FIX (code sample of usage) + +== REQUIREMENTS: + +* FIX (list of requirements) + +== INSTALL: + +* FIX (sudo gem install, anything else) + +== LICENSE: + +(The MIT License) + +Copyright (c) 2008 FIX + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..386d6df --- /dev/null +++ b/Rakefile @@ -0,0 +1,32 @@ +# -*- ruby -*- + +require 'rubygems' +require 'hoe' +require './lib/pure_m_v_c_gen/version.rb' + +PKG_NAME = "puremvc-gen" +PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' +version = PureMVCGen::Version::STRING.dup +if ENV['SNAPSHOT'].to_i == 1 + version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S") +end +PKG_VERSION = version +PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" + +Hoe.new(PKG_NAME, PKG_VERSION) do |p| + p.rubyforge_name = 'gjastrab' # if different than lowercase project name + p.developer('Greg Jastrab', 'gjastrab.dev@gmail.com') + p.name = PKG_NAME + p.version = PKG_VERSION + #p.platform = Gem::Platform::RUBY + p.author = "Greg Jastrab" + p.email = "gjastrab.dev@gmail.com" + p.description = %q(An ANT-based PureMVC generator.) + p.summary = p.description # More details later?? + p.remote_rdoc_dir = PKG_NAME # Release to /PKG_NAME + # p.changes = p.paragraphs_of('CHANGELOG', 0..1).join("\n\n") + p.need_zip = true + p.need_tar = false +end + +# vim: syntax=Ruby diff --git a/bin/puremvc-gen b/bin/puremvc-gen new file mode 100644 index 0000000..71d5fab --- /dev/null +++ b/bin/puremvc-gen @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +puts "About to run the ant script" + +path = File.join(File.dirname(__FILE__), '..', 'conf', 'build.xml') +system "ant -f #{path}" diff --git a/conf/build.xml b/conf/build.xml new file mode 100644 index 0000000..061bbb3 --- /dev/null +++ b/conf/build.xml @@ -0,0 +1,367 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Read in PureMVCGen and project properties. + + + + PureMVCGen Properties have been set. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + name for the model directory ("model" by default) + -view.dir => name for the view directory ("view" by default) + -controller.dir => name for the controller directory ("controller" by default) + -events.dir => name for the events directory ("events" by default)]]> + + + + + + + + + + + + + Prefix you'd like prepended to your Facade and Application Mediator + -project.name => Name of the project which will be used to create the main MXML file + -core.namespace => Core package structure (where PureMVC directories and Facade will be placed) + Example: com.slslabs.puremvc.generator + -core.dir => Directory location of core package structure. This should just be the core.namespace with the .'s replaced with /'s + Example: com/slslabs/puremvc/generator + -pmvc.flavor => standard / multicore]]> + + + All properties have been read in and verified. + + + + + + + + + + + + + + + + + + + Basedir is: ${basedir} + + + + + + + + + + Creating PureMVC Core project directory: ${core.dir} + + Creating PureMVC directories in ${core.dir} + + + + + + + + + + + + + + + + + + + + + + + + + Creating main MXML for PureMVC project. + + + + + + + ${log.gen.event} + + + + + + + + + + + ${log.gen.facade} + + + + + + + ${log.gen.macro.command} + + + + + + + + + + + + + + ${log.gen.simple.command} + + + + + + + + + + ${log.gen.mediator} + + + + + + + + + + + ${log.gen.proxy} + + + + + + + + + + + ${log.gen.startup.command} + + + + + + + + ${log.gen.prepare.command} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/config/pmvcgen.log.properties b/conf/config/pmvcgen.log.properties new file mode 100644 index 0000000..d7393ea --- /dev/null +++ b/conf/config/pmvcgen.log.properties @@ -0,0 +1,25 @@ +##### =============== ERROR MESSAGES =============== ##### +log.invalid.properties = All required properties have not been set. Please verify you are including the necessary .properties files. +log.no.core.namespace = core.namespace is not set! The PureMVC-Gen convention is to specify this in a proj.properties file. +log.no.pmvcgen.home = The PMVC_GEN_HOME environment variable is not set! Be sure to set it and point it to the location of your PureMVCGen directory. + +##### =============== GENERATION MESSAGES =============== ##### +log.gen.facade = Creating PureMVC Facade class: ${core.namespace}.${app.prefix}Facade +log.gen.macro.command = Creating PureMVC MacroCommand class => ${cmd.name} +log.gen.simple.command = Creating PureMVC SimpleCommand class => ${cmd.name} +log.gen.startup.command = Creating PureMVC StartupCommand +log.gen.prepare.command = Creating PureMVC PrepareActorsCommand +log.gen.mediator.command = Creating PureMVC Mediator class => ${mediator.name} +log.gen.proxy.command = Creating PureMVC Proxy class => ${proxy.name} + +##### =============== PROMPT MESSAGES =============== ##### +log.prompt.command.name = Enter the name of the command you'd like to create. (i.e., generates ==> Command.as) +log.prompt.command.constant = Enter the name of the constant to be associated with the command. +log.prompt.mediator.name = Enter the name of the mediator you'd like to create. (i.e., generates ==> Mediator.as) +log.prompt.proxy.name = Enter the name of the proxy you'd like to create. (i.e., generates ==> Proxy.as) + +##### =============== PROMPT MESSAGES =============== ##### +log.fail.command.name = You must enter a name for the command! +log.fail.command.constant = You must enter a constant for the comman! +log.fail.mediator.name = You must enter a name for the mediator! +log.fail.proxy.name = You must enter a name for the proxy! \ No newline at end of file diff --git a/conf/config/pmvcgen.properties b/conf/config/pmvcgen.properties new file mode 100644 index 0000000..49e62b1 --- /dev/null +++ b/conf/config/pmvcgen.properties @@ -0,0 +1,7 @@ +##### =============== PureMVC GEN PROPERTIES =============== ##### +model.dir = model +view.dir = view +controller.dir = controller +events.dir = events + +templates.dir = templates diff --git a/conf/example/author.properties b/conf/example/author.properties new file mode 100644 index 0000000..ff67a9e --- /dev/null +++ b/conf/example/author.properties @@ -0,0 +1,2 @@ +author.name = Greg Jastrab +author.email = greg@smartlogicsolutions.com diff --git a/conf/example/proj.properties b/conf/example/proj.properties new file mode 100644 index 0000000..a0b8b1f --- /dev/null +++ b/conf/example/proj.properties @@ -0,0 +1,9 @@ +##### =============== PROJECT PROPERTIES =============== ##### +app.prefix = PMVCGen +project.name = PMVCGenDemo +core.namespace = net.slsdev.utils.pmvc.demo +core.dir = net/slsdev/utils/pmvc/demo +version = 1.0 + +##### =============== PureMVC PROPERTIES =============== ##### +pmvc.flavor = standard \ No newline at end of file diff --git a/conf/templates/Event.tpl b/conf/templates/Event.tpl new file mode 100644 index 0000000..56dea05 --- /dev/null +++ b/conf/templates/Event.tpl @@ -0,0 +1,55 @@ +@copy@ +package @namespace@.@events@ { + + import flash.events.Event; + + /** + * Event description here. + * + * @langversion ActionScript 3.0 + * @author @author.name@ @author.email@ + * @date @today@ + * @version @version@ + */ + public class @event.name@ extends Event { + + /* --- Variables --- */ + + //pmvcgen:varconsts + + /* === Variables === */ + + /* --- Constructor --- */ + + public function @event.name@(type:String) { + super(type); + } + + /* === Constructor === */ + + /* --- Functions --- */ + + /** + * Clones the @event.name@. + * + * @return Duplicates an instance of an Event subclass + */ + public function clone():Event { + var evt:@event.name@ = new @event.name@(type); + return evt; + } + + /** + * Formats the event to a string. + * + * @return Returns a string containing all the properties of the Event object + */ + override public function toString():String { + return formatToString("@event.name@", "type"); + } + + /* === Functions === */ + + } + +} \ No newline at end of file diff --git a/conf/templates/standard/Application.tpl b/conf/templates/standard/Application.tpl new file mode 100644 index 0000000..0c0c4ae --- /dev/null +++ b/conf/templates/standard/Application.tpl @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/conf/templates/standard/Facade.tpl b/conf/templates/standard/Facade.tpl new file mode 100644 index 0000000..3244aed --- /dev/null +++ b/conf/templates/standard/Facade.tpl @@ -0,0 +1,51 @@ +package @namespace@ { + + import @namespace@.@ctrls@.*; + + import org.puremvc.as3.patterns.facade.Facade; + + /** + * Application Facade. + * + * @langversion ActionScript 3.0 + * @author @author.name@ @author.email@ + * @date @today@ + * @version @version@ + */ + public class @app.prefix@Facade extends Facade { + + /* --- Variables --- */ + + public static const STARTUP:String = "startup"; + + //pmvcgen:varconsts + + /* === Variables === */ + + /* --- Functions --- */ + + public static function getInstance():@app.prefix@Facade { + if(instance == null) + instance = new @app.prefix@Facade(); + return instance as @app.prefix@Facade; + } + + /** + * Starts up @project.name@. + * + * @param app reference to the application + */ + public function startup(app:@project.name@):void { + sendNotification(STARTUP, app); + } + + override protected function initializeController():void { + super.initializeController(); + //pmvcgen:register commands + } + + /* === Functions === */ + + } + +} diff --git a/conf/templates/standard/MacroCommand.tpl b/conf/templates/standard/MacroCommand.tpl new file mode 100644 index 0000000..161ea3b --- /dev/null +++ b/conf/templates/standard/MacroCommand.tpl @@ -0,0 +1,24 @@ +package @namespace@.@ctrls@ { + + //pmvcgen:import commands + + import org.puremvc.as3.interfaces.INotification; + import org.puremvc.as3.patterns.command.MacroCommand; + + /** + * @command.name@ command. + * + * @langversion ActionScript 3.0 + * @author @author.name@ @author.email@ + * @date @today@ + * @version @version@ + */ + public class @command.name@Command extends MacroCommand { + + override protected function initializeMacroCommand():void { + //pmvcgen:chain simple commands + } + + } + +} diff --git a/conf/templates/standard/Mediator.tpl b/conf/templates/standard/Mediator.tpl new file mode 100644 index 0000000..5e98c2f --- /dev/null +++ b/conf/templates/standard/Mediator.tpl @@ -0,0 +1,56 @@ +package @namespace@.@view@ { + + import @namespace@.@facade@; + + import org.puremvc.as3.patterns.mediator.Mediator; + + /** + * @mediator.name@ mediator. + * + * @langversion ActionScript 3.0 + * @author @author.name@ @author.email@ + * @date @today@ + * @version @version@ + */ + public class @mediator.name@Mediator extends Mediator { + + /* --- Variables --- */ + + public static const NAME:String = "@mediator.name@Mediator"; + + /* === Variables === */ + + /* --- Constructor --- */ + + /** + * Constructor. + * + * @param viewComponent view component for mediator + */ + public function @mediator.name@Mediator(viewComponent:Object) { + super(NAME, viewComponent); + } + + /* === Constructor === */ + + /* --- Functions --- */ + + override public function handleNotification(note:INotification):void { + } + + override public function listNotificationInterests():Array { + return [ + ]; + } + + /* === Functions === */ + + /* --- Public Accessors --- */ + + public function get YOURVIEWNAME():YOURVIEWOBJ { return viewComponent as YOURVIEWOBJ; } + + /* === Public Accessors === */ + + } + +} diff --git a/conf/templates/standard/Proxy.tpl b/conf/templates/standard/Proxy.tpl new file mode 100644 index 0000000..e77de8a --- /dev/null +++ b/conf/templates/standard/Proxy.tpl @@ -0,0 +1,50 @@ +package @namespace@.@model@ { + + import @namespace@.@facade@; + + import org.puremvc.as3.patterns.proxy.Proxy; + + /** + * @proxy.name@ proxy. + * + * @langversion ActionScript 3.0 + * @author @author.name@ @author.email@ + * @date @today@ + * @version @version@ + */ + public class @proxy.name@Proxy extends Proxy { + + /* --- Variables --- */ + + public static const NAME:String = "@proxy.name@Proxy"; + + /* === Variables === */ + + /* --- Constructor --- */ + + /** + * Constructor. + * + * @param data data model for proxy + */ + public function @proxy.name@Proxy(data:Object=null) { + super(NAME, data); + } + + /* === Constructor === */ + + /* --- Functions --- */ + + //addfunctions + + /* === Functions === */ + + /* --- Public Accessors --- */ + + public function get data():Object { return data; } + + /* === Public Accessors === */ + + } + +} diff --git a/conf/templates/standard/SimpleCommand.tpl b/conf/templates/standard/SimpleCommand.tpl new file mode 100644 index 0000000..cc41f5f --- /dev/null +++ b/conf/templates/standard/SimpleCommand.tpl @@ -0,0 +1,24 @@ +package @namespace@.@ctrls@ { + + //pmvcgen:insert imports + + import org.puremvc.as3.interfaces.INotification; + import org.puremvc.as3.patterns.command.SimpleCommand; + + /** + * @command.name@ command. + * + * @langversion ActionScript 3.0 + * @author @author.name@ @author.email@ + * @date @today@ + * @version @version@ + */ + public class @command.name@Command extends SimpleCommand { + + override public function execute(note:INotification):void { + //pmvcgen:insert command logic + } + + } + +} diff --git a/lib/pure_m_v_c_gen.rb b/lib/pure_m_v_c_gen.rb new file mode 100644 index 0000000..e69de29 diff --git a/lib/pure_m_v_c_gen/version.rb b/lib/pure_m_v_c_gen/version.rb new file mode 100644 index 0000000..cabc6bc --- /dev/null +++ b/lib/pure_m_v_c_gen/version.rb @@ -0,0 +1,20 @@ +module PureMVCGen + module Version #:nodoc: + # A method for comparing versions of required modules. It expects two + # arrays of integers as parameters, the first being the minimum version + # required, and the second being the actual version available. It returns + # true if the actual version is at least equal to the required version. + def self.check(required, actual) #:nodoc: + required = required.map { |v| "%06d" % v }.join(".") + actual = actual.map { |v| "%06d" % v }.join(".") + return actual >= required + end + + MAJOR = 0 + MINOR = 1 + TINY = 0 + + STRING = [MAJOR, MINOR, TINY].join(".") + end +end + diff --git a/puremvc-gen.gemspec b/puremvc-gen.gemspec new file mode 100644 index 0000000..174c411 --- /dev/null +++ b/puremvc-gen.gemspec @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{puremvc-gen} + s.version = "0.1.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Greg Jastrab"] + s.date = %q{2008-12-02} + s.default_executable = %q{puremvc-gen} + s.description = %q{An ANT-based PureMVC generator.} + s.email = %q{gjastrab.dev@gmail.com} + s.executables = ["puremvc-gen"] + s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"] + s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/puremvc-gen", "conf/build.xml", "conf/config/pmvcgen.log.properties", "conf/config/pmvcgen.properties", "conf/example/author.properties", "conf/example/proj.properties", "conf/templates/.DS_Store", "conf/templates/Event.tpl", "conf/templates/standard/Application.tpl", "conf/templates/standard/Facade.tpl", "conf/templates/standard/MacroCommand.tpl", "conf/templates/standard/Mediator.tpl", "conf/templates/standard/Proxy.tpl", "conf/templates/standard/SimpleCommand.tpl", "lib/pure_m_v_c_gen.rb", "lib/pure_m_v_c_gen/version.rb", "test/test_pure_m_v_c_gen.rb"] + s.has_rdoc = true + s.homepage = %q{FIX (url)} + s.rdoc_options = ["--main", "README.txt"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{gjastrab} + s.rubygems_version = %q{1.3.1} + s.summary = %q{An ANT-based PureMVC generator.} + s.test_files = ["test/test_pure_m_v_c_gen.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, [">= 1.8.2"]) + else + s.add_dependency(%q, [">= 1.8.2"]) + end + else + s.add_dependency(%q, [">= 1.8.2"]) + end +end diff --git a/test/test_pure_m_v_c_gen.rb b/test/test_pure_m_v_c_gen.rb new file mode 100644 index 0000000..e69de29