cuitar 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +4 -4
- data/README.md +16 -2
- data/cuitar.gemspec +3 -3
- data/lib/cuit.rb +24 -6
- data/lib/cuitar/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c558641038eaa45b9d00fe5f7e0c8fe46c06aaec4bc3d42a8edd53ea86d722fc
|
4
|
+
data.tar.gz: ef534ebed29d24549b58bc1347d0620c0d5b6c5e52004c2d3af83ce5f208301f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd58ced15b82cb16b256addf25e279cf496b1b8c48e2cfc34a841c73e8fdb5b84178407bf19fe3f1cd03fcf4c6dc6b13c722a23a4a16a5ce4c61566dca388f8e
|
7
|
+
data.tar.gz: e1d054a05a214b7c7991dd393b53af0b251d184bd89899f9249130789c8d64c81c8fb7a6b38d8dcb59d60f6befd60e58435cfa15c69ab46613716876dd9c3817
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cuitar (1.
|
4
|
+
cuitar (1.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
minitest (5.
|
10
|
-
rake (12.3.
|
9
|
+
minitest (5.18.0)
|
10
|
+
rake (12.3.3)
|
11
11
|
|
12
12
|
PLATFORMS
|
13
13
|
ruby
|
@@ -18,4 +18,4 @@ DEPENDENCIES
|
|
18
18
|
rake (~> 12.0)
|
19
19
|
|
20
20
|
BUNDLED WITH
|
21
|
-
2.
|
21
|
+
2.4.10
|
data/README.md
CHANGED
@@ -28,8 +28,6 @@ cuit_number = '20228518310' # o '20-22851831-0' o 20228518310
|
|
28
28
|
|
29
29
|
cuit = Cuit.new(cuit_number)
|
30
30
|
|
31
|
-
cuit.valid? # => true
|
32
|
-
|
33
31
|
cuit.to_s # => '20-22851831-0'
|
34
32
|
```
|
35
33
|
|
@@ -41,6 +39,22 @@ cuit.to_s # => '20-22851831-0'
|
|
41
39
|
|
42
40
|
* Un `Integer` comprendido por los 11 números que componen una CUIT.
|
43
41
|
|
42
|
+
Instanciar la clase `Cuit` con una CUIT inválida genera un `ArgumentError`
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
cuit_number = 123
|
46
|
+
|
47
|
+
cuit = Cuit.new(cuit_number) # => Invalid CUIT (ArgumentError)
|
48
|
+
```
|
49
|
+
|
50
|
+
Es posible validar una CUIT
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
Cuit.valid?(123) # => false
|
54
|
+
|
55
|
+
Cuit.valid?(20228518310) # => #<Cuit:0x000000010f589930 @check_digit=0, @cuit="20228518310", @dni="22851831", @type="20">
|
56
|
+
```
|
57
|
+
|
44
58
|
|
45
59
|
## Contribuciones
|
46
60
|
|
data/cuitar.gemspec
CHANGED
@@ -7,20 +7,20 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.email = ['sebas@wasabit.com.ar']
|
8
8
|
|
9
9
|
spec.summary = 'Valida y formatea CUIT argentinas.'
|
10
|
-
spec.description = '
|
10
|
+
spec.description = 'Validador y formateador de CUIT (Clave Única Tributaria) Argentina.'
|
11
11
|
spec.homepage = 'https://github.com/srabuini/cuitar'
|
12
12
|
spec.license = 'MIT'
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
14
14
|
|
15
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
16
|
-
|
17
15
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
16
|
spec.metadata['source_code_uri'] = 'https://github.com/srabuini/cuitar'
|
19
17
|
|
20
18
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
19
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
20
|
end
|
21
|
+
|
23
22
|
spec.bindir = 'exe'
|
24
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
24
|
spec.require_paths = ['lib']
|
25
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
26
26
|
end
|
data/lib/cuit.rb
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
class Cuit
|
2
|
+
def self.valid?(cuit)
|
3
|
+
begin
|
4
|
+
new(cuit)
|
5
|
+
rescue
|
6
|
+
false
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
2
10
|
def initialize(cuit)
|
3
|
-
@cuit = cuit.to_s.
|
11
|
+
@cuit = cuit.to_s.gsub(/\D/, '')
|
12
|
+
|
13
|
+
raise ArgumentError, 'Invalid CUIT' unless valid?
|
4
14
|
end
|
5
15
|
|
6
16
|
def to_s
|
7
17
|
[type, dni, check_digit].join('-')
|
8
18
|
end
|
9
19
|
|
10
|
-
def valid?
|
11
|
-
@cuit.size == 11 && calculated_digit == check_digit
|
12
|
-
end
|
13
|
-
|
14
20
|
private
|
15
21
|
|
16
22
|
def type
|
@@ -35,8 +41,20 @@ class Cuit
|
|
35
41
|
.zip(cuit_sequence)
|
36
42
|
.reduce(0) { |a, e| a + e.reduce(:*) }
|
37
43
|
|
38
|
-
diff = 11 - sum % 11
|
44
|
+
diff = 11 - (sum % 11)
|
39
45
|
|
40
46
|
diff == 11 ? 0 : diff
|
41
47
|
end
|
48
|
+
|
49
|
+
def right_length?
|
50
|
+
@cuit.length == 11
|
51
|
+
end
|
52
|
+
|
53
|
+
def checked?
|
54
|
+
calculated_digit == check_digit
|
55
|
+
end
|
56
|
+
|
57
|
+
def valid?
|
58
|
+
right_length? && checked?
|
59
|
+
end
|
42
60
|
end
|
data/lib/cuitar/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuitar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Rabuini
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: Validador y formateador de CUIT (Clave Única Tributaria) Argentina.
|
14
14
|
email:
|
15
15
|
- sebas@wasabit.com.ar
|
16
16
|
executables: []
|
@@ -36,7 +36,8 @@ licenses:
|
|
36
36
|
metadata:
|
37
37
|
homepage_uri: https://github.com/srabuini/cuitar
|
38
38
|
source_code_uri: https://github.com/srabuini/cuitar
|
39
|
-
|
39
|
+
rubygems_mfa_required: 'true'
|
40
|
+
post_install_message:
|
40
41
|
rdoc_options: []
|
41
42
|
require_paths:
|
42
43
|
- lib
|
@@ -51,8 +52,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
52
|
- !ruby/object:Gem::Version
|
52
53
|
version: '0'
|
53
54
|
requirements: []
|
54
|
-
rubygems_version: 3.
|
55
|
-
signing_key:
|
55
|
+
rubygems_version: 3.4.6
|
56
|
+
signing_key:
|
56
57
|
specification_version: 4
|
57
58
|
summary: Valida y formatea CUIT argentinas.
|
58
59
|
test_files: []
|