summaryrefslogtreecommitdiff
path: root/tasks
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2016-03-02 21:52:55 +0100
committerChris Schlaeger <chris@linux.com>2016-03-02 21:52:55 +0100
commit755006d0b0bdbfff1cac4cafc7d7fce0fd2fff9e (patch)
treeb44e1a99e89ad44729083c6b20520e1fd392806c /tasks
parent2d19802c556349a770511a283b1af072f200a52e (diff)
downloadpostrunner-755006d0b0bdbfff1cac4cafc7d7fce0fd2fff9e.zip
Adding a rake task to ensure that all packaged files are world-readable
Diffstat (limited to 'tasks')
-rw-r--r--tasks/gem.rake50
1 files changed, 50 insertions, 0 deletions
diff --git a/tasks/gem.rake b/tasks/gem.rake
new file mode 100644
index 0000000..57a914d
--- /dev/null
+++ b/tasks/gem.rake
@@ -0,0 +1,50 @@
+# GEM TASK
+require 'find'
+require 'rubygems'
+require 'rubygems/package'
+
+# Unfortunately Rake::GemPackageTest cannot deal with files that are generated
+# by Rake targets. So we have to write our own packaging task.
+desc 'Build the gem package'
+task :gem => [:clobber] do
+ Rake::Task[:changelog].invoke
+ Rake::Task[:permissions].invoke
+
+ # Build the gem file according to the loaded spec.
+ if RUBY_VERSION >= "2.0.0"
+ Gem::Package.build(GEM_SPEC)
+ else
+ Gem::Builder.new(GEM_SPEC).build
+ end
+ pkgBase = "#{GEM_SPEC.name}-#{GEM_SPEC.version}"
+ # Create a pkg directory if it doesn't exist already.
+ FileUtils.mkdir_p('pkg')
+ # Move the gem file into the pkg directory.
+ verbose(true) { FileUtils.mv("#{pkgBase}.gem", "pkg/#{pkgBase}.gem")}
+end
+
+desc 'Make sure all files and directories are readable'
+task :permissions do
+ # Find the bin and test directories relative to this file.
+ baseDir = File.expand_path('..', File.dirname(__FILE__))
+
+ execs = Dir.glob("#{baseDir}/bin/*") +
+ Dir.glob("#{baseDir}/test/**/genrefs")
+
+ Find.find(baseDir) do |f|
+ # Ignore the whoke pkg directory as it may contain links to the other
+ # directories.
+ next if Regexp.new("#{baseDir}/pkg/*").match(f)
+
+ FileUtils.chmod_R((FileTest.directory?(f) ||
+ execs.include?(f) ? 0755 : 0644), f)
+ end
+end
+
+desc 'Run all tests and build scripts and create the gem package'
+task :release do
+ Rake::Task[:test].invoke
+ Rake::Task[:yard].invoke
+ Rake::Task[:gem].invoke
+end
+