semver_bump 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'semver_bump'
7
+
8
+
9
+
10
+ bump = SemverBump::Bump.new
11
+ command = ARGV[0]
12
+
13
+
14
+ if !command || command == 'current'
15
+ puts "#{bump.current}"
16
+ elsif !bump.respond_to?(command)
17
+ puts "Don't know how to bump '#{command}'!"
18
+ else
19
+ current = bump.current
20
+ updated = bump.send(command)
21
+ puts "Bumped from #{current} to #{updated}"
22
+ end
23
+
24
+
@@ -19,6 +19,10 @@ module SemverBump
19
19
  @version_file ||= VersionFile.new(version_file_path)
20
20
  end
21
21
 
22
+ def current
23
+ version_file.semver.to_s
24
+ end
25
+
22
26
  SemVer::PARTS.each do |name|
23
27
  define_method(:"#{name.to_s}") do
24
28
  version_file.send(:"bump_#{name.to_s}")
@@ -1,7 +1,7 @@
1
1
  module SemverBump
2
2
  class SemVer
3
3
 
4
- MATCHER = /^(\d+)\.(\d+)\.(\d+).([0-9A-Za-z]*)$/
4
+ MATCHER = /^(\d+)\.(\d+)\.(\d+)\.?([0-9A-Za-z]*)$/
5
5
  PARTS = [:major, :minor, :patch, :pre]
6
6
  attr_accessor *(PARTS << :pre_raw)
7
7
 
@@ -40,7 +40,7 @@ module SemverBump
40
40
  @pre_s
41
41
  end
42
42
 
43
- (PARTS - [:pre]).each do |name|
43
+ (PARTS - [:pre,:minor]).each do |name|
44
44
  define_method(:"bump_#{name.to_s}") do
45
45
  send(:"#{name.to_s}=",(send(:"#{name.to_s}")+1))
46
46
  PARTS[PARTS.index(name)+1..4].each do |name|
@@ -50,6 +50,14 @@ module SemverBump
50
50
  end
51
51
  end
52
52
 
53
+ def bump_patch
54
+ if pre && pre > 0
55
+ send(:pre=,0)
56
+ else
57
+ send(:patch=,(send(:patch)+1))
58
+ end
59
+ end
60
+
53
61
  def bump_pre
54
62
  if !pre || pre == 0
55
63
  bump_patch
@@ -1,3 +1,3 @@
1
1
  module SemverBump
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -3,7 +3,7 @@ module SemverBump
3
3
 
4
4
  attr_accessor :semver
5
5
 
6
- LINE_MATCH = /^\s*VERSION\s*=\s*"?'?([.\d]*.?[a-zA-Z]{0,4}[0-9]{0,3})"?'?\s*$/
6
+ LINE_MATCH = /^\s*VERSION\s*=\s*"?'?([.\d]*\.?[a-zA-Z]{0,4}[0-9]{0,3})"?'?\s*$/
7
7
 
8
8
  def initialize(filepath)
9
9
  @filepath = filepath
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semver_bump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -46,7 +46,8 @@ dependencies:
46
46
  description: Little utility for bumping version numbers
47
47
  email:
48
48
  - daniel.luxemburg@gmail.com
49
- executables: []
49
+ executables:
50
+ - semver-bump
50
51
  extensions: []
51
52
  extra_rdoc_files: []
52
53
  files:
@@ -55,6 +56,7 @@ files:
55
56
  - LICENSE.txt
56
57
  - README.md
57
58
  - Rakefile
59
+ - bin/semver-bump
58
60
  - lib/semver_bump.rb
59
61
  - lib/semver_bump/find.rb
60
62
  - lib/semver_bump/semver.rb
@@ -77,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
79
  version: '0'
78
80
  segments:
79
81
  - 0
80
- hash: 1605327279335832543
82
+ hash: 1797775827887834252
81
83
  required_rubygems_version: !ruby/object:Gem::Requirement
82
84
  none: false
83
85
  requirements:
@@ -86,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
88
  version: '0'
87
89
  segments:
88
90
  - 0
89
- hash: 1605327279335832543
91
+ hash: 1797775827887834252
90
92
  requirements: []
91
93
  rubyforge_project:
92
94
  rubygems_version: 1.8.24