deep_class_compare 1.0.4 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a81d53c15eaa2641d219e497526761801eb20313976e5814481497451dda787
4
- data.tar.gz: fbf943bc407f55f51621e7fb67f8f8aaa99924f5a83901ed7e11e849ee2ca77a
3
+ metadata.gz: c15d97b67b9093f7dd83d50eb6cc47cb1121490103a66c0e92830ea9fbeaa42c
4
+ data.tar.gz: e2cac516d02cd8cd1df55be2c0e7259ce28eaf6b33ddee3aa5d916e1ecf080a0
5
5
  SHA512:
6
- metadata.gz: 2e7b4e3fe1f1bc61847215f5bca6221560f3805854fb3d6e73861876641bca20058e9ec0cd3bcbfb162bd7f6e1a78b6819cf7e1d275d5bae090b1612db236b75
7
- data.tar.gz: f8792829f2d6528d7c2d60e0df5ed6e69b594e36611549268d2aac8182f27f2bc65384e15c14060115d7b607ef24a6f052e5a0adf934ddc2e90292228f2d1446
6
+ metadata.gz: '09bbe3137d0718251b5813ea2bba13e7ef8cfcb4eec191b271c9c6a7dd93578b4445b6a579b33229ce9dd9dce451db5af390db540aa86ef5ef6532af2504c92f'
7
+ data.tar.gz: 51995692e0bb252764c1622d6f97b109759a5cfc664532a4c6907f00b7e5f03ad445da2def4acf5fc42e7a131157c2da8b9818a20fbc6f6a1e7322595652e232
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- ```
25
+ ```ruby
26
26
  # Could compare container and value class with simple pattern
27
27
  ['string', 'string'].like_a? Array.of(String) => true
28
28
  [1, 2].like_a? Array.of(Hash) => false
@@ -1,8 +1,8 @@
1
1
  module DeepClassCompare
2
2
  class ArrayMatcher < Matcher
3
3
  include ContainerComparable
4
- def initialize
5
- super(Array)
4
+ def initialize(klass = Array)
5
+ super(klass)
6
6
  end
7
7
 
8
8
  def match?(array)
@@ -1,8 +1,8 @@
1
1
  module DeepClassCompare
2
2
  class HashMatcher < Matcher
3
3
  include ContainerComparable
4
- def initialize
5
- super(Hash)
4
+ def initialize(klass = Hash)
5
+ super(klass)
6
6
  end
7
7
 
8
8
  def match?(hash)
@@ -1,8 +1,8 @@
1
1
  module DeepClassCompare
2
2
  class Matcher
3
3
  def self.build(klass)
4
- if klass == Array then ArrayMatcher.new
5
- elsif klass == Hash then HashMatcher.new
4
+ if klass.ancestors.include?(Array) then ArrayMatcher.new(klass)
5
+ elsif klass.ancestors.include?(Hash) then HashMatcher.new(klass)
6
6
  else new(klass)
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeepClassCompare
4
- VERSION = "1.0.4"
4
+ VERSION = "1.3.0"
5
5
  end
@@ -12,14 +12,14 @@ end
12
12
 
13
13
  class Array
14
14
  def self.of(value_comparable)
15
- DeepClassCompare::ArrayMatcher.new.of(value_comparable)
15
+ DeepClassCompare::ArrayMatcher.new(self).of(value_comparable)
16
16
  end
17
17
  end
18
18
 
19
19
  class Hash
20
20
  def self.of(key_comparable, value_comparable = nil)
21
21
  key_comparable, value_comparable = Object, key_comparable if value_comparable.nil?
22
- DeepClassCompare::HashMatcher.new.of(key_comparable, value_comparable)
22
+ DeepClassCompare::HashMatcher.new(self).of(key_comparable, value_comparable)
23
23
  end
24
24
  end
25
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep_class_compare
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koten
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-26 00:00:00.000000000 Z
11
+ date: 2021-12-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A container class extend gem that could compare the values class in it
14
14
  easily, clearly, and more colloquialism.
@@ -22,7 +22,6 @@ files:
22
22
  - CHANGELOG.md
23
23
  - CODE_OF_CONDUCT.md
24
24
  - Gemfile
25
- - Gemfile.lock
26
25
  - LICENSE.txt
27
26
  - README.md
28
27
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,34 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- deep_class_compare (1.0.4)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.4.4)
10
- rake (13.0.3)
11
- rspec (3.9.0)
12
- rspec-core (~> 3.9.0)
13
- rspec-expectations (~> 3.9.0)
14
- rspec-mocks (~> 3.9.0)
15
- rspec-core (3.9.2)
16
- rspec-support (~> 3.9.3)
17
- rspec-expectations (3.9.2)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.9.0)
20
- rspec-mocks (3.9.1)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.9.0)
23
- rspec-support (3.9.3)
24
-
25
- PLATFORMS
26
- x86_64-darwin-18
27
-
28
- DEPENDENCIES
29
- deep_class_compare!
30
- rake (~> 13.0)
31
- rspec (~> 3.0)
32
-
33
- BUNDLED WITH
34
- 2.3.0