rake_roll 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09ef35c3d40587b26e5bdfbff1e5fa8e137c83cf
4
- data.tar.gz: 31482e4674fd576b4b0a8921ec0dc17c5bd1a975
3
+ metadata.gz: 293c0ecc0fbd7214eecc2109ae2154935265fe37
4
+ data.tar.gz: 4710b2e781c343490c15e0ac8da4032799b4ad83
5
5
  SHA512:
6
- metadata.gz: 48a993b6193748b25a0b0a5d21efe18f48a84d528d0d6e576362a3c40c4aec7d539afa45990bb999b2cf44432ea0aa85c99a1601e152ba6bc7f60517cffed00a
7
- data.tar.gz: 96cbc682bbd4bc26c883bcafac62e66767f44bf5d29154831c4a43aaa7de33dfd24576d10721e4c1a4dac412a3444918b830e9c1f296b5205af209e6315d899c
6
+ metadata.gz: bda6a79d4729c89a7ed438001a196916bebb627ad4a3534d98712ca938893ab9578e7833ef3d9eee7bf5e6c17dad027dfa63e3cb99790e05de8ff1f2549bbef3
7
+ data.tar.gz: c509a36586eff0c460f42d7fc32de80bb8d5a965b92581943928631f4546f7c33934bcec1692259e6e2cfcf0aa18a52152b7f8ca2fce69227034465c79a92021
data/Gemfile CHANGED
@@ -4,3 +4,4 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem "pry"
7
+ gem "rspec"
data/README.md CHANGED
@@ -20,11 +20,11 @@ Or install it yourself as:
20
20
 
21
21
  rake roll
22
22
 
23
- rake roll # shows version and all options
24
- rake roll:pre # Bump to 0.1.0a
25
- rake roll:bump # Bump to 0.1.1
26
- rake roll:major # Bump to 1.0.0
27
- rake roll:minor # Bump to 0.2.0
23
+ rake roll # shows version and all options
24
+ rake roll:pre # Bump to 0.1.0a
25
+ rake roll:bump # Bump to 0.1.1
26
+ rake roll:major # Bump to 1.0.0
27
+ rake roll:minor # Bump to 0.2.0
28
28
 
29
29
  The above will do a dry run, and show the changelog updates in the
30
30
  terminal window
@@ -36,14 +36,6 @@ Or install it yourself as:
36
36
 
37
37
  rake roll:bump PUSH=true
38
38
 
39
- INITIAL SETUP
40
-
41
- Create a VERSION file with the tag 0.0.1 (and git tag 0.0.1) if a
42
- version file does not already exist, it will then create CHANGELOG
43
- file if one does not already exist, use:
44
-
45
- rake roll:build
46
-
47
39
  CHANGELOG
48
40
 
49
41
  Only commits starting with * will be added to the changelog, example:
@@ -52,6 +44,11 @@ Or install it yourself as:
52
44
  * Feature: #1111 Adding rake_roll to the Gemfile
53
45
  * HotFix: Don't Delete current users
54
46
 
47
+ FILES
48
+
49
+ rake roll will create a VERSION and CHANGELOG file on the root of
50
+ your project if they do not already exist.
51
+
55
52
  TODO
56
53
 
57
54
  Write tests
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,41 @@
1
+ module RakeRoll
2
+
3
+ module GitCommands
4
+
5
+ def get_current_branch
6
+ #run as a direct command to retrieve the output
7
+ `git rev-parse --abbrev-ref HEAD`.chomp
8
+ end
9
+
10
+ def git_push_branch(branch)
11
+ puts "Pushing to origin #{branch}"
12
+ system("git push origin #{branch}")
13
+ end
14
+
15
+ def git_push_tags
16
+ puts "Pushing tags"
17
+ system("git push --tags")
18
+ end
19
+
20
+ def git_log(log_type)
21
+ #run as a direct command to retrieve the output
22
+ `git log #{log_type}`
23
+ end
24
+
25
+ def git_add(file)
26
+ puts "Adding #{file}"
27
+ system("git add #{file}")
28
+ end
29
+
30
+ def git_tag(tag)
31
+ puts "Creating tag #{new_version}"
32
+ system("git tag #{tag}")
33
+ end
34
+
35
+ def git_commit(message)
36
+ puts "Commiting: #{message}"
37
+ system("git commit -a -m '#{message}'")
38
+ end
39
+
40
+ end
41
+ end
@@ -1,6 +1,8 @@
1
1
  module RakeRoll
