tasks/package.rake in kpm-0.6.0 vs tasks/package.rake in kpm-0.6.1

- old
+ new

@@ -1,7 +1,8 @@ # For Bundler.with_clean_env require 'bundler/setup' +require 'yaml' PACKAGE_NAME = 'kpm' require './lib/kpm/version' VERSION = KPM::VERSION @@ -34,19 +35,23 @@ task :osx => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz"] do create_package('osx') end desc 'Install gems to local directory' - task :bundle_install do + task :bundle_install => [:clean] do + # abort if version packaging does not exist on repository + abort "KPM #{VERSION} does not exists in the repository." unless gem_exists? + # Note! Must match TRAVELING_RUBY_VERSION above expected_ruby_version = TRAVELING_RUBY_VERSION.split('-')[-1] if RUBY_VERSION !~ /#{Regexp.quote(expected_ruby_version)}/ abort "You can only 'bundle install' using Ruby #{expected_ruby_version}, because that's what Traveling Ruby uses." end sh 'rm -rf packaging/tmp' sh 'mkdir -p packaging/tmp' sh 'cp packaging/Gemfile packaging/tmp/' + sh "sed -i 's/VERSION/#{VERSION}/g' packaging/tmp/Gemfile" sh "rm -rf packaging/vendor/ruby/#{expected_ruby_version}/bundler" # if multiple clones of same repo, may load in wrong one Bundler.with_clean_env do sh 'cd packaging/tmp && env BUNDLE_IGNORE_CONFIG=1 bundle install --path ../vendor --without development' @@ -110,5 +115,13 @@ def download_runtime(target) sh 'mkdir -p packaging && cd packaging && curl -L -O --fail ' + "https://d6r77u77i8pq3.cloudfront.net/releases/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz" end + +def gem_exists? + response = `gem specification 'kpm' -r -v #{VERSION} 2>&1` + return false if response.nil? + + specification = YAML::load(response) + specification.instance_of?(Gem::Specification) +end \ No newline at end of file