sec_id 3.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/main.yml +39 -0
- data/.rubocop.yml +7 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile +12 -0
- data/README.md +2 -3
- data/lib/sec_id/base.rb +15 -13
- data/lib/sec_id/cusip.rb +3 -3
- data/lib/sec_id/isin.rb +2 -2
- data/lib/sec_id/sedol.rb +2 -2
- data/lib/sec_id/version.rb +1 -1
- data/sec_id.gemspec +2 -7
- metadata +12 -94
- data/.travis.yml +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 374eb5eb544fd34d09e5d5008473b5516c3b9ac13e720dd7ea01062478da5248
|
4
|
+
data.tar.gz: 6b785b97c0bd99c56feb8a500f1376f228077f0d58503cb823af3d2abc790ae6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca697d5bf5326587d437f6206e91d419ad11aad3166f6d2c75f423afae1fcaf3736860b313545d85761f9575bf85f56120f5d3d74e92158fa3c1ed9fc4d5be5d
|
7
|
+
data.tar.gz: 1c46330ecd6e07192eaf083dc28e41e7b3edbb83a1ee226f76817df4c3182fc20f4e42415350da9bf343b5e89445e1545d79cf1ca02dea15a380fe94f07bef82
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "weekly"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
concurrency:
|
4
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
5
|
+
cancel-in-progress: true
|
6
|
+
|
7
|
+
on:
|
8
|
+
push:
|
9
|
+
branches: ["main"]
|
10
|
+
pull_request:
|
11
|
+
branches: ["main"]
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
build:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
name: Ruby ${{ matrix.ruby_version }}
|
17
|
+
strategy:
|
18
|
+
matrix:
|
19
|
+
ruby_version: [ruby-head, '3.3', '3.2', '3.1']
|
20
|
+
|
21
|
+
env:
|
22
|
+
COVERAGE: true
|
23
|
+
CC_TEST_REPORTER_ID: ${{ vars.CC_TEST_REPORTER_ID }}
|
24
|
+
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v4
|
27
|
+
|
28
|
+
- uses: ruby/setup-ruby@v1
|
29
|
+
with:
|
30
|
+
ruby-version: ${{ matrix.ruby_version }}
|
31
|
+
bundler-cache: true
|
32
|
+
continue-on-error: ${{ matrix.ruby_version == 'ruby-head' }}
|
33
|
+
|
34
|
+
- run: bundle exec rake
|
35
|
+
continue-on-error: ${{ matrix.ruby_version == 'ruby-head' }}
|
36
|
+
|
37
|
+
- uses: paambaati/codeclimate-action@v8.0.0
|
38
|
+
# Only upload coverage for the latest Ruby
|
39
|
+
if: ${{ matrix.ruby_version == '3.3' }}
|
data/.rubocop.yml
CHANGED
@@ -2,10 +2,12 @@ require:
|
|
2
2
|
- rubocop-rspec
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
TargetRubyVersion:
|
5
|
+
TargetRubyVersion: 3.1
|
6
6
|
DisplayCopNames: true
|
7
7
|
DisplayStyleGuide: true
|
8
8
|
ExtraDetails: true
|
9
|
+
SuggestExtensions: false
|
10
|
+
NewCops: enable
|
9
11
|
|
10
12
|
Layout/LineLength:
|
11
13
|
Max: 120
|
@@ -26,6 +28,10 @@ Metrics/BlockLength:
|
|
26
28
|
Exclude:
|
27
29
|
- 'spec/**/*'
|
28
30
|
|
31
|
+
Lint/MissingSuper:
|
32
|
+
AllowedParentClasses:
|
33
|
+
- Base
|
34
|
+
|
29
35
|
RSpec/MultipleExpectations:
|
30
36
|
Max: 5
|
31
37
|
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [4.0.0] - 2024-07-09
|
4
|
+
|
5
|
+
### Breaking changes
|
6
|
+
|
7
|
+
- Minimum required Ruby version is 3.1 now
|
8
|
+
- Default repository branch renamed to `main`
|
9
|
+
|
10
|
+
### Updated
|
11
|
+
|
12
|
+
- Small internal refactorings
|
13
|
+
- TravisCI -> GitHub Actions
|
14
|
+
- Dropped tests for Ruby below 3.1
|
15
|
+
- Rubocop's Ruby target version changed to 3.1
|
16
|
+
|
3
17
|
## [3.0.0] - 2020-03-10
|
4
18
|
|
5
19
|
### Breaking changes
|
data/Gemfile
CHANGED
@@ -6,3 +6,15 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
6
6
|
|
7
7
|
# Specify your gem's dependencies in sec_id.gemspec
|
8
8
|
gemspec
|
9
|
+
|
10
|
+
# Specify your gem's development dependencies below
|
11
|
+
gem 'rake', '>= 13'
|
12
|
+
|
13
|
+
gem 'rspec', '~> 3.9'
|
14
|
+
gem 'rspec_junit_formatter'
|
15
|
+
|
16
|
+
gem 'rubocop', '~> 1.64'
|
17
|
+
gem 'rubocop-rspec', '~> 3.0'
|
18
|
+
|
19
|
+
gem 'simplecov', '~> 0.22', require: false
|
20
|
+
gem 'simplecov_json_formatter', require: false
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# SecId
|
2
2
|
[](https://badge.fury.io/rb/sec_id)
|
3
|
-
|
4
|
-
[](https://depfu.com/github/svyatov/sec_id?project_id=6878)
|
3
|
+

|
5
4
|
[](https://codeclimate.com/github/svyatov/sec_id/maintainability)
|
6
5
|
[](https://codeclimate.com/github/svyatov/sec_id/test_coverage)
|
7
6
|
|
@@ -22,7 +21,7 @@ Work in progress:
|
|
22
21
|
Add this line to your application's Gemfile:
|
23
22
|
|
24
23
|
```ruby
|
25
|
-
gem 'sec_id', '~>
|
24
|
+
gem 'sec_id', '~> 4.0'
|
26
25
|
```
|
27
26
|
|
28
27
|
And then execute:
|
data/lib/sec_id/base.rb
CHANGED
@@ -26,20 +26,22 @@ module SecId
|
|
26
26
|
class Base
|
27
27
|
attr_reader :full_number, :identifier, :check_digit
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
class << self
|
30
|
+
def valid?(id)
|
31
|
+
new(id).valid?
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def valid_format?(id)
|
35
|
+
new(id).valid_format?
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
def restore!(id_without_check_digit)
|
39
|
+
new(id_without_check_digit).restore!
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
def check_digit(id)
|
43
|
+
new(id).calculate_check_digit
|
44
|
+
end
|
43
45
|
end
|
44
46
|
|
45
47
|
def initialize(_sec_id_number)
|
@@ -89,11 +91,11 @@ module SecId
|
|
89
91
|
SecId::CHAR_TO_DIGIT.fetch(char)
|
90
92
|
end
|
91
93
|
|
92
|
-
def
|
94
|
+
def mod10(sum)
|
93
95
|
(10 - (sum % 10)) % 10
|
94
96
|
end
|
95
97
|
|
96
|
-
def
|
98
|
+
def div10mod10(number)
|
97
99
|
(number / 10) + (number % 10)
|
98
100
|
end
|
99
101
|
end
|
data/lib/sec_id/cusip.rb
CHANGED
@@ -8,7 +8,7 @@ module SecId
|
|
8
8
|
(?<cusip6>[A-Z0-9]{5}[A-Z0-9*@#])
|
9
9
|
(?<issue>[A-Z0-9*@#]{2}))
|
10
10
|
(?<check_digit>\d)?
|
11
|
-
\z/x
|
11
|
+
\z/x
|
12
12
|
|
13
13
|
attr_reader :cusip6, :issue
|
14
14
|
|
@@ -21,7 +21,7 @@ module SecId
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def calculate_check_digit
|
24
|
-
return
|
24
|
+
return mod10(modified_luhn_sum) if valid_format?
|
25
25
|
|
26
26
|
raise InvalidFormatError, "CUSIP '#{full_number}' is invalid and check-digit cannot be calculated!"
|
27
27
|
end
|
@@ -34,7 +34,7 @@ module SecId
|
|
34
34
|
|
35
35
|
id_digits.reverse.each_slice(2) do |even, odd|
|
36
36
|
double_even = (even || 0) * 2
|
37
|
-
sum +=
|
37
|
+
sum += div10mod10(double_even) + div10mod10(odd || 0)
|
38
38
|
end
|
39
39
|
|
40
40
|
sum
|
data/lib/sec_id/isin.rb
CHANGED
@@ -8,7 +8,7 @@ module SecId
|
|
8
8
|
(?<country_code>[A-Z]{2})
|
9
9
|
(?<nsin>[A-Z0-9]{9}))
|
10
10
|
(?<check_digit>\d)?
|
11
|
-
\z/x
|
11
|
+
\z/x
|
12
12
|
|
13
13
|
attr_reader :country_code, :nsin
|
14
14
|
|
@@ -21,7 +21,7 @@ module SecId
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def calculate_check_digit
|
24
|
-
return
|
24
|
+
return mod10(luhn_sum) if valid_format?
|
25
25
|
|
26
26
|
raise InvalidFormatError, "ISIN '#{full_number}' is invalid and check-digit cannot be calculated!"
|
27
27
|
end
|
data/lib/sec_id/sedol.rb
CHANGED
@@ -6,7 +6,7 @@ module SecId
|
|
6
6
|
ID_REGEX = /\A
|
7
7
|
(?<identifier>[0-9BCDFGHJKLMNPQRSTVWXYZ]{6})
|
8
8
|
(?<check_digit>\d)?
|
9
|
-
\z/x
|
9
|
+
\z/x
|
10
10
|
|
11
11
|
CHARACTER_WEIGHTS = [1, 3, 1, 7, 3, 9].freeze
|
12
12
|
|
@@ -17,7 +17,7 @@ module SecId
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def calculate_check_digit
|
20
|
-
return
|
20
|
+
return mod10(weighted_sum) if valid_format?
|
21
21
|
|
22
22
|
raise InvalidFormatError, "SEDOL '#{full_number}' is invalid and check-digit cannot be calculated!"
|
23
23
|
end
|
data/lib/sec_id/version.rb
CHANGED
data/sec_id.gemspec
CHANGED
@@ -15,17 +15,12 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = 'https://github.com/svyatov/sec_id'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
|
-
spec.required_ruby_version = '>=
|
18
|
+
spec.required_ruby_version = '>= 3.1.0'
|
19
19
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
22
22
|
f.match(%r{^(test|spec|features)/})
|
23
23
|
end
|
24
24
|
|
25
|
-
spec.
|
26
|
-
spec.add_development_dependency 'rake', '>= 10.0'
|
27
|
-
spec.add_development_dependency 'rspec', '~> 3.9'
|
28
|
-
spec.add_development_dependency 'rubocop', '~> 0.80.1'
|
29
|
-
spec.add_development_dependency 'rubocop-rspec', '~> 1.38'
|
30
|
-
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
25
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
31
26
|
end
|
metadata
CHANGED
@@ -1,99 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sec_id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Svyatov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.16'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.16'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.9'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.9'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.80.1
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.80.1
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop-rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.38'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.38'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: simplecov
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.17.1
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.17.1
|
11
|
+
date: 2024-07-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
97
13
|
description: 'Validate securities identification numbers with ease! Currently supported
|
98
14
|
standards: ISIN, CUSIP, SEDOL.'
|
99
15
|
email:
|
@@ -102,10 +18,11 @@ executables: []
|
|
102
18
|
extensions: []
|
103
19
|
extra_rdoc_files: []
|
104
20
|
files:
|
21
|
+
- ".github/dependabot.yml"
|
22
|
+
- ".github/workflows/main.yml"
|
105
23
|
- ".gitignore"
|
106
24
|
- ".rspec"
|
107
25
|
- ".rubocop.yml"
|
108
|
-
- ".travis.yml"
|
109
26
|
- CHANGELOG.md
|
110
27
|
- Gemfile
|
111
28
|
- LICENSE.txt
|
@@ -123,8 +40,9 @@ files:
|
|
123
40
|
homepage: https://github.com/svyatov/sec_id
|
124
41
|
licenses:
|
125
42
|
- MIT
|
126
|
-
metadata:
|
127
|
-
|
43
|
+
metadata:
|
44
|
+
rubygems_mfa_required: 'true'
|
45
|
+
post_install_message:
|
128
46
|
rdoc_options: []
|
129
47
|
require_paths:
|
130
48
|
- lib
|
@@ -132,15 +50,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
50
|
requirements:
|
133
51
|
- - ">="
|
134
52
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
53
|
+
version: 3.1.0
|
136
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
55
|
requirements:
|
138
56
|
- - ">="
|
139
57
|
- !ruby/object:Gem::Version
|
140
58
|
version: '0'
|
141
59
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
143
|
-
signing_key:
|
60
|
+
rubygems_version: 3.5.14
|
61
|
+
signing_key:
|
144
62
|
specification_version: 4
|
145
63
|
summary: Validate securities identification numbers with ease!
|
146
64
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sudo: false
|
3
|
-
cache: bundler
|
4
|
-
language: ruby
|
5
|
-
|
6
|
-
env:
|
7
|
-
global:
|
8
|
-
- CC_TEST_REPORTER_ID=48c33b2bc3ccdc6dafe9ed76482eca03cde47b922a7859074fc2be791247e5fd
|
9
|
-
|
10
|
-
rvm:
|
11
|
-
- 2.5
|
12
|
-
- 2.6
|
13
|
-
- 2.7
|
14
|
-
- ruby-head
|
15
|
-
- truffleruby
|
16
|
-
|
17
|
-
matrix:
|
18
|
-
allow_failures:
|
19
|
-
- rvm: ruby-head
|
20
|
-
- rvm: truffleruby
|
21
|
-
fast_finish: true
|
22
|
-
|
23
|
-
before_script:
|
24
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
25
|
-
- chmod +x ./cc-test-reporter
|
26
|
-
- ./cc-test-reporter before-build
|
27
|
-
|
28
|
-
script:
|
29
|
-
- bundle exec rake
|
30
|
-
|
31
|
-
after_script:
|
32
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|