diff options
author | Chris Schlaeger <chris@linux.com> | 2016-03-02 21:52:55 +0100 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2016-03-02 21:52:55 +0100 |
commit | 755006d0b0bdbfff1cac4cafc7d7fce0fd2fff9e (patch) | |
tree | b44e1a99e89ad44729083c6b20520e1fd392806c | |
parent | 2d19802c556349a770511a283b1af072f200a52e (diff) | |
download | postrunner-755006d0b0bdbfff1cac4cafc7d7fce0fd2fff9e.zip |
Adding a rake task to ensure that all packaged files are world-readable
-rw-r--r-- | postrunner.gemspec | 4 | ||||
-rw-r--r-- | tasks/gem.rake | 50 |
2 files changed, 52 insertions, 2 deletions
diff --git a/postrunner.gemspec b/postrunner.gemspec index 9b53496..faec05d 100644 --- a/postrunner.gemspec +++ b/postrunner.gemspec @@ -3,7 +3,7 @@ lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'postrunner/version' -Gem::Specification.new do |spec| +GEM_SPEC = Gem::Specification.new do |spec| spec.name = "postrunner" spec.version = PostRunner::VERSION spec.authors = ["Chris Schlaeger"] @@ -19,7 +19,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.required_ruby_version = '>=2.0' - spec.add_dependency 'fit4ruby', '~> 0.0.11' + spec.add_dependency 'fit4ruby', '~> 0.0.12' spec.add_dependency 'perobs', '~> 2.2' spec.add_dependency 'nokogiri', '~> 1.6' 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 + |