rake_rack 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +26 -0
- data/Rakefile +1 -0
- data/history.rdoc +5 -0
- data/lib/rake_rack.rb +3 -0
- data/lib/version.rb +59 -0
- data/rake_rack.gemspec +1 -1
- data/spec/spec_helper.rb +10 -0
- data/spec/version_spec.rb +150 -0
- data/tasks/version.rake +7 -63
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f3ce1fb58a6142ef4ee8b5dbb63b56ecca4651e
|
4
|
+
data.tar.gz: 2d02f6292f670be585aa6c28c57a27fef7e79b4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3457e22c01719b5616fa2f36211d80bc09194bb5ad94e0405d08665afd48ef2b365edb734ffaaedf65543bc095a39eb48a66e489ac54670e7bf465daba81c28e
|
7
|
+
data.tar.gz: 5cc284136eed4066da4c2f1cc9be874c24719fd397d8c04c7a1a2e323b0d2cdcb2785be7940aed30859c242da0ae2e5a6b062f5be915c844c488100a714b72c7
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,23 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
+
byebug (2.7.0)
|
5
|
+
columnize (~> 0.3)
|
6
|
+
debugger-linecache (~> 1.2)
|
7
|
+
coderay (1.1.0)
|
8
|
+
columnize (0.8.9)
|
9
|
+
debugger-linecache (1.2.0)
|
4
10
|
diff-lcs (1.2.5)
|
11
|
+
docile (1.1.5)
|
12
|
+
method_source (0.8.2)
|
13
|
+
multi_json (1.10.1)
|
14
|
+
pry (0.10.0)
|
15
|
+
coderay (~> 1.1.0)
|
16
|
+
method_source (~> 0.8.1)
|
17
|
+
slop (~> 3.4)
|
18
|
+
pry-byebug (1.3.3)
|
19
|
+
byebug (~> 2.7)
|
20
|
+
pry (~> 0.10)
|
5
21
|
rake (10.1.0)
|
6
22
|
rspec (3.0.0)
|
7
23
|
rspec-core (~> 3.0.0)
|
@@ -15,10 +31,20 @@ GEM
|
|
15
31
|
rspec-mocks (3.0.2)
|
16
32
|
rspec-support (~> 3.0.0)
|
17
33
|
rspec-support (3.0.2)
|
34
|
+
simplecov (0.8.2)
|
35
|
+
docile (~> 1.1.0)
|
36
|
+
multi_json
|
37
|
+
simplecov-html (~> 0.8.0)
|
38
|
+
simplecov-html (0.8.0)
|
39
|
+
slop (3.5.0)
|
40
|
+
timecop (0.7.1)
|
18
41
|
|
19
42
|
PLATFORMS
|
20
43
|
ruby
|
21
44
|
|
22
45
|
DEPENDENCIES
|
46
|
+
pry-byebug
|
23
47
|
rake
|
24
48
|
rspec
|
49
|
+
simplecov
|
50
|
+
timecop
|
data/Rakefile
CHANGED
data/history.rdoc
CHANGED
data/lib/rake_rack.rb
CHANGED
data/lib/version.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
class RakeRack
|
2
|
+
class Version
|
3
|
+
HISTORY_FILE = "history.rdoc"
|
4
|
+
def self.current_history history_file
|
5
|
+
File.read history_file
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.latest_version
|
9
|
+
latest_version_string = current_history(HISTORY_FILE)[/== ([\d\.]*)/, 1] || "0.0.0"
|
10
|
+
@latest_version ||= latest_version_string.split(".").map(&:to_i)
|
11
|
+
def @latest_version.to_s
|
12
|
+
join "."
|
13
|
+
end
|
14
|
+
@latest_version
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.update_to version
|
18
|
+
add_history_header version
|
19
|
+
update_gem version if gem?
|
20
|
+
commit version
|
21
|
+
tag version
|
22
|
+
branch = `git symbolic-ref HEAD`[%r{.*/(.*)}, 1]
|
23
|
+
puts "To push the new tag, use 'git push origin #{branch} --tags'"
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.add_history_header(version, history_file = HISTORY_FILE)
|
27
|
+
history = current_history history_file
|
28
|
+
File.open history_file, "w" do |f|
|
29
|
+
f.puts "== #{version} (#{Time.now.strftime "%d %B %Y"})"
|
30
|
+
f.puts
|
31
|
+
f.print history
|
32
|
+
end
|
33
|
+
puts "Added version to history.rdoc"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.update_gem version
|
37
|
+
path = Dir.glob('*.gemspec').first
|
38
|
+
text = File.read path
|
39
|
+
File.open(path, "w") do |file|
|
40
|
+
file.puts text.sub(/(.*version\s*=\s*)(['|"].*['|"])/, "\\1'#{version}'")
|
41
|
+
end
|
42
|
+
puts "Added version to .gemfile"
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.commit version
|
46
|
+
`git add . && git commit -m 'increment version to #{version}'`
|
47
|
+
puts "Committed change"
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.tag version
|
51
|
+
`git tag #{version}`
|
52
|
+
puts "Tagged with #{version}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.gem?
|
56
|
+
!Dir.glob('*.gemspec').empty?
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/rake_rack.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "rake_rack"
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.6'
|
8
8
|
spec.authors = ["Richard Vickerstaff"]
|
9
9
|
spec.email = ["m3akq@btinternet.com"]
|
10
10
|
spec.description = "A set of rake tasks I commonly use - Formerly known as pool_net"
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RakeRack::Version do
|
4
|
+
before do
|
5
|
+
allow(described_class).to receive(:`)
|
6
|
+
allow(described_class).to receive(:puts)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '.current_history' do
|
10
|
+
before do
|
11
|
+
allow(File).to receive(:read).and_return 'history'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns the current history file' do
|
15
|
+
expect(described_class.current_history('./path')).to eq 'history'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.latest_version' do
|
20
|
+
before do
|
21
|
+
allow(File).to receive(:read).and_return "== 1.2.3 (16 July 2014)\n * Change version tack so it can update gem version"
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'there is no version'do
|
25
|
+
it 'returns a version of [0,0,0]' do
|
26
|
+
allow(File).to receive(:read).and_return ""
|
27
|
+
expect(described_class.latest_version).to eq [1,2,3]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'there is a version' do
|
32
|
+
it 'returns the latest version' do
|
33
|
+
expect(described_class.latest_version).to eq [1,2,3]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'defines the .to_s of the latest version'do
|
38
|
+
expect(described_class.latest_version.to_s).to eq "1.2.3"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.gem?' do
|
43
|
+
context 'the project is a gem' do
|
44
|
+
before do
|
45
|
+
allow(Dir).to receive(:glob).and_return ['a gem spec']
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'returns true' do
|
49
|
+
expect(described_class.gem?).to eq true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'the project is not a gem' do
|
54
|
+
before do
|
55
|
+
allow(Dir).to receive(:glob).and_return []
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'returns false' do
|
59
|
+
expect(described_class.gem?).to eq false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '.update_gem' do
|
65
|
+
let(:tmp_file) { Tempfile.new(['rake_rack','.gemspec']) }
|
66
|
+
|
67
|
+
before do
|
68
|
+
gemspec = <<-GEM
|
69
|
+
Gem::Specification.new do |spec|
|
70
|
+
spec.name = "rake_rack"
|
71
|
+
spec.version = '0.0.5'
|
72
|
+
spec.authors = ["Richard Vickerstaff"]
|
73
|
+
end
|
74
|
+
GEM
|
75
|
+
tmp_file.write gemspec
|
76
|
+
tmp_file.rewind
|
77
|
+
allow(Dir).to receive(:glob).and_return [tmp_file.path]
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'updates the gem version' do
|
81
|
+
t = Time.local(2014, 7, 16)
|
82
|
+
Timecop.travel(t) do
|
83
|
+
described_class.update_gem 'foo'
|
84
|
+
expect(File.read(tmp_file)).to match(/.*version\s*= 'foo'/)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'outputs a message to the user' do
|
89
|
+
expect(described_class).to receive(:puts).with 'Added version to .gemfile'
|
90
|
+
described_class.update_gem 'foo'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '.update_to' do
|
95
|
+
before do
|
96
|
+
allow(described_class).to receive(:`).and_return "refs/heads/master"
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'updates the version' do
|
100
|
+
expect(described_class).to receive(:add_history_header).with 'foo'
|
101
|
+
expect(described_class).to receive(:update_gem).with 'foo'
|
102
|
+
expect(described_class).to receive(:commit).with 'foo'
|
103
|
+
expect(described_class).to receive(:tag).with 'foo'
|
104
|
+
expect(described_class).to receive(:`).with 'git symbolic-ref HEAD'
|
105
|
+
expect(described_class).to receive(:puts).with "To push the new tag, use 'git push origin master --tags'"
|
106
|
+
described_class.update_to 'foo'
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '.add_history_header' do
|
111
|
+
let(:tmp_file) { Tempfile.new('foo').path }
|
112
|
+
|
113
|
+
it 'adds the new headre to the history.rdoc' do
|
114
|
+
t = Time.local(2014, 7, 16)
|
115
|
+
Timecop.travel(t) do
|
116
|
+
described_class.add_history_header 'foo', tmp_file
|
117
|
+
expect(File.read tmp_file).to eq "== foo (16 July 2014)\n\n"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'outputs a message to the user' do
|
122
|
+
expect(described_class).to receive(:puts).with 'Added version to history.rdoc'
|
123
|
+
described_class.add_history_header 'foo', tmp_file
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '.commit' do
|
128
|
+
it 'commits all changes' do
|
129
|
+
expect(described_class).to receive(:`).with "git add . && git commit -m 'increment version to foo'"
|
130
|
+
described_class.commit 'foo'
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'outputs a message to the user' do
|
134
|
+
expect(described_class).to receive(:puts).with 'Committed change'
|
135
|
+
described_class.commit 'foo'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '.tag' do
|
140
|
+
it 'it tags the commit with the new version' do
|
141
|
+
expect(described_class).to receive(:`).with 'git tag foo'
|
142
|
+
described_class.tag 'foo'
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'outputs a message to the user' do
|
146
|
+
expect(described_class).to receive(:puts).with 'Tagged with foo'
|
147
|
+
described_class.tag 'foo'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/tasks/version.rake
CHANGED
@@ -1,87 +1,31 @@
|
|
1
|
-
module Rake::Version
|
2
|
-
def self.current_history
|
3
|
-
File.read "history.rdoc"
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.latest_version
|
7
|
-
latest_version_string = current_history[/== ([\d\.]*)/, 1] || "0.0.0"
|
8
|
-
@latest_version ||= latest_version_string.split(".").map(&:to_i)
|
9
|
-
def @latest_version.to_s
|
10
|
-
join "."
|
11
|
-
end
|
12
|
-
@latest_version
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.update_to version
|
16
|
-
add_history_header version
|
17
|
-
update_gem version if gem?
|
18
|
-
commit version
|
19
|
-
tag version
|
20
|
-
branch = `git symbolic-ref HEAD`[%r{.*/(.*)}, 1]
|
21
|
-
puts "To push the new tag, use 'git push origin #{branch} --tags'"
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.add_history_header version
|
25
|
-
history = current_history
|
26
|
-
File.open "history.rdoc", "w" do |f|
|
27
|
-
f.puts "== #{version} (#{Time.now.strftime "%d %B %Y"})"
|
28
|
-
f.puts
|
29
|
-
f.print history
|
30
|
-
end
|
31
|
-
puts "Added version to history.rdoc"
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.update_gem version
|
35
|
-
path = Dir.glob('*.gemspec').first
|
36
|
-
text = File.read path
|
37
|
-
File.open(path, "w") do |file|
|
38
|
-
file.puts text.sub(/(.*version\s*=\s*)(['|"].*['|"])/, "\\1'#{version}'")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.commit version
|
43
|
-
`git add . && git commit -m 'increment version to #{version}'`
|
44
|
-
puts "Committed change"
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.tag version
|
48
|
-
`git tag #{version}`
|
49
|
-
puts "Tagged with #{version}"
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.gem?
|
53
|
-
!Dir.glob('*.gemspec').empty?
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
1
|
desc "Display the latest version (from history.rdoc)"
|
58
2
|
task :"rake_rack:version" do
|
59
|
-
puts "Latest version is #{
|
3
|
+
puts "Latest version is #{RakeRack::Version.latest_version}"
|
60
4
|
end
|
61
5
|
|
62
6
|
namespace :rake_rack do
|
63
7
|
namespace :version do
|
64
8
|
desc "Increment the major version in history.rdoc (eg 1.2.3 => 2.0.0)"
|
65
9
|
task :major do
|
66
|
-
new_version =
|
10
|
+
new_version = RakeRack::Version.latest_version
|
67
11
|
new_version[0] += 1
|
68
12
|
new_version[1,2] = 0, 0
|
69
|
-
|
13
|
+
RakeRack::Version.update_to new_version
|
70
14
|
end
|
71
15
|
|
72
16
|
desc "Increment the minor version in history.rdoc (eg 1.2.3 => 1.3.0)"
|
73
17
|
task :minor do
|
74
|
-
new_version =
|
18
|
+
new_version = RakeRack::Version.latest_version
|
75
19
|
new_version[1] += 1
|
76
20
|
new_version[2] = 0
|
77
|
-
|
21
|
+
RakeRack::Version.update_to new_version
|
78
22
|
end
|
79
23
|
|
80
24
|
desc "Increment the patch version in history.rdoc (eg 1.2.3 => 1.2.4)"
|
81
25
|
task :patch do
|
82
|
-
new_version =
|
26
|
+
new_version = RakeRack::Version.latest_version
|
83
27
|
new_version[2] += 1
|
84
|
-
|
28
|
+
RakeRack::Version.update_to new_version
|
85
29
|
end
|
86
30
|
end
|
87
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake_rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Vickerstaff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -54,8 +54,11 @@ files:
|
|
54
54
|
- Rakefile
|
55
55
|
- history.rdoc
|
56
56
|
- lib/rake_rack.rb
|
57
|
+
- lib/version.rb
|
57
58
|
- rake_rack.gemspec
|
58
59
|
- spec/.keep
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- spec/version_spec.rb
|
59
62
|
- tasks/code_quality.rake
|
60
63
|
- tasks/coverage.rake
|
61
64
|
- tasks/karma.rake
|