Skip to content

Commit

Permalink
Merge pull request #129 from ruby/xz-package-task
Browse files Browse the repository at this point in the history
Support xz compress format for packagetask
  • Loading branch information
hsbt committed May 4, 2016
2 parents de15c12 + f2e7c36 commit 2e14e7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/rake/packagetask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class PackageTask < TaskLib
# is false).
attr_accessor :need_tar_bz2

# True if a xz'd tar file (tar.xz) should be produced (default is false)
attr_accessor :need_tar_xz

# True if a zip file should be produced (default is false)
attr_accessor :need_zip

Expand Down Expand Up @@ -94,6 +97,7 @@ def init(name, version)
@need_tar = false
@need_tar_gz = false
@need_tar_bz2 = false
@need_tar_xz = false
@need_zip = false
@tar_command = 'tar'
@zip_command = 'zip'
Expand All @@ -120,7 +124,8 @@ def define
[
[need_tar, tgz_file, "z"],
[need_tar_gz, tar_gz_file, "z"],
[need_tar_bz2, tar_bz2_file, "j"]
[need_tar_bz2, tar_bz2_file, "j"],
[need_tar_xz, tar_xz_file, "J"]
].each do |(need, file, flag)|
if need
task :package => ["#{package_dir}/#{file}"]
Expand Down Expand Up @@ -189,6 +194,12 @@ def tar_bz2_file
"#{package_name}.tar.bz2"
end

# The package name with .tar.xz added

def tar_xz_file
"#{package_name}.tar.xz"
end

# The package name with .zip added

def zip_file
Expand Down
3 changes: 2 additions & 1 deletion test/test_rake_package_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test_initialize
p.need_tar = true
p.need_tar_gz = true
p.need_tar_bz2 = true
p.need_tar_xz = true
p.need_zip = true
}

Expand All @@ -32,6 +33,7 @@ def test_initialize
assert Rake::Task['pkg/pkgr-1.2.3.tgz']
assert Rake::Task['pkg/pkgr-1.2.3.tar.gz']
assert Rake::Task['pkg/pkgr-1.2.3.tar.bz2']
assert Rake::Task['pkg/pkgr-1.2.3.tar.xz']
assert Rake::Task['pkg/pkgr-1.2.3.zip']
assert Rake::Task['pkg/pkgr-1.2.3']
assert Rake::Task[:clobber_package]
Expand Down Expand Up @@ -76,4 +78,3 @@ def test_package_name_noversion
end

end

0 comments on commit 2e14e7f

Please sign in to comment.