[SCM] ci-tooling packaging branch, master, updated. 38c796a485dac23384bcad370db9a4716050bb34
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Tue Oct 27 10:54:31 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=472a576
The following commit has been merged in the master branch:
commit 472a576d7efecf46e0a69d096fbfeea3e02129b1
Author: Harald Sitter <sitter at kde.org>
Date: Tue Oct 27 11:53:04 2015 +0100
add new deprecation helper for variables, builds ontop of gem deprecation
---
lib/deprecate.rb | 22 ++++++++++++++++++++++
test/test_deprecate.rb | 22 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/lib/deprecate.rb b/lib/deprecate.rb
new file mode 100644
index 0000000..e9bd9ae
--- /dev/null
+++ b/lib/deprecate.rb
@@ -0,0 +1,22 @@
+module Deprecate
+ include Gem::Deprecate
+
+ def self.extended(othermod)
+ othermod.send :include, InstanceMethods
+ super(othermod)
+ end
+
+ module InstanceMethods
+ def variable_deprecation(variable, repl = :none)
+ klass = self.is_a? Module
+ target = klass ? "#{self}." : "#{self.class}#"
+ meth = caller_locations(1, 1)[0].label
+ msg = [
+ "NOTE: Variable '#{variable}' in #{target}#{meth} is deprecated",
+ repl == :none ? ' with no replacement' : "; use '#{repl}' instead",
+ "
'#{variable}' used around #{Gem.location_of_caller.join(":")}"
+ ]
+ warn "#{msg.join}." unless Gem::Deprecate.skip
+ end
+ end
+end
diff --git a/test/test_deprecate.rb b/test/test_deprecate.rb
new file mode 100644
index 0000000..cfa8cf8
--- /dev/null
+++ b/test/test_deprecate.rb
@@ -0,0 +1,22 @@
+require_relative 'lib/testcase'
+
+require_relative '../lib/deprecate'
+
+class DeprecateTest < TestCase
+ class Dummy
+ extend Deprecate
+
+ def a
+ variable_deprecation('variable', 'replacement')
+ end
+ end
+
+ def test_deprecate_var
+ assert_include(Deprecate.ancestors, Gem::Deprecate)
+ dummy = Dummy.new
+ assert(dummy.class.is_a?(Deprecate))
+ assert_include(dummy.class.ancestors, Deprecate::InstanceMethods)
+ dummy.send :variable_deprecation, 'variable', 'replacement'
+ dummy.a
+ end
+end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list