Permalink
Browse files

finalized

  • Loading branch information...
1 parent dcfcf7a commit c1729ff53a974c50c5ff8fd8a5afe26a5fad9108 @jondot committed Jan 5, 2011
Showing with 96 additions and 19 deletions.
  1. +41 −0 README.md
  2. +0 −19 README.rdoc
  3. +4 −0 integration_project/Gemfile
  4. +2 −0 integration_project/Rakefile
  5. +1 −0 integration_project/version.txt
  6. +48 −0 lib/bumper/version.rb
View
@@ -0,0 +1,41 @@
+= version_bumper
+
+Simple. Bump your versions.
+
+ $ gem install version_bumper
+
+In your Rakefile `require 'version_bumper'` and you're done.
+
+ $ rake -T
+ rake bump:build # bump build
+ rake bump:init # write a blank version to VERSION
+ rake bump:major # bump major
+ rake bump:minor # bump minor
+ rake bump:revision # bump revision
+
+
+ $ rake bump:init
+ version: 0.0.0.0
+ $ rake bump:revision
+ version: 0.0.1.0
+ $ rake bump:major
+ version: 1.0.0.0
+
+You can optionally use `bumper_file 'version.txt'` in your rake file to switch from the default `VERSION` file name.
+Use `bumper_version` anywhere you need access to the current version in your rake script.
+
+== Contributing to version_bumper
+
+* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
+* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
+* Fork the project
+* Start a feature/bugfix branch
+* Commit and push until you are happy with your contribution
+* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
+* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
+
+== Copyright
+
+Copyright (c) 2011 Dotan Nahum. See LICENSE.txt for
+further details.
+
View
@@ -1,19 +0,0 @@
-= version_bumper
-
-Description goes here.
-
-== Contributing to version_bumper
-
-* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
-* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
-* Fork the project
-* Start a feature/bugfix branch
-* Commit and push until you are happy with your contribution
-* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
-* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
-
-== Copyright
-
-Copyright (c) 2011 jondot. See LICENSE.txt for
-further details.
-
@@ -0,0 +1,4 @@
+# A sample Gemfile
+source "http://rubygems.org"
+gem 'version_bumper'
+# gem "rails"
@@ -0,0 +1,2 @@
+require 'version_bumper'
+bumper_file 'version.txt'
@@ -0,0 +1 @@
+0.0.0.0
View
@@ -0,0 +1,48 @@
+module Bumper
+ class Version
+
+ ['major', 'minor', 'revision', 'build'].each do |part|
+ define_method part do
+ @v[part]
+ end
+ end
+
+ def initialize(v)
+ @v= {}
+ if v =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
+ @v['major'] = $1.to_i
+ @v['minor'] = $2.to_i
+ @v['revision'] = $3.to_i
+ @v['build'] = $4
+ end
+ end
+
+ def bump(part)
+ @v[part] = @v[part].succ
+
+ return @v[part] if part == 'build'
+ @v['build'] = '0'
+ return @v[part] if part == 'revision'
+ @v['revision'] = 0
+ return @v[part] if part == 'minor'
+ @v['minor'] = 0
+ @v[part]
+ end
+
+ def method_missing(m, *args, &block)
+ if(m.to_s =~ /^bump_(.*)$/)
+ if @v.has_key? $1
+ return send(:bump, $1)
+ end
+ end
+ super
+ end
+
+ def to_s
+ "#{major}.#{minor}.#{revision}" + (build.nil? ? "" : ".#{build}")
+ end
+ def write(f)
+ File.open(f,'w'){ |h| h.write(self.to_s) }
+ end
+ end
+end

0 comments on commit c1729ff

Please sign in to comment.