cfnv 0.1.0 → 0.2.3
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 +4 -4
- data/.gitignore +1 -1
- data/README.md +3 -3
- data/Rakefile +2 -2
- data/bin/console +1 -1
- data/{c_fnv.gemspec → cfnv.gemspec} +3 -3
- data/ext/cfnv/cfnv.c +87 -0
- data/ext/cfnv/extconf.rb +2 -0
- data/lib/{c_fnv.rb → cfnv.rb} +2 -2
- data/lib/cfnv/version.rb +3 -0
- metadata +9 -9
- data/ext/c_fnv/c_fnv.c +0 -30
- data/ext/c_fnv/extconf.rb +0 -2
- data/lib/c_fnv/version.rb +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72b78963de0dcb28834950849ea30ce48cd31a756eaffdb0410fedc896d006c1
|
|
4
|
+
data.tar.gz: 100a735e3e09b8f60a96019725eb6fca6bc9890ae2e3be196005ba39a124545d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 408aba0fa9ea8d1c7de2bf9a8b7a760f9f16925b8d7cdd3db05238cb5f71baf884e928036423986caa7c3cdb03882fde67ffcdd59e9a5844d0c2106b1d31217f
|
|
7
|
+
data.tar.gz: aace38f6b61de277f8f7fae5adf7aa48b86f9ba42b14b8e46a10bbc8d03e6f8c131a858043db1aa7f7dec594e303b187627b1c80965bb3389ac5d801c392632d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CFnv
|
|
2
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/
|
|
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/cfnv`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
4
|
|
|
5
5
|
TODO: Delete this and the text above, and describe your gem
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
|
|
|
9
9
|
Add this line to your application's Gemfile:
|
|
10
10
|
|
|
11
11
|
```ruby
|
|
12
|
-
gem '
|
|
12
|
+
gem 'cfnv'
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
And then execute:
|
|
@@ -18,7 +18,7 @@ And then execute:
|
|
|
18
18
|
|
|
19
19
|
Or install it yourself as:
|
|
20
20
|
|
|
21
|
-
$ gem install
|
|
21
|
+
$ gem install cfnv
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
data/Rakefile
CHANGED
|
@@ -2,8 +2,8 @@ require "bundler/gem_tasks"
|
|
|
2
2
|
#require "rspec/core/rake_task"
|
|
3
3
|
require "rake/extensiontask"
|
|
4
4
|
|
|
5
|
-
Rake::ExtensionTask.new "
|
|
6
|
-
ext.lib_dir = "lib/
|
|
5
|
+
Rake::ExtensionTask.new "cfnv" do |ext|
|
|
6
|
+
ext.lib_dir = "lib/cfnv"
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
#RSpec::Core::RakeTask.new(:spec)
|
data/bin/console
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
lib = File.expand_path("../lib", __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require "
|
|
4
|
+
require "cfnv/version"
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "cfnv"
|
|
8
8
|
spec.version = CFnv::VERSION
|
|
9
|
-
spec.authors = ["
|
|
9
|
+
spec.authors = ["g-ken"]
|
|
10
10
|
spec.email = ["31506@toyota.kosen-ac.jp"]
|
|
11
11
|
|
|
12
12
|
spec.summary = %q{fnv1 and fnv1a hash algo in C-Extentions.}
|
|
13
13
|
spec.description = %q{fnv1 and fnv1a hash algo in C-Extentions.}
|
|
14
14
|
spec.homepage = "https://github.com/g-ken/cfnv"
|
|
15
15
|
spec.license = "MIT"
|
|
16
|
-
spec.extensions = %w[ext/
|
|
16
|
+
spec.extensions = %w[ext/cfnv/extconf.rb]
|
|
17
17
|
|
|
18
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
19
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
data/ext/cfnv/cfnv.c
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#include <ruby.h>
|
|
2
|
+
#include <stdint.h>
|
|
3
|
+
#include <string.h>
|
|
4
|
+
|
|
5
|
+
static VALUE
|
|
6
|
+
|
|
7
|
+
fnv_fnv132(VALUE self, VALUE arg) {
|
|
8
|
+
char *str = NULL;
|
|
9
|
+
uint32_t offset_basis = 2166136261U;
|
|
10
|
+
uint32_t cFNV_PRIME = 16777619U;
|
|
11
|
+
uint32_t hash = 0;
|
|
12
|
+
int i;
|
|
13
|
+
|
|
14
|
+
Check_Type(arg, T_STRING);
|
|
15
|
+
str = StringValuePtr(arg);
|
|
16
|
+
int len = strlen(str);
|
|
17
|
+
hash = offset_basis;
|
|
18
|
+
for (i = 0; i < len; i++) {
|
|
19
|
+
hash *= cFNV_PRIME;
|
|
20
|
+
hash ^= str[i];
|
|
21
|
+
}
|
|
22
|
+
return INT2FIX(hash);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fnv_fnv1a32(VALUE self, VALUE arg) {
|
|
26
|
+
char *str = NULL;
|
|
27
|
+
uint32_t offset_basis = 2166136261U;
|
|
28
|
+
uint32_t cFNV_PRIME = 16777619U;
|
|
29
|
+
uint32_t hash = 0;
|
|
30
|
+
int i;
|
|
31
|
+
|
|
32
|
+
Check_Type(arg, T_STRING);
|
|
33
|
+
str = StringValuePtr(arg);
|
|
34
|
+
int len = strlen(str);
|
|
35
|
+
hash = offset_basis;
|
|
36
|
+
for (i = 0; i < len; i++) {
|
|
37
|
+
hash ^= str[i];
|
|
38
|
+
hash *= cFNV_PRIME;
|
|
39
|
+
}
|
|
40
|
+
return INT2FIX(hash);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fnv_fnv164(VALUE self, VALUE arg) {
|
|
44
|
+
char *str = NULL;
|
|
45
|
+
uint64_t offset_basis = 14695981039346656037U;
|
|
46
|
+
uint64_t cFNV_PRIME = 1099511628211U;
|
|
47
|
+
uint64_t hash = 0;
|
|
48
|
+
int i;
|
|
49
|
+
|
|
50
|
+
Check_Type(arg, T_STRING);
|
|
51
|
+
str = StringValuePtr(arg);
|
|
52
|
+
int len = strlen(str);
|
|
53
|
+
hash = offset_basis;
|
|
54
|
+
for (i = 0; i < len; i++) {
|
|
55
|
+
hash *= cFNV_PRIME;
|
|
56
|
+
hash ^= str[i];
|
|
57
|
+
}
|
|
58
|
+
return INT2FIX(hash);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
fnv_fnv1a64(VALUE self, VALUE arg) {
|
|
62
|
+
char *str = NULL;
|
|
63
|
+
uint64_t offset_basis = 14695981039346656037U;
|
|
64
|
+
uint64_t cFNV_PRIME = 1099511628211U;
|
|
65
|
+
uint64_t hash = 0;
|
|
66
|
+
int i;
|
|
67
|
+
|
|
68
|
+
Check_Type(arg, T_STRING);
|
|
69
|
+
str = StringValuePtr(arg);
|
|
70
|
+
int len = strlen(str);
|
|
71
|
+
hash = offset_basis;
|
|
72
|
+
for (i = 0; i < len; i++) {
|
|
73
|
+
hash ^= str[i];
|
|
74
|
+
hash *= cFNV_PRIME;
|
|
75
|
+
}
|
|
76
|
+
return INT2FIX(hash);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void Init_cfnv() {
|
|
80
|
+
/*Fnv classを定義*/
|
|
81
|
+
VALUE cFnv = rb_define_class("CFnv", rb_cObject);
|
|
82
|
+
/*fnv132 methodを定義*/
|
|
83
|
+
rb_define_method(cFnv, "fnv132", fnv_fnv132, 1);
|
|
84
|
+
rb_define_method(cFnv, "fnv1a32", fnv_fnv1a32, 1);
|
|
85
|
+
rb_define_method(cFnv, "fnv164", fnv_fnv164, 1);
|
|
86
|
+
rb_define_method(cFnv, "fnv1a64", fnv_fnv1a64, 1);
|
|
87
|
+
}
|
data/ext/cfnv/extconf.rb
ADDED
data/lib/{c_fnv.rb → cfnv.rb}
RENAMED
data/lib/cfnv/version.rb
ADDED
metadata
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cfnv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- g-ken
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
@@ -57,7 +57,7 @@ email:
|
|
|
57
57
|
- 31506@toyota.kosen-ac.jp
|
|
58
58
|
executables: []
|
|
59
59
|
extensions:
|
|
60
|
-
- ext/
|
|
60
|
+
- ext/cfnv/extconf.rb
|
|
61
61
|
extra_rdoc_files: []
|
|
62
62
|
files:
|
|
63
63
|
- ".gitignore"
|
|
@@ -70,11 +70,11 @@ files:
|
|
|
70
70
|
- Rakefile
|
|
71
71
|
- bin/console
|
|
72
72
|
- bin/setup
|
|
73
|
-
-
|
|
74
|
-
- ext/
|
|
75
|
-
- ext/
|
|
76
|
-
- lib/
|
|
77
|
-
- lib/
|
|
73
|
+
- cfnv.gemspec
|
|
74
|
+
- ext/cfnv/cfnv.c
|
|
75
|
+
- ext/cfnv/extconf.rb
|
|
76
|
+
- lib/cfnv.rb
|
|
77
|
+
- lib/cfnv/version.rb
|
|
78
78
|
homepage: https://github.com/g-ken/cfnv
|
|
79
79
|
licenses:
|
|
80
80
|
- MIT
|
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '0'
|
|
96
96
|
requirements: []
|
|
97
|
-
rubygems_version: 3.0.
|
|
97
|
+
rubygems_version: 3.0.2
|
|
98
98
|
signing_key:
|
|
99
99
|
specification_version: 4
|
|
100
100
|
summary: fnv1 and fnv1a hash algo in C-Extentions.
|
data/ext/c_fnv/c_fnv.c
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#include <ruby.h>
|
|
2
|
-
#include <stdint.h>
|
|
3
|
-
#include <string.h>
|
|
4
|
-
|
|
5
|
-
static VALUE
|
|
6
|
-
|
|
7
|
-
fnv_fnv132(VALUE self, VALUE arg) {
|
|
8
|
-
char *str = NULL;
|
|
9
|
-
uint32_t offset_basis = 2166136261U;
|
|
10
|
-
uint32_t cFNV_PRIME = 16777619U;
|
|
11
|
-
uint32_t hash = 0;
|
|
12
|
-
int i;
|
|
13
|
-
|
|
14
|
-
Check_Type(arg, T_STRING);
|
|
15
|
-
str = StringValuePtr(arg);
|
|
16
|
-
int len = strlen(str);
|
|
17
|
-
hash = offset_basis;
|
|
18
|
-
for (i = 0; i < len; i++) {
|
|
19
|
-
hash *= cFNV_PRIME;
|
|
20
|
-
hash ^= str[i];
|
|
21
|
-
}
|
|
22
|
-
return INT2FIX(hash);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
void Init_fnv() {
|
|
26
|
-
/*Fnv classを定義*/
|
|
27
|
-
VALUE cFnv = rb_define_class("CFnv", rb_cObject);
|
|
28
|
-
/*fnv132 methodを定義*/
|
|
29
|
-
rb_define_method(cFnv, "fnv132", fnv_fnv132, 1);
|
|
30
|
-
}
|
data/ext/c_fnv/extconf.rb
DELETED
data/lib/c_fnv/version.rb
DELETED