require "open-uri" class DangoGenerator < Rails::Generator::NamedBase # ~ 引数・オプションの解釈と初期化 ~ # def initialize(runtime_args, runtime_options = {}) #p runtime_args # super # end # 初期化の共通で使う部分 def common_init(m) # 起動スクリプト m.file "script/dango_server" , "script/dango_server", :collision => :force # crossdomain.xml m.file "public/crossdomain.xml" , "public/crossdomain.xml", :collision => :force # vendorプラグイン m.directory 'vendor/plugins/dango/lib' m.file "lib/dango_monitor_client.rb" , "vendor/plugins/dango/lib/dango_monitor_client.rb", :collision => :force m.file "lib/dango_controller_plugin.rb" , "vendor/plugins/dango/lib/dango_controller_plugin.rb", :collision => :force m.directory 'vendor/plugins/dango/tasks' m.file "tasks/dango.rake" , "vendor/plugins/dango/tasks/dango.rake", :collision => :force # dangoフォルダ内 m.directory 'dango/server' m.file "dango/server/99_dango_server.rb" , "dango/server/99_dango_server.rb", :collision => :skip # dangoのclient_swf m.directory 'dango/client_swf' m.directory 'dango/client_swf/src' m.file "dango/client_swf/src/DangoConfig.as" , "dango/client_swf/src/DangoConfig.as", :collision => :skip # dangoコンフィグ m.directory 'config/dango' %w( development.yml test.yml production.yml system_message.yml ).each do |as3_file| m.file "config/dango/#{as3_file}", "config/dango/#{as3_file}", :collision => :skip end # dangoのas3ライブラリ m.directory 'dango/client_swf/src/org/rubyforge/dango' %w( DangoAS3Mode.as DangoAS3ModeReceiveEvent.as DangoClientFramework.as DangoError.as DangoErrorCode.as DangoErrorEvent.as DangoReceiveEvent.as DangoURLLoader.as DangoURLLoaderEvent.as DangoUtil.as ).each do |as3_file| m.file "as3/org/rubyforge/dango/#{as3_file}", "dango/client_swf/src/org/rubyforge/dango/#{as3_file}", :collision => :force end # http://code.google.com/p/as3corelib/のインポート # as3corelib-readme.txt # as3corelib-license.txt %w( com/adobe/crypto/MD5.as com/adobe/crypto/SHA1.as com/adobe/crypto/SHA224.as com/adobe/crypto/SHA256.as com/adobe/crypto/WSSEUsernameToken.as com/adobe/errors/IllegalStateError.as com/adobe/images/BitString.as com/adobe/images/JPGEncoder.as com/adobe/images/PNGEncoder.as com/adobe/net/DynamicURLLoader.as com/adobe/net/IURIResolver.as com/adobe/net/URI.as com/adobe/net/URIEncodingBitmap.as com/adobe/net/proxies/RFC2817Socket.as com/adobe/serialization/json/JSON.as com/adobe/serialization/json/JSONDecoder.as com/adobe/serialization/json/JSONEncoder.as com/adobe/serialization/json/JSONParseError.as com/adobe/serialization/json/JSONToken.as com/adobe/serialization/json/JSONTokenizer.as com/adobe/serialization/json/JSONTokenType.as com/adobe/utils/ArrayUtil.as com/adobe/utils/DateUtil.as com/adobe/utils/DictionaryUtil.as com/adobe/utils/IntUtil.as com/adobe/utils/NumberFormatter.as com/adobe/utils/StringUtil.as com/adobe/utils/XMLUtil.as com/adobe/webapis/ServiceBase.as com/adobe/webapis/URLLoaderBase.as com/adobe/webapis/events/ServiceEvent.as ).each do |as3corelib_file| m.directory File.dirname("dango/client_swf/src/#{as3corelib_file}") m.file "as3/#{as3corelib_file}", "dango/client_swf/src/#{as3corelib_file}", :collision => :force end end def manifest record do |m| # p methods # p instance_variables # p name # p class_name # dangoの初期設定 common_init(m) if name == "init_as3mode" # init_as3mode m.file "sample_as3mode/dango/server/99_dango_server.rb" , "dango/server/99_dango_server.rb", :collision => :force m.directory "dango/client_swf/bin-debug" %w( sample_as3mode.swf sample_as3mode.html AC_OETags.js playerProductInstall.swf ).each do |file| m.file "sample_as3mode/dango/client_swf/bin-debug/#{file}", "dango/client_swf/bin-debug/#{file}", :collision => :force end m.file "sample_as3mode/dango/client_swf/src/sample_asmode.mxml" , "dango/client_swf/src/sample_as3mode.mxml", :collision => :force elsif name == "sample_servermode_chat" m.directory "dango/client_swf/bin-debug" %w( sample_servermode_chat.swf sample_servermode_chat.html AC_OETags.js playerProductInstall.swf ).each do |file| m.file "sample_servermode_chat/dango/client_swf/bin-debug/#{file}", "dango/client_swf/bin-debug/#{file}", :collision => :force end m.file "sample_servermode_chat/dango/client_swf/src/sample_servermode_chat.mxml" , "dango/client_swf/src/sample_servermode_chat.mxml", :collision => :force m.file "sample_servermode_chat/dango/server/99_dango_server.rb" , "dango/server/99_dango_server.rb", :collision => :force end end # puts "completed to dango_generator" end # end manifest attr_accessor :controller_class_name end