interface_comparator 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/interface_comparator.rb +3 -3
- data/lib/interface_comparator/minitest.rb +3 -3
- data/lib/interface_comparator/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72fe80ef785b45a49d3d797b0a4b89fcd3840861
|
4
|
+
data.tar.gz: 37acee2a314d3bfcc6ac129c51c227b53174207e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8df2e9d820bd5b7c7a7e870cb43bcdff06af2c1ee7df68d9ba2b97531857962df581d487b1540b61dcce37bf19646a5af6930f4f15090c34ee286308baf0bea9
|
7
|
+
data.tar.gz: 5f00aad85d3a02f81922926b7556fe742fb3c850771f1ea97f5635c8a4e92aa7ca03edb3450ff93d4368382b6dbc1f466fc76cb14d7d4a87d327b288d639543c
|
data/README.md
CHANGED
@@ -22,11 +22,11 @@ Or install it yourself as:
|
|
22
22
|
require 'interface_comparator'
|
23
23
|
# check if two objects has the same interface
|
24
24
|
# including public methods list and their arity
|
25
|
-
InterfaceComparator.
|
25
|
+
InterfaceComparator.same?(a, b) # => true or false
|
26
26
|
|
27
27
|
# see detailed list of difference between interfaces
|
28
28
|
# of two objects
|
29
|
-
InterfaceComparator.
|
29
|
+
InterfaceComparator.diff(a, b)
|
30
30
|
# if there are difference between methods
|
31
31
|
# it will return them in aa array of hashes:
|
32
32
|
#[{
|
@@ -58,7 +58,7 @@ assert_equal_interfaces a, b
|
|
58
58
|
refute_equal_interfaces a, b
|
59
59
|
```
|
60
60
|
|
61
|
-
Output in case of failure will be similar to those in
|
61
|
+
Output in case of failure will be similar to those in diff.
|
62
62
|
|
63
63
|
## Development
|
64
64
|
|
data/lib/interface_comparator.rb
CHANGED
@@ -4,12 +4,12 @@ require 'interface_comparator/version'
|
|
4
4
|
# including public methods list and their arity
|
5
5
|
module InterfaceComparator
|
6
6
|
# is the interface of this two objects are the same?
|
7
|
-
def self.
|
8
|
-
|
7
|
+
def self.same?(a, b)
|
8
|
+
diff(a, b).empty?
|
9
9
|
end
|
10
10
|
|
11
11
|
# show me the difference between interface of these two objects
|
12
|
-
def self.
|
12
|
+
def self.diff(a, b)
|
13
13
|
methods_diff = diff_methods(a, b)
|
14
14
|
return methods_diff unless methods_diff.empty?
|
15
15
|
arity_diff = methods_arity_diff(a, b)
|
@@ -3,15 +3,15 @@ module Minitest::Assertions
|
|
3
3
|
# Fails unless +object_a and +object_a have the same interfaces (in terms of method and their arity).
|
4
4
|
#
|
5
5
|
def assert_equal_interfaces(object_a, object_b)
|
6
|
-
assert InterfaceComparator.
|
7
|
-
"Interfaces are not the same: #{InterfaceComparator.
|
6
|
+
assert InterfaceComparator.same?(object_a, object_b),
|
7
|
+
"Interfaces are not the same: #{InterfaceComparator.diff(object_a, object_b)}"
|
8
8
|
end
|
9
9
|
|
10
10
|
#
|
11
11
|
# Fails if +object_a and +object_a have the same interfaces (in terms of method and their arity).
|
12
12
|
#
|
13
13
|
def refute_equal_interfaces(object_a, object_b)
|
14
|
-
refute InterfaceComparator.
|
14
|
+
refute InterfaceComparator.same?(object_a, object_b),
|
15
15
|
"Interfaces are of these two object are the same"
|
16
16
|
end
|
17
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interface_comparator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Szmielew
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.6.
|
109
|
+
rubygems_version: 2.6.13
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Module that checks if two objects has the same interface including public
|