In Files

Parent

Methods

Rake::ShipitTask::Step::ChangeVersion

Public Class Methods

new(step, file, name="VERSION") click to toggle source
     # File lib/shipit.rb, line 126
126:         def initialize(step, file, name="VERSION")
127:                 @file = file
128:                 @name = name
129:         end

Public Instance Methods

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.