bcd 1.0.1 → 1.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8345a229c3a07b8fb0c35d66d48739fd08a4f6a4482fc861e5857027266c85fd
4
- data.tar.gz: f507b3d23278d6c9211e9fc7839b42b0f88053aaa9ff28c67d98f33685ba3f95
3
+ metadata.gz: 43d349a90d0e08d30e3db724dbd74e6976ae19cf3d3778874c19774484b0ce8a
4
+ data.tar.gz: 5f6a9695ee9ad293db4050fcaba8a1085ed43e0c4e3b8ccb6e1726b5ebcbd7fe
5
5
  SHA512:
6
- metadata.gz: 6d81ccf95c501f76de100b0b613186a82af7656b7fe88aadb2de3d3010cc80cda10454227078e4459871a094918485432f63f4b5cb44b4a833ea9acd3aa91743
7
- data.tar.gz: 67ad12ce9f96fa2a3c9cbd330e9ed2e9503c5278f0c383596b1e14393535fc7644db9f90227f567698cd0e457ecb97955456b429ae8ec0103e688e3563dbd153
6
+ metadata.gz: 07a323238c74d36d9fcd611ef495d73a9701a1abb0a6122106a2778eb92242cc7013bde0e53f1f0b25f623eb59988998ee920d446bd423862cc546a561111095
7
+ data.tar.gz: 1f85aeca97c32a17348a056e42deba5029f13d3a8ecb5dee77a969d2a9e268afbf1e3b6d16a5615039a7d0a47d0558d373d66ced3eeac5b01b44c275cbcede51
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at dave@dafyddcrosby.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile CHANGED
@@ -1,11 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  group :development, optional: true do
6
- gem 'minitest'
7
- gem 'rake'
8
- gem 'rubocop'
9
- gem 'rubocop-minitest'
10
- gem 'rubocop-rake'
6
+ gem "dc-devtools", "~> 0.5"
7
+ gem("dc-typing", "~> 0.1.1") unless RUBY_VERSION.match?("3.[0-2]")
11
8
  end
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rake/testtask'
3
+ require "dc_rake"
4
+ require "dc_typing/rake"
5
+ require "rake/testtask"
4
6
 
5
7
  Rake::TestTask.new do |t|
6
- t.libs << 'test'
8
+ t.libs << "test"
7
9
  end
8
10
 
9
- desc 'Run tests'
10
- task default: :test
11
+ desc "Run tests"
12
+ task default: %i[test rubocop steep]
data/bcd.gemspec CHANGED
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'English'
3
+ require_relative "lib/bcd/version"
4
+
4
5
  Gem::Specification.new do |gem|
5
- gem.name = 'bcd'
6
- gem.version = '1.0.1'
7
- gem.summary = 'Binary Coded Decimal library'
8
- gem.description = 'A library for decoding and encoding binary coded decimal'
9
- gem.author = 'David Crosby'
10
- gem.email = 'dafydd@dafyddcrosby.com'
11
- gem.homepage = 'https://github.com/dafyddcrosby/ruby_bcd'
12
- gem.required_ruby_version = '>= 2.5'
13
- gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
14
- gem.require_paths = ['lib']
15
- gem.license = 'BSD-2-Clause'
16
- gem.metadata['rubygems_mfa_required'] = 'true'
6
+ gem.name = "bcd"
7
+ gem.version = BCD::VERSION
8
+ gem.summary = "Binary Coded Decimal library"
9
+ gem.description = "A library for decoding and encoding binary coded decimal"
10
+ gem.author = "David Crosby"
11
+ gem.email = "dafydd@dafyddcrosby.com"
12
+ gem.homepage = "https://github.com/dafyddcrosby/ruby_bcd"
13
+ gem.required_ruby_version = ">= 3.0"
14
+ gem.files = File.read("Manifest.txt").split
15
+ gem.require_paths = ["lib"]
16
+ gem.license = "BSD-2-Clause"
17
+ gem.metadata["rubygems_mfa_required"] = "true"
17
18
  end
data/lib/bcd.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rbs_inline: enabled
4
+
3
5
  # Methods to translate to and from binary coded decimal
4
6
  #
5
7
  # Author:: David Crosby <dafydd@dafyddcrosby.com>
@@ -8,15 +10,16 @@
8
10
 
