monkeyhelper-jeweler 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/ChangeLog.markdown +83 -0
- data/LICENSE +20 -0
- data/README.markdown +170 -0
- data/ROADMAP +12 -0
- data/Rakefile +106 -0
- data/VERSION.yml +4 -0
- data/bin/jeweler +8 -0
- data/features/generator/cucumber.feature +83 -0
- data/features/generator/directory_layout.feature +76 -0
- data/features/generator/dotdocument.feature +14 -0
- data/features/generator/env_options.feature +9 -0
- data/features/generator/git.feature +94 -0
- data/features/generator/license.feature +11 -0
- data/features/generator/rakefile.feature +110 -0
- data/features/generator/readme.feature +12 -0
- data/features/generator/test.feature +41 -0
- data/features/generator/test_helper.feature +49 -0
- data/features/placeholder.feature +5 -0
- data/features/step_definitions/debug_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +65 -0
- data/features/step_definitions/generator_steps.rb +251 -0
- data/features/step_definitions/task_steps.rb +6 -0
- data/features/support/env.rb +19 -0
- data/features/tasks/build_gem.feature +9 -0
- data/features/tasks/version.feature +24 -0
- data/features/tasks/version_bumping.feature +33 -0
- data/jeweler.gemspec +204 -0
- data/lib/jeweler.rb +142 -0
- data/lib/jeweler/commands.rb +12 -0
- data/lib/jeweler/commands/build_gem.rb +31 -0
- data/lib/jeweler/commands/install_gem.rb +26 -0
- data/lib/jeweler/commands/release.rb +83 -0
- data/lib/jeweler/commands/release_to_rubyforge.rb +51 -0
- data/lib/jeweler/commands/setup_rubyforge.rb +38 -0
- data/lib/jeweler/commands/validate_gemspec.rb +30 -0
- data/lib/jeweler/commands/version/base.rb +41 -0
- data/lib/jeweler/commands/version/bump_major.rb +13 -0
- data/lib/jeweler/commands/version/bump_minor.rb +12 -0
- data/lib/jeweler/commands/version/bump_patch.rb +14 -0
- data/lib/jeweler/commands/version/write.rb +12 -0
- data/lib/jeweler/commands/write_gemspec.rb +39 -0
- data/lib/jeweler/errors.rb +20 -0
- data/lib/jeweler/gemspec_helper.rb +76 -0
- data/lib/jeweler/generator.rb +284 -0
- data/lib/jeweler/generator/application.rb +54 -0
- data/lib/jeweler/generator/bacon_mixin.rb +39 -0
- data/lib/jeweler/generator/micronaut_mixin.rb +38 -0
- data/lib/jeweler/generator/minitest_mixin.rb +39 -0
- data/lib/jeweler/generator/options.rb +77 -0
- data/lib/jeweler/generator/rspec_mixin.rb +39 -0
- data/lib/jeweler/generator/shoulda_mixin.rb +39 -0
- data/lib/jeweler/generator/testunit_mixin.rb +39 -0
- data/lib/jeweler/rubyforge_tasks.rb +46 -0
- data/lib/jeweler/specification.rb +67 -0
- data/lib/jeweler/tasks.rb +124 -0
- data/lib/jeweler/templates/.document +5 -0
- data/lib/jeweler/templates/.gitignore +5 -0
- data/lib/jeweler/templates/LICENSE +20 -0
- data/lib/jeweler/templates/README.rdoc +7 -0
- data/lib/jeweler/templates/Rakefile +102 -0
- data/lib/jeweler/templates/bacon/flunking.rb +7 -0
- data/lib/jeweler/templates/bacon/helper.rb +8 -0
- data/lib/jeweler/templates/features/default.feature +9 -0
- data/lib/jeweler/templates/features/support/env.rb +8 -0
- data/lib/jeweler/templates/micronaut/flunking.rb +7 -0
- data/lib/jeweler/templates/micronaut/helper.rb +17 -0
- data/lib/jeweler/templates/minitest/flunking.rb +7 -0
- data/lib/jeweler/templates/minitest/helper.rb +11 -0
- data/lib/jeweler/templates/rspec/flunking.rb +7 -0
- data/lib/jeweler/templates/rspec/helper.rb +9 -0
- data/lib/jeweler/templates/shoulda/flunking.rb +7 -0
- data/lib/jeweler/templates/shoulda/helper.rb +10 -0
- data/lib/jeweler/templates/testunit/flunking.rb +7 -0
- data/lib/jeweler/templates/testunit/helper.rb +9 -0
- data/lib/jeweler/version_helper.rb +128 -0
- data/test/fixtures/bar/VERSION.yml +4 -0
- data/test/fixtures/bar/bin/foo_the_ultimate_bin +1 -0
- data/test/fixtures/bar/hey_include_me_in_gemspec +0 -0
- data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/.document +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-plaintext/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version-plaintext/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version-plaintext/VERSION +1 -0
- data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-plaintext/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-plaintext/test/test_helper.rb +10 -0
- data/test/fixtures/existing-project-with-version-yaml/.document +5 -0
- data/test/fixtures/existing-project-with-version-yaml/.gitignore +5 -0
- data/test/fixtures/existing-project-with-version-yaml/LICENSE +20 -0
- data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +82 -0
- data/test/fixtures/existing-project-with-version-yaml/VERSION.yml +4 -0
- data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +29 -0
- data/test/fixtures/existing-project-with-version-yaml/lib/existing_project_with_version.rb +0 -0
- data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +7 -0
- data/test/fixtures/existing-project-with-version-yaml/test/test_helper.rb +10 -0
- data/test/geminstaller.yml +12 -0
- data/test/jeweler/commands/test_build_gem.rb +72 -0
- data/test/jeweler/commands/test_install_gem.rb +21 -0
- data/test/jeweler/commands/test_release.rb +405 -0
- data/test/jeweler/commands/test_release_to_rubyforge.rb +157 -0
- data/test/jeweler/commands/test_setup_rubyforge.rb +88 -0
- data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
- data/test/jeweler/commands/test_write_gemspec.rb +92 -0
- data/test/jeweler/commands/version/test_base.rb +32 -0
- data/test/jeweler/commands/version/test_bump_major.rb +22 -0
- data/test/jeweler/commands/version/test_bump_minor.rb +19 -0
- data/test/jeweler/commands/version/test_bump_patch.rb +20 -0
- data/test/jeweler/commands/version/test_write.rb +23 -0
- data/test/shoulda_macros/jeweler_macros.rb +35 -0
- data/test/test_application.rb +139 -0
- data/test/test_gemspec_helper.rb +40 -0
- data/test/test_generator.rb +154 -0
- data/test/test_generator_initialization.rb +113 -0
- data/test/test_generator_mixins.rb +18 -0
- data/test/test_helper.rb +133 -0
- data/test/test_jeweler.rb +174 -0
- data/test/test_options.rb +116 -0
- data/test/test_specification.rb +61 -0
- data/test/test_tasks.rb +51 -0
- data/test/test_version_helper.rb +153 -0
- metadata +228 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
class Rake::Application
|
5
|
+
attr_accessor :jeweler
|
6
|
+
end
|
7
|
+
|
8
|
+
class Jeweler
|
9
|
+
class Tasks < ::Rake::TaskLib
|
10
|
+
attr_accessor :gemspec, :jeweler
|
11
|
+
|
12
|
+
def initialize(gemspec = nil, &block)
|
13
|
+
@gemspec = gemspec || Gem::Specification.new
|
14
|
+
@jeweler = Jeweler.new(@gemspec)
|
15
|
+
yield @gemspec if block_given?
|
16
|
+
|
17
|
+
Rake.application.jeweler = @jeweler
|
18
|
+
define
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def define
|
23
|
+
desc "Setup initial version of 0.0.0"
|
24
|
+
task :version_required do
|
25
|
+
unless jeweler.version_exists?
|
26
|
+
abort "Expected VERSION or VERSION.yml to exist. See version:write to create an initial one."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Build gem"
|
31
|
+
task :build do
|
32
|
+
jeweler.build_gem
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Install gem using sudo"
|
36
|
+
task :install => :build do
|
37
|
+
jeweler.install_gem
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Generate and validates gemspec"
|
41
|
+
task :gemspec => ['gemspec:generate', 'gemspec:validate']
|
42
|
+
|
43
|
+
namespace :gemspec do
|
44
|
+
desc "Validates the gemspec"
|
45
|
+
task :validate => :version_required do
|
46
|
+
jeweler.validate_gemspec
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Generates the gemspec, using version from VERSION"
|
50
|
+
task :generate => :version_required do
|
51
|
+
jeweler.write_gemspec
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Displays the current version"
|
56
|
+
task :version => :version_required do
|
57
|
+
$stdout.puts "Current version: #{jeweler.version}"
|
58
|
+
end
|
59
|
+
|
60
|
+
namespace :version do
|
61
|
+
desc "Writes out an explicit version. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH"
|
62
|
+
task :write do
|
63
|
+
major, minor, patch = ENV['MAJOR'].to_i, ENV['MINOR'].to_i, ENV['PATCH'].to_i
|
64
|
+
jeweler.write_version(major, minor, patch, :announce => false, :commit => false)
|
65
|
+
$stdout.puts "Updated version: #{jeweler.version}"
|
66
|
+
end
|
67
|
+
|
68
|
+
namespace :bump do
|
69
|
+
desc "Bump the gemspec by a major version."
|
70
|
+
task :major => [:version_required, :version] do
|
71
|
+
jeweler.bump_major_version
|
72
|
+
$stdout.puts "Updated version: #{jeweler.version}"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Bump the gemspec by a minor version."
|
76
|
+
task :minor => [:version_required, :version] do
|
77
|
+
jeweler.bump_minor_version
|
78
|
+
$stdout.puts "Updated version: #{jeweler.version}"
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Bump the gemspec by a patch version."
|
82
|
+
task :patch => [:version_required, :version] do
|
83
|
+
jeweler.bump_patch_version
|
84
|
+
$stdout.puts "Updated version: #{jeweler.version}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Release the current version. Includes updating the gemspec, pushing, and tagging the release"
|
90
|
+
task :release do
|
91
|
+
jeweler.release
|
92
|
+
end
|
93
|
+
|
94
|
+
namespace :rubyforge do
|
95
|
+
namespace :release do
|
96
|
+
desc "Release the current gem version to RubyForge."
|
97
|
+
task :gem => [:gemspec, :build] do
|
98
|
+
begin
|
99
|
+
jeweler.release_gem_to_rubyforge
|
100
|
+
rescue NoRubyForgeProjectInGemspecError => e
|
101
|
+
abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
|
102
|
+
rescue MissingRubyForgePackageError => e
|
103
|
+
abort "Rubyforge reported that the #{e.message} package isn't setup. Run rake rubyforge:setup to do so."
|
104
|
+
rescue RubyForgeProjectNotConfiguredError => e
|
105
|
+
abort "RubyForge reported that #{e.message} wasn't configured. This means you need to run 'rubyforge setup', 'rubyforge login', and 'rubyforge configure', or maybe the project doesn't exist on RubyForge"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
desc "Setup a rubyforge project for this gem"
|
111
|
+
task :setup do
|
112
|
+
begin
|
113
|
+
jeweler.setup_rubyforge
|
114
|
+
rescue NoRubyForgeProjectInGemspecError => e
|
115
|
+
abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
|
116
|
+
rescue RubyForgeProjectNotConfiguredError => e
|
117
|
+
abort "The RubyForge reported that #{e.message} wasn't configured. This means you need to run 'rubyforge setup', 'rubyforge login', and 'rubyforge configure', or maybe the project doesn't exist on RubyForge"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 <%= user_name %>
|
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.
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "<%= project_name %>"
|
8
|
+
gem.summary = %Q{<%= summary %>}
|
9
|
+
gem.email = "<%= user_email %>"
|
10
|
+
gem.homepage = "<%= project_homepage %>"
|
11
|
+
gem.authors = ["<%= user_name %>"]
|
12
|
+
<% if should_setup_rubyforge %>
|
13
|
+
gem.rubyforge_project = "<%= project_name %>"
|
14
|
+
<% end %>
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
|
18
|
+
<% if should_setup_rubyforge %>
|
19
|
+
Jeweler::RubyforgeTasks.new
|
20
|
+
<% end %>
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
<% case testing_framework %>
|
26
|
+
<% when :rspec %>
|
27
|
+
require 'spec/rake/spectask'
|
28
|
+
Spec::Rake::SpecTask.new(:<%= test_task %>) do |<%= test_task %>|
|
29
|
+
<%= test_task %>.libs << 'lib' << '<%= test_dir %>'
|
30
|
+
<%= test_task %>.spec_files = FileList['<%= test_pattern %>']
|
31
|
+
end
|
32
|
+
<% when :micronaut %>
|
33
|
+
require 'micronaut/rake_task'
|
34
|
+
Micronaut::RakeTask.new(<%= test_task %>) do |<%= test_task %>|
|
35
|
+
<%= test_task %>.pattern = '<%= test_pattern %>'
|
36
|
+
<%= test_task %>.ruby_opts << '-Ilib -I<%= test_dir %>'
|
37
|
+
end
|
38
|
+
<% else %>
|
39
|
+
require 'rake/testtask'
|
40
|
+
Rake::TestTask.new(:<%= test_task %>) do |<%= test_task %>|
|
41
|
+
<%= test_task %>.libs << 'lib' << '<%= test_dir %>'
|
42
|
+
<%= test_task %>.pattern = '<%= test_pattern %>'
|
43
|
+
<%= test_task %>.verbose = true
|
44
|
+
end
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<% case testing_framework %>
|
48
|
+
<% when :rspec %>
|
49
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
50
|
+
spec.libs << 'lib' << 'spec'
|
51
|
+
spec.pattern = '<%= test_pattern %>'
|
52
|
+
spec.rcov = true
|
53
|
+
end
|
54
|
+
<% when :micronaut %>
|
55
|
+
Micronaut::RakeTask.new(:rcov) do |examples|
|
56
|
+
examples.pattern = '<%= test_pattern %>'
|
57
|
+
examples.rcov_opts = '-Ilib -I<%= test_dir %>'
|
58
|
+
examples.rcov = true
|
59
|
+
end
|
60
|
+
<% else %>
|
61
|
+
begin
|
62
|
+
require 'rcov/rcovtask'
|
63
|
+
Rcov::RcovTask.new do |<%= test_task %>|
|
64
|
+
<%= test_task %>.libs << '<%= test_dir %>'
|
65
|
+
<%= test_task %>.pattern = '<%= test_pattern %>'
|
66
|
+
<%= test_task %>.verbose = true
|
67
|
+
end
|
68
|
+
rescue LoadError
|
69
|
+
task :rcov do
|
70
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
<% end %>
|
74
|
+
|
75
|
+
<% if should_use_cucumber %>
|
76
|
+
begin
|
77
|
+
require 'cucumber/rake/task'
|
78
|
+
Cucumber::Rake::Task.new(:features)
|
79
|
+
rescue LoadError
|
80
|
+
task :features do
|
81
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
<% end %>
|
85
|
+
|
86
|
+
task :default => :<%= default_task %>
|
87
|
+
|
88
|
+
require 'rake/rdoctask'
|
89
|
+
Rake::RDocTask.new do |rdoc|
|
90
|
+
if File.exist?('VERSION.yml')
|
91
|
+
config = YAML.load(File.read('VERSION.yml'))
|
92
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
93
|
+
else
|
94
|
+
version = ""
|
95
|
+
end
|
96
|
+
|
97
|
+
rdoc.rdoc_dir = 'rdoc'
|
98
|
+
rdoc.title = "<%= project_name %> #{version}"
|
99
|
+
rdoc.rdoc_files.include('README*')
|
100
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
101
|
+
end
|
102
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'micronaut'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
|
7
|
+
require '<%= require_name %>'
|
8
|
+
|
9
|
+
def not_in_editor?
|
10
|
+
!(ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM'))
|
11
|
+
end
|
12
|
+
|
13
|
+
Micronaut.configure do |c|
|
14
|
+
c.color_enabled = not_in_editor?
|
15
|
+
c.filter_run :focused => true
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class Jeweler
|
4
|
+
class VersionHelper
|
5
|
+
attr_accessor :base_dir
|
6
|
+
attr_reader :major, :minor, :patch
|
7
|
+
|
8
|
+
module YamlExtension
|
9
|
+
def write
|
10
|
+
File.open(yaml_path, 'w+') do |f|
|
11
|
+
YAML.dump(self.to_hash, f)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_hash
|
16
|
+
{
|
17
|
+
:major => major,
|
18
|
+
:minor => minor,
|
19
|
+
:patch => patch
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def refresh
|
24
|
+
parse_yaml
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse_yaml
|
28
|
+
yaml = read_yaml
|
29
|
+
@major = (yaml['major'] || yaml[:major]).to_i
|
30
|
+
@minor = (yaml['minor'] || yaml[:minor]).to_i
|
31
|
+
@patch = (yaml['patch'] || yaml[:patch]).to_i
|
32
|
+
end
|
33
|
+
|
34
|
+
def read_yaml
|
35
|
+
if File.exists?(yaml_path)
|
36
|
+
YAML.load_file(yaml_path)
|
37
|
+
else
|
38
|
+
raise VersionYmlError, "#{yaml_path} does not exist!"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def path
|
43
|
+
yaml_path
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module PlaintextExtension
|
48
|
+
def write
|
49
|
+
File.open(plaintext_path, 'w') do |file|
|
50
|
+
file.puts to_s
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def parse_plaintext
|
55
|
+
plaintext = read_plaintext.chomp
|
56
|
+
if plaintext =~ /^(\d+)\.(\d+)\.(\d+)$/
|
57
|
+
@major = $1.to_i
|
58
|
+
@minor = $2.to_i
|
59
|
+
@patch = $3.to_i
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def read_plaintext
|
64
|
+
File.read(plaintext_path)
|
65
|
+
end
|
66
|
+
|
67
|
+
def refresh
|
68
|
+
parse_plaintext
|
69
|
+
end
|
70
|
+
|
71
|
+
def path
|
72
|
+
plaintext_path
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def initialize(base_dir)
|
77
|
+
self.base_dir = base_dir
|
78
|
+
|
79
|
+
if File.exists?(yaml_path)
|
80
|
+
extend YamlExtension
|
81
|
+
parse_yaml
|
82
|
+
else
|
83
|
+
extend PlaintextExtension
|
84
|
+
if File.exists?(plaintext_path)
|
85
|
+
parse_plaintext
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def bump_major
|
91
|
+
@major += 1
|
92
|
+
@minor = 0
|
93
|
+
@patch = 0
|
94
|
+
end
|
95
|
+
|
96
|
+
def bump_minor
|
97
|
+
@minor += 1
|
98
|
+
@patch = 0
|
99
|
+
end
|
100
|
+
|
101
|
+
def bump_patch
|
102
|
+
@patch += 1
|
103
|
+
end
|
104
|
+
|
105
|
+
def update_to(major, minor, patch)
|
106
|
+
@major = major
|
107
|
+
@minor = minor
|
108
|
+
@patch = patch
|
109
|
+
end
|
110
|
+
|
111
|
+
def to_s
|
112
|
+
"#{major}.#{minor}.#{patch}"
|
113
|
+
end
|
114
|
+
|
115
|
+
def yaml_path
|
116
|
+
denormalized_path = File.join(@base_dir, 'VERSION.yml')
|
117
|
+
absolute_path = File.expand_path(denormalized_path)
|
118
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
119
|
+
end
|
120
|
+
|
121
|
+
def plaintext_path
|
122
|
+
denormalized_path = File.join(@base_dir, 'VERSION')
|
123
|
+
absolute_path = File.expand_path(denormalized_path)
|
124
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|