xor_reverse_bitswap 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d1f93033512a439e8fb22494b9142a0cebb1a0a01e1b98a77663d88b86ad9210
4
+ data.tar.gz: 385dc2881b5e581e456e44351c4a85858ae53702e32531c996087fe391599c0f
5
+ SHA512:
6
+ metadata.gz: 5b7aaa5d691f45fe01096d576795f423892b1c6949a9060ab16470b693a6f5c0d7f997fee31805f814af648e3942236b60d3bcacb2ef30fbe19d8b4c8b90d427
7
+ data.tar.gz: f4127f207273af8a9d020e07c3138510bb41f0eed44303de3fed27d44d91280557b671f713d9db155ed3e13a5214f0baab358b9882ca2c7ab6c73513f3e94639
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.8
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-07-28
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in xor_reverse_bitswap.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ xor_reverse_bitswap (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ json (2.7.2)
11
+ language_server-protocol (3.17.0.3)
12
+ minitest (5.24.1)
13
+ parallel (1.25.1)
14
+ parser (3.3.4.0)
15
+ ast (~> 2.4.1)
16
+ racc
17
+ racc (1.8.0)
18
+ rainbow (3.1.1)
19
+ rake (13.2.1)
20
+ regexp_parser (2.9.2)
21
+ rexml (3.3.2)
22
+ strscan
23
+ rubocop (1.65.0)
24
+ json (~> 2.3)
25
+ language_server-protocol (>= 3.17.0)
26
+ parallel (~> 1.10)
27
+ parser (>= 3.3.0.2)
28
+ rainbow (>= 2.2.2, < 4.0)
29
+ regexp_parser (>= 2.4, < 3.0)
30
+ rexml (>= 3.2.5, < 4.0)
31
+ rubocop-ast (>= 1.31.1, < 2.0)
32
+ ruby-progressbar (~> 1.7)
33
+ unicode-display_width (>= 2.4.0, < 3.0)
34
+ rubocop-ast (1.31.3)
35
+ parser (>= 3.3.1.0)
36
+ ruby-progressbar (1.13.0)
37
+ strscan (3.1.0)
38
+ unicode-display_width (2.5.0)
39
+
40
+ PLATFORMS
41
+ x86_64-darwin-21
42
+
43
+ DEPENDENCIES
44
+ minitest (~> 5.0)
45
+ rake (~> 13.0)
46
+ rubocop (~> 1.21)
47
+ xor_reverse_bitswap!
48
+
49
+ BUNDLED WITH
50
+ 2.3.26
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # XorReverseBitswap
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/xor_reverse_bitswap`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add xor_reverse_bitswap
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install xor_reverse_bitswap
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/xor_reverse_bitswap.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module XorReverseBitswap
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "xor_reverse_bitswap/version"
4
+
5
+ module XorReverseBitswap
6
+ def self.single(n:, max_n:)
7
+ raise "max_n must be full 1s binary" unless max_n.to_s(2).count("0").zero?
8
+
9
+ (n ^ max_n).to_s(2).rjust(max_n.to_s(2).size, "0").reverse.to_i(2)
10
+ end
11
+
12
+ def self.enumerator(start_range:, end_range:, step_size: 1)
13
+ range_size = (end_range - start_range) / step_size
14
+ raise "range_size must be full 1s binary" unless range_size.to_s(2).count("0").zero?
15
+
16
+ bit_range_size = range_size.to_s(2).size
17
+ (0..range_size).map do |n|
18
+ (n ^ range_size).to_s(2).rjust(bit_range_size, "0").reverse.to_i(2)
19
+ end
20
+ end
21
+
22
+ def self.ranger(start_range:, end_range:, step_size: 1)
23
+ range_size = (end_range - start_range) / step_size
24
+ offset = (end_range - start_range)
25
+ raise "range_size must be full 1s binary" unless range_size.to_s(2).count("0").zero?
26
+
27
+ bit_range_size = range_size.to_s(2).size
28
+ (1..range_size).map do |n|
29
+ value = (n ^ range_size).to_s(2).rjust(bit_range_size, "0").reverse.to_i(2)
30
+ Range.new(
31
+ offset + (value * step_size),
32
+ offset + ((value + 1) * step_size)
33
+ ).tap do |r|
34
+ raise "range #{r} is out of bounds" unless (start_range..end_range).cover?(r)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,4 @@
1
+ module XorReverseBitswap
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xor_reverse_bitswap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Patryk Ptasinski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-07-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Xor Reverse Bitswap - Single, Range, Enumerated Traversal
14
+ email:
15
+ - patryk@ipepe.pl
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".rubocop.yml"
21
+ - ".ruby-version"
22
+ - CHANGELOG.md
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - README.md
26
+ - Rakefile
27
+ - lib/xor_reverse_bitswap.rb
28
+ - lib/xor_reverse_bitswap/version.rb
29
+ - sig/xor_reverse_bitswap.rbs
30
+ homepage: https://github.com/ipepe-oss/xor_reverse_bitswap
31
+ licenses: []
32
+ metadata:
33
+ allowed_push_host: https://rubygems.org
34
+ homepage_uri: https://github.com/ipepe-oss/xor_reverse_bitswap
35
+ source_code_uri: https://github.com/ipepe-oss/xor_reverse_bitswap
36
+ changelog_uri: https://github.com/ipepe-oss/xor_reverse_bitswap
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 2.7.0
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.1.6
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Xor Reverse Bitswap - Single, Range, Enumerated Traversal
56
+ test_files: []