9
11
  module BCD
10
12
  # Translates binary coded decimal into an integer
13
+ # : (Integer) -> Integer
11
14
  def self.decode(bcd)
12
- raise ArgumentError, 'Argument is not numeric' unless bcd.is_a? Numeric
13
- raise ArgumentError, 'Cannot be a negative integer' if bcd.negative?
15
+ raise ArgumentError, "Argument is not Integer" unless bcd.is_a? Integer
16
+ raise ArgumentError, "Cannot be a negative integer" if bcd.negative?
14
17
 
15
18
  binstring = String.new
16
19
  loop do
17
20
  q, r = bcd.divmod(10)
18
21
  nibble = r.to_s(2)
19
- nibble.prepend('0') while nibble.length < 4
22
+ nibble.prepend("0") while nibble.length < 4
20
23
  binstring.prepend(nibble)
21
24
  q.zero? ? break : bcd = q
22
25
  end
@@ -25,9 +28,10 @@ module BCD
25
28
  end
26
29
 
27
30
  # Translate an integer into binary coded decimal
31
+ # : (Integer) -> Integer
28
32
  def self.encode(int)
29
- raise ArgumentError, 'Argument is not numeric' unless int.is_a? Numeric
30
- raise ArgumentError, 'Cannot be a negative integer' if int.negative?
33
+ raise ArgumentError, "Argument is not Integer" unless int.is_a? Integer
34
+ raise ArgumentError, "Cannot be a negative integer" if int.negative?
31
35
 
32
36
  bcdstring = String.new
33
37
  while int.positive?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Crosby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-29 00:00:00.000000000 Z
11
+ date: 2025-06-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A library for decoding and encoding binary coded decimal
14
14
  email: dafydd@dafyddcrosby.com
@@ -16,15 +16,12 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - ".github/workflows/ruby.yaml"
20
- - ".gitignore"
21
- - ".rubocop.yml"
19
+ - CODE_OF_CONDUCT.md
22
20
  - Gemfile
23
21
  - README.md
24
22
  - Rakefile
25
23
  - bcd.gemspec
26
24
  - lib/bcd.rb
27
- - test/test_bcd.rb
28
25
  homepage: https://github.com/dafyddcrosby/ruby_bcd
29
26
  licenses:
30
27
  - BSD-2-Clause
@@ -38,14 +35,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
38
35
  requirements:
39
36
  - - ">="
40
37
  - !ruby/object:Gem::Version
41
- version: '2.5'
38
+ version: '3.0'
42
39
  required_rubygems_version: !ruby/object:Gem::Requirement
43
40
  requirements:
44
41
  - - ">="
45
42
  - !ruby/object:Gem::Version
46
43
  version: '0'
47
44
  requirements: []
48
- rubygems_version: 3.3.7
45
+ rubygems_version: 3.5.22
49
46
  signing_key:
50
47
  specification_version: 4
51
48
  summary: Binary Coded Decimal library
@@ -1,25 +0,0 @@
1
- name: Ruby
2
- on:
3
- push:
4
- branches: [ main ]
5
- pull_request:
6
- branches: [ main ]
7
- permissions:
8
- contents: read
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
- env:
13
- BUNDLE_WITH: development
14
- strategy:
15
- matrix:
16
- ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1']
17
- steps:
18
- - uses: actions/checkout@v3
19
- - name: Set up Ruby
20
- uses: ruby/setup-ruby@v1
21
- with:
22
- ruby-version: ${{ matrix.ruby-version }}
23
- bundler-cache: true
24
- - name: Run tests
25
- run: bundle exec rake
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *gem
2
- vendor
3
- .bundle
4
- Gemfile.lock
data/.rubocop.yml DELETED
@@ -1,3 +0,0 @@
1
- AllCops:
2
- NewCops: enable
3
- TargetRubyVersion: 2.5
data/test/test_bcd.rb DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'minitest/autorun'
4
- require 'minitest/pride'
5
- require 'bcd'
6
-
7
- class TestBCD < Minitest::Test
8
- def test_encode
9
- assert_equal 4, BCD.encode(4)
10
- assert_equal 22, BCD.encode(34)
11
- end
12
-
13
- def test_decode
14
- assert_equal 4, BCD.decode(4)
15
- assert_equal 345, BCD.decode(159)
16
- end
17
- end