Class: DTR::PackageTask
- Includes:
- SyncCodebase::Package
- Defined in:
- lib/dtr/raketasks.rb
Overview
Create a packaging task that will package the project into distributable files for running test on remote machine. It uses zip and unzip to package and unpackage files. All test files should be included.
The PackageTask will create the following targets:
- :dtr_package
-
Create all the requested package files.
- :dtr_clobber_package
-
Delete all the package files. This target is automatically added to the main clobber target.
- :dtr_repackage
-
Rebuild the package files from scratch, even if they are not out of date.
Example:
DTR::PackageTask.new do |p|
p.package_files.include("lib/**/*.rb")
p.package_files.include("test/**/*.rb")
end
Instance Attribute Summary collapse
-
#package_files ⇒ Object
List of files to be included in the package.
Instance Method Summary collapse
-
#define ⇒ Object
Create the tasks defined by this task library.
-
#initialize {|_self| ... } ⇒ PackageTask
constructor
Create a Package Task with the given name and version.
Methods included from SyncCodebase::Package
#do_work, #package_cmd, #package_copy_file, #package_dir, #package_dir_path, #package_file, #package_name, #unpackage_cmd
Constructor Details
#initialize {|_self| ... } ⇒ PackageTask
Create a Package Task with the given name and version.
149 150 151 152 153 |
# File 'lib/dtr/raketasks.rb', line 149 def initialize @package_files = Rake::FileList.new yield self if block_given? define end |
Instance Attribute Details
#package_files ⇒ Object
List of files to be included in the package.
146 147 148 |
# File 'lib/dtr/raketasks.rb', line 146 def package_files @package_files end |
Instance Method Details
#define ⇒ Object
Create the tasks defined by this task library.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/dtr/raketasks.rb', line 156 def define desc "Build packages for dtr task" task :dtr_package desc "Force a rebuild of the package files for dtr task" task :dtr_repackage => [:dtr_clobber_package, :dtr_package] desc "Remove package for dtr task" task :dtr_clobber_package do rm_r package_dir rescue nil end file, flag = package_file, 'j' task :dtr_package => ["#{package_dir}/#{file}"] file "#{package_dir}/#{file}" => [package_dir_path] do chdir(package_dir) do do_work(package_cmd) end end directory package_dir file package_dir_path do mkdir_p package_dir rescue nil @package_files.exclude(package_dir) @package_files.each do |fn| f = File.join(package_dir_path, fn) fdir = File.dirname(f) mkdir_p(fdir) if !File.exist?(fdir) if File.directory?(fn) mkdir_p(f) else rm_f f safe_ln(fn, f) end end end self end |