bcd 0.3 → 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
- SHA1:
3
- metadata.gz: 32f1c0f41a42224ef25c90cd97ae4ec55668b6e4
4
- data.tar.gz: a5eb982d4f553eaca3ff51fcc24e03d1754a7961
2
+ SHA256:
3
+ metadata.gz: 43d349a90d0e08d30e3db724dbd74e6976ae19cf3d3778874c19774484b0ce8a
4
+ data.tar.gz: 5f6a9695ee9ad293db4050fcaba8a1085ed43e0c4e3b8ccb6e1726b5ebcbd7fe
5
5
  SHA512:
6
- metadata.gz: c9c0558a5cee280d7bebee0913dfce0d064de23fd43f29db0644b7f464b5eaec2d75190804c85e07e681668b4243fbf144a25068952e16e00cd20a2b210782d6
7
- data.tar.gz: 215ba5c0037d806b0461a1380cb89edac80312b2a926d7d1f9293608786c76b5c0b443f8db91c048c8ba09eeea62ac46c39cb53a651cb516f923a906596f2011
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 ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ group :development, optional: true do
6
+ gem "dc-devtools", "~> 0.5"
7
+ gem("dc-typing", "~> 0.1.1") unless RUBY_VERSION.match?("3.[0-2]")
8
+ end
data/Rakefile CHANGED
@@ -1,8 +1,12 @@
1
- require 'rake/testtask'
1
+ # frozen_string_literal: true
2
+
3
+ require "dc_rake"
4
+ require "dc_typing/rake"
5
+ require "rake/testtask"
2
6
 
3
7
  Rake::TestTask.new do |t|
4
- t.libs << 'test'
8
+ t.libs << "test"
5
9
  end
6
10
 
7
11
  desc "Run tests"
8
- task :default => :test
12
+ task default: %i[test rubocop steep]
data/bcd.gemspec CHANGED
@@ -1,14 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/bcd/version"
4
+
1
5
  Gem::Specification.new do |gem|
2
- gem.name = 'bcd'
3
- gem.version = '0.3'
4
- gem.summary = %q{Binary Coded Decimal library}
5
- gem.description = %q{A library for decoding and encoding binary coded decimal}
6
- gem.author = 'Dafydd Crosby'
7
- gem.email = 'dafydd@dafyddcrosby.com'
8
- gem.homepage = 'https://github.com/dafyddcrosby/ruby_bcd'
9
- gem.required_ruby_version = '>= 1.9'
10
- gem.files = `git ls-files`.split($\)
11
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
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
12
15
  gem.require_paths = ["lib"]
13
- gem.license = 'bsd' # (two-clause) BSD license
16
+ gem.license = "BSD-2-Clause"
17
+ gem.metadata["rubygems_mfa_required"] = "true"
14
18
  end
data/lib/bcd.rb CHANGED
@@ -1,36 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rbs_inline: enabled
4
+
1
5
  # Methods to translate to and from binary coded decimal
2
6
  #
3
- # Author:: Dafydd Crosby <dafydd@dafyddcrosby.com>
4
- # Copyright:: Copyright 2013, Dafydd Crosby
7
+ # Author:: David Crosby <dafydd@dafyddcrosby.com>
8
+ # Copyright:: Copyright 2013-2022 David Crosby
5
9
  # License:: BSD 2-clause
6
10
 
7
11
  module BCD
8
12
  # Translates binary coded decimal into an integer
13
+ # : (Integer) -> Integer
9
14
  def self.decode(bcd)
10
- raise ArgumentError, 'Argument is not numeric' unless bcd.is_a? Numeric
11
- raise ArgumentError, 'Cannot be a negative integer' if bcd < 0
15
+ raise ArgumentError, "Argument is not Integer" unless bcd.is_a? Integer
16
+ raise ArgumentError, "Cannot be a negative integer" if bcd.negative?
12
17
 
13
- binstring = ''
14
- while true do
18
+ binstring = String.new
19
+ loop do
15
20
  q, r = bcd.divmod(10)
16
21
  nibble = r.to_s(2)
17
- while nibble.length < 4 do
18
- nibble.prepend('0')
19
- end
22
+ nibble.prepend("0") while nibble.length < 4
20
23
  binstring.prepend(nibble)
21
- q == 0 ? break : bcd = q
24
+ q.zero? ? break : bcd = q
22
25
  end
23
26
 
24
27
  binstring.to_i(2)
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 < 0
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
- bcdstring = ''
33
- while int > 0 do
36
+ bcdstring = String.new
37
+ while int.positive?
34
38
  nibble = int % 16
35
39
  bcdstring.prepend(nibble.to_s)
36
40
  int >>= 4
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: '0.3'
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
- - Dafydd Crosby
8
- autorequire:
7
+ - David Crosby
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-15 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,35 +16,34 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - .gitignore
19
+ - CODE_OF_CONDUCT.md
20
+ - Gemfile
20
21
  - README.md
21
22
  - Rakefile
22
23
  - bcd.gemspec
23
24
  - lib/bcd.rb
24
- - test/test_bcd.rb
25
25
  homepage: https://github.com/dafyddcrosby/ruby_bcd
26
26
  licenses:
27
- - bsd
28
- metadata: {}
29
- post_install_message:
27
+ - BSD-2-Clause
28
+ metadata:
29
+ rubygems_mfa_required: 'true'
30
+ post_install_message:
30
31
  rdoc_options: []
31
32
  require_paths:
32
33
  - lib
33
34
  required_ruby_version: !ruby/object:Gem::Requirement
34
35
  requirements:
35
- - - '>='
36
+ - - ">="
36
37
  - !ruby/object:Gem::Version
37
- version: '1.9'
38
+ version: '3.0'
38
39
  required_rubygems_version: !ruby/object:Gem::Requirement
39
40
  requirements:
40
- - - '>='
41
+ - - ">="
41
42
  - !ruby/object:Gem::Version
42
43
  version: '0'
43
44
  requirements: []
44
- rubyforge_project:
45
- rubygems_version: 2.0.3
46
- signing_key:
45
+ rubygems_version: 3.5.22
46
+ signing_key:
47
47
  specification_version: 4
48
48
  summary: Binary Coded Decimal library
49
- test_files:
50
- - test/test_bcd.rb
49
+ test_files: []
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- *gem
data/test/test_bcd.rb DELETED
@@ -1,14 +0,0 @@
1
- require 'test/unit'
2
- require 'bcd'
3
-
4
- class TestBCD < Test::Unit::TestCase
5
- def test_encode
6
- assert_equal 4, BCD.encode(4)
7
- assert_equal 22, BCD.encode(34)
8
- end
9
-
10
- def test_decode
11
- assert_equal 4, BCD.decode(4)
12
- assert_equal 345, BCD.decode(159)
13
- end
14
- end