gem_version 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .DS_Store
2
+ pkg
3
+ nbproject
4
+ arspy*.gem
5
+ arspy*.gemspec
6
+ TODO.txt
7
+ spec/next_gem_version
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006-2009 Jeff Patmon
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,59 @@
1
+ = gem_version
2
+
3
+ Automated version management for your Gem builds.
4
+
5
+ == Resources
6
+
7
+ Install
8
+
9
+ * sudo gem install gem_version
10
+
11
+ Use
12
+
13
+ * require 'gem_version'
14
+
15
+
16
+ == Description
17
+
18
+ Never bother updating the version for your next gem build by hand. Configured in your Rakefile, gem_version automatically provides the next version and commits it to the repository.
19
+
20
+ == Use
21
+
22
+ Require the library in your Rakefile:
23
+
24
+ require 'gem_version'
25
+
26
+ Use gem_version in your Gem Specification:
27
+
28
+ spec = Gem::Specification.new do |s|
29
+ s.version = GemVersion.next_version
30
+ ...
31
+ end
32
+
33
+ Increment and commit the gem version in your Gemspec rake task:
34
+
35
+ desc 'Generate a gemspec file.'
36
+ task :gemspec do
37
+ File.open("#{spec.name}.gemspec", 'w') do |f|
38
+ f.write spec.to_ruby
39
+ end
40
+ GemVersion.increment_version
41
+ GemVersion.commit_and_push
42
+ end
43
+
44
+ Everytime you build your gem (this example uses Gemcutter):
45
+
46
+ rake gemspec
47
+ gem build your_gem_name.gemspec
48
+
49
+ gem_version provides the next version for each build.
50
+
51
+
52
+ == Bumping or resetting the next gem version
53
+
54
+ Gem version creates a file named 'next_gem_version' in the root directory of your project which contains the 'next' gem version. Edit the version in this file to bump or reset the version for the next build.
55
+
56
+
57
+ == Dependencies
58
+
59
+ * Git gem (>= 1.2.5)
data/Rakefile ADDED
@@ -0,0 +1,67 @@
1
+ #require 'rake/testtask'
2
+ require 'rake/rdoctask'
3
+ require 'rake/gempackagetask'
4
+ #require 'rake/contrib/sshpublisher'
5
+ require 'lib/gem_version'
6
+
7
+ spec = Gem::Specification.new do |s|
8
+ s.name = 'gem_version'
9
+ s.version = GemVersion.next_version
10
+ s.platform = Gem::Platform::RUBY
11
+ s.required_ruby_version = '>= 1.8.6'
12
+ s.description = 'Automated version management for your Gem builds'
13
+ s.summary = 'Never bother updating the version for your next gem build by hand. Configured in your Rakefile, gem_version provides the next Gem version and stores it to the repository.'
14
+
15
+ s.add_dependency('git', '>= 1.2.5')
16
+
17
+ exclude_folders = '' # 'spec/rails/{doc,lib,log,nbproject,tmp,vendor,test}'
18
+ exclude_files = [] # FileList['**/*.log'] + FileList[exclude_folders+'/**/*'] + FileList[exclude_folders]
19
+ s.files = FileList['{lib,spec}/**/*'] + %w(init.rb LICENSE Rakefile README.rdoc .gitignore) - exclude_files
20
+ s.require_path = 'lib'
21
+ s.has_rdoc = true
22
+ s.test_files = Dir['spec/*_spec.rb']
23
+
24
+ s.author = 'Jeff Patmon'
25
+ s.email = 'jpatmon@gmail.com'
26
+ s.homepage = 'http://github.com/jeffp/gem_version/tree/master'
27
+ end
28
+
29
+ require 'spec/version'
30
+ require 'spec/rake/spectask'
31
+
32
+ desc "Run specs"
33
+ Spec::Rake::SpecTask.new(:spec) do |t|
34
+ t.spec_files = FileList['spec/*_spec.rb']
35
+ t.libs << 'lib' << 'spec'
36
+ t.rcov = false
37
+ t.spec_opts = ['--options', 'spec/spec.opts']
38
+ #t.rcov_dir = 'coverage'
39
+ #t.rcov_opts = ['--exclude', "kernel,load-diff-lcs\.rb,instance_exec\.rb,lib/spec.rb,lib/spec/runner.rb,^spec/*,bin/spec,examples,/gems,/Library/Ruby,\.autotest,#{ENV['GEM_HOME']}"]
40
+ end
41
+
42
+
43
+ desc "Generate documentation for the #{spec.name} gem."
44
+ Rake::RDocTask.new(:rdoc) do |rdoc|
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = spec.name
47
+ #rdoc.template = '../rdoc_template.rb'
48
+ rdoc.options << '--line-numbers' << '--inline-source'
49
+ rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'lib/**/*.rb')
50
+ end
51
+
52
+ desc 'Generate a gemspec file.'
53
+ task :gemspec do
54
+ File.open("#{spec.name}.gemspec", 'w') do |f|
55
+ f.write spec.to_ruby
56
+ end
57
+ GemVersion.increment_version
58
+ GemVersion.commit_and_push
59
+ end
60
+
61
+ Rake::GemPackageTask.new(spec) do |p|
62
+ p.gem_spec = spec
63
+ p.need_tar = RUBY_PLATFORM =~ /mswin/ ? false : true
64
+ p.need_zip = true
65
+ end
66
+
67
+ Dir['tasks/**/*.rake'].each {|rake| load rake}
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'arspy'
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require 'git'
3
+ require 'logger'
4
+
5
+ module GemVersion
6
+ @@gem_version_file = 'next_gem_version'
7
+ @@default_commit_message = 'incremented gem version'
8
+
9
+ def self.gem_version_file=(str)
10
+ @@gem_version_file = str
11
+ end
12
+
13
+ def self.next_version
14
+ init_version_file unless File.exist?(@@gem_version_file)
15
+ file = File.new(@@gem_version_file, 'r')
16
+ version = file.gets.chomp
17
+ raise "#{@@gem_version_file} file corrupt" unless (version && version =~ /^\d+\.\d+[\.\d+]+$/)
18
+ file.close
19
+ version
20
+ end
21
+
22
+ def self.init_version_file
23
+ file = File.new(@@gem_version_file, 'w')
24
+ file.puts '0.0.1'
25
+ file.close
26
+ end
27
+
28
+ def self.increment_version
29
+ version = self.next_version
30
+ components = version.split('.')
31
+ components.push((components.pop.to_i + 1).to_s)
32
+ new_version = components.join('.')
33
+ file = File.new(@@gem_version_file, 'w')
34
+ file.puts new_version
35
+ file.close
36
+ version
37
+ end
38
+
39
+ def self.commit_and_push(project_directory = nil, msg = nil)
40
+ g=Git.open(project_directory || Dir.pwd, :log=>Logger.new(STDOUT))
41
+ g.add(@@gem_version_file)
42
+ g.commit(msg || @@default_commit_message)
43
+ g.push
44
+ end
45
+ end
@@ -0,0 +1,59 @@
1
+ require 'lib/gem_version'
2
+
3
+ $gem_version_file = File.expand_path(File.dirname(__FILE__)) + '/next_gem_version'
4
+
5
+ describe "GemVersion" do
6
+ describe "next_version method" do
7
+ it "should create an initial 'next_gem_version' file with the version 0.0.1 if none exists" do
8
+ GemVersion.gem_version_file = $gem_version_file
9
+ File.delete($gem_version_file) if File.exists?($gem_version_file)
10
+ File.exists?($gem_version_file).should == false
11
+ GemVersion.next_version.should == '0.0.1'
12
+ File.exists?($gem_version_file).should == true
13
+ File.new($gem_version_file).gets.chomp.should == '0.0.1'
14
+ end
15
+ it "should return the 'next' version from the 'next_gem_version' file" do
16
+ GemVersion.gem_version_file = $gem_version_file
17
+ file = File.new($gem_version_file, 'w')
18
+ version = '111.222.333.444'
19
+ file.puts version
20
+ file.close
21
+ GemVersion.next_version.should == version
22
+ end
23
+ it "should raise exception if version value corrupted in file" do
24
+ GemVersion.gem_version_file = $gem_version_file
25
+ file = File.new($gem_version_file, 'w')
26
+ file.puts '.1.2.'
27
+ file.close
28
+ lambda { GemVersion.next_version }.should raise_exception(/corrupt/)
29
+ end
30
+ it "should raise exception if version value is nil (non-existent)" do
31
+ GemVersion.gem_version_file = $gem_version_file
32
+ File.delete($gem_version_file)
33
+ file = File.new($gem_version_file, 'w')
34
+ file.puts
35
+ file.close
36
+ lambda { GemVersion.next_version }.should raise_exception(/corrupt/)
37
+ end
38
+ end
39
+ describe "increment_version method" do
40
+ it "should increment and store the next version number" do
41
+ GemVersion.gem_version_file = $gem_version_file
42
+ File.delete($gem_version_file)
43
+ file = File.new($gem_version_file, 'w')
44
+ file.puts '1.2.3'
45
+ file.close
46
+ GemVersion.increment_version
47
+ file = File.new($gem_version_file, 'r')
48
+ file.gets.chomp.should == '1.2.4'
49
+ end
50
+ it "should return the 'next' version number" do
51
+ GemVersion.gem_version_file = $gem_version_file
52
+ File.delete($gem_version_file)
53
+ file = File.new($gem_version_file, 'w')
54
+ file.puts '1.2.5'
55
+ file.close
56
+ GemVersion.increment_version.should == '1.2.5'
57
+ end
58
+ end
59
+ end
@@ -0,0 +1 @@
1
+
data/spec/spec.opts ADDED
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem_version
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Jeff Patmon
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-28 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: git
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 5
31
+ version: 1.2.5
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Automated version management for your Gem builds
35
+ email: jpatmon@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - lib/gem_version.rb
44
+ - spec/next_gem_version
45
+ - spec/spec.opts
46
+ - spec/gem_version_spec.rb
47
+ - init.rb
48
+ - LICENSE
49
+ - Rakefile
50
+ - README.rdoc
51
+ - .gitignore
52
+ has_rdoc: true
53
+ homepage: http://github.com/jeffp/gem_version/tree/master
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 1
67
+ - 8
68
+ - 6
69
+ version: 1.8.6
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.3.6
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Never bother updating the version for your next gem build by hand. Configured in your Rakefile, gem_version provides the next Gem version and stores it to the repository.
84
+ test_files:
85
+ - spec/gem_version_spec.rb