Skip to content

Commit

Permalink
Cleaning up the repository preparing for the move to GemCutter, and i…
Browse files Browse the repository at this point in the history
…mplementing capistrano#95 (Move to formally deprecate before_task and after_task callbacks)
  • Loading branch information
leehambley committed Nov 3, 2009
1 parent 203fe8b commit 1c7acac
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 159 deletions.
94 changes: 0 additions & 94 deletions 2.5.9-Release-Notes.txt.md

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Fixes Darcs remote repository problem when using the copy strategy [Alex `regularfry` Young]
* Documentation improvements for embedding Capistrano [Lee Hambley]
* Fixes ticket #95 -formally deprecating the before_something and after_something methods [Lee Hambley]

== 2.5.9 / 1 August 2009

Expand Down
47 changes: 0 additions & 47 deletions capistrano.gemspec

This file was deleted.

14 changes: 0 additions & 14 deletions examples/sample.rb

This file was deleted.

11 changes: 8 additions & 3 deletions lib/capistrano/task_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ module Capistrano
# Represents the definition of a single task.
class TaskDefinition
attr_reader :name, :namespace, :options, :body, :desc, :on_error, :max_hosts

def initialize(name, namespace, options={}, &block)

if name.to_s =~ /^(?:before_|after_)/
Kernel.warn("[Deprecation Warning] Naming tasks with before_ and after_ is deprecated, please see the new before() and after() methods. (Offending task name was #{name})")
end

@name, @namespace, @options = name, namespace, options
@desc = @options.delete(:desc)
@on_error = options.delete(:on_error)
Expand All @@ -24,15 +29,15 @@ def fully_qualified_name
end
end
end

# Returns the description for this task, with newlines collapsed and
# whitespace stripped. Returns the empty string if there is no
# description for this task.
def description(rebuild=false)
@description = nil if rebuild
@description ||= begin
description = @desc || ""

indentation = description[/\A\s+/]
if indentation
reformatted_description = ""
Expand Down
15 changes: 15 additions & 0 deletions test/task_definition_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
require "utils"
require 'capistrano/task_definition'

# Silences the wanrnings raised in the two deprecation tests
$VERBOSE = nil

class TaskDefinitionTest < Test::Unit::TestCase
def setup
@namespace = namespace
Expand All @@ -22,6 +25,18 @@ def test_fqn_at_top_level_when_default_should_be_default
assert_equal "default", task.fully_qualified_name
end

def test_deprecation_warning_on_method_name_beginning_with_before_underscore
name = "before_test"
Kernel.expects(:warn).with("[Deprecation Warning] Naming tasks with before_ and after_ is deprecated, please see the new before() and after() methods. (Offending task name was #{name})")
new_task(name)
end

def test_deprecation_warning_on_method_name_beginning_with_after_underscore
name = "after_test"
Kernel.expects(:warn).with("[Deprecation Warning] Naming tasks with before_ and after_ is deprecated, please see the new before() and after() methods. (Offending task name was #{name})")
new_task(name)
end

def test_fqn_in_namespace_when_default_should_be_namespace_fqn
ns = namespace("outer:inner")
task = new_task(:default, ns)
Expand Down
2 changes: 1 addition & 1 deletion test/utils.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
begin
require 'rubygems'
require 'redgreen'
require 'redgreen' unless ENV['TM_FILENAME']
gem 'mocha'
rescue LoadError
end
Expand Down

0 comments on commit 1c7acac

Please sign in to comment.