jeweler_style_versioning 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/jeweler_style_versioning.gemspec +67 -0
- data/lib/jeweler_style_versioning/commands/version/base.rb +55 -0
- data/lib/jeweler_style_versioning/commands/version/bump_major.rb +13 -0
- data/lib/jeweler_style_versioning/commands/version/bump_minor.rb +12 -0
- data/lib/jeweler_style_versioning/commands/version/bump_patch.rb +14 -0
- data/lib/jeweler_style_versioning/commands/version/write.rb +12 -0
- data/lib/jeweler_style_versioning/tasks.rb +94 -0
- data/lib/jeweler_style_versioning/version_helper.rb +141 -0
- data/lib/jeweler_style_versioning.rb +68 -0
- data/spec/jeweler_style_versioning_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +147 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.3.0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.6.4"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rake (0.9.2.2)
|
11
|
+
rcov (1.0.0)
|
12
|
+
rspec (2.3.0)
|
13
|
+
rspec-core (~> 2.3.0)
|
14
|
+
rspec-expectations (~> 2.3.0)
|
15
|
+
rspec-mocks (~> 2.3.0)
|
16
|
+
rspec-core (2.3.1)
|
17
|
+
rspec-expectations (2.3.0)
|
18
|
+
diff-lcs (~> 1.1.2)
|
19
|
+
rspec-mocks (2.3.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
bundler (~> 1.0.0)
|
26
|
+
jeweler (~> 1.6.4)
|
27
|
+
rcov
|
28
|
+
rspec (~> 2.3.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 jeremiahishere
|
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,19 @@
|
|
1
|
+
= jeweler_style_versioning
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to jeweler_style_versioning
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* 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.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 jeremiahishere. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "jeweler_style_versioning"
|
18
|
+
gem.homepage = "http://github.com/jeremiahishere/jeweler_style_versioning"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Ripped out the versioning rake tasks from jeweler}
|
21
|
+
gem.description = %Q{Ripped out the versioning rake tasks from jeweler}
|
22
|
+
gem.email = "jeremiah@cloudspace.com"
|
23
|
+
gem.authors = ["jeremiahishere"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "jeweler_style_versioning #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{jeweler_style_versioning}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["jeremiahishere"]
|
12
|
+
s.date = %q{2012-03-25}
|
13
|
+
s.description = %q{Ripped out the versioning rake tasks from jeweler}
|
14
|
+
s.email = %q{jeremiah@cloudspace.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"jeweler_style_versioning.gemspec",
|
29
|
+
"lib/jeweler_style_versioning.rb",
|
30
|
+
"lib/jeweler_style_versioning/commands/version/base.rb",
|
31
|
+
"lib/jeweler_style_versioning/commands/version/bump_major.rb",
|
32
|
+
"lib/jeweler_style_versioning/commands/version/bump_minor.rb",
|
33
|
+
"lib/jeweler_style_versioning/commands/version/bump_patch.rb",
|
34
|
+
"lib/jeweler_style_versioning/commands/version/write.rb",
|
35
|
+
"lib/jeweler_style_versioning/tasks.rb",
|
36
|
+
"lib/jeweler_style_versioning/version_helper.rb",
|
37
|
+
"spec/jeweler_style_versioning_spec.rb",
|
38
|
+
"spec/spec_helper.rb"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/jeremiahishere/jeweler_style_versioning}
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = %q{1.5.0}
|
44
|
+
s.summary = %q{Ripped out the versioning rake tasks from jeweler}
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
51
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
52
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
53
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
64
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
module Commands
|
5
|
+
module Version
|
6
|
+
class Base
|
7
|
+
|
8
|
+
attr_accessor :repo, :version_helper, :gemspec, :commit, :base_dir
|
9
|
+
|
10
|
+
def run
|
11
|
+
update_version
|
12
|
+
|
13
|
+
self.version_helper.write
|
14
|
+
self.gemspec.version = self.version_helper.to_s
|
15
|
+
|
16
|
+
commit_version if self.repo && self.commit
|
17
|
+
end
|
18
|
+
|
19
|
+
def update_version
|
20
|
+
raise "Subclasses should implement this"
|
21
|
+
end
|
22
|
+
|
23
|
+
def commit_version
|
24
|
+
if self.repo
|
25
|
+
self.repo.add(working_subdir.join(version_helper.path))
|
26
|
+
self.repo.commit("Version bump to #{self.version_helper.to_s}")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def working_subdir
|
31
|
+
return @working_subdir if @working_subdir
|
32
|
+
cwd = base_dir_path
|
33
|
+
@working_subdir = cwd.relative_path_from(Pathname.new(repo.dir.path))
|
34
|
+
@working_subdir
|
35
|
+
end
|
36
|
+
|
37
|
+
def base_dir_path
|
38
|
+
Pathname.new(base_dir).realpath
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def self.build_for(jeweler)
|
43
|
+
command = new
|
44
|
+
command.repo = jeweler.repo
|
45
|
+
command.version_helper = jeweler.version_helper
|
46
|
+
command.gemspec = jeweler.gemspec
|
47
|
+
command.commit = jeweler.commit
|
48
|
+
command.base_dir = jeweler.base_dir
|
49
|
+
|
50
|
+
command
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
# Clean up after gem building
|
5
|
+
require 'rake/clean'
|
6
|
+
CLEAN.include('pkg/*.gem')
|
7
|
+
|
8
|
+
class Rake::Application
|
9
|
+
attr_accessor :jeweler_style_versioning_tasks
|
10
|
+
|
11
|
+
# The jeweler instance that has be instantiated in the current Rakefile.
|
12
|
+
#
|
13
|
+
# This is usually useful if you want to get at info like version from other files.
|
14
|
+
def jeweler_style_versioning
|
15
|
+
jeweler_style_versioning_tasks.jeweler_style_versioning
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class JewelerStyleVersioning
|
20
|
+
# Rake tasks for managing your gem.
|
21
|
+
#
|
22
|
+
# Here's a basic usage example:
|
23
|
+
#
|
24
|
+
# Jeweler::Tasks.new do |gem|
|
25
|
+
# gem.name = "jeweler"
|
26
|
+
# gem.summary = "Simple and opinionated helper for creating RubyGem projects on GitHub"
|
27
|
+
# gem.email = "josh@technicalpickles.com"
|
28
|
+
# gem.homepage = "http://github.com/technicalpickles/jeweler"
|
29
|
+
# gem.description = "Simple and opinionated helper for creating RubyGem projects on GitHub"
|
30
|
+
# gem.authors = ["Josh Nichols"]
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# The block variable gem is actually a Gem::Specification, so you can
|
34
|
+
# do anything you would normally do with a Gem::Specification.
|
35
|
+
# For more details, see the official gemspec reference:
|
36
|
+
# http://docs.rubygems.org/read/chapter/20
|
37
|
+
#
|
38
|
+
# In addition, it provides reasonable defaults for several values. See Jeweler::Specification for more details.
|
39
|
+
class Tasks < ::Rake::TaskLib
|
40
|
+
attr_accessor :gemspec, :jeweler_style_versioning, :gemspec_building_block
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
Rake.application.jeweler_style_versioning_tasks = self
|
44
|
+
define
|
45
|
+
end
|
46
|
+
|
47
|
+
def jeweler_style_versioning
|
48
|
+
if @jeweler_style_versioning.nil?
|
49
|
+
@jeweler_style_versioning = JewelerStyleVersioning.new
|
50
|
+
end
|
51
|
+
@jeweler_style_versioning
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def define
|
57
|
+
task :version_required do
|
58
|
+
if jeweler_style_versioning.expects_version_file? && !jeweler_style_versioning.version_file_exists?
|
59
|
+
abort "Expected VERSION or VERSION.yml to exist. Use 'rake version:write' to create an initial one."
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
namespace :version do
|
65
|
+
desc "Writes out an explicit version. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH. Also recognizes BUILD, which defaults to nil"
|
66
|
+
task :write do
|
67
|
+
major, minor, patch, build = ENV['MAJOR'].to_i, ENV['MINOR'].to_i, ENV['PATCH'].to_i, (ENV['BUILD'] || nil )
|
68
|
+
jeweler_style_versioning.write_version(major, minor, patch, build, :announce => false, :commit => false)
|
69
|
+
$stdout.puts "Updated version: #{jeweler_style_versioning.version}"
|
70
|
+
end
|
71
|
+
|
72
|
+
namespace :bump do
|
73
|
+
desc "Bump the major version by 1"
|
74
|
+
task :major => [:version_required, :version] do
|
75
|
+
jeweler_style_versioning.bump_major_version
|
76
|
+
$stdout.puts "Updated version: #{jeweler_style_versioning.version}"
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Bump the a minor version by 1"
|
80
|
+
task :minor => [:version_required, :version] do
|
81
|
+
jeweler_style_versioning.bump_minor_version
|
82
|
+
$stdout.puts "Updated version: #{jeweler_style_versioning.version}"
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "Bump the patch version by 1"
|
86
|
+
task :patch => [:version_required, :version] do
|
87
|
+
jeweler_style_versioning.bump_patch_version
|
88
|
+
$stdout.puts "Updated version: #{jeweler_style_versioning.version}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
begin
|
2
|
+
require 'psych'
|
3
|
+
rescue ::LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
class Jeweler
|
9
|
+
class VersionHelper
|
10
|
+
attr_accessor :base_dir
|
11
|
+
attr_reader :major, :minor, :patch, :build
|
12
|
+
|
13
|
+
module YamlExtension
|
14
|
+
def write
|
15
|
+
File.open(yaml_path, 'w+') do |f|
|
16
|
+
YAML.dump(self.to_hash, f)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_hash
|
21
|
+
{
|
22
|
+
:major => major,
|
23
|
+
:minor => minor,
|
24
|
+
:patch => patch,
|
25
|
+
:build => build
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def refresh
|
30
|
+
parse_yaml
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse_yaml
|
34
|
+
yaml = read_yaml
|
35
|
+
@major = (yaml['major'] || yaml[:major]).to_i
|
36
|
+
@minor = (yaml['minor'] || yaml[:minor]).to_i
|
37
|
+
@patch = (yaml['patch'] || yaml[:patch]).to_i
|
38
|
+
@build = (yaml['build'] || yaml[:build])
|
39
|
+
end
|
40
|
+
|
41
|
+
def read_yaml
|
42
|
+
if File.exists?(yaml_path)
|
43
|
+
YAML.load_file(yaml_path)
|
44
|
+
else
|
45
|
+
raise VersionYmlError, "#{yaml_path} does not exist!"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def path
|
50
|
+
yaml_path
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
module PlaintextExtension
|
55
|
+
def write
|
56
|
+
File.open(plaintext_path, 'w') do |file|
|
57
|
+
file.write to_s
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def parse_plaintext
|
62
|
+
plaintext = read_plaintext.chomp
|
63
|
+
# http://rubular.com/regexes/10467 -> 3.5.4.a1
|
64
|
+
# http://rubular.com/regexes/10468 -> 3.5.4
|
65
|
+
if plaintext =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
|
66
|
+
@major = $1.to_i
|
67
|
+
@minor = $2.to_i
|
68
|
+
@patch = $3.to_i
|
69
|
+
@build = $4
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def read_plaintext
|
74
|
+
File.read(plaintext_path)
|
75
|
+
end
|
76
|
+
|
77
|
+
def refresh
|
78
|
+
parse_plaintext
|
79
|
+
end
|
80
|
+
|
81
|
+
def path
|
82
|
+
plaintext_path
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def initialize(base_dir)
|
87
|
+
self.base_dir = base_dir
|
88
|
+
|
89
|
+
if File.exists?(yaml_path)
|
90
|
+
extend YamlExtension
|
91
|
+
parse_yaml
|
92
|
+
else
|
93
|
+
extend PlaintextExtension
|
94
|
+
if File.exists?(plaintext_path)
|
95
|
+
parse_plaintext
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def bump_major
|
101
|
+
@major += 1
|
102
|
+
@minor = 0
|
103
|
+
@patch = 0
|
104
|
+
@build = nil
|
105
|
+
end
|
106
|
+
|
107
|
+
def bump_minor
|
108
|
+
@minor += 1
|
109
|
+
@patch = 0
|
110
|
+
@build = nil
|
111
|
+
end
|
112
|
+
|
113
|
+
def bump_patch
|
114
|
+
@patch += 1
|
115
|
+
@build = nil
|
116
|
+
end
|
117
|
+
|
118
|
+
def update_to(major, minor, patch, build=nil)
|
119
|
+
@major = major
|
120
|
+
@minor = minor
|
121
|
+
@patch = patch
|
122
|
+
@build = build
|
123
|
+
end
|
124
|
+
|
125
|
+
def to_s
|
126
|
+
[major, minor, patch, build].compact.join('.')
|
127
|
+
end
|
128
|
+
|
129
|
+
def yaml_path
|
130
|
+
denormalized_path = File.join(@base_dir, 'VERSION.yml')
|
131
|
+
absolute_path = File.expand_path(denormalized_path)
|
132
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
133
|
+
end
|
134
|
+
|
135
|
+
def plaintext_path
|
136
|
+
denormalized_path = File.join(@base_dir, 'VERSION')
|
137
|
+
absolute_path = File.expand_path(denormalized_path)
|
138
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class JewelerStyleVersioning
|
2
|
+
autoload :VersionHelper, 'jeweler_style_versioning/version_helper'
|
3
|
+
|
4
|
+
attr_reader :version_helper
|
5
|
+
|
6
|
+
def initialize(base_dir = ".")
|
7
|
+
@version_helper = Jeweler::VersionHelper.new(base_dir)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Major version, as defined by the gemspec's Version module.
|
11
|
+
# For 1.5.3, this would return 1.
|
12
|
+
def major_version
|
13
|
+
@version_helper.major
|
14
|
+
end
|
15
|
+
|
16
|
+
# Minor version, as defined by the gemspec's Version module.
|
17
|
+
# For 1.5.3, this would return 5.
|
18
|
+
def minor_version
|
19
|
+
@version_helper.minor
|
20
|
+
end
|
21
|
+
|
22
|
+
# Patch version, as defined by the gemspec's Version module.
|
23
|
+
# For 1.5.3, this would return 5.
|
24
|
+
def patch_version
|
25
|
+
@version_helper.patch
|
26
|
+
end
|
27
|
+
|
28
|
+
# Human readable version, which is used in the gemspec.
|
29
|
+
def version
|
30
|
+
@version_helper.to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
# Bumps the patch version.
|
34
|
+
#
|
35
|
+
# 1.5.1 -> 1.5.2
|
36
|
+
def bump_patch_version()
|
37
|
+
Jeweler::Commands::Version::BumpPatch.build_for(self).run
|
38
|
+
end
|
39
|
+
|
40
|
+
# Bumps the minor version.
|
41
|
+
#
|
42
|
+
# 1.5.1 -> 1.6.0
|
43
|
+
def bump_minor_version()
|
44
|
+
Jeweler::Commands::Version::BumpMinor.build_for(self).run
|
45
|
+
end
|
46
|
+
|
47
|
+
# Bumps the major version.
|
48
|
+
#
|
49
|
+
# 1.5.1 -> 2.0.0
|
50
|
+
def bump_major_version()
|
51
|
+
Jeweler::Commands::Version::BumpMajor.build_for(self).run
|
52
|
+
end
|
53
|
+
|
54
|
+
# Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
|
55
|
+
def write_version(major, minor, patch, build, options = {})
|
56
|
+
command = Jeweler::Commands::Version::Write.build_for(self)
|
57
|
+
command.major = major
|
58
|
+
command.minor = minor
|
59
|
+
command.patch = patch
|
60
|
+
command.build = build
|
61
|
+
|
62
|
+
command.run
|
63
|
+
end
|
64
|
+
|
65
|
+
def version_file_exists?
|
66
|
+
File.exists?(@version_helper.plaintext_path) || File.exists?(@version_helper.yaml_path)
|
67
|
+
end
|
68
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'jeweler_style_versioning'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jeweler_style_versioning
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 0.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- jeremiahishere
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-03-25 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 3
|
32
|
+
- 0
|
33
|
+
version: 2.3.0
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
requirement: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: bundler
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 23
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 0
|
48
|
+
- 0
|
49
|
+
version: 1.0.0
|
50
|
+
prerelease: false
|
51
|
+
type: :development
|
52
|
+
requirement: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: jeweler
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 7
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 6
|
64
|
+
- 4
|
65
|
+
version: 1.6.4
|
66
|
+
prerelease: false
|
67
|
+
type: :development
|
68
|
+
requirement: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rcov
|
71
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
prerelease: false
|
81
|
+
type: :development
|
82
|
+
requirement: *id004
|
83
|
+
description: Ripped out the versioning rake tasks from jeweler
|
84
|
+
email: jeremiah@cloudspace.com
|
85
|
+
executables: []
|
86
|
+
|
87
|
+
extensions: []
|
88
|
+
|
89
|
+
extra_rdoc_files:
|
90
|
+
- LICENSE.txt
|
91
|
+
- README.rdoc
|
92
|
+
files:
|
93
|
+
- .document
|
94
|
+
- .rspec
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.rdoc
|
99
|
+
- Rakefile
|
100
|
+
- VERSION
|
101
|
+
- jeweler_style_versioning.gemspec
|
102
|
+
- lib/jeweler_style_versioning.rb
|
103
|
+
- lib/jeweler_style_versioning/commands/version/base.rb
|
104
|
+
- lib/jeweler_style_versioning/commands/version/bump_major.rb
|
105
|
+
- lib/jeweler_style_versioning/commands/version/bump_minor.rb
|
106
|
+
- lib/jeweler_style_versioning/commands/version/bump_patch.rb
|
107
|
+
- lib/jeweler_style_versioning/commands/version/write.rb
|
108
|
+
- lib/jeweler_style_versioning/tasks.rb
|
109
|
+
- lib/jeweler_style_versioning/version_helper.rb
|
110
|
+
- spec/jeweler_style_versioning_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
has_rdoc: true
|
113
|
+
homepage: http://github.com/jeremiahishere/jeweler_style_versioning
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
129
|
+
version: "0"
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
version: "0"
|
139
|
+
requirements: []
|
140
|
+
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 1.5.0
|
143
|
+
signing_key:
|
144
|
+
specification_version: 3
|
145
|
+
summary: Ripped out the versioning rake tasks from jeweler
|
146
|
+
test_files: []
|
147
|
+
|