ritual 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/lib/ritual.rb +56 -115
- data/lib/ritual/changelog.rb +21 -0
- data/lib/ritual/lib.rb +5 -0
- data/lib/ritual/version.rb +1 -1
- data/lib/ritual/version_file.rb +61 -0
- metadata +27 -6
data/CHANGELOG
CHANGED
data/lib/ritual.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'date'
|
2
2
|
require 'fileutils'
|
3
|
-
|
4
|
-
desc "Build and install the gem."
|
5
|
-
task :install => %w'ritual:build_gem ritual:install_gem'
|
3
|
+
require 'ritual/lib'
|
6
4
|
|
7
5
|
desc "Select a major version bump."
|
8
6
|
task :major do
|
@@ -20,16 +18,13 @@ task :patch do
|
|
20
18
|
end
|
21
19
|
|
22
20
|
desc "Bump the selected version component and do the release ritual."
|
23
|
-
task :release => %w'
|
21
|
+
task :release => %w'repo:bump repo:tag repo:push gem:build gem:push'
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
task :
|
23
|
+
namespace :repo do
|
24
|
+
desc "Bump and commit the version file and changelog."
|
25
|
+
task :bump do
|
28
26
|
Ritual.component or
|
29
27
|
raise "Please select a version component to bump, e.g.: rake patch release"
|
30
|
-
end
|
31
|
-
|
32
|
-
task :bump do
|
33
28
|
version.increment(Ritual.component)
|
34
29
|
changelog.set_latest_version(version)
|
35
30
|
version.write
|
@@ -38,137 +33,44 @@ namespace :ritual do
|
|
38
33
|
puts "Bumped to version #{version}."
|
39
34
|
end
|
40
35
|
|
36
|
+
desc "Tag the release with the current version."
|
41
37
|
task :tag do
|
42
38
|
sh "git tag v#{version}"
|
43
39
|
end
|
44
40
|
|
41
|
+
desc "Push updates upstream."
|
45
42
|
task :push do
|
46
43
|
sh "git push origin master"
|
47
44
|
end
|
45
|
+
end
|
48
46
|
|
49
|
-
|
47
|
+
namespace :gem do
|
48
|
+
desc "Build the gem."
|
49
|
+
task :build do
|
50
50
|
sh "gem build #{library_name}.gemspec"
|
51
51
|
end
|
52
52
|
|
53
|
-
|
53
|
+
desc "Push the gem to the gem server."
|
54
|
+
task :push do
|
54
55
|
sh "gem push #{library_name}-#{version}.gem"
|
55
56
|
end
|
56
57
|
|
57
|
-
|
58
|
+
desc "Install the gem. May require running with sudo."
|
59
|
+
task :install => :build do
|
58
60
|
sh "gem install #{library_name}-#{version}.gem"
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
62
|
-
module Ritual
|
63
|
-
class << self
|
64
|
-
attr_accessor :component
|
65
|
-
|
66
|
-
def library_name
|
67
|
-
ENV['LIB'] || default_library_name
|
68
|
-
end
|
69
|
-
|
70
|
-
def default_library_name
|
71
|
-
gemspecs = Dir['*.gemspec']
|
72
|
-
names = gemspecs.map{|path| File.basename(path, '.gemspec')}
|
73
|
-
if names.size.zero?
|
74
|
-
abort "cannot find any gemspecs"
|
75
|
-
elsif names.size > 1
|
76
|
-
abort "choose a gemspec: LIB=#{names.join('|')}"
|
77
|
-
end
|
78
|
-
names.first
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class Version
|
83
|
-
def initialize(library_name)
|
84
|
-
@library_name = library_name
|
85
|
-
@value ||= read
|
86
|
-
end
|
87
|
-
|
88
|
-
attr_reader :value, :library_name
|
89
|
-
|
90
|
-
def to_s
|
91
|
-
value.to_s
|
92
|
-
end
|
93
|
-
|
94
|
-
def read
|
95
|
-
File.exist?(path) or
|
96
|
-
write([0, 0, 0])
|
97
|
-
load path
|
98
|
-
self.module::VERSION
|
99
|
-
end
|
100
|
-
|
101
|
-
def write(value=self.value)
|
102
|
-
FileUtils.mkdir_p File.dirname(path)
|
103
|
-
open(path, 'w') do |file|
|
104
|
-
file.puts <<-EOS.gsub(/^ *\|/, '')
|
105
|
-
|module #{module_name}
|
106
|
-
| VERSION = #{value.inspect}
|
107
|
-
|
|
108
|
-
| class << VERSION
|
109
|
-
| include Comparable
|
110
|
-
|
|
111
|
-
| def to_s
|
112
|
-
| join('.')
|
113
|
-
| end
|
114
|
-
| end
|
115
|
-
|end
|
116
|
-
EOS
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def increment(component)
|
121
|
-
(value.size..component).each{|i| value[i] = 0}
|
122
|
-
value[component] += 1
|
123
|
-
(component+1 ... value.size).each{|i| value[i] = 0}
|
124
|
-
end
|
125
|
-
|
126
|
-
def path
|
127
|
-
"lib/#{library_name}/version.rb"
|
128
|
-
end
|
129
|
-
|
130
|
-
def module_name
|
131
|
-
library_name.gsub(/(?:\A|_)(.)/){$1.upcase}
|
132
|
-
end
|
133
|
-
|
134
|
-
def module
|
135
|
-
Object.const_defined?(module_name) or
|
136
|
-
Object.const_set(module_name, Module.new)
|
137
|
-
Object.const_get(module_name)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
class Changelog
|
142
|
-
def path
|
143
|
-
'CHANGELOG'
|
144
|
-
end
|
145
|
-
|
146
|
-
def set_latest_version(version)
|
147
|
-
File.exist?(path) or
|
148
|
-
raise "Don't release without a CHANGELOG!"
|
149
|
-
text = File.read(path)
|
150
|
-
heading = "#{version} #{Date.today.strftime('%Y-%m-%d')}"
|
151
|
-
text.sub!(/^(== )LATEST$/i, "\\1#{heading}") or
|
152
|
-
raise "No LATEST entry in CHANGELOG - did you forget to update it?"
|
153
|
-
open(path, 'w'){|f| f.print text}
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
#
|
159
|
-
# Global API
|
160
|
-
#
|
161
|
-
|
162
64
|
def library_name
|
163
65
|
Ritual.library_name
|
164
66
|
end
|
165
67
|
|
166
68
|
def version
|
167
|
-
@version ||= Ritual
|
69
|
+
@version ||= Ritual.version_file
|
168
70
|
end
|
169
71
|
|
170
72
|
def changelog
|
171
|
-
@changelog ||= Ritual
|
73
|
+
@changelog ||= Ritual.changelog
|
172
74
|
end
|
173
75
|
|
174
76
|
def spec_task(*args, &block)
|
@@ -187,3 +89,42 @@ def rdoc_task(*args, &block)
|
|
187
89
|
require 'rake/rdoctask'
|
188
90
|
Rake::RDocTask.new(*args, &block)
|
189
91
|
end
|
92
|
+
|
93
|
+
def remove_task(name)
|
94
|
+
Rake.application.instance_variable_get(:@tasks).delete(name) or
|
95
|
+
raise ArgumentError, "task not found: #{name}"
|
96
|
+
end
|
97
|
+
|
98
|
+
def replace_task(name, *args, &block)
|
99
|
+
remove_task name
|
100
|
+
task(name, *args, &block)
|
101
|
+
end
|
102
|
+
|
103
|
+
module Ritual
|
104
|
+
class << self
|
105
|
+
attr_accessor :component
|
106
|
+
|
107
|
+
def library_name
|
108
|
+
ENV['LIB'] || default_library_name
|
109
|
+
end
|
110
|
+
|
111
|
+
def default_library_name
|
112
|
+
gemspecs = Dir['*.gemspec']
|
113
|
+
names = gemspecs.map{|path| File.basename(path, '.gemspec')}
|
114
|
+
if names.size.zero?
|
115
|
+
abort "cannot find any gemspecs"
|
116
|
+
elsif names.size > 1
|
117
|
+
abort "choose a gemspec: LIB=#{names.join('|')}"
|
118
|
+
end
|
119
|
+
names.first
|
120
|
+
end
|
121
|
+
|
122
|
+
def version_file
|
123
|
+
@version ||= VersionFile.new("lib/#{library_name}/version.rb", library_name)
|
124
|
+
end
|
125
|
+
|
126
|
+
def changelog
|
127
|
+
@changelog ||= Changelog.new('CHANGELOG')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ritual
|
2
|
+
class Changelog
|
3
|
+
Error = Class.new(RuntimeError)
|
4
|
+
|
5
|
+
def initialize(path)
|
6
|
+
@path = path
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :path
|
10
|
+
|
11
|
+
def set_latest_version(version)
|
12
|
+
File.exist?(path) or
|
13
|
+
raise Error, "Don't release without a CHANGELOG!"
|
14
|
+
text = File.read(path)
|
15
|
+
heading = "#{version} #{Date.today.strftime('%Y-%m-%d')}"
|
16
|
+
text.sub!(/^(== )LATEST$/i, "\\1#{heading}") or
|
17
|
+
raise Error, "No LATEST entry in CHANGELOG - did you forget to update it?"
|
18
|
+
open(path, 'w'){|f| f.print text}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/ritual/lib.rb
ADDED
data/lib/ritual/version.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
module Ritual
|
2
|
+
class VersionFile
|
3
|
+
def initialize(path, library_name)
|
4
|
+
@path = path
|
5
|
+
@library_name = library_name
|
6
|
+
@value ||= read
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :path, :library_name, :value
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
value.join('.')
|
13
|
+
end
|
14
|
+
|
15
|
+
def write
|
16
|
+
FileUtils.mkdir_p File.dirname(path)
|
17
|
+
open(path, 'w') do |file|
|
18
|
+
file.puts <<-EOS.gsub(/^ *\|/, '')
|
19
|
+
|module #{module_name}
|
20
|
+
| VERSION = #{value.inspect}
|
21
|
+
|
|
22
|
+
| class << VERSION
|
23
|
+
| include Comparable
|
24
|
+
|
|
25
|
+
| def to_s
|
26
|
+
| join('.')
|
27
|
+
| end
|
28
|
+
| end
|
29
|
+
|end
|
30
|
+
EOS
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def increment(component)
|
35
|
+
(value.size..component).each{|i| value[i] = 0}
|
36
|
+
value[component] += 1
|
37
|
+
(component+1 ... value.size).each{|i| value[i] = 0}
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def read
|
43
|
+
if File.exist?(path)
|
44
|
+
File.read(path) =~ /^\s*VERSION\s*=\s*(\[.*?\])/ and
|
45
|
+
eval $1
|
46
|
+
else
|
47
|
+
[0, 0, 0]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def module
|
52
|
+
Object.const_defined?(module_name) or
|
53
|
+
Object.const_set(module_name, Module.new)
|
54
|
+
Object.const_get(module_name)
|
55
|
+
end
|
56
|
+
|
57
|
+
def module_name
|
58
|
+
library_name.gsub(/(?:\A|_)(.)/){$1.upcase}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ritual
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
8
|
+
- 1
|
7
9
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.5
|
10
|
+
version: 0.1.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- George Ogata
|
@@ -14,10 +15,23 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-01-17 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rake
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
21
35
|
description: |
|
22
36
|
Adds tasks and helpers to your Rakefile to manage releases in a
|
23
37
|
lightweight manner.
|
@@ -31,7 +45,10 @@ extensions: []
|
|
31
45
|
extra_rdoc_files: []
|
32
46
|
|
33
47
|
files:
|
48
|
+
- lib/ritual/changelog.rb
|
49
|
+
- lib/ritual/lib.rb
|
34
50
|
- lib/ritual/version.rb
|
51
|
+
- lib/ritual/version_file.rb
|
35
52
|
- lib/ritual.rb
|
36
53
|
- LICENSE
|
37
54
|
- README.markdown
|
@@ -47,16 +64,20 @@ rdoc_options: []
|
|
47
64
|
require_paths:
|
48
65
|
- lib
|
49
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
50
68
|
requirements:
|
51
69
|
- - ">="
|
52
70
|
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
53
72
|
segments:
|
54
73
|
- 0
|
55
74
|
version: "0"
|
56
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
57
77
|
requirements:
|
58
78
|
- - ">="
|
59
79
|
- !ruby/object:Gem::Version
|
80
|
+
hash: 23
|
60
81
|
segments:
|
61
82
|
- 1
|
62
83
|
- 3
|
@@ -65,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
86
|
requirements: []
|
66
87
|
|
67
88
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.3.
|
89
|
+
rubygems_version: 1.3.7
|
69
90
|
signing_key:
|
70
91
|
specification_version: 3
|
71
92
|
summary: Rakefile release tasks and helpers.
|