croatia 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 91babeb96c8b99906844e087b9599ec530c4b972b6d1bdf2cded59dfbbb178d1
4
+ data.tar.gz: cd5b1dece16ed4f0d9ec3e2b8ceac8b2b44ad251f7eb2f07e119491bc638cb9f
5
+ SHA512:
6
+ metadata.gz: f103227a100270c0d53c8bf45edb30532a852719866900fed949996e1afbfcb4fd3525c0e7ae4828bd8e16a1137357f3345810600b24cd3db174774ba2f4a5fd
7
+ data.tar.gz: cec02f409ded5d60f9535464669219314f4da1ab516ef5139b550d033552ac9393cd6105e37486427cfe6ee606c93636caa85c2a3f7994dc783cf9984643b110
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ inherit_gem:
2
+ rubocop-rails-omakase: rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 3.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Stanko K.R.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[test rubocop]
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Croatia::PIN
4
+ def self.valid?(pin)
5
+ return false unless pin
6
+
7
+ pin = pin.to_s.strip
8
+ return false unless pin.match?(/\A\d{11}\Z/)
9
+
10
+ digits = pin.chars.map(&:to_i)
11
+ control = digits.pop
12
+
13
+ checksum = 10
14
+ digits.each do |digit|
15
+ checksum = (checksum + digit) % 10
16
+ checksum = (checksum == 0 ? 10 : checksum) * 2 % 11
17
+ end
18
+
19
+ expected_control = (11 - checksum) % 10
20
+ control == expected_control
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Croatia
4
+ VERSION = "0.1.0"
5
+ end
data/lib/croatia.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "croatia/version"
4
+
5
+ module Croatia
6
+ class Error < StandardError; end
7
+ end
data/sig/croatia.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Croatia
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: croatia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stanko K.R.
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 2025-05-29 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: 'Croatia is a gem that contains various utilities for performing Croatia-specific
13
+ actions - like PIN/OIB validation
14
+
15
+ '
16
+ email:
17
+ - hey@stanko.io
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".rubocop.yml"
23
+ - LICENSE.txt
24
+ - Rakefile
25
+ - lib/croatia.rb
26
+ - lib/croatia/pin.rb
27
+ - lib/croatia/version.rb
28
+ - sig/croatia.rbs
29
+ homepage: https://github.com/monorkin/croatia
30
+ licenses:
31
+ - MIT
32
+ metadata:
33
+ allowed_push_host: https://rubygems.org
34
+ homepage_uri: https://github.com/monorkin/croatia
35
+ source_code_uri: https://github.com/monorkin/croatia
36
+ changelog_uri: https://github.com/monorkin/croatia/blob/main/CHANGELOG.md
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 3.1.0
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubygems_version: 3.6.2
52
+ specification_version: 4
53
+ summary: A gem for performing tasks specific to Croatia
54
+ test_files: []