Class: Bump::Bump

Inherits:
Object
  • Object
show all
Defined in:
lib/bump.rb

Constant Summary collapse

BUMPS =
%w(major minor patch pre)
PRERELEASE =
["alpha","beta","rc",nil]
OPTIONS =
BUMPS | ["current"]
VERSION_REGEX =
/(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join('|')}))?)/

Class Method Summary collapse

Class Method Details

.currentObject



43
44
45
# File 'lib/bump.rb', line 43

def self.current
  current_info.first
end

.defaultsObject



13
14
15
16
17
18
# File 'lib/bump.rb', line 13

def self.defaults
  {
    :commit => true,
    :bundle => File.exist?("Gemfile")
  }
end

.run(bump, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bump.rb', line 20

def self.run(bump, options={})
  options = defaults.merge(options)

  case bump
  when *BUMPS
    bump(bump, options)
  when "current"
    ["Current version: #{current}", 0]
  else
    raise InvalidOptionError
  end
rescue InvalidOptionError
  ["Invalid option. Choose between #{OPTIONS.join(',')}.", 1]
rescue UnfoundVersionError
  ["Unable to find your gem version", 1]
rescue UnfoundVersionFileError
  ["Unable to find a file with the gem version", 1]
rescue TooManyVersionFilesError
  ["More than one gemspec file", 1]
rescue Exception => e
  ["Something wrong happened: #{e.message}\n#{e.backtrace.join("\n")}", 1]
end