# 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 content of Rakefile check_version = nil @org = @file.parent + "#{@file.basename}.org" FileUtils.cp @file, @org @file.open("w") do |f| f.print @newcont end ## run ruby not to duplicate rake tasks. IO.popen("ruby", "r+") do |ruby| ruby << m = Module.new m.module_eval(File.read("Rakefile")) print Marshal.dump(m.const_get(:VERS)) 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
Generated with the Darkfish Rdoc Generator 2.