2
2
  class Roller
3
3
 
4
+ include GitCommands
5
+
4
6
  attr_reader :current_version, :current_branch
5
7
  attr_accessor :new_version
6
8
 
@@ -20,7 +22,7 @@ module RakeRoll
20
22
  end
21
23
 
22
24
  def current_branch
23
- @current_branch ||= `git rev-parse --abbrev-ref HEAD`.chomp
25
+ @current_branch ||= get_current_branch
24
26
  end
25
27
 
26
28
  def new_version
@@ -31,9 +33,7 @@ module RakeRoll
31
33
  puts "----------------------"
32
34
  puts "CHANGELOG"
33
35
  puts parsed_git_log
34
- if parsed_git_log.empty?
35
- puts "WARNING: no new CHANGELOG commits added"
36
- end
36
+ puts "WARNING: no new CHANGELOG commits added" if parsed_git_log.empty?
37
37
  puts "----------------------"
38
38
  end
39
39
 
@@ -50,25 +50,26 @@ module RakeRoll
50
50
  end
51
51
 
52
52
  def parsed_git_log(tag=nil)
53
- git_log(tag).split("\n").select{|line| line[0] == "*"}
53
+ tag ||= current_branch
54
+ log_type = "#{current_version}..#{tag} --pretty=format:'%s'"
55
+ git_log(log_type).split("\n").select{|line| line[0] == "*"}
54
56
  end
55
57
 
56
58
  def push
57
59
  puts "Rake Rolling..."
58
- if parsed_git_log.empty?
59
- puts "WARNING: no new CHANGELOG commits added"
60
- end
61
- update_version
60
+ puts "WARNING: no new CHANGELOG commits added" if parsed_git_log.empty?
61
+ update_version_file
62
62
  update_changelog
63
- commit_changes
64
- update_tag
65
- push_tag_and_branch
63
+ git_commit("Updating Version to #{new_version}")
64
+ git_tag(new_version)
65
+ git_push_branch(@current_branch)
66
+ git_push_tags
66
67
  puts RakeRoll::Never.new.line
67
68
  end
68
69
 
69
70
  private
70
71
 
71
- def update_version
72
+ def update_version_file
72
73
  puts "updating version to #{new_version}"
73
74
  File.open("VERSION", "w") {|f| f.write(new_version) }
74
75
  end
@@ -90,38 +91,13 @@ module RakeRoll
90
91
  system("mv changelog.tmp CHANGELOG")
91
92
  end
92
93
 
93
- def commit_changes
94
- puts "committing changes"
95
- system("git commit -a -m 'Updating Version to #{new_version}'")
96
- end
97
-
98
- def update_tag
99
- puts "updating tag to #{new_version}"
100
- system("git tag #{new_version}")
101
- end
102
-
103
- def push_tag_and_branch
104
- puts "pushing tag and branch"
105
- system("git push origin #{@current_branch}")
106
- system("git push --tags")
107
- end
108
-
109
- def format
110
- #"--pretty=format:'%s | %an | %h'"
111
- "--pretty=format:'%s'"
112
- end
113
-
114
- def git_log(tag=nil)
115
- tag ||= current_branch
116
- `git log #{current_version}..#{tag} #{format}`
117
- end
118
-
119
94
  def build_version
120
95
  File.open("VERSION", "w") {|f| f.write("0.0.1") }
121
96
  File.open("CHANGELOG", "w") {|f| f.write("0.0.1") } unless File.exist?("CHANGELOG")
122
- system('git add VERSION CHANGELOG')
123
- system('git commit -a -m "Creating Version and Changelog version 0.0.1"')
124
- system('git tag 0.0.1')
97
+ git_add("VERSION")
98
+ git_add("CHANGELOG")
99
+ git_commit("Creating Version and Changelog version 0.0.1")
100
+ git_tag("0.0.1")
125
101
  end
126
102
 
127
103
  end
@@ -1,6 +1,6 @@
1
1
  task :roll => :environment do
2
2
  roller = RakeRoll::Roller.new
3
- version = RakeRoll::Version.new(roller.current_version)
3
+ version = RakeRoll::Versioning.new(roller.current_version)
4
4
  puts "----------------------"
5
5
  puts "rake roll options are:"
6
6
  puts "----------------------"
@@ -18,10 +18,10 @@ end
18
18
  desc "bump the version, update the tag and changelog"
