sec_id 2.0.1 → 4.0.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 +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/main.yml +39 -0
- data/.rubocop.yml +17 -2
- data/CHANGELOG.md +26 -0
- data/Gemfile +12 -0
- data/README.md +2 -3
- data/lib/sec_id/base.rb +40 -38
- data/lib/sec_id/cusip.rb +6 -6
- data/lib/sec_id/isin.rb +5 -5
- data/lib/sec_id/sedol.rb +6 -8
- data/lib/sec_id/version.rb +1 -1
- data/sec_id.gemspec +2 -7
- metadata +12 -94
- data/.travis.yml +0 -35
    
        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,21 +2,36 @@ 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
         | 
| 12 14 |  | 
| 13 15 | 
             
            Style/Documentation:
         | 
| 14 16 | 
             
              Enabled: false
         | 
| 15 17 |  | 
| 18 | 
            +
            Style/HashEachMethods:
         | 
| 19 | 
            +
              Enabled: true
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            Style/HashTransformKeys:
         | 
| 22 | 
            +
              Enabled: true
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            Style/HashTransformValues:
         | 
| 25 | 
            +
              Enabled: true
         | 
| 26 | 
            +
             | 
| 16 27 | 
             
            Metrics/BlockLength:
         | 
| 17 28 | 
             
              Exclude:
         | 
| 18 29 | 
             
                - 'spec/**/*'
         | 
| 19 30 |  | 
| 31 | 
            +
            Lint/MissingSuper:
         | 
| 32 | 
            +
              AllowedParentClasses:
         | 
| 33 | 
            +
                - Base
         | 
| 34 | 
            +
             | 
| 20 35 | 
             
            RSpec/MultipleExpectations:
         | 
| 21 36 | 
             
              Max: 5
         | 
| 22 37 |  | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,31 @@ | |
| 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 | 
            +
             | 
| 17 | 
            +
            ## [3.0.0] - 2020-03-10
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ### Breaking changes
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            - Minimum required Ruby version is 2.5 now
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ### Updated
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            - Small internal refactorings
         | 
| 26 | 
            +
            - TravisCI config updated: dropped Ruby 2.3 and 2.4, added Ruby 2.7
         | 
| 27 | 
            +
            - Rubocop's Ruby target version changed to 2.5
         | 
| 28 | 
            +
             | 
| 3 29 | 
             
            ## [2.0.0] - 2019-02-03
         | 
| 4 30 |  | 
| 5 31 | 
             
            ### Added
         | 
    
        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
    
    | @@ -1,45 +1,47 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            module SecId
         | 
| 4 | 
            -
               | 
| 5 | 
            -
                 | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
                 | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
                }.freeze
         | 
| 4 | 
            +
              CHAR_TO_DIGITS = {
         | 
| 5 | 
            +
                '0' => 0,      '1' => 1,      '2' => 2,      '3' => 3,      '4' => 4,
         | 
| 6 | 
            +
                '5' => 5,      '6' => 6,      '7' => 7,      '8' => 8,      '9' => 9,
         | 
| 7 | 
            +
                'A' => [1, 0], 'B' => [1, 1], 'C' => [1, 2], 'D' => [1, 3], 'E' => [1, 4],
         | 
| 8 | 
            +
                'F' => [1, 5], 'G' => [1, 6], 'H' => [1, 7], 'I' => [1, 8], 'J' => [1, 9],
         | 
| 9 | 
            +
                'K' => [2, 0], 'L' => [2, 1], 'M' => [2, 2], 'N' => [2, 3], 'O' => [2, 4],
         | 
| 10 | 
            +
                'P' => [2, 5], 'Q' => [2, 6], 'R' => [2, 7], 'S' => [2, 8], 'T' => [2, 9],
         | 
| 11 | 
            +
                'U' => [3, 0], 'V' => [3, 1], 'W' => [3, 2], 'X' => [3, 3], 'Y' => [3, 4], 'Z' => [3, 5],
         | 
| 12 | 
            +
                '*' => [3, 6], '@' => [3, 7], '#' => [3, 8]
         | 
| 13 | 
            +
              }.freeze
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              CHAR_TO_DIGIT = {
         | 
| 16 | 
            +
                '0' => 0,  '1' => 1,  '2' => 2,  '3' => 3,  '4' =>  4,
         | 
| 17 | 
            +
                '5' => 5,  '6' => 6,  '7' => 7,  '8' => 8,  '9' =>  9,
         | 
| 18 | 
            +
                'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, 'E' => 14,
         | 
| 19 | 
            +
                'F' => 15, 'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19,
         | 
| 20 | 
            +
                'K' => 20, 'L' => 21, 'M' => 22, 'N' => 23, 'O' => 24,
         | 
| 21 | 
            +
                'P' => 25, 'Q' => 26, 'R' => 27, 'S' => 28, 'T' => 29,
         | 
| 22 | 
            +
                'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34, 'Z' => 35,
         | 
| 23 | 
            +
                '*' => 36, '@' => 37, '#' => 38
         | 
| 24 | 
            +
              }.freeze
         | 
