Class: Bump::Bump
- Inherits:
-
Object
- Object
- Bump::Bump
- Defined in:
- lib/bump.rb
Constant Summary collapse
- BUMPS =
%w(major minor patch pre)
- PRERELEASE =
["alpha","beta","rc",nil]
- OPTIONS =
BUMPS | ["set", "current", "file"]
- VERSION_REGEX =
/(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join('|')}))?)/
Class Method Summary collapse
- .current ⇒ Object
- .defaults ⇒ Object
- .file ⇒ Object
- .parse_cli_options!(options) ⇒ Object
- .run(bump, options = {}) ⇒ Object
Class Method Details
.current ⇒ Object
57 58 59 |
# File 'lib/bump.rb', line 57 def current current_info.first end |
.defaults ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/bump.rb', line 21 def defaults { :tag => ::Bump.tag_by_default, :commit => true, :bundle => File.exist?("Gemfile") } end |
.file ⇒ Object
61 62 63 |
# File 'lib/bump.rb', line 61 def file current_info.last end |
.parse_cli_options!(options) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/bump.rb', line 65 def () .each do |key, value| [key] = (value) end .delete_if{|key, value| value.nil?} end |
.run(bump, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bump.rb', line 29 def run(bump, ={}) = defaults.merge() case bump when *BUMPS bump_part(bump, ) when "set" raise InvalidVersionError unless [:version] bump_set([:version], ) when "current" ["Current version: #{current}", 0] when "file" ["Version file path: #{file}", 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 version file found (#{$!.})", 1] end |