19
19
  namespace :roll do
20
20
 
21
- desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Version.new(RakeRoll::Roller.new.current_version).bump}"
21
+ desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Versioning.new(RakeRoll::Roller.new.current_version).bump}"
22
22
  task :bump => :environment do
23
23
  roller = RakeRoll::Roller.new
24
- version = RakeRoll::Version.new(roller.current_version)
24
+ version = RakeRoll::Versioning.new(roller.current_version)
25
25
  if version
26
26
  roller.new_version = version.bump
27
27
  do_your_thing(roller, version, "bump")
@@ -30,10 +30,10 @@ namespace :roll do
30
30
  end
31
31
  end
32
32
 
33
- desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Version.new(RakeRoll::Roller.new.current_version).major}"
33
+ desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Versioning.new(RakeRoll::Roller.new.current_version).major}"
34
34
  task :major => :environment do
35
35
  roller = RakeRoll::Roller.new
36
- version = RakeRoll::Version.new(roller.current_version)
36
+ version = RakeRoll::Versioning.new(roller.current_version)
37
37
  if version
38
38
  roller.new_version = version.major
39
39
  do_your_thing(roller, version, "major")
@@ -42,10 +42,10 @@ namespace :roll do
42
42
  end
43
43
  end
44
44
 
45
- desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Version.new(RakeRoll::Roller.new.current_version).minor}"
45
+ desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Versioning.new(RakeRoll::Roller.new.current_version).minor}"
46
46
  task :minor => :environment do
47
47
  roller = RakeRoll::Roller.new
48
- version = RakeRoll::Version.new(roller.current_version)
48
+ version = RakeRoll::Versioning.new(roller.current_version)
49
49
  if version
50
50
  roller.new_version = version.minor
51
51
  do_your_thing(roller, version, "minor")
@@ -54,10 +54,10 @@ namespace :roll do
54
54
  end
55
55
  end
56
56
 
57
- desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Version.new(RakeRoll::Roller.new.current_version).pre}"
57
+ desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Versioning.new(RakeRoll::Roller.new.current_version).pre}"
58
58
  task :pre => :environment do
59
59
  roller = RakeRoll::Roller.new
60
- version = RakeRoll::Version.new(roller.current_version)
60
+ version = RakeRoll::Versioning.new(roller.current_version)
61
61
  if version
62
62
  roller.new_version = version.pre
63
63
  do_your_thing(roller, version, "pre")
@@ -1,61 +1,5 @@
1
1
  module RakeRoll
2
2
 
3
- class Version
4
-
5
- attr_reader :current_version
6
-
7
- def initialize(current_version)
8
- @current_version = check_current_version(current_version)
9
- end
10
-
11
- def bump
12
- nums = current_version.split(".")
13
- last_number = nums[-1].scan(/\d/).first.to_i
14
- last_number = last_number + 1
15
- nums[-1] = last_number
16
- nums.join(".")
17
- end
18
-
19
- def pre
20
- nums = current_version.split(".")
21
- pre_letter = nums[-1].scan(/\D/).first
22
- if pre_letter
23
- next_letter = pre_letter.next
24
- nums[-1].gsub!(pre_letter, next_letter)
25
- else
26
- nums[-1] = nums[-1] + "a"
27
- end
28
- nums.join(".")
29
- end
30
-
31
- def minor
32
- nums = current_version.split(".")
33
- minor_number = nums[1].scan(/\d/).first.to_i
34
- minor_number = minor_number + 1
35
- nums[1] = minor_number.to_s
36
- nums.last.gsub!(/\D/, "")
37
- nums[-1] = "0" if nums.length == 3
38
- nums.join(".")
39
- end
40
-
41
- def major
42
- nums = current_version.split(".")
43
- major_number = nums[0].scan(/\d/).first.to_i
44
- major_number = major_number + 1
45
- nums[0] = major_number
46
- nums[-1] = "0"
47
- nums[-2] = "0" if nums.length == 3
48
- nums.join(".")
49
- end
50
-
51
- private
52
-
53
- def check_current_version(current)
54
- splits = current.split(".")
55
- return false if splits.size < 2 || splits.size > 3
56
- current
57
- end
58
-
59
- end
3
+ VERSION = File.read(File.expand_path("../../../VERSION", __FILE__)).chomp
60
4
 
61
5
  end
