From kato-k at rubyforge.org Fri Feb 20 02:00:03 2009 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Fri, 20 Feb 2009 02:00:03 -0500 (EST) Subject: [ap4r-devel] [933] trunk/samples/hello_world_for_rails2/vendor/plugins/ap4r/tasks/ap4r. rake: Added rake task for creating SAF migration file. Message-ID: <20090220070003.3AFC418580EB@rubyforge.org> Revision: 933 Author: kato-k Date: 2009-02-20 02:00:02 -0500 (Fri, 20 Feb 2009) Log Message: ----------- Added rake task for creating SAF migration file. Modified Paths: -------------- trunk/samples/hello_world_for_rails2/vendor/plugins/ap4r/tasks/ap4r.rake Modified: trunk/samples/hello_world_for_rails2/vendor/plugins/ap4r/tasks/ap4r.rake =================================================================== --- trunk/samples/hello_world_for_rails2/vendor/plugins/ap4r/tasks/ap4r.rake 2009-02-20 06:57:47 UTC (rev 932) +++ trunk/samples/hello_world_for_rails2/vendor/plugins/ap4r/tasks/ap4r.rake 2009-02-20 07:00:02 UTC (rev 933) @@ -38,3 +38,44 @@ end end + namespace :db do + namespace :ap4r do + desc "Create SAF migration file." + task :create_saf => :environment do |t| + + require 'rails_generator' + require 'rails_generator/scripts/generate' + + args = %w(migration create_stored_messages) + Rails::Generator::Scripts::Generate.new.run(args) + + migration_directory = "#{RAILS_ROOT}/db/migrate" + migration_name = "create_stored_messages" + migration_file_name = Dir.glob("#{migration_directory}/[0-9]*_*.rb").grep(/[0-9]+_#{migration_file_name}.rb$/).first + + File.open(migration_file_name, "w") do |f| + f.write < false + t.column :queue, :string, :null => false + t.column :headers, :binary, :null => false + t.column :object, :binary, :null => false + t.column :status, :integer, :null => false + t.column :created_at, :datetime, :null => false + t.column :updated_at, :datetime, :null => false + end + end + + def self.down + drop_table :stored_messages + end +end +EOS + end + end + end +end + + From kato-k at rubyforge.org Fri Feb 20 04:27:14 2009 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Fri, 20 Feb 2009 04:27:14 -0500 (EST) Subject: [ap4r-devel] [934] trunk/ap4r/lib/ap4r/script/workspace_generator.rb: Added Rakefile to working directory. Message-ID: <20090220092714.DBA1918580EB@rubyforge.org> Revision: 934 Author: kato-k Date: 2009-02-20 04:27:13 -0500 (Fri, 20 Feb 2009) Log Message: ----------- Added Rakefile to working directory. Modified Paths: -------------- trunk/ap4r/lib/ap4r/script/workspace_generator.rb Modified: trunk/ap4r/lib/ap4r/script/workspace_generator.rb =================================================================== --- trunk/ap4r/lib/ap4r/script/workspace_generator.rb 2009-02-20 07:00:02 UTC (rev 933) +++ trunk/ap4r/lib/ap4r/script/workspace_generator.rb 2009-02-20 09:27:13 UTC (rev 934) @@ -9,11 +9,11 @@ module Script class WorkspaceGenerator < Base AP4R_Directories = %w(config log public script tmp) - + def run argv, options OptionParser.new {|opt| opt.on('-m'){ - # merge to rails project but not implemented yet... + # merge to rails project but not implemented yet... } opt.parse!(argv) @@ -38,6 +38,8 @@ File.join(root_dir, recursive_copy_dir)) } + copy_file(File.join(ap4r_base, "Rakefile"), root_dir) + logger.info{"\n[#{root_dir}] has successfully set up!\n"} end @@ -58,6 +60,11 @@ } end + def copy_file(path, dest_dir) + FileUtils.cp(path, dest_dir) + logger.info{"copy file from #{File.expand_path(path)} to #{dest_dir} ..."} + end + end end end From kato-k at rubyforge.org Fri Feb 20 04:27:58 2009 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Fri, 20 Feb 2009 04:27:58 -0500 (EST) Subject: [ap4r-devel] [935] trunk/ap4r/lib/ap4r/version.rb: Incremented version number. Message-ID: <20090220092758.B2CF118580ED@rubyforge.org> Revision: 935 Author: kato-k Date: 2009-02-20 04:27:58 -0500 (Fri, 20 Feb 2009) Log Message: ----------- Incremented version number. Modified Paths: -------------- trunk/ap4r/lib/ap4r/version.rb Modified: trunk/ap4r/lib/ap4r/version.rb =================================================================== --- trunk/ap4r/lib/ap4r/version.rb 2009-02-20 09:27:13 UTC (rev 934) +++ trunk/ap4r/lib/ap4r/version.rb 2009-02-20 09:27:58 UTC (rev 935) @@ -8,7 +8,7 @@ module VERSION #:nodoc: MAJOR = 0 MINOR = 3 - TINY = 6 + TINY = 7 STRING = [MAJOR, MINOR, TINY].join('.') end From kato-k at rubyforge.org Fri Feb 20 06:17:13 2009 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Fri, 20 Feb 2009 06:17:13 -0500 (EST) Subject: [ap4r-devel] [936] trunk/ap4r: Modified Rakefile and Separated tasks for user. Message-ID: <20090220111713.A4DFB18580E4@rubyforge.org> Revision: 936 Author: kato-k Date: 2009-02-20 06:17:12 -0500 (Fri, 20 Feb 2009) Log Message: ----------- Modified Rakefile and Separated tasks for user. Modified Paths: -------------- trunk/ap4r/Manifest.txt trunk/ap4r/Rakefile trunk/ap4r/lib/ap4r/script/workspace_generator.rb Added Paths: ----------- trunk/ap4r/fresh_rakefile trunk/ap4r/lib/tasks/ trunk/ap4r/lib/tasks/ap4r.rb trunk/ap4r/lib/tasks/databases.rake Modified: trunk/ap4r/Manifest.txt =================================================================== --- trunk/ap4r/Manifest.txt 2009-02-20 09:27:58 UTC (rev 935) +++ trunk/ap4r/Manifest.txt 2009-02-20 11:17:12 UTC (rev 936) @@ -11,6 +11,7 @@ config/queues_disk.cfg config/queues_mysql.cfg config/queues_pgsql.cfg +fresh_rakefile lib/ap4r.rb lib/ap4r/carrier.rb lib/ap4r/db/migrate/001_reliable_msg_queue_and_topic.rb @@ -39,6 +40,8 @@ lib/ap4r/version.rb lib/ap4r/xxx_create_table_for_saf.rb lib/ap4r/xxx_create_table_for_saf_to_postgresql.rb +lib/tasks/ap4r.rb +lib/tasks/databases.rake rails_plugin/ap4r/init.rb rails_plugin/ap4r/lib/ap4r/queue_put_stub.rb rails_plugin/ap4r/lib/ap4r/service_handler.rb Modified: trunk/ap4r/Rakefile =================================================================== --- trunk/ap4r/Rakefile 2009-02-20 09:27:58 UTC (rev 935) +++ trunk/ap4r/Rakefile 2009-02-20 11:17:12 UTC (rev 936) @@ -151,26 +151,6 @@ ).to_s end -namespace :qdb do - desc "Make queue and topic tables through scripts in lib/ap4r/db/migrate." - task :migrate do - - # Todo: configurable file name, 2007/10/01 kiwamu - ap4r_config_file = "config/queues_ar.cfg" - ap4r_config = YAML::load(ERB.new(IO.read(ap4r_config_file)).result) - database_config = ap4r_config["store"] - if "activerecord" == database_config["type"].downcase - database_config["adapter"] = database_config["adapter"].downcase - else - # Todo - end - ActiveRecord::Base.logger = Logger.new(STDOUT) - ActiveRecord::Base.establish_connection(database_config) - - ActiveRecord::Migrator.migrate("lib/ap4r/db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) - end -end - todos_dirs = %w(lib rails_plugin spec) desc "List TODO comments in #{todos_dirs.join(", ")} directories" Added: trunk/ap4r/fresh_rakefile =================================================================== --- trunk/ap4r/fresh_rakefile (rev 0) +++ trunk/ap4r/fresh_rakefile 2009-02-20 11:17:12 UTC (rev 936) @@ -0,0 +1,10 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require 'rake' +require 'rake/testtask' +require 'rake/rdoctask' + +require 'ap4r' +require 'tasks/ap4r' + Modified: trunk/ap4r/lib/ap4r/script/workspace_generator.rb =================================================================== --- trunk/ap4r/lib/ap4r/script/workspace_generator.rb 2009-02-20 09:27:58 UTC (rev 935) +++ trunk/ap4r/lib/ap4r/script/workspace_generator.rb 2009-02-20 11:17:12 UTC (rev 936) @@ -38,7 +38,7 @@ File.join(root_dir, recursive_copy_dir)) } - copy_file(File.join(ap4r_base, "Rakefile"), root_dir) + copy_file(File.join(ap4r_base, "fresh_rakefile"), File.join(root_dir, "Rakefile")) logger.info{"\n[#{root_dir}] has successfully set up!\n"} @@ -60,9 +60,9 @@ } end - def copy_file(path, dest_dir) - FileUtils.cp(path, dest_dir) - logger.info{"copy file from #{File.expand_path(path)} to #{dest_dir} ..."} + def copy_file(src, dest) + FileUtils.cp(src, dest) + logger.info{"copy file from #{File.expand_path(src)} to #{dest} ..."} end end Added: trunk/ap4r/lib/tasks/ap4r.rb =================================================================== --- trunk/ap4r/lib/tasks/ap4r.rb (rev 0) +++ trunk/ap4r/lib/tasks/ap4r.rb 2009-02-20 11:17:12 UTC (rev 936) @@ -0,0 +1,7 @@ +$VERBOSE = nil + +# Load AP4R rakefile extensions +Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext } + +# Load any custom rakefile extensions +#Dir["#{AP4R_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext } Added: trunk/ap4r/lib/tasks/databases.rake =================================================================== --- trunk/ap4r/lib/tasks/databases.rake (rev 0) +++ trunk/ap4r/lib/tasks/databases.rake 2009-02-20 11:17:12 UTC (rev 936) @@ -0,0 +1,26 @@ +require 'rubygems' +require 'erb' +require 'find' +require 'active_record' +require File.join(File.dirname(__FILE__), '/../ap4r/version') + +namespace :qdb do + desc "Make queue and topic tables through scripts in lib/ap4r/db/migrate." + task :migrate do + + # Todo: configurable file name, 2007/10/01 kiwamu + ap4r_config_file = "config/queues_ar.cfg" + ap4r_config = YAML::load(ERB.new(IO.read(ap4r_config_file)).result) + database_config = ap4r_config["store"] + if "activerecord" == database_config["type"].downcase + database_config["adapter"] = database_config["adapter"].downcase + else + # Todo + end + ActiveRecord::Base.logger = Logger.new(STDOUT) + ActiveRecord::Base.establish_connection(database_config) + + ActiveRecord::Migrator.migrate("lib/ap4r/db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) + end +end +