snappy-ruby 0.1.0 → 1.0.1
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/CLAUDE.md +117 -0
- data/ext/snappy/extconf.rb +20 -70
- data/ext/snappy/snappy-src/snappy-stubs-public.h +5 -2
- data/ext/snappy/snappy-src/snappy_benchmark.cc +398 -0
- data/ext/snappy/snappy-src/snappy_compress_fuzzer.cc +64 -0
- data/ext/snappy/snappy-src/snappy_uncompress_fuzzer.cc +58 -0
- data/ext/snappy/snappy-src/testdata/alice29.txt +3609 -0
- data/ext/snappy/snappy-src/testdata/asyoulik.txt +4122 -0
- data/ext/snappy/snappy-src/testdata/baddata1.snappy +0 -0
- data/ext/snappy/snappy-src/testdata/baddata2.snappy +0 -0
- data/ext/snappy/snappy-src/testdata/baddata3.snappy +0 -0
- data/ext/snappy/snappy-src/testdata/fireworks.jpeg +0 -0
- data/ext/snappy/snappy-src/testdata/geo.protodata +0 -0
- data/ext/snappy/snappy-src/testdata/html +1 -0
- data/ext/snappy/snappy-src/testdata/html_x_4 +1 -0
- data/ext/snappy/snappy-src/testdata/kppkn.gtb +0 -0
- data/ext/snappy/snappy-src/testdata/lcet10.txt +7519 -0
- data/ext/snappy/snappy-src/testdata/paper-100k.pdf +600 -2
- data/ext/snappy/snappy-src/testdata/plrabn12.txt +10699 -0
- data/ext/snappy/snappy-src/testdata/urls.10K +10000 -0
- data/ext/snappy/snappy_ext.cpp +218 -0
- data/lib/snappy/snappy.so +0 -0
- data/lib/snappy/version.rb +3 -0
- data/lib/snappy.rb +92 -2
- metadata +36 -32
- data/LICENSE +0 -21
- data/README.md +0 -77
- data/Rakefile +0 -12
- data/ext/snappy/snappy-src/config.h +0 -78
- data/ext/snappy/snappy.c +0 -282
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
#include <ruby.h>
|
|
2
|
+
#include <ruby/encoding.h>
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <stdexcept>
|
|
5
|
+
#include "snappy-src/snappy.h"
|
|
6
|
+
|
|
7
|
+
static VALUE rb_mSnappy;
|
|
8
|
+
static VALUE rb_eSnappyError;
|
|
9
|
+
|
|
10
|
+
// Helper function to raise Snappy::Error
|
|
11
|
+
static void raise_snappy_error(const char* message) {
|
|
12
|
+
rb_raise(rb_eSnappyError, "%s", message);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Snappy.compress(data) -> compressed_string
|
|
16
|
+
static VALUE
|
|
17
|
+
rb_snappy_compress(VALUE self, VALUE input)
|
|
18
|
+
{
|
|
19
|
+
Check_Type(input, T_STRING);
|
|
20
|
+
|
|
21
|
+
const char* input_data = RSTRING_PTR(input);
|
|
22
|
+
size_t input_length = RSTRING_LEN(input);
|
|
23
|
+
|
|
24
|
+
std::string compressed;
|
|
25
|
+
try {
|
|
26
|
+
snappy::Compress(input_data, input_length, &compressed);
|
|
27
|
+
} catch (const std::exception& e) {
|
|
28
|
+
raise_snappy_error(e.what());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
VALUE result = rb_str_new(compressed.data(), compressed.size());
|
|
32
|
+
rb_enc_associate(result, rb_ascii8bit_encoding());
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Snappy.uncompress(compressed_data) -> uncompressed_string
|
|
37
|
+
static VALUE
|
|
38
|
+
rb_snappy_uncompress(VALUE self, VALUE input)
|
|
39
|
+
{
|
|
40
|
+
Check_Type(input, T_STRING);
|
|
41
|
+
|
|
42
|
+
const char* compressed_data = RSTRING_PTR(input);
|
|
43
|
+
size_t compressed_length = RSTRING_LEN(input);
|
|
44
|
+
|
|
45
|
+
std::string uncompressed;
|
|
46
|
+
bool result;
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
result = snappy::Uncompress(compressed_data, compressed_length, &uncompressed);
|
|
50
|
+
} catch (const std::exception& e) {
|
|
51
|
+
raise_snappy_error(e.what());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!result) {
|
|
55
|
+
raise_snappy_error("Failed to uncompress data - data may be corrupted");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return rb_str_new(uncompressed.data(), uncompressed.size());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Snappy.raw_compress(data) -> compressed_string
|
|
62
|
+
static VALUE
|
|
63
|
+
rb_snappy_raw_compress(VALUE self, VALUE input)
|
|
64
|
+
{
|
|
65
|
+
Check_Type(input, T_STRING);
|
|
66
|
+
|
|
67
|
+
const char* input_data = RSTRING_PTR(input);
|
|
68
|
+
size_t input_length = RSTRING_LEN(input);
|
|
69
|
+
|
|
70
|
+
// Get maximum possible compressed size
|
|
71
|
+
size_t max_compressed_length = snappy::MaxCompressedLength(input_length);
|
|
72
|
+
|
|
73
|
+
// Allocate buffer for compressed data
|
|
74
|
+
char* compressed_buffer = new char[max_compressed_length];
|
|
75
|
+
size_t compressed_length;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
snappy::RawCompress(input_data, input_length, compressed_buffer, &compressed_length);
|
|
79
|
+
} catch (const std::exception& e) {
|
|
80
|
+
delete[] compressed_buffer;
|
|
81
|
+
raise_snappy_error(e.what());
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
VALUE result = rb_str_new(compressed_buffer, compressed_length);
|
|
85
|
+
rb_enc_associate(result, rb_ascii8bit_encoding());
|
|
86
|
+
|
|
87
|
+
delete[] compressed_buffer;
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Snappy.raw_uncompress(compressed_data) -> uncompressed_string
|
|
92
|
+
static VALUE
|
|
93
|
+
rb_snappy_raw_uncompress(VALUE self, VALUE input)
|
|
94
|
+
{
|
|
95
|
+
Check_Type(input, T_STRING);
|
|
96
|
+
|
|
97
|
+
const char* compressed_data = RSTRING_PTR(input);
|
|
98
|
+
size_t compressed_length = RSTRING_LEN(input);
|
|
99
|
+
|
|
100
|
+
// Get the uncompressed length first
|
|
101
|
+
size_t uncompressed_length;
|
|
102
|
+
bool length_result;
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
length_result = snappy::GetUncompressedLength(compressed_data, compressed_length, &uncompressed_length);
|
|
106
|
+
} catch (const std::exception& e) {
|
|
107
|
+
raise_snappy_error(e.what());
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!length_result) {
|
|
111
|
+
raise_snappy_error("Failed to get uncompressed length - data may be corrupted");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Allocate buffer for uncompressed data
|
|
115
|
+
char* uncompressed_buffer = new char[uncompressed_length];
|
|
116
|
+
bool uncompress_result;
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
uncompress_result = snappy::RawUncompress(compressed_data, compressed_length, uncompressed_buffer);
|
|
120
|
+
} catch (const std::exception& e) {
|
|
121
|
+
delete[] uncompressed_buffer;
|
|
122
|
+
raise_snappy_error(e.what());
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!uncompress_result) {
|
|
126
|
+
delete[] uncompressed_buffer;
|
|
127
|
+
raise_snappy_error("Failed to uncompress data - data may be corrupted");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
VALUE result = rb_str_new(uncompressed_buffer, uncompressed_length);
|
|
131
|
+
delete[] uncompressed_buffer;
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Snappy.max_compressed_length(source_length) -> integer
|
|
136
|
+
static VALUE
|
|
137
|
+
rb_snappy_max_compressed_length(VALUE self, VALUE source_length)
|
|
138
|
+
{
|
|
139
|
+
Check_Type(source_length, T_FIXNUM);
|
|
140
|
+
|
|
141
|
+
long length = NUM2LONG(source_length);
|
|
142
|
+
if (length < 0) {
|
|
143
|
+
rb_raise(rb_eArgError, "source_length must be non-negative");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
size_t max_length = snappy::MaxCompressedLength(length);
|
|
147
|
+
return ULONG2NUM(max_length);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Snappy.uncompressed_length(compressed_data) -> integer
|
|
151
|
+
static VALUE
|
|
152
|
+
rb_snappy_uncompressed_length(VALUE self, VALUE input)
|
|
153
|
+
{
|
|
154
|
+
Check_Type(input, T_STRING);
|
|
155
|
+
|
|
156
|
+
const char* compressed_data = RSTRING_PTR(input);
|
|
157
|
+
size_t compressed_length = RSTRING_LEN(input);
|
|
158
|
+
|
|
159
|
+
size_t uncompressed_length;
|
|
160
|
+
bool result;
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
result = snappy::GetUncompressedLength(compressed_data, compressed_length, &uncompressed_length);
|
|
164
|
+
} catch (const std::exception& e) {
|
|
165
|
+
raise_snappy_error(e.what());
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!result) {
|
|
169
|
+
raise_snappy_error("Failed to get uncompressed length - data may be corrupted");
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return ULONG2NUM(uncompressed_length);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Snappy.valid?(compressed_data) -> true/false
|
|
176
|
+
static VALUE
|
|
177
|
+
rb_snappy_valid(VALUE self, VALUE input)
|
|
178
|
+
{
|
|
179
|
+
Check_Type(input, T_STRING);
|
|
180
|
+
|
|
181
|
+
const char* compressed_data = RSTRING_PTR(input);
|
|
182
|
+
size_t compressed_length = RSTRING_LEN(input);
|
|
183
|
+
|
|
184
|
+
bool valid;
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
valid = snappy::IsValidCompressedBuffer(compressed_data, compressed_length);
|
|
188
|
+
} catch (const std::exception& e) {
|
|
189
|
+
// If an exception occurs, the data is invalid
|
|
190
|
+
valid = false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return valid ? Qtrue : Qfalse;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Initialize the Snappy module
|
|
197
|
+
extern "C" void
|
|
198
|
+
Init_snappy(void)
|
|
199
|
+
{
|
|
200
|
+
rb_mSnappy = rb_define_module("Snappy");
|
|
201
|
+
rb_eSnappyError = rb_define_class_under(rb_mSnappy, "Error", rb_eStandardError);
|
|
202
|
+
|
|
203
|
+
// Define module methods (private methods prefixed with underscore)
|
|
204
|
+
rb_define_singleton_method(rb_mSnappy, "_compress",
|
|
205
|
+
reinterpret_cast<VALUE(*)(...)>(rb_snappy_compress), 1);
|
|
206
|
+
rb_define_singleton_method(rb_mSnappy, "_uncompress",
|
|
207
|
+
reinterpret_cast<VALUE(*)(...)>(rb_snappy_uncompress), 1);
|
|
208
|
+
rb_define_singleton_method(rb_mSnappy, "_raw_compress",
|
|
209
|
+
reinterpret_cast<VALUE(*)(...)>(rb_snappy_raw_compress), 1);
|
|
210
|
+
rb_define_singleton_method(rb_mSnappy, "_raw_uncompress",
|
|
211
|
+
reinterpret_cast<VALUE(*)(...)>(rb_snappy_raw_uncompress), 1);
|
|
212
|
+
rb_define_singleton_method(rb_mSnappy, "_max_compressed_length",
|
|
213
|
+
reinterpret_cast<VALUE(*)(...)>(rb_snappy_max_compressed_length), 1);
|
|
214
|
+
rb_define_singleton_method(rb_mSnappy, "_uncompressed_length",
|
|
215
|
+
reinterpret_cast<VALUE(*)(...)>(rb_snappy_uncompressed_length), 1);
|
|
216
|
+
rb_define_singleton_method(rb_mSnappy, "_valid?",
|
|
217
|
+
reinterpret_cast<VALUE(*)(...)>(rb_snappy_valid), 1);
|
|
218
|
+
}
|
data/lib/snappy/snappy.so
CHANGED
|
Binary file
|
data/lib/snappy.rb
CHANGED
|
@@ -1,5 +1,95 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'snappy/version'
|
|
2
|
+
require 'snappy/snappy'
|
|
2
3
|
|
|
3
4
|
module Snappy
|
|
4
|
-
|
|
5
|
+
# Error class for Snappy-related errors
|
|
6
|
+
class Error < StandardError; end
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
# Compress data using Snappy compression
|
|
10
|
+
#
|
|
11
|
+
# @param data [String] The data to compress
|
|
12
|
+
# @return [String] The compressed data (binary encoding)
|
|
13
|
+
# @raise [TypeError] If data is not a String
|
|
14
|
+
def compress(data)
|
|
15
|
+
raise TypeError, "data must be a String" unless data.is_a?(String)
|
|
16
|
+
_compress(data)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Uncompress data that was compressed with Snappy
|
|
20
|
+
#
|
|
21
|
+
# @param data [String] The compressed data
|
|
22
|
+
# @return [String] The uncompressed data
|
|
23
|
+
# @raise [TypeError] If data is not a String
|
|
24
|
+
# @raise [Snappy::Error] If the data is corrupted or invalid
|
|
25
|
+
def uncompress(data)
|
|
26
|
+
raise TypeError, "data must be a String" unless data.is_a?(String)
|
|
27
|
+
_uncompress(data)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Alias for uncompress
|
|
31
|
+
alias_method :decompress, :uncompress
|
|
32
|
+
|
|
33
|
+
# Compress data using raw Snappy compression (without framing)
|
|
34
|
+
#
|
|
35
|
+
# @param data [String] The data to compress
|
|
36
|
+
# @return [String] The compressed data (binary encoding)
|
|
37
|
+
# @raise [TypeError] If data is not a String
|
|
38
|
+
def raw_compress(data)
|
|
39
|
+
raise TypeError, "data must be a String" unless data.is_a?(String)
|
|
40
|
+
_raw_compress(data)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Uncompress raw Snappy compressed data (without framing)
|
|
44
|
+
#
|
|
45
|
+
# @param data [String] The compressed data
|
|
46
|
+
# @return [String] The uncompressed data
|
|
47
|
+
# @raise [TypeError] If data is not a String
|
|
48
|
+
# @raise [Snappy::Error] If the data is corrupted or invalid
|
|
49
|
+
def raw_uncompress(data)
|
|
50
|
+
raise TypeError, "data must be a String" unless data.is_a?(String)
|
|
51
|
+
_raw_uncompress(data)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Get the maximum possible compressed size for data of given length
|
|
55
|
+
#
|
|
56
|
+
# @param source_length [Integer] The length of uncompressed data
|
|
57
|
+
# @return [Integer] Maximum possible size of compressed output
|
|
58
|
+
# @raise [TypeError] If source_length is not an Integer
|
|
59
|
+
# @raise [ArgumentError] If source_length is negative
|
|
60
|
+
def max_compressed_length(source_length)
|
|
61
|
+
unless source_length.is_a?(Integer) || source_length.is_a?(Numeric)
|
|
62
|
+
raise TypeError, "source_length must be an Integer"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
source_length = source_length.to_i
|
|
66
|
+
|
|
67
|
+
if source_length < 0
|
|
68
|
+
raise ArgumentError, "source_length must be non-negative"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
_max_compressed_length(source_length)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Get the uncompressed length from compressed data
|
|
75
|
+
#
|
|
76
|
+
# @param compressed [String] The compressed data
|
|
77
|
+
# @return [Integer] The length of the uncompressed data
|
|
78
|
+
# @raise [TypeError] If compressed is not a String
|
|
79
|
+
# @raise [Snappy::Error] If the data is corrupted or invalid
|
|
80
|
+
def uncompressed_length(compressed)
|
|
81
|
+
raise TypeError, "compressed must be a String" unless compressed.is_a?(String)
|
|
82
|
+
_uncompressed_length(compressed)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Check if compressed data is valid
|
|
86
|
+
#
|
|
87
|
+
# @param compressed [String] The compressed data to validate
|
|
88
|
+
# @return [Boolean] true if valid, false otherwise
|
|
89
|
+
# @raise [TypeError] If compressed is not a String
|
|
90
|
+
def valid?(compressed)
|
|
91
|
+
raise TypeError, "compressed must be a String" unless compressed.is_a?(String)
|
|
92
|
+
_valid?(compressed)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
5
95
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: snappy-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Greninger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-11-
|
|
11
|
+
date: 2025-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: bundler
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.0'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2.0'
|
|
27
13
|
- !ruby/object:Gem::Dependency
|
|
28
14
|
name: rake
|
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,32 +39,31 @@ dependencies:
|
|
|
53
39
|
- !ruby/object:Gem::Version
|
|
54
40
|
version: '1.2'
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
42
|
+
name: minitest
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
58
44
|
requirements:
|
|
59
45
|
- - "~>"
|
|
60
46
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
47
|
+
version: '5.0'
|
|
62
48
|
type: :development
|
|
63
49
|
prerelease: false
|
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
51
|
requirements:
|
|
66
52
|
- - "~>"
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
69
|
-
description: Ruby bindings for Google's Snappy compression
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
version: '5.0'
|
|
55
|
+
description: Snappy-ruby provides native Ruby bindings for Google's Snappy compression
|
|
56
|
+
library. The gem bundles the Snappy C++ source code and compiles it as a native
|
|
57
|
+
extension, providing fast and efficient compression/decompression with a simple
|
|
58
|
+
Ruby API.
|
|
72
59
|
email:
|
|
73
|
-
-
|
|
60
|
+
- jgreninger@hotmail.com
|
|
74
61
|
executables: []
|
|
75
62
|
extensions:
|
|
76
63
|
- ext/snappy/extconf.rb
|
|
77
64
|
extra_rdoc_files: []
|
|
78
65
|
files:
|
|
79
|
-
-
|
|
80
|
-
- README.md
|
|
81
|
-
- Rakefile
|
|
66
|
+
- CLAUDE.md
|
|
82
67
|
- ext/snappy/extconf.rb
|
|
83
68
|
- ext/snappy/snappy-src/AUTHORS
|
|
84
69
|
- ext/snappy/snappy-src/BUILD.bazel
|
|
@@ -92,7 +77,6 @@ files:
|
|
|
92
77
|
- ext/snappy/snappy-src/WORKSPACE.bzlmod
|
|
93
78
|
- ext/snappy/snappy-src/cmake/SnappyConfig.cmake.in
|
|
94
79
|
- ext/snappy/snappy-src/cmake/config.h.in
|
|
95
|
-
- ext/snappy/snappy-src/config.h
|
|
96
80
|
- ext/snappy/snappy-src/docs/README.md
|
|
97
81
|
- ext/snappy/snappy-src/format_description.txt
|
|
98
82
|
- ext/snappy/snappy-src/framing_format.txt
|
|
@@ -109,17 +93,37 @@ files:
|
|
|
109
93
|
- ext/snappy/snappy-src/snappy-test.h
|
|
110
94
|
- ext/snappy/snappy-src/snappy.cc
|
|
111
95
|
- ext/snappy/snappy-src/snappy.h
|
|
96
|
+
- ext/snappy/snappy-src/snappy_benchmark.cc
|
|
97
|
+
- ext/snappy/snappy-src/snappy_compress_fuzzer.cc
|
|
112
98
|
- ext/snappy/snappy-src/snappy_test_data.cc
|
|
113
99
|
- ext/snappy/snappy-src/snappy_test_data.h
|
|
114
100
|
- ext/snappy/snappy-src/snappy_test_tool.cc
|
|
101
|
+
- ext/snappy/snappy-src/snappy_uncompress_fuzzer.cc
|
|
115
102
|
- ext/snappy/snappy-src/snappy_unittest.cc
|
|
116
|
-
- ext/snappy/snappy.
|
|
103
|
+
- ext/snappy/snappy-src/testdata/alice29.txt
|
|
104
|
+
- ext/snappy/snappy-src/testdata/asyoulik.txt
|
|
105
|
+
- ext/snappy/snappy-src/testdata/baddata1.snappy
|
|
106
|
+
- ext/snappy/snappy-src/testdata/baddata2.snappy
|
|
107
|
+
- ext/snappy/snappy-src/testdata/baddata3.snappy
|
|
108
|
+
- ext/snappy/snappy-src/testdata/fireworks.jpeg
|
|
109
|
+
- ext/snappy/snappy-src/testdata/geo.protodata
|
|
110
|
+
- ext/snappy/snappy-src/testdata/html
|
|
111
|
+
- ext/snappy/snappy-src/testdata/html_x_4
|
|
112
|
+
- ext/snappy/snappy-src/testdata/kppkn.gtb
|
|
113
|
+
- ext/snappy/snappy-src/testdata/lcet10.txt
|
|
114
|
+
- ext/snappy/snappy-src/testdata/paper-100k.pdf
|
|
115
|
+
- ext/snappy/snappy-src/testdata/plrabn12.txt
|
|
116
|
+
- ext/snappy/snappy-src/testdata/urls.10K
|
|
117
|
+
- ext/snappy/snappy_ext.cpp
|
|
117
118
|
- lib/snappy.rb
|
|
118
119
|
- lib/snappy/snappy.so
|
|
120
|
+
- lib/snappy/version.rb
|
|
119
121
|
homepage: https://github.com/jgreninger/snappy-ruby
|
|
120
122
|
licenses:
|
|
121
|
-
-
|
|
122
|
-
metadata:
|
|
123
|
+
- BSD-3-Clause
|
|
124
|
+
metadata:
|
|
125
|
+
homepage_uri: https://github.com/jgreninger/snappy-ruby
|
|
126
|
+
source_code_uri: https://github.com/jgreninger/snappy-ruby
|
|
123
127
|
post_install_message:
|
|
124
128
|
rdoc_options: []
|
|
125
129
|
require_paths:
|
|
@@ -128,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
128
132
|
requirements:
|
|
129
133
|
- - ">="
|
|
130
134
|
- !ruby/object:Gem::Version
|
|
131
|
-
version:
|
|
135
|
+
version: 2.5.0
|
|
132
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
137
|
requirements:
|
|
134
138
|
- - ">="
|
|
@@ -138,5 +142,5 @@ requirements: []
|
|
|
138
142
|
rubygems_version: 3.4.20
|
|
139
143
|
signing_key:
|
|
140
144
|
specification_version: 4
|
|
141
|
-
summary: Ruby bindings for
|
|
145
|
+
summary: Ruby bindings for Google's Snappy compression library
|
|
142
146
|
test_files: []
|
data/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 snappy-ruby
|
|
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 all
|
|
13
|
-
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 THE
|
|
21
|
-
SOFTWARE.
|
data/README.md
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# Snappy Ruby Bindings
|
|
2
|
-
|
|
3
|
-
Ruby bindings for Google's Snappy compression library (https://github.com/google/snappy) with **bundled libsnappy source** - no system dependencies required!
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Fast compression and decompression using Snappy
|
|
8
|
-
- **Bundled Snappy library** - no need to install libsnappy separately
|
|
9
|
-
- File-based compression/decompression with input and output filename support
|
|
10
|
-
- Compression level support (compatible with Snappy's range: 1-9)
|
|
11
|
-
- Compatible with Ruby 3.0+
|
|
12
|
-
- Works on Linux, macOS, and Windows
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
Add this line to your application's Gemfile:
|
|
17
|
-
|
|
18
|
-
```ruby
|
|
19
|
-
gem 'snappy-ruby'
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
And then execute:
|
|
23
|
-
|
|
24
|
-
$ bundle install
|
|
25
|
-
|
|
26
|
-
Or install it yourself as:
|
|
27
|
-
|
|
28
|
-
$ gem install snappy-ruby
|
|
29
|
-
|
|
30
|
-
## Usage
|
|
31
|
-
|
|
32
|
-
```ruby
|
|
33
|
-
require 'snappy'
|
|
34
|
-
|
|
35
|
-
# Compress data from a file
|
|
36
|
-
Snappy.compress_file('input.txt', 'output.snappy', level: 6)
|
|
37
|
-
|
|
38
|
-
# Decompress data to a file
|
|
39
|
-
Snappy.decompress_file('output.snappy', 'decompressed.txt')
|
|
40
|
-
|
|
41
|
-
# In-memory compression/decompression
|
|
42
|
-
compressed = Snappy.compress('Hello, World!', level: 6)
|
|
43
|
-
decompressed = Snappy.decompress(compressed)
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Development
|
|
47
|
-
|
|
48
|
-
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
|
|
49
|
-
|
|
50
|
-
## Requirements
|
|
51
|
-
|
|
52
|
-
- Ruby 3.0 or higher
|
|
53
|
-
- Ruby development headers (ruby-dev)
|
|
54
|
-
- C++ compiler with C++11 support
|
|
55
|
-
|
|
56
|
-
**Note:** The Snappy library is bundled with this gem, so you don't need to install libsnappy separately!
|
|
57
|
-
|
|
58
|
-
### Installing Build Dependencies
|
|
59
|
-
|
|
60
|
-
On Ubuntu/Debian:
|
|
61
|
-
```bash
|
|
62
|
-
sudo apt-get install ruby-dev build-essential
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
On macOS (requires Xcode Command Line Tools):
|
|
66
|
-
```bash
|
|
67
|
-
xcode-select --install
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
On Fedora/RHEL:
|
|
71
|
-
```bash
|
|
72
|
-
sudo dnf install ruby-devel gcc-c++ make
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## License
|
|
76
|
-
|
|
77
|
-
The gem is available as open source under the terms of the MIT License.
|
data/Rakefile
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require "bundler/gem_tasks"
|
|
2
|
-
require "rspec/core/rake_task"
|
|
3
|
-
require "rake/extensiontask"
|
|
4
|
-
|
|
5
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
6
|
-
|
|
7
|
-
Rake::ExtensionTask.new("snappy") do |ext|
|
|
8
|
-
ext.lib_dir = "lib/snappy"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
task default: [:compile, :spec]
|
|
12
|
-
task spec: :compile
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// Auto-generated config.h for snappy-ruby gem
|
|
2
|
-
// This file provides configuration for bundled Snappy library
|
|
3
|
-
|
|
4
|
-
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
|
|
5
|
-
#define THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
|
|
6
|
-
|
|
7
|
-
// Define to 1 if the compiler supports __builtin_ctzll
|
|
8
|
-
#if defined(__GNUC__) || defined(__clang__)
|
|
9
|
-
#define HAVE_BUILTIN_CTZ 1
|
|
10
|
-
#endif
|
|
11
|
-
|
|
12
|
-
// Define to 1 if the compiler supports __builtin_expect
|
|
13
|
-
#if defined(__GNUC__) || defined(__clang__)
|
|
14
|
-
#define HAVE_BUILTIN_EXPECT 1
|
|
15
|
-
#endif
|
|
16
|
-
|
|
17
|
-
// Define to 1 if the compiler supports __builtin_prefetch
|
|
18
|
-
#if defined(__GNUC__) || defined(__clang__)
|
|
19
|
-
#define HAVE_BUILTIN_PREFETCH 1
|
|
20
|
-
#endif
|
|
21
|
-
|
|
22
|
-
// Define to 1 if you have <sys/mman.h>
|
|
23
|
-
#if !defined(_WIN32)
|
|
24
|
-
#define HAVE_SYS_MMAN_H 1
|
|
25
|
-
#endif
|
|
26
|
-
|
|
27
|
-
// Define to 1 if you have <sys/resource.h>
|
|
28
|
-
#if !defined(_WIN32)
|
|
29
|
-
#define HAVE_SYS_RESOURCE_H 1
|
|
30
|
-
#endif
|
|
31
|
-
|
|
32
|
-
// Define to 1 if you have <sys/time.h>
|
|
33
|
-
#if !defined(_WIN32)
|
|
34
|
-
#define HAVE_SYS_TIME_H 1
|
|
35
|
-
#endif
|
|
36
|
-
|
|
37
|
-
// Define to 1 if you have <sys/uio.h>
|
|
38
|
-
#if !defined(_WIN32)
|
|
39
|
-
#define HAVE_SYS_UIO_H 1
|
|
40
|
-
#endif
|
|
41
|
-
|
|
42
|
-
// Define to 1 if you have <unistd.h>
|
|
43
|
-
#if !defined(_WIN32)
|
|
44
|
-
#define HAVE_UNISTD_H 1
|
|
45
|
-
#endif
|
|
46
|
-
|
|
47
|
-
// Define to 1 on Windows
|
|
48
|
-
#ifdef _WIN32
|
|
49
|
-
#define HAVE_WINDOWS_H 1
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
// Define to 1 if the compiler supports __attribute__((always_inline))
|
|
53
|
-
#if defined(__GNUC__) || defined(__clang__)
|
|
54
|
-
#define HAVE_ATTRIBUTE_ALWAYS_INLINE 1
|
|
55
|
-
#endif
|
|
56
|
-
|
|
57
|
-
// Define to 1 if you have SSSE3 support
|
|
58
|
-
#ifdef __SSSE3__
|
|
59
|
-
#define SNAPPY_HAVE_SSSE3 1
|
|
60
|
-
#endif
|
|
61
|
-
|
|
62
|
-
// Define to 1 if you have x86 CRC32 support
|
|
63
|
-
#ifdef __SSE4_2__
|
|
64
|
-
#define SNAPPY_HAVE_X86_CRC32 1
|
|
65
|
-
#endif
|
|
66
|
-
|
|
67
|
-
// Define to 1 if you have ARM NEON CRC32 support
|
|
68
|
-
#if defined(__ARM_FEATURE_CRC32)
|
|
69
|
-
#define SNAPPY_HAVE_NEON_CRC32 1
|
|
70
|
-
#endif
|
|
71
|
-
|
|
72
|
-
// Define to 1 if your processor stores words with the most significant byte
|
|
73
|
-
// first (like Motorola and SPARC, unlike Intel and VAX).
|
|
74
|
-
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
|
75
|
-
#define SNAPPY_IS_BIG_ENDIAN 1
|
|
76
|
-
#endif
|
|
77
|
-
|
|
78
|
-
#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
|