@@ -0,0 +1,64 @@
1
+ module RakeRoll
2
+
3
+ class Versioning
4
+
5
+ attr_reader :current_version
6
+
7
+ def initialize(current_version)
8
+ @current_version = validate_current_version(current_version)
9
+ end
10
+
11
+ def bump
12
+ if nums = current_version.dup
13
+ last_number = nums[-1].scan(/\d/).first.to_i
14
+ last_number = last_number + 1
15
+ nums[-1] = last_number
16
+ nums.join(".")
17
+ end
18
+ end
19
+
20
+ def pre
21
+ if nums = current_version.dup
22
+ pre_letter = nums[-1].scan(/\D/).first
23
+ if pre_letter
24
+ next_letter = pre_letter.next
25
+ nums[-1].gsub!(pre_letter, next_letter)
26
+ else
27
+ nums[-1] = nums[-1] + "a"
28
+ end
29
+ nums.join(".")
30
+ end
31
+ end
32
+
33
+ def minor
34
+ if nums = current_version.dup
35
+ minor_number = nums[1].scan(/\d/).first.to_i
36
+ minor_number = minor_number + 1
37
+ nums[1] = minor_number.to_s
38
+ nums.last.gsub!(/\D/, "")
39
+ nums[-1] = "0" if nums.length == 3
40
+ nums.join(".")
41
+ end
42
+ end
43
+
44
+ def major
45
+ if nums = current_version.dup
46
+ major_number = nums[0].scan(/\d/).first.to_i
47
+ major_number = major_number + 1
48
+ nums[0] = major_number
49
+ nums[-1] = "0"
50
+ nums[-2] = "0" if nums.length == 3
51
+ nums.join(".")
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def validate_current_version(current)
58
+ splits = current.split(".")
59
+ splits.size < 2 || splits.size > 3 ? false : splits
60
+ end
61
+
62
+ end
63
+
64
+ end
data/lib/rake_roll.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require "rake"
2
2
  require "rake_roll/version"
3
+ require "rake_roll/versioning"
3
4
  require "rake_roll/never"
5
+ require "rake_roll/git_commands"
4
6
  require "rake_roll/roller"
5
7
  import File.join(File.dirname(__FILE__), "rake_roll/tasks/roll.rake")
6
8
 
data/rake_roll.gemspec CHANGED
@@ -1,10 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rake_roll/version'
4
5
 
5
6
  Gem::Specification.new do |spec|
6
7
  spec.name = "rake_roll"
7
- spec.version = "0.1.2"
8
+ spec.version = RakeRoll::VERSION
8
9
  spec.authors = ["Stuart Hanscombe"]
9
10
  spec.email = ["hanscs1969@yahoo.co.uk"]
10
11
  spec.summary = "RakeRoll: Git version tagger and changelog creator"
@@ -19,5 +20,6 @@ Gem::Specification.new do |spec|
19
20
 
20
21
  spec.add_development_dependency "bundler", "~> 1.5"
21
22
  spec.add_development_dependency "rake", "~> 0"
23
+ spec.add_development_dependency "rspec", "~> 0"
22
24
  spec.add_development_dependency "pry", "~> 0"
23
25
  end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe RakeRoll::Roller do
