npi 1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 24d68e6fa444a2204dc0ea3a61b7698b52441d4820b1d34ec63ee0ae437716ed
4
+ data.tar.gz: ec755732e814a52343412df7dc55c139c3ae15127ad1e3e8789b0971eabe3782
5
+ SHA512:
6
+ metadata.gz: 41199ba660e59864eeed5f7e70081eec35d97f37dba6bd29d0660be23cce45a2ca42c5622bb93864a17b402bc0343b6e16017700f3ca9db6a7453a38cafbff20
7
+ data.tar.gz: 343505c5957d49f2f4281c6f7908ec45556c5da2c06b05b871fd59013371be54ff884febf0d28818218213f927940c17c6a0cce1a6f302136b947e5e00839f7d
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+
5
+ ---
6
+
7
+ <!--
8
+
9
+ Have you read our Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/mylanconnolly/npi/blob/main/CODE_OF_CONDUCT.md
10
+
11
+ -->
12
+
13
+ ### Prerequisites
14
+
15
+ * [ ] Put an X between the brackets on this line if you have done all of the following:
16
+ * Checked that your issue isn't already filed: <https://github.com/mylanconnolly/npi/issues>
17
+
18
+ ### Description
19
+
20
+ <!-- Description of the issue -->
21
+
22
+ ### Steps to Reproduce
23
+
24
+ 1. <!-- First Step -->
25
+ 2. <!-- Second Step -->
26
+ 3. <!-- and so on… -->
27
+
28
+ **Expected behavior:**
29
+
30
+ <!-- What you expect to happen -->
31
+
32
+ **Actual behavior:**
33
+
34
+ <!-- What actually happens -->
35
+
36
+ **Reproduces how often:**
37
+
38
+ <!-- What percentage of the time does it reproduce? -->
39
+
40
+ ### Versions
41
+
42
+ <!-- Which version of the gem are you using? -->
43
+
44
+ ### Additional Information
45
+
46
+ <!-- Any additional information, configuration or data that might be necessary to reproduce the issue. -->
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+
5
+ ---
6
+
7
+ <!--
8
+
9
+ Have you read our Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/mylanconnolly/npi/blob/main/CODE_OF_CONDUCT.md
10
+
11
+ -->
12
+
13
+ ## Summary
14
+
15
+ <!-- One paragraph explanation of the feature. -->
16
+
17
+ ## Motivation
18
+
19
+ <!-- Why are we doing this? What use cases does it support? What is the expected outcome? -->
20
+
21
+ ## Describe alternatives you've considered
22
+
23
+ <!-- A clear and concise description of the alternative solutions you've considered. Be sure to explain why the existing functionality isn't suitable for this feature. -->
24
+
25
+ ## Additional context
26
+
27
+ <!-- Add any other context or information about the feature request here. -->
@@ -0,0 +1,7 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: "bundler" # See documentation for possible values
5
+ directory: "/" # Location of package manifests
6
+ schedule:
7
+ interval: "daily"
@@ -0,0 +1,27 @@
1
+ name: Ruby
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ${{ matrix.os }}
8
+
9
+ strategy:
10
+ matrix:
11
+ os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
12
+ ruby: ['2.7', '3.0', 'truffleruby']
13
+ exclude:
14
+ - os: windows-latest
15
+ ruby: truffleruby
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ bundler-cache: true
25
+
26
+ - name: Run the tests
27
+ run: bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ # build artifacts
14
+ *.gem
15
+
16
+ # Gemfile.lock, since we're a gem
17
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 2.7
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+
15
+ Metrics/BlockLength:
16
+ Exclude:
17
+ - 'spec/**/*'
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2021-09-03
9
+
10
+ Initial release.
@@ -0,0 +1,133 @@
1
+
2
+ # Contributor Covenant Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, caste, color, religion, or sexual identity
11
+ and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ ## Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the
27
+ overall community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or
32
+ advances of any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement at
64
+ mylan@mylan.io. All complaints will be reviewed and investigated promptly and
65
+ fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
85
+
86
+ **Community Impact**: A violation through a single incident or series
87
+ of actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or
94
+ permanent ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within
114
+ the community.
115
+
116
+ ## Attribution
117
+
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.1, available at
120
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
121
+
122
+ Community Impact Guidelines were inspired by
123
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124
+
125
+ For answers to common questions about this code of conduct, see the FAQ at
126
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
127
+ at [https://www.contributor-covenant.org/translations][translations].
128
+
129
+ [homepage]: https://www.contributor-covenant.org
130
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
131
+ [Mozilla CoC]: https://github.com/mozilla/diversity
132
+ [FAQ]: https://www.contributor-covenant.org/faq
133
+ [translations]: https://www.contributor-covenant.org/translations
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in npi.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
11
+
12
+ gem 'rubocop', '~> 1.10'
13
+ gem 'rubocop-performance'
14
+ gem 'rubocop-rake'
15
+ gem 'rubocop-rspec'
16
+
17
+ gem 'solargraph'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Mylan Connolly
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/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # NPI
2
+
3
+ This is a simple Ruby gem for interacting with NPI numbers. Currently, the only
4
+ available method is `NPI.valid?`, which checks whether the NPI number is a valid
5
+ NPI number. Note that this just performs the check digit verification, so it
6
+ could potentially be unassigned.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'npi'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle install
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install npi
23
+
24
+ ## Usage
25
+
26
+ Check an NPI number's validity in the following way:
27
+
28
+ ```ruby
29
+ NPI.valid?(1234)
30
+ #=> false
31
+
32
+ NPI.valid?(1215290382)
33
+ #=> true
34
+ ```
35
+
36
+ Note that you can use a string or integer.
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
41
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
42
+ prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To
45
+ release a new version, update the version number in `version.rb`, and then run
46
+ `bundle exec rake release`, which will create a git tag for the version, push
47
+ git commits and the created tag, and push the `.gem` file to
48
+ [rubygems.org](https://rubygems.org).
49
+
50
+ ## Contributing
51
+
52
+ Bug reports and pull requests are welcome on GitHub at
53
+ https://github.com/mylanconnolly/npi. This project is intended to be a safe,
54
+ welcoming space for collaboration, and contributors are expected to adhere to
55
+ the [code of conduct](https://github.com/mylanconnolly/npi/blob/main/CODE_OF_CONDUCT.md).
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the
60
+ [MIT License](https://opensource.org/licenses/MIT).
61
+
62
+ ## Code of Conduct
63
+
64
+ Everyone interacting in the Npi project's codebases, issue trackers, chat rooms
65
+ and mailing lists is expected to follow the
66
+ [code of conduct](https://github.com/mylanconnolly/npi/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'npi'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NPI
4
+ VERSION = '1.0.0'
5
+ end
data/lib/npi.rb ADDED
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'npi/version'
4
+
5
+ # This is the main NPI module. Currently, the only public method here is
6
+ # `valid?`, whch is used to check whether an NPI number is valid.
7
+ module NPI
8
+ NPI_LENGTH = 10
9
+ NUMERIC_REGEXP = /\A\d+\z/.freeze
10
+
11
+ # This method is used to check whether an NPI number is valid. For our
12
+ # purposes, "valid" is defined as having a matching check digit and matching
13
+ # the defined NPI format.
14
+ #
15
+ # This does not check whether the NPI number has been assigned.
16
+ def self.valid?(number)
17
+ number = number.to_s
18
+ return false if number.length < 10 || !number.match(NUMERIC_REGEXP)
19
+
20
+ check_digit(number) == number[-1].to_i
21
+ end
22
+
23
+ def self.check_digit(number)
24
+ check_val = check_value(number)
25
+ check_digit = check_val % 10
26
+ check_digit.zero? ? check_digit : 10 - check_digit
27
+ end
28
+
29
+ private_class_method :check_digit
30
+
31
+ def self.check_value(number)
32
+ number[0...9]
33
+ .chars
34
+ .map(&:to_i)
35
+ .each_with_index
36
+ .map { |v, i| i.even? ? v * 2 : v }
37
+ .map { |v| v < 10 ? v : v.to_s.chars.map(&:to_i) }
38
+ .flatten
39
+ .push(24)
40
+ .sum
41
+ end
42
+
43
+ private_class_method :check_value
44
+ end
data/npi.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/npi/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'npi'
7
+ spec.version = NPI::VERSION
8
+ spec.authors = ['Mylan Connolly']
9
+ spec.email = ['mylan@mylan.io']
10
+ spec.summary = 'A Ruby library for interacting with NPI numbers.'
11
+ spec.homepage = 'https://github.com/mylanconnolly/npi'
12
+ spec.license = 'MIT'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
14
+
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = 'https://github.com/mylanconnolly/npi'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/mylanconnolly/npi/blob/main/CHANGELOG.md'
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
23
+ end
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ # Uncomment to register a new dependency of your gem
29
+ # spec.add_dependency "example-gem", "~> 1.0"
30
+
31
+ # For more information and examples about making a new gem, checkout our
32
+ # guide at: https://bundler.io/guides/creating_gem.html
33
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: npi
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mylan Connolly
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - mylan@mylan.io
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
21
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
22
+ - ".github/dependabot.yml"
23
+ - ".github/workflows/main.yml"
24
+ - ".gitignore"
25
+ - ".rspec"
26
+ - ".rubocop.yml"
27
+ - CHANGELOG.md
28
+ - CODE_OF_CONDUCT.md
29
+ - Gemfile
30
+ - LICENSE.txt
31
+ - README.md
32
+ - Rakefile
33
+ - bin/console
34
+ - bin/setup
35
+ - lib/npi.rb
36
+ - lib/npi/version.rb
37
+ - npi.gemspec
38
+ homepage: https://github.com/mylanconnolly/npi
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ homepage_uri: https://github.com/mylanconnolly/npi
43
+ source_code_uri: https://github.com/mylanconnolly/npi
44
+ changelog_uri: https://github.com/mylanconnolly/npi/blob/main/CHANGELOG.md
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.7.0
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.2.3
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: A Ruby library for interacting with NPI numbers.
64
+ test_files: []