lib/capsulecd/ruby/ruby_engine.rb in capsulecd-1.0.9 vs lib/capsulecd/ruby/ruby_engine.rb in capsulecd-1.0.10

- old
+ new

@@ -8,18 +8,12 @@ module Ruby class RubyEngine < Engine def build_step super gemspec_path = CapsuleCD::Ruby::RubyHelper.get_gemspec_path(@source_git_local_path) + gem_name = CapsuleCD::Ruby::RubyHelper.get_gem_name(@source_git_local_path) - # check for required VERSION file - gemspec_data = CapsuleCD::Ruby::RubyHelper.get_gemspec_data(@source_git_local_path) - - if !File.exist?(CapsuleCD::Ruby::RubyHelper.version_filepath(@source_git_local_path, gemspec_data.name)) - fail CapsuleCD::Error::BuildPackageInvalid, 'version.rb file is required to process Ruby gem' - end - # bump up the version here. # since there's no standardized way to bump up the version in the *.gemspec file, we're going to assume that the version # is specified in a version file in the lib/<gem_name>/ directory, similar to how the bundler gem does it. # ie. bundle gem <gem_name> will create a file: my_gem/lib/my_gem/version.rb with the following contents # module MyGem @@ -29,16 +23,14 @@ # Jeweler and Hoe both do something similar. # http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/ # http://timelessrepo.com/making-ruby-gems # http://guides.rubygems.org/make-your-own-gem/ - version_str = CapsuleCD::Ruby::RubyHelper.read_version_file(@source_git_local_path, gemspec_data.name) - next_version = bump_version(SemVer.parse(gemspec_data.version.to_s)) + gem_version = CapsuleCD::Ruby::RubyHelper.get_version(@source_git_local_path) + next_version = bump_version(SemVer.parse(gem_version)) + CapsuleCD::Ruby::RubyHelper.set_version(@source_git_local_path, next_version.to_s) - new_version_str = version_str.gsub(/(VERSION\s*=\s*['"])[0-9\.]+(['"])/, "\\1#{next_version.to_s}\\2") - CapsuleCD::Ruby::RubyHelper.write_version_file(@source_git_local_path, gemspec_data.name, new_version_str) - # check for/create any required missing folders/files unless File.exist?(@source_git_local_path + '/Gemfile') File.open(@source_git_local_path + '/Gemfile', 'w') { |file| file.puts("source 'https://rubygems.org'") file.puts('gemspec') @@ -67,12 +59,12 @@ # wait for process external.join unless external.value.success? fail CapsuleCD::Error::BuildPackageFailed, 'gem build failed. Check gemspec file and dependencies' end - unless File.exist?(@source_git_local_path + "/#{gemspec_data.name}-#{next_version.to_s}.gem") - fail CapsuleCD::Error::BuildPackageFailed, "gem build failed. #{gemspec_data.name}-#{next_version.to_s}.gem not found" + unless File.exist?(@source_git_local_path + "/#{gem_name}-#{next_version.to_s}.gem") + fail CapsuleCD::Error::BuildPackageFailed, "gem build failed. #{gem_name}-#{next_version.to_s}.gem not found" end end end end @@ -141,11 +133,11 @@ def package_step super # commit changes to the cookbook. (test run occurs before this, and it should clean up any instrumentation files, created, # as they will be included in the commmit and any release artifacts) - gemspec_data = CapsuleCD::Ruby::RubyHelper.get_gemspec_data(@source_git_local_path) - next_version = SemVer.parse(gemspec_data.version.to_s) + gem_version = CapsuleCD::Ruby::RubyHelper.get_version(@source_git_local_path) + next_version = SemVer.parse(gem_version) CapsuleCD::GitUtils.commit(@source_git_local_path, "(v#{next_version}) Automated packaging of release by CapsuleCD") @source_release_commit = CapsuleCD::GitUtils.tag(@source_git_local_path, "v#{next_version}") end # this step should push the release to the package repository (ie. npm, chef supermarket, rubygems)