foxify 0.9.2 → 0.9.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/CHANGELOG.md +8 -0
- data/README.md +7 -0
- data/ext/foxify/foxify.go +11 -6
- data/lib/foxify/resumable_sha1.rb +10 -0
- data/lib/foxify/resumable_sha256.rb +10 -0
- data/lib/foxify/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f26749a717084f16f09d980a516f9091fac7e721d91e4cedbbb881fc69c46a1
|
4
|
+
data.tar.gz: b61f00854ef46ef26933be9c3c29cf994932945af640b3ab198eef7716683943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0256939b9a297eb2df40c13fc2467d64c6256462d2dbcb884addac3e0016072d774ecf1b1d53eda9770ec361c54caf64aa47b724fe03722cade6fe63f237aaba'
|
7
|
+
data.tar.gz: a07b91c76af00c10be2438d1a215d6b45adc39b024813805c3c5535cdb0805fb52ff8e59cd4cf6d38409b80c3e9c31aad9c4d38abc979a0b43af0f70844774e0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
## [0.9.3] - 2025-03-31
|
6
|
+
|
7
|
+
- Switch to pointers for data passing
|
8
|
+
- [#2](https://github.com/orlon-pro/foxify/issues/2#issue-2782741001) Implement the `file` class method
|
9
|
+
- Update dependencies
|
10
|
+
|
3
11
|
## [0.9.2] - 2025-01-12
|
4
12
|
|
5
13
|
- Implement `hexdigest` class method
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
[](https://github.com/orlon-pro/foxify/actions/workflows/main.yml)
|
2
|
+
[](https://badge.fury.io/rb/foxify)
|
2
3
|
|
3
4
|
# Foxify
|
4
5
|
|
@@ -87,6 +88,12 @@ restored.update("jumps over the lazy dog")
|
|
87
88
|
restored.hexdigest # returns "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"
|
88
89
|
```
|
89
90
|
|
91
|
+
## Mascot
|
92
|
+
|
93
|
+
You asked for it, here we go:
|
94
|
+
|
95
|
+
<img src="https://github.com/user-attachments/assets/d24520da-ffa5-4203-b0b6-c0770f1b9964" width="200">
|
96
|
+
|
90
97
|
## Contributing
|
91
98
|
|
92
99
|
Bug reports and pull requests are welcome on GitHub at https://github.com/orlon-pro/foxify.
|
data/ext/foxify/foxify.go
CHANGED
@@ -19,6 +19,7 @@ import (
|
|
19
19
|
"encoding/base64"
|
20
20
|
"encoding/hex"
|
21
21
|
"log"
|
22
|
+
"unsafe"
|
22
23
|
|
23
24
|
"github.com/ruby-go-gem/go-gem-wrapper/ruby"
|
24
25
|
)
|
@@ -58,9 +59,11 @@ func rb_foxify_resumable_sha256_update(_ C.VALUE, state C.VALUE, data C.VALUE) C
|
|
58
59
|
unmarshaler := h.(encoding.BinaryUnmarshaler)
|
59
60
|
unmarshaler.UnmarshalBinary(s)
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
rValue := ruby.VALUE(data)
|
63
|
+
rLength := ruby.RSTRING_LENINT(rValue)
|
64
|
+
if rLength > 0 {
|
65
|
+
char := ruby.RSTRING_PTR(rValue)
|
66
|
+
h.Write(C.GoBytes(unsafe.Pointer(char), C.int(rLength)))
|
64
67
|
}
|
65
68
|
|
66
69
|
marshaler := h.(encoding.BinaryMarshaler)
|
@@ -80,9 +83,11 @@ func rb_foxify_resumable_sha1_update(_ C.VALUE, state C.VALUE, data C.VALUE) C.V
|
|
80
83
|
unmarshaler := h.(encoding.BinaryUnmarshaler)
|
81
84
|
unmarshaler.UnmarshalBinary(s)
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
+
rValue := ruby.VALUE(data)
|
87
|
+
rLength := ruby.RSTRING_LENINT(rValue)
|
88
|
+
if rLength > 0 {
|
89
|
+
char := ruby.RSTRING_PTR(rValue)
|
90
|
+
h.Write(C.GoBytes(unsafe.Pointer(char), C.int(rLength)))
|
86
91
|
}
|
87
92
|
|
88
93
|
marshaler := h.(encoding.BinaryMarshaler)
|
@@ -5,6 +5,8 @@ require "msgpack"
|
|
5
5
|
module Foxify
|
6
6
|
# A resumable SHA1 implementation
|
7
7
|
class ResumableSHA1
|
8
|
+
CHUNK_SIZE = 1024 * 1024 * 5
|
9
|
+
|
8
10
|
attr_reader :state, :finalized
|
9
11
|
|
10
12
|
def initialize(state = nil, finalized: false)
|
@@ -40,6 +42,14 @@ module Foxify
|
|
40
42
|
new.update(data).hexdigest
|
41
43
|
end
|
42
44
|
|
45
|
+
def self.file(path)
|
46
|
+
new.tap do |t|
|
47
|
+
stream = File.open(path, "rb")
|
48
|
+
t.update stream.read(CHUNK_SIZE) until stream.eof?
|
49
|
+
stream.close
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
43
53
|
def ==(other)
|
44
54
|
self.class == other.class && state == other.state && finalized == other.finalized
|
45
55
|
end
|
@@ -5,6 +5,8 @@ require "msgpack"
|
|
5
5
|
module Foxify
|
6
6
|
# A resumable SHA256 implementation
|
7
7
|
class ResumableSHA256
|
8
|
+
CHUNK_SIZE = 1024 * 1024 * 5
|
9
|
+
|
8
10
|
attr_reader :state, :finalized
|
9
11
|
|
10
12
|
def initialize(state = nil, finalized: false)
|
@@ -40,6 +42,14 @@ module Foxify
|
|
40
42
|
new.update(data).hexdigest
|
41
43
|
end
|
42
44
|
|
45
|
+
def self.file(path)
|
46
|
+
new.tap do |t|
|
47
|
+
stream = File.open(path, "rb")
|
48
|
+
t.update stream.read(CHUNK_SIZE) until stream.eof?
|
49
|
+
stream.close
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
43
53
|
def ==(other)
|
44
54
|
self.class == other.class && state == other.state && finalized == other.finalized
|
45
55
|
end
|
data/lib/foxify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foxify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr. Zarkov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: go_gem
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.7.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.7.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: msgpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
|
-
rubygems_version: 3.5.
|
89
|
+
rubygems_version: 3.5.22
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Implementation of resumable digests and other nifty foxalike things
|