131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'lib/shipit.rb', line 131
def prepare
require "pathname"
@file = Pathname.new(@file)
@content = @file.read
@match = @content.match(/#{@name}\s*=\s*['"](\d+\.\d+\.\d+)['"]/)
@new_version = @match[1].succ
@newcont = @content[0..@match.begin(1)-1] + @new_version + @content[@match.end(1)..-1]
raise "Can't find version string in #{@file}." if @match.nil?
puts "Find version string #{@match[1]} and will change to #{@new_version}"
check_version = nil
@org = @file.parent + "#{@file.basename}.org"
FileUtils.cp @file, @org
@file.open("w") do |f|
f.print @newcont
end
IO.popen("ruby", "r+") do |ruby|
ruby << <<-EOS
m = Module.new
m.module_eval(File.read("Rakefile"))
print Marshal.dump(m.const_get(:VERS))
EOS
ruby.close_write
check_version = Marshal.load(ruby.read)
end
FileUtils.mv @org, @file
raise "Constant VERS in Rakefile must be same as 3rd argument of ChangeVersion step." unless @new_version == check_version
VERS.replace @new_version
end
|