| 26 25 |  | 
| 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)
         | 
| @@ -72,7 +74,7 @@ module SecId | |
| 72 74 |  | 
| 73 75 | 
             
                private
         | 
| 74 76 |  | 
| 75 | 
            -
                def  | 
| 77 | 
            +
                def id_digits
         | 
| 76 78 | 
             
                  raise NotImplementedError
         | 
| 77 79 | 
             
                end
         | 
| 78 80 |  | 
| @@ -82,18 +84,18 @@ module SecId | |
| 82 84 | 
             
                end
         | 
| 83 85 |  | 
| 84 86 | 
             
                def char_to_digits(char)
         | 
| 85 | 
            -
                  CHAR_TO_DIGITS.fetch(char)
         | 
| 87 | 
            +
                  SecId::CHAR_TO_DIGITS.fetch(char)
         | 
| 86 88 | 
             
                end
         | 
| 87 89 |  | 
| 88 90 | 
             
                def char_to_digit(char)
         | 
| 89 | 
            -
                  CHAR_TO_DIGIT.fetch(char)
         | 
| 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
         | 
| @@ -32,16 +32,16 @@ module SecId | |
| 32 32 | 
             
                def modified_luhn_sum
         | 
| 33 33 | 
             
                  sum = 0
         | 
| 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
         | 
| 41 41 | 
             
                end
         | 
| 42 42 |  | 
| 43 | 
            -
                def  | 
| 44 | 
            -
                  @ | 
| 43 | 
            +
                def id_digits
         | 
| 44 | 
            +
                  @id_digits ||= identifier.each_char.map(&method(:char_to_digit))
         | 
| 45 45 | 
             
                end
         | 
| 46 46 | 
             
              end
         | 
| 47 47 | 
             
            end
         | 
    
        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
         | 
| @@ -32,7 +32,7 @@ module SecId | |
| 32 32 | 
             
                def luhn_sum
         | 
| 33 33 | 
             
                  sum = 0
         | 
| 34 34 |  | 
| 35 | 
            -
                   | 
| 35 | 
            +
                  id_digits.reverse.each_slice(2) do |even, odd|
         | 
| 36 36 | 
             
                    double_even = (even || 0) * 2
         | 
| 37 37 | 
             
                    double_even -= 9 if double_even > 9
         | 
| 38 38 | 
             
                    sum += double_even + (odd || 0)
         | 
| @@ -41,8 +41,8 @@ module SecId | |
| 41 41 | 
             
                  sum
         | 
| 42 42 | 
             
                end
         | 
| 43 43 |  | 
| 44 | 
            -
                def  | 
| 45 | 
            -
                  @ | 
| 44 | 
            +
                def id_digits
         | 
| 45 | 
            +
                  @id_digits ||= identifier.each_char.flat_map(&method(:char_to_digits))
         | 
| 46 46 | 
             
                end
         | 
| 47 47 | 
             
              end
         | 
