hoe-version 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
data/.gemtest ADDED
File without changes
data/History.txt ADDED
@@ -0,0 +1,11 @@
1
+ === 1.0.0 / 2012-07-17
2
+
3
+ * 5 unknowns:
4
+
5
+ * Adds doco.
6
+ * Adds hoe-git plugin.
7
+ * Adds tests and updates readme.
8
+ * Initial commit.
9
+ * Updates history.
10
+
11
+
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ lib/hoe/version.rb
7
+ test/test_hoe_version.rb
data/README.txt ADDED
@@ -0,0 +1,55 @@
1
+ = hoe-version
2
+
3
+ * https://github.com/bhenderson/hoe-version
4
+
5
+ == DESCRIPTION:
6
+
7
+ Hoe plugin to provide rake tasks to bump version.
8
+
9
+ Supported by http://yp.com
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ * requires that your code set a VERSION constant.
14
+
15
+ == SYNOPSIS:
16
+
17
+ rake -T version
18
+
19
+ == INSTALL:
20
+
21
+ * gem install hoe-version
22
+
23
+ == DEVELOPERS:
24
+
25
+ After checking out the source, run:
26
+
27
+ $ rake newb
28
+
29
+ This task will install any missing dependencies, run the tests/specs,
30
+ and generate the RDoc.
31
+
32
+ == LICENSE:
33
+
34
+ (The MIT License)
35
+
36
+ Copyright (c) 2012 bhenderson
37
+
38
+ Permission is hereby granted, free of charge, to any person obtaining
39
+ a copy of this software and associated documentation files (the
40
+ 'Software'), to deal in the Software without restriction, including
41
+ without limitation the rights to use, copy, modify, merge, publish,
42
+ distribute, sublicense, and/or sell copies of the Software, and to
43
+ permit persons to whom the Software is furnished to do so, subject to
44
+ the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be
47
+ included in all copies or substantial portions of the Software.
48
+
49
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
50
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
52
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
53
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
54
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
55
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ $:.unshift 'lib'
6
+
7
+ Hoe.plugin :version
8
+ Hoe.plugin :git
9
+
10
+ Hoe.spec 'hoe-version' do
11
+ developer('bhenderson', 'henderson.bj@gmail.com')
12
+
13
+ # self.rubyforge_name = 'hoe-versionx' # if different than 'hoe-version'
14
+ end
15
+
16
+ # vim: syntax=ruby
@@ -0,0 +1,81 @@
1
+ ##
2
+ # Version plugin for hoe.
3
+ #
4
+ # === Tasks Provided:
5
+ #
6
+ # version:: Print the current version.
7
+ # version:write:: Writes out new version.
8
+ # version:bump:: Writes out version, bumping to next minor release.
9
+ # version:bump:major:: Writes out version, bumping to next major release.
10
+ # version:bump:patch:: Writes out version, bumping to next patch level release.
11
+ #
12
+ module Hoe::Version
13
+ VERSION = '1.0.0'
14
+
15
+ def define_version_tasks
16
+ desc 'print current version'
17
+ task 'version' do
18
+ puts version
19
+ end
20
+
21
+ desc 'write version. VERSION=x.y.z'
22
+ task 'version:write' do
23
+ vers = ENV['VERSION'] or fail 'VERSION=x.y.z is required.'
24
+ fail "unable to increment version to #{vers}" unless
25
+ update_version vers
26
+ end
27
+
28
+ desc 'bump minor version.'
29
+ task 'version:bump' do
30
+ increment [0, 1, nil]
31
+ task('version:write').invoke
32
+ end
33
+
34
+ desc 'bump major version'
35
+ task 'version:bump:major' do
36
+ increment [1, nil, nil]
37
+ task('version:write').invoke
38
+ end
39
+
40
+ # alias
41
+ task 'version:bump:minor' => 'version:bump'
42
+
43
+ desc 'bump patch version'
44
+ task 'version:bump:patch' do
45
+ increment [0, 0, 1]
46
+ task('version:write').invoke
47
+ end
48
+ end
49
+
50
+ def increment mask
51
+ segments = version.split('.')[0,3].map!{|p| p.to_i}
52
+
53
+ mask.each_with_index do |m, i|
54
+ case m
55
+ when nil
56
+ segments[i] = 0
57
+ else
58
+ segments[i] += m
59
+ end
60
+ end
61
+
62
+ ENV['VERSION'] = segments.join '.'
63
+ end
64
+
65
+ def update_version vers
66
+ # copied from hoe
67
+ version_re = /VERSION += +([\"\'])(#{version})\1/
68
+
69
+ spec.files.each do |file|
70
+ next unless File.exist? file
71
+ data = File.read_utf(file) rescue nil
72
+ if data and data[version_re, 2] &&= vers
73
+ #File.write(file, data)
74
+ File.open(file, 'w'){|f| f.write data}
75
+ return true
76
+ end
77
+ end
78
+
79
+ false
80
+ end
81
+ end
@@ -0,0 +1,67 @@
1
+ require "minitest/autorun"
2
+ require 'hoe'
3
+ require "hoe/version"
4
+ require 'tempfile'
5
+
6
+ class TestHoe; end
7
+
8
+ class TestHoe::TestVersion < MiniTest::Unit::TestCase
9
+ include Hoe::Version
10
+
11
+ def setup
12
+ @version = '1.1.1'
13
+ @files = []
14
+ @spec = MiniTest::Mock.new
15
+ @spec.expect(:files, @files)
16
+ end
17
+
18
+ def test_increment_minor
19
+ v = increment [0,1,nil]
20
+ assert_equal '1.2.0', v
21
+ end
22
+
23
+ def test_increment_major
24
+ v = increment [1,nil,nil]
25
+ assert_equal '2.0.0', v
26
+ end
27
+
28
+ def test_increment_patch
29
+ v = increment [0,0,1]
30
+ assert_equal '1.1.2', v
31
+ end
32
+
33
+ def test_update_version
34
+ expected = ["def nothing() 'No version here' end\n",
35
+ "class Blah\n VERSION = '1.1.1'\nend\n"]
36
+
37
+ with_mock_files *expected do
38
+ update_version '3.2.1'
39
+
40
+ assert_equal expected[0], File.read(@files[0])
41
+ expected[1].gsub! '1.1.1', '3.2.1'
42
+ assert_equal expected[1], File.read(@files[1])
43
+ end
44
+ end
45
+
46
+ def test_update_version_false
47
+ refute update_version 'vers'
48
+ end
49
+
50
+ def with_mock_files no_vers, with_vers
51
+ Tempfile.open('no_vers') do |f1|
52
+ f1.write no_vers
53
+ f1.rewind
54
+ @files << f1.path
55
+ Tempfile.open('with_vers') do |f2|
56
+ f2.write with_vers
57
+ f2.rewind
58
+ @files << f2.path
59
+
60
+ yield
61
+ end
62
+ end
63
+ end
64
+
65
+ def spec() @spec end
66
+ def version() @version end
67
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hoe-version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - bhenderson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.10'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.10'
30
+ - !ruby/object:Gem::Dependency
31
+ name: hoe
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ description: ! 'Hoe plugin to provide rake tasks to bump version.
47
+
48
+
49
+ Supported by http://yp.com'
50
+ email:
51
+ - henderson.bj@gmail.com
52
+ executables: []
53
+ extensions: []
54
+ extra_rdoc_files:
55
+ - History.txt
56
+ - Manifest.txt
57
+ - README.txt
58
+ files:
59
+ - .autotest
60
+ - History.txt
61
+ - Manifest.txt
62
+ - README.txt
63
+ - Rakefile
64
+ - lib/hoe/version.rb
65
+ - test/test_hoe_version.rb
66
+ - .gemtest
67
+ homepage: https://github.com/bhenderson/hoe-version
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --main
72
+ - README.txt
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project: hoe-version
89
+ rubygems_version: 1.8.24
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Hoe plugin to provide rake tasks to bump version
93
+ test_files:
94
+ - test/test_hoe_version.rb