djb2 0.1.1-x86_64-linux

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: 2148eed697b613f247f044631c4016feb1d997e0c1d0d389adeb4f1b25c35532
4
+ data.tar.gz: b415a467b72c80902300a173d2656c59370631766f5068e08a3ff7b3d76cb712
5
+ SHA512:
6
+ metadata.gz: 2b8e50d5cd201cfd975396eddecb54f7f8efeb3ff8176c6ddc8daaae6f15f1d30c73e3375fe6de19758a5efa6480fe128eb0b27cb96491b059dfbbd7c8d253ea
7
+ data.tar.gz: d752e8275cb956495cfc5c0b96296ee58d230e3143d8f4700eaaa1e148a5867a85fe0ba365c363e0ade4aff20cf308949101df203fdf7d28d7da8929860ed498
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 4.0.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-11-24
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Shopify
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,35 @@
1
+ # DJB2
2
+
3
+ Native djb2 hash implementation
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ $ bundle add djb2
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install djb2
14
+
15
+ ## Usage
16
+
17
+ ```ruby
18
+ require "djb2"
19
+
20
+ DJB2.digest("Some String") # => 13838202372652591140
21
+ ```
22
+
23
+ ## Development
24
+
25
+ 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.
26
+
27
+ 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).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/djb2.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,22 @@
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 "rake/extensiontask"
13
+
14
+ task build: :compile
15
+
16
+ GEMSPEC = Gem::Specification.load("djb2.gemspec")
17
+
18
+ Rake::ExtensionTask.new("djb2", GEMSPEC) do |ext|
19
+ ext.lib_dir = "lib/djb2"
20
+ end
21
+
22
+ task default: %i[clobber compile test]
data/ext/djb2/djb2.c ADDED
@@ -0,0 +1,28 @@
1
+ #include "ruby.h"
2
+
3
+ VALUE rb_mDJB2;
4
+
5
+ uint64_t
6
+ djb_hash_2(const char *string, long length)
7
+ {
8
+ uint64_t hash = 5381;
9
+ long index;
10
+ for (index = 0; index < length; index++) {
11
+ hash = (hash * 33) ^ (unsigned char)string[index];
12
+ }
13
+ return hash;
14
+ }
15
+
16
+ static VALUE
17
+ rb_djb_hash_2(VALUE self, VALUE str)
18
+ {
19
+ Check_Type(str, T_STRING);
20
+ return ULL2NUM(djb_hash_2(RSTRING_PTR(str), RSTRING_LEN(str)));
21
+ }
22
+
23
+ RUBY_FUNC_EXPORTED void
24
+ Init_djb2(void)
25
+ {
26
+ rb_mDJB2 = rb_define_module("DJB2");
27
+ rb_define_singleton_method(rb_mDJB2, "digest", rb_djb_hash_2, 1);
28
+ }
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+
5
+ # Makes all symbols private by default to avoid unintended conflict
6
+ # with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
7
+ # selectively, or entirely remove this flag.
8
+ append_cflags("-fvisibility=hidden")
9
+
10
+ create_makefile("djb2/djb2")
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DJB2
4
+ VERSION = "0.1.1"
5
+ end
data/lib/djb2.rb ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "djb2/version"
4
+
5
+ begin
6
+ # Load the precompiled version of the library
7
+ ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION)
8
+ require "djb2/#{ruby_version}/djb2"
9
+ rescue LoadError
10
+ # It's important to leave for users that can not or don't want to use the gem with precompiled binaries.
11
+ require "djb2/djb2"
12
+ end
13
+
14
+ module DJB2
15
+ class Error < StandardError; end
16
+ # Your code goes here...
17
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: djb2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: x86_64-linux
6
+ authors:
7
+ - Jean Boussier
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-02-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - jean.boussier@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".ruby-version"
21
+ - CHANGELOG.md
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - ext/djb2/djb2.c
26
+ - ext/djb2/extconf.rb
27
+ - lib/djb2.rb
28
+ - lib/djb2/3.1/djb2.so
29
+ - lib/djb2/3.2/djb2.so
30
+ - lib/djb2/3.3/djb2.so
31
+ - lib/djb2/3.4/djb2.so
32
+ - lib/djb2/4.0/djb2.so
33
+ - lib/djb2/version.rb
34
+ homepage: https://github.com/Shopify/djb2
35
+ licenses:
36
+ - MIT
37
+ metadata:
38
+ bug_tracker_uri: https://github.com/Shopify/djb2/issues
39
+ source_code_uri: https://github.com/Shopify/djb2
40
+ allowed_push_host: https://rubygems.org
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '3.1'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 4.1.dev
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubygems_version: 3.3.27
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Native djb2 hash implementation
63
+ test_files: []