| 48 48 | 
             
            end
         | 
    
        data/lib/sec_id/sedol.rb
    CHANGED
    
    | @@ -6,12 +6,10 @@ 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 |  | 
| 13 | 
            -
                attr_reader :full_number
         | 
| 14 | 
            -
             | 
| 15 13 | 
             
                def initialize(sedol)
         | 
| 16 14 | 
             
                  sedol_parts = parse sedol
         | 
| 17 15 | 
             
                  @identifier = sedol_parts[:identifier]
         | 
| @@ -19,7 +17,7 @@ module SecId | |
| 19 17 | 
             
                end
         | 
| 20 18 |  | 
| 21 19 | 
             
                def calculate_check_digit
         | 
| 22 | 
            -
                  return  | 
| 20 | 
            +
                  return mod10(weighted_sum) if valid_format?
         | 
| 23 21 |  | 
| 24 22 | 
             
                  raise InvalidFormatError, "SEDOL '#{full_number}' is invalid and check-digit cannot be calculated!"
         | 
| 25 23 | 
             
                end
         | 
| @@ -31,16 +29,16 @@ module SecId | |
| 31 29 | 
             
                  index = 0
         | 
| 32 30 | 
             
                  sum = 0
         | 
| 33 31 |  | 
| 34 | 
            -
                  while index <  | 
| 35 | 
            -
                    sum +=  | 
| 32 | 
            +
                  while index < id_digits.size
         | 
| 33 | 
            +
                    sum += id_digits[index] * CHARACTER_WEIGHTS[index]
         | 
| 36 34 | 
             
                    index += 1
         | 
| 37 35 | 
             
                  end
         | 
| 38 36 |  | 
| 39 37 | 
             
                  sum
         | 
| 40 38 | 
             
                end
         | 
| 41 39 |  | 
| 42 | 
            -
                def  | 
| 43 | 
            -
                  @ | 
| 40 | 
            +
                def id_digits
         | 
| 41 | 
            +
                  @id_digits ||= identifier.each_char.map(&method(:char_to_digit))
         | 
| 44 42 | 
             
                end
         | 
| 45 43 | 
             
              end
         | 
| 46 44 | 
             
            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.8'
         | 
| 28 | 
            -
              spec.add_development_dependency 'rubocop', '~> 0.63.1'
         | 
| 29 | 
            -
              spec.add_development_dependency 'rubocop-rspec', '~> 1.32'
         | 
| 30 | 
            -
              spec.add_development_dependency 'simplecov', '~> 0.16.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.8'
         | 
| 48 | 
            -
              type: :development
         | 
| 49 | 
            -
              prerelease: false
         | 
| 50 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            -
                requirements:
         | 
| 52 | 
            -
                - - "~>"
         | 
| 53 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: '3.8'
         | 
| 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.63.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.63.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.32'
         | 
| 76 | 
            -
              type: :development
         | 
| 77 | 
            -
              prerelease: false
         | 
| 78 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            -
                requirements:
         | 
| 80 | 
            -
                - - "~>"
         | 
| 81 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version: '1.32'
         | 
| 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.16.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.16.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,35 +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.3
         | 
| 12 | 
            -
              - 2.4
         | 
| 13 | 
            -
              - 2.5
         | 
| 14 | 
            -
              - 2.6
         | 
| 15 | 
            -
              - ruby-head
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            matrix:
         | 
| 18 | 
            -
              allow_failures:
         | 
| 19 | 
            -
                - rvm: ruby-head
         | 
| 20 | 
            -
              fast_finish: true
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            before_script:
         | 
| 23 | 
            -
              - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
         | 
| 24 | 
            -
              - chmod +x ./cc-test-reporter
         | 
| 25 | 
            -
              - ./cc-test-reporter before-build
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            script:
         | 
| 28 | 
            -
              - bundle exec rake
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            after_script:
         | 
| 31 | 
            -
              - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
         | 
| 32 | 
            -
             | 
| 33 | 
            -
            notifications:
         | 
| 34 | 
            -
              recipients: leonid@svyatov.ru
         | 
| 35 | 
            -
              on_failure: change
         |