Class: Gem::Commands::BumpCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems/commands/bump_command.rb

Constant Summary collapse

BUMP_METHODS =
["major", "minor", "patch", "subpatch"]

Instance Method Summary collapse

Constructor Details

#initializeBumpCommand

Returns a new instance of BumpCommand.



4
5
6
# File 'lib/rubygems/commands/bump_command.rb', line 4

def initialize
  super("bump", "Increases the version of a .gemspec file")
end

Instance Method Details

#argumentsObject



12
13
14
15
16
17
# File 'lib/rubygems/commands/bump_command.rb', line 12

def arguments
  <<-ARGUMENTS
  METHOD        version to update (#{BUMP_METHODS.join(", ")})
  FILE          name of the gemspec file (you can omit the .gemspec extension)
  ARGUMENTS
end

#defaults_strObject



19
20
21
# File 'lib/rubygems/commands/bump_command.rb', line 19

def defaults_str
  "METHOD        patch"
end

#executeObject



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
49
50
# File 'lib/rubygems/commands/bump_command.rb', line 23

def execute
  bump_method = options[:args][0] || ""
  gemspec = options[:args][1]

  if BUMP_METHODS.include?(bump_method)
    unless gemspec_exists?(gemspec)
      puts "No gemspec name specified"
      show_help
      return
    end
  else
    unless gemspec_exists?(bump_method)
      if gemspec_exists?(gemspec)
        puts "Invalid bump method specified."
      else
        puts "Invalid gemspec name specified."
      end
      show_help
      return
    end
    gemspec = bump_method
    bump_method = "patch"
  end
  gemspec = gemspec_file(gemspec)
  scrape_gemspec(gemspec)
  bump_gemspec_version(bump_method)
  write_gemspec_file(gemspec)
end

#usageObject



8
9
10
# File 'lib/rubygems/commands/bump_command.rb', line 8

def usage
  "#{program_name} [METHOD] FILE"
end