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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 788d0384a5d7fbc2a7471e966c22bb89064495508bbe3e6b870c2b9ac8527277
4
- data.tar.gz: 547120561153ad0bfcde59563c7f83f6a5e3c47fe09e9aa2c00fe0bc087fb8e3
3
+ metadata.gz: 72b78963de0dcb28834950849ea30ce48cd31a756eaffdb0410fedc896d006c1
4
+ data.tar.gz: 100a735e3e09b8f60a96019725eb6fca6bc9890ae2e3be196005ba39a124545d
5
5
  SHA512:
6
- metadata.gz: db7ecd23585b13b2e1f9e185f6ac3d76d3c582bd27cb88cf25c419c027e2ce7caf7dab6452a195176cd49f757d3e1455df1e4953e4fe33bf48f910a304c8c976
7
- data.tar.gz: 68c75445a2b8d5b65b17ac7f7e1e3bbe81520448246ca2c9d499b710de0eef5d1cc9a137d64d44b2964e580adf1ac2f67851238b14aa7e8c6de3868c70bdd2b6
6
+ metadata.gz: 408aba0fa9ea8d1c7de2bf9a8b7a760f9f16925b8d7cdd3db05238cb5f71baf884e928036423986caa7c3cdb03882fde67ffcdd59e9a5844d0c2106b1d31217f
7
+ data.tar.gz: aace38f6b61de277f8f7fae5adf7aa48b86f9ba42b14b8e46a10bbc8d03e6f8c131a858043db1aa7f7dec594e303b187627b1c80965bb3389ac5d801c392632d
data/.gitignore CHANGED
@@ -6,6 +6,6 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
-
9
+ /.gem
10
10
  # rspec failure tracking
11
11
  .rspec_status
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/c_fnv`. To experiment with that code, run `bin/console` for an interactive prompt.
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 'c_fnv'
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 c_fnv
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 "c_fnv" do |ext|
6
- ext.lib_dir = "lib/c_fnv"
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)
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "c_fnv"
4
+ require "cfnv"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -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 "c_fnv/version"
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 = ["Riki Ueno"]
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/c_fnv/extconf.rb]
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.
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ require "mkmf"
2
+ create_makefile("cfnv/cfnv")
@@ -1,5 +1,5 @@
1
- require "c_fnv/version"
2
- require "c_fnv/c_fnv"
1
+ require "cfnv/version"
2
+ require "cfnv/cfnv"
3
3
 
4
4
  class CFnv
5
5
  class Error < StandardError; end
@@ -0,0 +1,3 @@
1
+ class CFnv
2
+ VERSION = "0.2.3"
3
+ end
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.1.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
- - Riki Ueno
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/c_fnv/extconf.rb
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
- - c_fnv.gemspec
74
- - ext/c_fnv/c_fnv.c
75
- - ext/c_fnv/extconf.rb
76
- - lib/c_fnv.rb
77
- - lib/c_fnv/version.rb
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.1
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.
@@ -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
- }
@@ -1,2 +0,0 @@
1
- require "mkmf"
2
- create_makefile("c_fnv/c_fnv")
@@ -1,3 +0,0 @@
1
- class CFnv
2
- VERSION = "0.1.0"
3
- end