cpf_cnpj 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 060f6cfefb56f74570849d75281ab0f5d00fe500
4
- data.tar.gz: 52d7c441db65b19ce5175aa82c168a670e708f06
2
+ SHA256:
3
+ metadata.gz: dae51c08f0746495d4b9470e710aea34f447b8ee11322554fa085e712d0f9f89
4
+ data.tar.gz: 2762cf150ab69f44c8c24d72da6c33dfd89db999dfacbccf329a66ac92477226
5
5
  SHA512:
6
- metadata.gz: 21a524afa4993d82d12b1abe9ee15f957a786acf5ba89704dc5916f35946e475d50842ce40f78e56bd979c4ec66afdd90376da8d011b28e41e5203a31e8a5530
7
- data.tar.gz: 9c25eb4c0c480eb29b040b8595d1b1a9b9e768f21dd689f4c24adc0b4f22be4051624013398a4259c400985c1f843e7a35859681409b0b3a9205f0f8f53866e5
6
+ metadata.gz: 562be436dbdebcf3f0730430fe36c72897d3ce894c4806b2c8298988233008f5e28a80250e42bb97e5d363e14ffd14dd16eca9716066582c8ccd8848e08654dd
7
+ data.tar.gz: 6476ab415fc627a01f69407a1c8624f997ed40d8745313cc2ca092bd61f2e424571bb7dcd3ee3a8cca57c0239611b4f74b4aa30b34ff74942fb57454c1c64256
@@ -66,6 +66,11 @@ class CNPJ
66
66
  digits[-2, 2] == numbers[-2, 2]
67
67
  end
68
68
 
69
+ def ==(object)
70
+ super || object.instance_of?(self.class) && object.stripped == stripped
71
+ end
72
+ alias :eql? :==
73
+
69
74
  private
70
75
 
71
76
  def numbers
data/lib/cpf.rb CHANGED
@@ -68,6 +68,11 @@ class CPF
68
68
  digits[-2, 2] == numbers[-2, 2]
69
69
  end
70
70
 
71
+ def ==(object)
72
+ super || object.instance_of?(self.class) && object.stripped == stripped
73
+ end
74
+ alias :eql? :==
75
+
71
76
  private
72
77
 
73
78
  def numbers
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CpfCnpj
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.0"
5
5
  end
6
6
 
7
7
  class CPF
@@ -54,4 +54,15 @@ class CnpjTest < Minitest::Test
54
54
  test "rejects strings (strict)" do
55
55
  refute CNPJ.valid?("aa.bb.ccc/dddd-ee", strict: true)
56
56
  end
57
+
58
+ test "compare objects by their numeric value" do
59
+ one = CNPJ.new("54550752000155")
60
+ other = CNPJ.new("54550752000155")
61
+ different = CNPJ.new("32228235377")
62
+
63
+ assert_equal one, other
64
+
65
+ refute_equal one, different
66
+ refute_equal other, different
67
+ end
57
68
  end
@@ -79,4 +79,15 @@ class CpfTest < Minitest::Test
79
79
  assert_equal "52139989171", cpf.stripped
80
80
  assert_equal "521.399.891-71", cpf.formatted
81
81
  end
82
+
83
+ test "compare objects by their numeric value" do
84
+ one = CPF.new("29537995593")
85
+ other = CPF.new("29537995593")
86
+ different = CPF.new("76556868310")
87
+
88
+ assert_equal one, other
89
+
90
+ refute_equal one, different
91
+ refute_equal other, different
92
+ end
82
93
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpf_cnpj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry-meta
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.6.13
114
+ rubygems_version: 2.7.6
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Validate, generate and format CPF/CNPJ numbers. Include command-line tools.