ritual 0.0.3 → 0.0.4

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.
Files changed (4) hide show
  1. data/CHANGELOG +5 -0
  2. data/lib/ritual.rb +46 -14
  3. data/lib/ritual/version.rb +9 -1
  4. metadata +3 -3
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.0.4 2010-04-26
2
+
3
+ * Set version in CHANGELOG when bumping version.
4
+ * Make VERSION objects comparable, and make them print nicely.
5
+
1
6
  == 0.0.3 2010-04-22
2
7
 
3
8
  * Add install task.
data/lib/ritual.rb CHANGED
@@ -1,7 +1,8 @@
1
+ require 'date'
1
2
  require 'fileutils'
2
3
 
3
4
  desc "Build and install the gem."
4
- task :install => %w'ritual:build ritual:install_gem'
5
+ task :install => %w'ritual:build_gem ritual:install_gem'
5
6
 
6
7
  desc "Select a major version bump."
7
8
  task :major do
@@ -19,7 +20,7 @@ task :patch do
19
20
  end
20
21
 
21
22
  desc "Bump the selected version component and do the release ritual."
22
- task :release => %w'ritual:check_release_args ritual:bump ritual:tag ritual:push ritual:build ritual:push_gem'
23
+ task :release => %w'ritual:check_release_args ritual:bump ritual:tag ritual:push ritual:build_gem ritual:push_gem'
23
24
 
24
25
  # Private helper tasks.
25
26
  namespace :ritual do
@@ -30,9 +31,10 @@ namespace :ritual do
30
31
 
31
32
  task :bump do
32
33
  version.increment(Ritual.component)
34
+ changelog.set_latest_version(version)
33
35
  version.write
34
- sh "git add #{version.path}"
35
- sh "git commit #{version.path} -m 'Bump to version #{version}.'"
36
+ sh "git add #{version.path} #{changelog.path}"
37
+ sh "git commit #{version.path} #{changelog.path} -m 'Bump to version #{version}.'"
36
38
  puts "Bumped to version #{version}."
37
39
  end
38
40
 
@@ -44,7 +46,7 @@ namespace :ritual do
44
46
  sh "git push origin master"
45
47
  end
46
48
 
47
- task :build do
49
+ task :build_gem do
48
50
  sh "gem build #{library_name}.gemspec"
49
51
  end
50
52
 
@@ -86,22 +88,32 @@ module Ritual
86
88
  attr_reader :value, :library_name
87
89
 
88
90
  def to_s
89
- value.join('.')
91
+ value.to_s
90
92
  end
91
93
 
92
94
  def read
93
- if File.exist?(path)
94
- load path
95
- self.module::VERSION
96
- else
97
- self.module.const_set(:VERSION, [0, 0, 0])
98
- end
95
+ File.exist?(path) or
96
+ write([0, 0, 0])
97
+ load path
98
+ self.module::VERSION
99
99
  end
100
100
 
101
- def write
101
+ def write(value=self.value)
102
102
  FileUtils.mkdir_p File.dirname(path)
103
103
  open(path, 'w') do |file|
104
- file.puts "module #{module_name}\n VERSION = #{value.inspect}\nend"
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
105
117
  end
106
118
  end
107
119
 
@@ -124,6 +136,22 @@ module Ritual
124
136
  Object.const_get(module_name)
125
137
  end
126
138
  end
139
+
140
+ class Changelog
141
+ def path
142
+ 'CHANGELOG'
143
+ end
144
+
145
+ def set_latest_version(version)
146
+ File.exist?(path) or
147
+ raise "Don't release without a CHANGELOG!"
148
+ text = File.read(path)
149
+ heading = "#{version} #{Date.today.strftime('%Y-%m-%d')}"
150
+ text.sub!(/^(== )LATEST$/i, "\\1#{heading}") or
151
+ raise "No LATEST entry in CHANGELOG - did you forget to update it?"
152
+ open(path, 'w'){|f| f.print text}
153
+ end
154
+ end
127
155
  end
128
156
 
129
157
  #
@@ -138,6 +166,10 @@ def version
138
166
  @version ||= Ritual::Version.new(library_name)
139
167
  end
140
168
 
169
+ def changelog
170
+ @changelog ||= Ritual::Changelog.new
171
+ end
172
+
141
173
  def spec_task(*args, &block)
142
174
  require 'spec/rake/spectask'
143
175
  Spec::Rake::SpecTask.new(*args, &block)
@@ -1,3 +1,11 @@
1
1
  module Ritual
2
- VERSION = [0, 0, 3]
2
+ VERSION = [0, 0, 4]
3
+
4
+ class << VERSION
5
+ include Comparable
6
+
7
+ def to_s
8
+ join('.')
9
+ end
10
+ end
3
11
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - George Ogata
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-22 00:00:00 -04:00
17
+ date: 2010-04-26 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20