4
+
5
+ let(:roller) { RakeRoll::Roller.new }
6
+
7
+ it "Should check the current version" do
8
+ expect(roller.current_version).to eq(RakeRoll::VERSION)
9
+ end
10
+
11
+ it "Should accept a new version" do
12
+ expect(roller.new_version).to eq(RakeRoll::VERSION)
13
+ roller.new_version = "3.0.0"
14
+ expect(roller.new_version).to eq("3.0.0")
15
+ end
16
+
17
+ it "Should Roll out the changes" do
18
+ #TODO Mock all those system calls
19
+ end
20
+
21
+ end
@@ -0,0 +1,88 @@
1
+ describe RakeRoll::Versioning do
2
+
3
+
4
+ it "should validate the version" do
5
+ expect(RakeRoll::Versioning.new("1").current_version).to eq(false)
6
+ end
7
+
8
+ context "Dealing with 3 levels" do
9
+
10
+ let(:version) { RakeRoll::Versioning.new("1.0.0") }
11
+
12
+ it "#bump should => 1.0.0 to 1.0.1" do
13
+ expect(version.bump).to eq("1.0.1")
14
+ end
15
+
16
+ it "#pre should => 1.0.0 to 1.0.0a" do
17
+ expect(version.pre).to eq("1.0.0a")
18
+ end
19
+
20
+ it "#minor should => 1.0.0 to 1.1.0" do
21
+ expect(version.minor).to eq("1.1.0")
22
+ end
23
+
24
+ it "#major should => 1.0.0 to 2.0.0" do
25
+ expect(version.major).to eq("2.0.0")
26
+ end
27
+
28
+ end
29
+
30
+ context "Dealing with 2 levels" do
31
+
32
+ let(:version) { RakeRoll::Versioning.new("1.0") }
33
+
34
+ it "#bump should => 1.0 to 1.1" do
35
+ expect(version.bump).to eq("1.1")
36
+ end
37
+
38
+ it "#pre should => 1.0 to 1.0a" do
39
+ expect(version.pre).to eq("1.0a")
40
+ end
41
+
42
+ it "#minor should => 1.0 to 1.1" do
43
+ expect(version.minor).to eq("1.1")
44
+ end
45
+
46
+ it "#major should => 1.0 to 2.0" do
47
+ expect(version.major).to eq("2.0")
48
+ end
49
+
50
+ end
51
+
52
+ context "Other versioning cases" do
53
+
54
+ it "#bump should => 1.0a to 1.1" do
55
+ expect(RakeRoll::Versioning.new("1.0a").bump).to eq("1.1")
56
+ end
57
+
58
+ it "#major should => 1.5a to 2.0" do
59
+ expect(RakeRoll::Versioning.new("1.5a").major).to eq("2.0")
60
+ end
61
+
62
+ it "#minor should => 1.9a to 1.10" do
63
+ expect(RakeRoll::Versioning.new("1.9a").minor).to eq("1.10")
64
+ end
65
+
66
+ it "#pre should => 1.5a to 1.5b" do
67
+ expect(RakeRoll::Versioning.new("1.5a").pre).to eq("1.5b")
68
+ end
69
+
70
+ it "#bump should => 1.0.0a to 1.0.1" do
71
+ expect(RakeRoll::Versioning.new("1.0.0a").bump).to eq("1.0.1")
72
+ end
73
+
74
+ it "#major should => 1.5.5a to 2.0.0" do
75
+ expect(RakeRoll::Versioning.new("1.5.5a").major).to eq("2.0.0")
76
+ end
77
+
78
+ it "#minor should => 1.5.5a to 1.6.0" do
79
+ expect(RakeRoll::Versioning.new("1.5.5a").minor).to eq("1.6.0")
80
+ end
81
+
82
+ it "#pre should => 1.5.5a to 1.5.5b" do
83
+ expect(RakeRoll::Versioning.new("1.5.5a").pre).to eq("1.5.5b")
84
+ end
85
+
86
+ end
87
+
88
+ end
data/spec/spec_helper.rb CHANGED
@@ -0,0 +1,2 @@
1
+ require "rspec"
2
+ require_relative "../lib/rake_roll"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_roll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Hanscombe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -62,18 +76,22 @@ extensions: []
62
76
  extra_rdoc_files: []
63
77
  files:
64
78
  - ".gitignore"
79
+ - CHANGELOG
65
80
  - Gemfile
66
81
  - LICENSE.txt
67
82
  - README.md
68
83
  - Rakefile
84
+ - VERSION
69
85
  - lib/rake_roll.rb
86
+ - lib/rake_roll/git_commands.rb
70
87
  - lib/rake_roll/never.rb
71
88
  - lib/rake_roll/roller.rb
72
89
  - lib/rake_roll/tasks/roll.rake
73
90
  - lib/rake_roll/version.rb
91
+ - lib/rake_roll/versioning.rb
74
92
  - rake_roll.gemspec
75
93
  - spec/lib/rake_roll/roller_spec.rb
76
- - spec/lib/rake_roll/version_spec.rb
94
+ - spec/lib/rake_roll/versioning_spec.rb
77
95
  - spec/spec_helper.rb
78
96
  homepage: http://www.thelazycamel.com
79
97
  licenses:
@@ -101,5 +119,5 @@ specification_version: 4
101
119
  summary: 'RakeRoll: Git version tagger and changelog creator'
102
120
  test_files:
103
121
  - spec/lib/rake_roll/roller_spec.rb
104
- - spec/lib/rake_roll/version_spec.rb
122
+ - spec/lib/rake_roll/versioning_spec.rb
105
123
  - spec/spec_helper.rb
File without changes