# # Copyright (C) 2007 Mobio Networks, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # require 'rake' require 'rake/clean' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails' require 'rake/gempackagetask' require 'rake/rdoctask' require 'fileutils' require 'rcov/rcovtask' CLEAN.include('pkg/*') CLEAN.include('coverage/*') # BEGIN CRUISE SECTION def get_version if not defined? PKG_VERSION @version = `svnversion #{RAILS_ROOT}` if @version.nil? || @version == 'exported' @version = '1.0.0' else @version =~ /([0-9]+)/ @version = $1 if @version.nil? @version = '1.0.0' else @version = '1.0.' + @version end end else @version = PKG_VERSION end @version end task :reconnect do require 'active_record' configurations = ActiveRecord::Base.configurations if configurations and configurations.has_key?("test") and configurations["test"]["adapter"] == 'mysql' ActiveRecord::Base.establish_connection(:test) end end task :install_gem do target = ENV['GEM_INSTALL_DIR'] unless target.nil? cp("pkg/" + PKG_NAME + "-" + get_version + ".gem", target) end end task :package_gem do ENV['RAILS_ENV'] = 'test' spec = Gem::Specification.new do |s| if not defined? DEP_ADD DEP_ADD = true end s.name = PKG_NAME s.version = get_version s.authors = PKG_AUTHORS s.email = PKG_EMAILS s.homepage = PKG_HOMEPAGE s.platform = Gem::Platform::RUBY s.summary = PKG_SUMMARY s.description = PKG_DESCRIPTION if not defined? PKG_INCLUDE s.files = FileList.new('**/*').to_a else s.files = FileList[PKG_INCLUDE].to_a end s.has_rdoc = false s.add_dependency("rmobio", ">= 1.1.0") unless DEP_ADD == false s.add_dependency("hpricot", ">= 0.6") s.add_dependency('builder', '>= 2.1.1') end Rake::GemPackageTask.new(spec) do |p| end end task :rcov do Rcov::RcovTask.new do |t| t.rcov_opts << '-T --rails' t.libs << 'test' t.test_files = FileList['test/*/*_test.rb', 'test/*/*/*_test.rb'] t.verbose = true end end task :cruise =>[:clean, 'db:test:purge', 'reconnect', 'db:migrate', :rcov, :package_gem, :package, :install_gem] do end # END CRUISE SECTION # BEGIN CONFIG SECTION namespace :rmobio do desc "Set up the rmobio.yml configuration file. This is put into config/rmobio.yml. Using similar logic to the rfacebook plugin." task :setup do filename = "#{RAILS_ROOT}/config/rmobio.yml" puts "Setting up rmobio configuration file: config/rmobio.yml" file = File.new(filename, "w") file << " development: app_server_external: http://someexternalhost:someport app_server_internal: http://somehost:someport #example of a filtered property service_base_url: @app_server_external@/service test: app_server_external: http://someexternalhost:someport app_server_internal: http://somehost:someport #example of a filtered property service_base_url: @app_server_external@/service production: app_server_external: http://someexternalhost:someport app_server_internal: http://somehost:someport #example of a filtered property service_base_url: @app_server_external@/service " file.close_write puts " [1] Created config/rmobio.yml <-- Please add the appropriate configuration options for your application!" puts "Done." end end # END CONFIG SECTION