Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix version task for version constants.

  • Loading branch information...
commit 24170414bf06fa0a5d708952447faab1bf3b074e 1 parent 103dd53
@technicalpickles authored
View
7 features/tasks/version.feature
@@ -22,3 +22,10 @@ Feature: version rake task
When I run "rake version" in "existing-project-with-version-plaintext"
Then the process should exit cleanly
And the current version, 1.5.3, is displayed
+
+ Scenario: an existing project with version constant
+ Given a working directory
+ And I use the existing project "existing-project-with-version-constant" as a template
+ When I run "rake version" in "existing-project-with-version-constant"
+ Then the process should exit cleanly
+ And the current version, 1.0.0, is displayed
View
2  lib/jeweler.rb
@@ -55,7 +55,7 @@ def patch_version
# Human readable version, which is used in the gemspec.
def version
- @version_helper.to_s
+ @gemspec.version || @version_helper.to_s
end
# Writes out the gemspec
View
5 test/fixtures/existing-project-with-version-constant/.document
@@ -0,0 +1,5 @@
+README.rdoc
+lib/**/*.rb
+bin/*
+features/**/*.feature
+LICENSE
View
5 test/fixtures/existing-project-with-version-constant/.gitignore
@@ -0,0 +1,5 @@
+*.sw?
+.DS_Store
+coverage
+rdoc
+pkg
View
20 test/fixtures/existing-project-with-version-constant/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Josh Nichols
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
7 test/fixtures/existing-project-with-version-constant/README.rdoc
@@ -0,0 +1,7 @@
+= existing-project-with-version
+
+Description goes here.
+
+== Copyright
+
+Copyright (c) 2009 Josh Nichols. See LICENSE for details.
View
83 test/fixtures/existing-project-with-version-constant/Rakefile
@@ -0,0 +1,83 @@
+require 'rubygems'
+require 'rake'
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.version = "1.0.0"
+ gem.name = "existing-project-with-version"
+ gem.summary = %Q{Summarize your gem}
+ gem.email = "josh@technicalpickles.com"
+ gem.homepage = "http://github.com/technicalpickles/existing-project-with-version"
+ gem.authors = ["Josh Nichols"]
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
+ end
+rescue LoadError
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
+end
+
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'lib' << 'test'
+ test.pattern = 'test/**/*_test.rb'
+ test.verbose = false
+end
+
+begin
+ require 'rcov/rcovtask'
+ Rcov::RcovTask.new do |test|
+ test.libs << 'test'
+ test.pattern = 'test/**/*_test.rb'
+ test.verbose = true
+ end
+rescue LoadError
+ task :rcov do
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
+ end
+end
+
+
+task :default => :test
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ if File.exist?('VERSION.yml')
+ config = YAML.load(File.read('VERSION.yml'))
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
+ else
+ version = ""
+ end
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "existing-project-with-version #{version}"
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+# Rubyforge documentation task
+begin
+ require 'rake/contrib/sshpublisher'
+ namespace :rubyforge do
+
+ desc "Release gem and RDoc documentation to RubyForge"
+ task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
+
+ namespace :release do
+ desc "Publish RDoc to RubyForge."
+ task :docs => [:rdoc] do
+ config = YAML.load(
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
+ )
+
+ host = "#{config['username']}@rubyforge.org"
+ remote_dir = "/var/www/gforge-projects/existing-project-with-version/"
+ local_dir = 'rdoc'
+
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
+ end
+ end
+ end
+rescue LoadError
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
+end
View
29 test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec
@@ -0,0 +1,29 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{existing-project-with-version}
+ s.version = "1.5.3"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Josh Nichols"]
+ s.date = %q{2009-03-13}
+ s.email = %q{josh@technicalpickles.com}
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
+ s.files = ["README.rdoc", "VERSION.yml", "lib/existing_project_with_version.rb", "test/existing_project_with_version_test.rb", "test/test_helper.rb", "LICENSE"]
+ s.has_rdoc = true
+ s.homepage = %q{http://github.com/technicalpickles/existing-project-with-version}
+ s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.1}
+ s.summary = %q{Summarize your gem}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 2
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
View
0  test/fixtures/existing-project-with-version-constant/lib/existing_project_with_version.rb
No changes.
View
7 test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ExistingProjectWithVersionTest < Test::Unit::TestCase
+ should "probably rename this file and start testing for real" do
+ flunk "hey buddy, you should probably rename this file and start testing for real"
+ end
+end
View
10 test/fixtures/existing-project-with-version-constant/test/test_helper.rb
@@ -0,0 +1,10 @@
+require 'rubygems'
+require 'test/unit'
+require 'shoulda'
+
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+require 'existing_project_with_version'
+
+class Test::Unit::TestCase
+end
Please sign in to comment.
Something went wrong with that request. Please try again.