Commits

Anonymous committed c660b58

Have working generator for creation of flex app

  • Participants
  • Parent commits f7b732a

Comments (0)

Files changed (5)

File flex_dev/generators/flex_app/flex_app_generator.rb

-class FlexAppGenerator < RAils::Generator::NamedBase
+require "flex_dev"
+class FlexAppGenerator < Rails::Generator::NamedBase
   def manifest
     record do |m|
-      # m.directory "lib"
+      if(!File.exist?(File.join( "config", "flex-config.yml")))
+        write_flex_config
+      end
+      flex_apps = {}
+      if(File.exist?(File.join( "config", "flex-apps.yml")))
+        flex_apps = YAML::load(File.open(File.join( "config", "flex-apps.yml")))
+      end
+      
+      # create flex flex app data
+      app_name = "#{class_name}"
+      flex_bin = "public"
+      flex_src = "flex/#{file_name}/src"
+      flex_lib = "flex/#{file_name}/lib"
+      flex_main = "#{flex_src}/main.mxml"
+
+      m.directory flex_bin
+      m.directory flex_src
+      m.directory flex_lib
+      m.template "main.mxml", flex_main
+
+      flex_app = {
+        "flex-bin" => flex_bin,
+        "flex-src" => flex_src,
+        "flex-lib" => flex_lib,
+        "flex-main" => flex_main,
+      }
+      flex_apps[app_name] =  flex_app
+      puts "modifing config/flex-apps.yml"
+      File.open(File.join("config", "flex-apps.yml"), "w") do |f|
+        f.puts YAML::dump(flex_apps)
+      end
       # m.template 'README', "README"
     end
   end

File flex_dev/generators/flex_app/templates/main.mxml

 <?xml version="1.0" encoding="utf-8"?>
-<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
+<mx:Application name="<%= class_name %>"xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 
 </mx:Application>

File flex_dev/install.rb

 # Install hook code here
-require "yaml"
+
+require "flex_dev"
 # Build properties map
-flex = {
-	"flex-bin" => "public", 
-	"flex-src" => "flex/src", 
-	"flex-lib" =>"flex/lib", 
-	"flex-home"=>"c:/addata/flex",
-	}
-#prompt for flex home 
-puts "Please enter the Install directory of the FLEX SDK"
-flex["flex-home"] = gets
-#Dir.chdir(File.join("..", ".."))
-# write out properties file
-File.open(File.join("config", "flex.yml"), "w") do |f|
-	f.puts YAML::dump(flex)
-end
+
+#prompt for flex home
+write_flex_config
 # create flex directories
-Dir.mkdir("flex")
-Dir.mkdir(File.join("flex", "src"))
-Dir.mkdir(File.join("flex", "lib"))
+
+

File flex_dev/lib/flex_dev.rb

 # FlexDev
+require "yaml"
+
+def write_flex_config
+  flex = {}
+  puts "Please enter the Install directory of the FLEX SDK"
+  flex["flex-home"] = gets
+  #Dir.chdir(File.join("..", ".."))
+  # write out properties file
+  File.open(File.join("config", "flex-config.yml"), "w") do |f|
+    f.puts YAML::dump(flex)
+  end
+end
+
+def read_flex_config
+  return YAML::load(File.open(File.join( "config", "flex-config.yml")))
+end

File flex_dev/tasks/flex_dev_tasks.rake

-require "yaml"
+require "flex_dev"
 namespace :flex do
   desc "Build flex app in rails"
   task :build do
 	# read the YAML file for Configuration
-	flex = YAML::load(File.open(File.join( "config", "flex.yml"))) 
+	flex = read_flex_config
 	# Build the command string
   sep = File::SEPERATOR
-	command = "#{flex["flex_home"]}#{sep}bin#{sep}mxmlc "
+  command = "mxmlc"
+  if !flex["flex_home"].nil?
+    command = "#{flex["flex_home"]}#{sep}bin#{sep}mxmlc "
+  end
   sh command
   end
 end