Class: Bump::Bump

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

Defined Under Namespace

Classes: InvalidOptionError, TooManyGemspecsFoundError, UnfoundGemspecError, UnfoundVersionError

Constant Summary collapse

BUMPS =
%w(major minor tiny)
OPTIONS =
BUMPS | ["current"]
VERSION_REGEX =
/version\s*=\s*["|'](\d.\d.\d)["|']/

Instance Method Summary collapse

Constructor Details

#initialize(bump) ⇒ Bump

Returns a new instance of Bump.



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

def initialize(bump)
  @bump = bump.is_a?(Array) ? bump.first : bump
end

Instance Method Details

#runObject



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

def run
  begin
    raise InvalidOptionError unless OPTIONS.include?(@bump)

    gemspec = find_gemspec_file
    current_version = find_current_version(gemspec)
    
    case @bump
      when "major", "minor", "tiny"
        bump(current_version, gemspec)
      when "current"
        current(current_version)
      else
        raise Exception
    end
    
    rescue InvalidOptionError
      puts "Invalid option. Choose between #{OPTIONS.join(',')}."
    rescue UnfoundVersionError
      puts "Unable to find your gem version"
    rescue UnfoundGemspecError
      puts "Unable to find gemspec file"
    rescue TooManyGemspecsFoundError
      puts "More than one gemspec file"
    rescue Exception => e
      puts "Something wrong happened: #{e.message}"
  end   
end