module Gersion
Constants
- VERSION
Public Class Methods
current_version()
click to toggle source
# File lib/gersion.rb, line 7 def self.current_version the_current_tag || the_current_sha end
version_of(gem)
click to toggle source
# File lib/gersion.rb, line 11 def self.version_of gem find_the_gem_in_the_git_repos_section(gem) || find_the_gem_in_the_rubygems_section(gem) end
Private Class Methods
find_gem_version_in_content(gem, content)
click to toggle source
# File lib/gersion.rb, line 28 def find_gem_version_in_content gem, content regex = Regexp.new(" #{gem} \\(([01234567890\.]*)\\)") find_the_match_between content, regex rescue nil end
find_the_gem_in_the_git_repos_section(gem)
click to toggle source
# File lib/gersion.rb, line 18 def find_the_gem_in_the_git_repos_section gem if git_match = gemlock_content.split('GEM')[0].split('GIT').select { |c| find_gem_version_in_content(gem, c) }.first find_the_match_between(git_match, /tag: (.*)/) || find_the_match_between(git_match, /revision: (.*)/) end end
find_the_gem_in_the_rubygems_section(gem)
click to toggle source
# File lib/gersion.rb, line 24 def find_the_gem_in_the_rubygems_section gem find_gem_version_in_content gem, gemlock_content end
find_the_match_between(content, regex)
click to toggle source
# File lib/gersion.rb, line 39 def find_the_match_between content, regex content.scan(regex)[0][0] rescue nil end
gemlock_content()
click to toggle source
# File lib/gersion.rb, line 35 def gemlock_content @gemlock_content ||= Gersion::File.read('Gemfile.lock') end
the_current_sha()
click to toggle source
# File lib/gersion.rb, line 49 def the_current_sha Gersion::Bash.run('git rev-list -1 HEAD').split("\n")[0] end
the_current_tag()
click to toggle source
# File lib/gersion.rb, line 45 def the_current_tag Gersion::Bash.run('git tag --points-at HEAD').split("\n")[0] end