[SCM] ci-tooling packaging branch, master, updated. 9280fa5b1b77bdfb6890d8a950f2f7d82bc35972

Harald Sitter apachelogger-guest at moszumanska.debian.org
Wed Apr 29 11:40:33 UTC 2015


Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=9280fa5

The following commit has been merged in the master branch:
commit 9280fa5b1b77bdfb6890d8a950f2f7d82bc35972
Author: Harald Sitter <sitter at kde.org>
Date:   Wed Apr 29 13:39:14 2015 +0200

    implement a variant of ignorerule == operator supporting qml::module
    
    this is purely convenience to be able to use array.include? on an
    array of ignorerules (as returned by read) to check if any of the ignores
    matches a given module
---
 lib/qml_ignore_rule.rb       | 10 ++++++++++
 test/test_qml_ignore_rule.rb | 18 ++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/lib/qml_ignore_rule.rb b/lib/qml_ignore_rule.rb
index cef2414..89a3b40 100644
--- a/lib/qml_ignore_rule.rb
+++ b/lib/qml_ignore_rule.rb
@@ -25,6 +25,16 @@ module QML
       rules.compact
     end
 
+    # Helper overload for {Array#include?} allowing include? checks with a
+    # {Module} resulting in {#ignore?} checks of the rule (i.e. Array#include?
+    # is equal to iterating over the array and calling ignore? on all rules).
+    # If the rule is compared to anything but a {Module} instance it will
+    # yield to super.
+    def ==(other)
+      return ignore?(other) if other.is_a?(QML::Module)
+      super(other)
+    end
+
     private
 
     def initialize(identifier, version = nil)
diff --git a/test/test_qml_ignore_rule.rb b/test/test_qml_ignore_rule.rb
index c52c438..9a2d0ee 100644
--- a/test/test_qml_ignore_rule.rb
+++ b/test/test_qml_ignore_rule.rb
@@ -87,4 +87,22 @@ class QMLIgnoreRuleTest < TestCase
     end
     assert_empty(expected, "Did not get all expected rules")
   end
+
+  def test_compare
+    # comparing defers to ignore, so we only check that compare actually calls
+    # ignore as intended.
+    id = 'org.kde.plasma'
+    version = '2.0'
+    m = new_mod(id, version)
+    r = new_rule(id, nil)
+    assert_equal(r == m, r.ignore?(m))
+    # Comparing with a string on the other hand should defer to super and return
+    # false.
+    assert_not_equal(r == id, r.ignore?(m))
+    # This is just an means to an end that we can use Array.include?, so make
+    # sure that actually works.
+    assert_include([r], m)
+    # And with a string again.
+    assert_not_include([id], m)
+  end
 end

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list