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 | ["set", "current"]
VERSION_REGEX =
/(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join('|')}))?)/

Class Method Summary collapse

Class Method Details

.currentObject



50
51
52
# File 'lib/bump.rb', line 50

def self.current
  current_info.first
end

.defaultsObject



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

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

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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bump.rb', line 22

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

  case bump
  when *BUMPS
    bump_part(bump, options)
  when "set"
    raise InvalidVersionError unless options[:version]
    bump_set(options[:version], options)
  when "current"
    ["Current version: #{current}", 0]
  else
    raise InvalidOptionError
  end
rescue InvalidOptionError
  ["Invalid option. Choose between #{OPTIONS.join(',')}.", 1]
rescue InvalidVersionError
  ["Invalid version number given.", 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