buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lac...@apache.org
Subject svn commit: r690731 - /incubator/buildr/trunk/lib/buildr/core/build.rb
Date Sun, 31 Aug 2008 17:08:39 GMT
Author: lacton
Date: Sun Aug 31 10:08:39 2008
New Revision: 690731

URL: http://svn.apache.org/viewvc?rev=690731&view=rev
Log:
BUILDR-141 Refactored some code duplication

Modified:
    incubator/buildr/trunk/lib/buildr/core/build.rb

Modified: incubator/buildr/trunk/lib/buildr/core/build.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/build.rb?rev=690731&r1=690730&r2=690731&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/build.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/build.rb Sun Aug 31 10:08:39 2008
@@ -237,11 +237,7 @@
       # for the release buildfile.
       def with_release_candidate_version
         release_candidate_buildfile = Buildr.application.buildfile.to_s + '.next'
-        release_candidate_buildfile_contents = change_version do |version|
-          release_candidate_version = version.split('.')
-          release_candidate_version[-1] = release_candidate_version[-1].to_i
-          release_candidate_version.join('.')
-        end
+        release_candidate_buildfile_contents = change_version { |version| version[-1] = version[-1].to_i
}
         File.open(release_candidate_buildfile, 'w') { |file| file.write release_candidate_buildfile_contents
}
         begin
           yield release_candidate_buildfile
@@ -257,11 +253,13 @@
       # Change version number in the current Buildfile, but without writing a new file (yet).
       # Returns the contents of the Buildfile with the modified version number.
       #
-      # This method yields to the block with the current (this) version number and expects
-      # a new version number.
+      # This method yields to the block with the current (this) version number as an array
and expects
+      # the block to update it.
       def change_version()
         this_version = extract_version
-        new_version = yield(this_version)
+        new_version = this_version.split('.')
+        yield(new_version)
+        new_version = new_version.join('.')
         if verbose
           puts 'Upgrading version numbers:' # TODO Add tests on this
           puts "  This:  #{this_version}"
@@ -287,11 +285,7 @@
       #
       # Last, we commit what we currently have in the working copy with an upgraded version
number.
       def commit_new_snapshot
-        buildfile = change_version do |version|
-          version = version.split('.')
-          version[-1] = version[-1].to_i + 1
-          version.join('.') + '-SNAPSHOT'
-        end
+        buildfile = change_version { |version| version[-1] = (version[-1].to_i + 1).to_s
+ '-SNAPSHOT' }
         File.open(Buildr.application.buildfile.to_s, 'w') { |file| file.write buildfile }
         Svn.commit Buildr.application.buildfile.to_s, "Changed version number to #{extract_version}"
       end



Mime
View raw message