Class: CapsuleCD::Ruby::RubyHelper
- Inherits:
-
Object
- Object
- CapsuleCD::Ruby::RubyHelper
- Defined in:
- lib/capsulecd/ruby/ruby_helper.rb
Constant Summary collapse
- PRERELEASE =
["alpha","beta","rc",nil]
- VERSION_REGEX =
/(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join('|')}))?)/
- REPLACE_VERSION_REGEX =
def self.get_gemspec_path(repo_path) gemspecs = Dir.glob(repo_path + '/*.gemspec') if gemspecs.empty? fail CapsuleCD::Error::BuildPackageInvalid, '*.gemspec file is required to process Ruby gem' end gemspecs.first end
Class Method Summary collapse
-
.get_gem_name(repo_path) ⇒ Object
get gem name.
-
.get_version(repo_path) ⇒ Object
get gem version.
-
.set_version(repo_path, next_version) ⇒ Object
set gem version.
Class Method Details
.get_gem_name(repo_path) ⇒ Object
get gem name
21 22 23 |
# File 'lib/capsulecd/ruby/ruby_helper.rb', line 21 def self.get_gem_name(repo_path) self.load_gemspec_data(self.get_gemspec_path(repo_path)).name end |
.get_version(repo_path) ⇒ Object
get gem version
26 27 28 29 30 31 32 33 |
# File 'lib/capsulecd/ruby/ruby_helper.rb', line 26 def self.get_version(repo_path) gem_version_file = self.find_version_file(repo_path) gem_version = File.read(gem_version_file)[VERSION_REGEX] if !gem_version fail CapsuleCD::Error::BuildPackageInvalid, 'version.rb file is invalid' end return gem_version end |
.set_version(repo_path, next_version) ⇒ Object
set gem version
36 37 38 39 40 41 42 43 |
# File 'lib/capsulecd/ruby/ruby_helper.rb', line 36 def self.set_version(repo_path, next_version) gem_version_file = self.find_version_file(repo_path) gem_version_file_content = File.read(gem_version_file) next_gem_version_file_content = gem_version_file_content.gsub(/(VERSION\s*=\s*['"])[0-9\.]+(['"])/, "\\1#{next_version.to_s}\\2") File.open(gem_version_file, 'w') { |file| file.write(next_gem_version_file_content) } end |