b4n1-boost 0.4.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3e546425c6b9b741e9b811b06e581e3e149131a195ecc5e1e6645a8a81c107a9
4
+ data.tar.gz: fb50104d7a4b56531dfea70e445b6c6b9a54f8b038f4ec1ae5d7949aced42189
5
+ SHA512:
6
+ metadata.gz: d1ccc7b76c4cf3339606a122b6d68ee8d4fa4fccf69a86d4b681c955ba308c464661ed9cc795f5b8c9f412e289eb669192a37ee82dae8ff85967d29c87c32f65
7
+ data.tar.gz: 5fbd80daa8c39dc9f3084b2a1e63b8ed5f87d59328fba74c59b415e9e8465f63f811b9fbb8d8f63cacfab3221b476d5a4c3ebfc6d83d337c908c4e490772cd92
data/EULA.txt ADDED
@@ -0,0 +1,77 @@
1
+ B4N1-BOOST — END USER LICENSE AGREEMENT (BINARIES)
2
+ ==================================================
3
+
4
+ Version: 1.0 | Effective: 2026-09-27 | Applies to: b4n1-boost 0.3.5+
5
+
6
+ This End User License Agreement ("EULA") governs your use of the B4N1
7
+ BINARY ARTIFACTS of b4n1-boost — the compiled native libraries
8
+ (`libb4n1_boost.so`, `b4n1_boost.dylib`, `b4n1_boost.dll`), the packaged
9
+ per-language bindings (`*.node`, `*.jar`, `*.nupkg`, `*.gem`, `*.phar`,
10
+ platform wheels), and the `b4n1-boost` standalone executable.
11
+
12
+ The SDK wrapper source files (the thin per-language bindings) are licensed
13
+ separately under the Business Source License 1.1 — see the `LICENSE` file
14
+ and each registry's license metadata.
15
+
16
+ 1. DEFINITIONS
17
+ "Binaries" means the compiled artifacts described above.
18
+ "SDK" means the BSL 1.1 licensed wrapper source distributed for each language.
19
+ "Source" means the Rust implementation, build scripts, internal tests and
20
+ internal documentation of the B4N1 engine. Source is NOT distributed under
21
+ this EULA or any other license and remains proprietary.
22
+
23
+ 2. GRANT OF LICENSE
24
+ Subject to your compliance with this EULA and payment of any applicable
25
+ subscription, B4N1 grants you a limited, non-exclusive, non-transferable,
26
+ revocable license to install and use the Binaries within your own products
27
+ and internal tooling, in object form only.
28
+
29
+ 3. RESTRICTIONS (strictly enforced)
30
+ a. NO REDISTRIBUTION OF SOURCE. You may not publish, disclose, sublicense
31
+ or otherwise make the B4N1 Rust Source available, in whole or in part,
32
+ modified or unmodified, by any means, including in public repositories.
33
+ b. NO DECOMPILATION OR REVERSE ENGINEERING. You may not decompile,
34
+ disassemble, deobfuscate, or otherwise reverse engineer the Binaries
35
+ except to the extent such restriction is prohibited by applicable law
36
+ that cannot be waived.
37
+ c. NO REMOVAL OF NOTICES. You may not remove, alter, or obscure any
38
+ copyright, license, watermark, or proprietary notices in the Binaries.
39
+ d. NO RESALE AS A STANDALONE PRODUCT. The Binaries may not be resold,
40
+ sublicensed, or offered as a competing product.
41
+ e. COMPLIANCE AND AUDIT. You will cooperate with reasonable verification of
42
+ license status, including honoring embedded license validation.
43
+
44
+ 4. SUBSCRIPTION TIERS
45
+ The Binaries operate under the applicable tier, validated offline against a
46
+ license file (`.b4n1lic`):
47
+ - Community: free, with attribution/watermark obligations.
48
+ - Pro / Corporate / Enterprise: paid tiers, no watermark, per the
49
+ commercial license purchased from B4N1.
50
+ License files are validated fully offline; no network calls are made at
51
+ runtime to verify entitlement.
52
+
53
+ 5. TERMINATION
54
+ This EULA terminates automatically if you breach any term. Upon
55
+ termination you must cease all use and destroy the Binaries and copies.
56
+
57
+ 6. DISCLAIMER OF WARRANTY
58
+ The Binaries are provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or
59
+ implied, including merchantability, fitness for a particular purpose, and
60
+ non-infringement. B4N1 does not warrant that the Binaries will be
61
+ uninterrupted or error-free.
62
+
63
+ 7. LIMITATION OF LIABILITY
64
+ To the maximum extent permitted by law, B4N1 shall not be liable for any
65
+ indirect, incidental, special, consequential, or punitive damages, or for
66
+ any loss of profits, revenue, data, or goodwill, arising out of your use
67
+ of the Binaries, regardless of the legal theory, even if advised of the
68
+ possibility of such damages.
69
+
70
+ 8. GOVERNING LAW AND SEVERABILITY
71
+ This EULA is governed by applicable law. If any provision is held
72
+ unenforceable, the remaining provisions stay in full force.
73
+
74
+ 9. CONTACT
75
+ Licensing questions: licensing@b4n1.com | https://b4n1.com
76
+
77
+ B4N1 — Todos los derechos reservados. Fuente proprietary: privada y secreta.
data/LICENSE ADDED
@@ -0,0 +1,95 @@
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+
6
+ -----------------------------------------------------------------------------
7
+
8
+ Parameters
9
+
10
+ Licensor: B4N1 (b4n1.com)
11
+ Licensed Work: b4n1-boost — Python SDK and native acceleration
12
+ libraries for Django, FastAPI, Flask, WSGI and ASGI.
13
+ Additional Use Grant: You may use the Licensed Work in production, free of
14
+ charge, provided that your organization's total annual
15
+ gross revenue does not exceed USD $100,000. Organizations
16
+ whose annual gross revenue exceeds USD $100,000 must
17
+ obtain a commercial license from the Licensor before any
18
+ production use. You may not resell or provide the
19
+ Licensed Work as a managed commercial service without
20
+ authorization from the Licensor.
21
+ Change Date: Four years after the first publicly available
22
+ distribution of the Licensed Work under this License.
23
+ Change License: Apache License, Version 2.0
24
+
25
+ For information about alternative licensing arrangements for the Licensed
26
+ Work, please contact b4n1@b4n1.com.
27
+
28
+ -----------------------------------------------------------------------------
29
+
30
+ Terms
31
+
32
+ The Licensor hereby grants you the right to copy, modify, create derivative
33
+ works, redistribute, and make non-production use of the Licensed Work. The
34
+ Licensor may make an Additional Use Grant, above, permitting limited
35
+ production use.
36
+
37
+ Effective on the Change Date, or the fourth anniversary of the first publicly
38
+ available distribution of a specific version of the Licensed Work under this
39
+ License, whichever comes first, the Licensor hereby grants you rights under
40
+ the terms of the Change License, and the rights granted in the paragraph
41
+ above terminate.
42
+
43
+ If your use of the Licensed Work does not comply with the requirements
44
+ currently in effect as described in this License, you must purchase a
45
+ commercial license from the Licensor, its affiliated entities, or authorized
46
+ resellers, or you must refrain from using the Licensed Work.
47
+
48
+ All copies of the original and modified Licensed Work, and derivative works
49
+ of the Licensed Work, are subject to this License. This License applies
50
+ separately for each version of the Licensed Work and the Change Date may vary
51
+ for each version of the Licensed Work released by Licensor.
52
+
53
+ You must conspicuously display this License on each original or modified copy
54
+ of the Licensed Work. If you receive the Licensed Work in original or
55
+ modified form from a third party, the terms and conditions set forth in this
56
+ License apply to your use of that work.
57
+
58
+ Any use of the Licensed Work in violation of this License will automatically
59
+ terminate your rights under this License for the current and all other
60
+ versions of the Licensed Work.
61
+
62
+ This License does not grant you any right in any trademark or logo of
63
+ Licensor or its affiliates (provided that you may use a trademark or logo of
64
+ Licensor as expressly required by this License).
65
+
66
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
67
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
68
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
69
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
70
+ TITLE. MariaDB hereby grants you permission to use this License's text to
71
+ license your works, and to refer to it using the trademark "Business Source
72
+ License", as long as you comply with the Covenants of Licensor below.
73
+
74
+ Covenants of Licensor
75
+
76
+ In consideration of the right to use this License's text and the "Business
77
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
78
+ other recipients of the licensed work to be provided by Licensor:
79
+
80
+ To specify as the Change License a license that is compatible with GPL
81
+ Version 2.0 or a later version, where "compatible" means that software
82
+ provided under the Change License can be included in a program with software
83
+ provided under GPL Version 2.0 or a later version. Licensor may specify
84
+ additional Change Licenses without limitation.
85
+
86
+ To either: (a) specify an additional grant of rights to use that does not
87
+ impose any additional restriction on the right granted in this License, as
88
+ the Additional Use Grant; or (b) insert the text "None" to specify a Change
89
+ License. Not to modify this License in any other way.
90
+
91
+ Notice
92
+
93
+ The Business Source License (this document, or the "License") is not an Open
94
+ Source license. However, the Licensed Work will eventually be made available
95
+ under an Open Source License, as stated in this License.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # b4n1-boost — Ruby SDK
2
+
3
+ Transparent high-performance native boost layer for Ruby, Rack and Rails.
4
+
5
+ - Gzip and Zstd compression with a native C-ABI core (Fiddle, no compiler needed)
6
+ - HTML minification
7
+ - Fast JSON validation
8
+ - Rack middleware: compression + minification in one drop-in
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ gem install b4n1-boost
14
+ ```
15
+
16
+ The gem ships the native core for `linux-x64`, `linux-arm64`, `macos-x64`,
17
+ `macos-arm64` and `windows-x64`, and loads the correct one automatically.
18
+
19
+ ## Use
20
+
21
+ ```ruby
22
+ require 'boost'
23
+
24
+ compressed = B4N1::Boost.compress_gzip('hello world')
25
+ packed = B4N1::Boost.compress_zstd('hello world')
26
+ html = B4N1::Boost.minify_html('<p> hi </p>')
27
+ valid = B4N1::Boost.json_valid?('{"a":1}')
28
+ ```
29
+
30
+ Rack:
31
+
32
+ ```ruby
33
+ require 'rack'
34
+ require 'rack' # plus the bundled rack middleware
35
+ use B4N1::Boost::RackMiddleware
36
+ ```
37
+
38
+ Set `B4N1_BOOST_LIB_PATH` to override the bundled native library (for
39
+ custom builds or development against a local artifact).
40
+
41
+ ## License
42
+
43
+ BUSL-1.1 (see LICENSE). The native binary is licensed separately under the
44
+ B4N1 EULA (see EULA.txt).
data/boost.rb ADDED
@@ -0,0 +1,107 @@
1
+ # B4N1-Boost Ruby SDK — Business Source License 1.1 (BUSL-1.1).
2
+ # Thin FFI wrapper over the proprietary B4N1 native core.
3
+ # The native binary is licensed separately under the B4N1 EULA (EULA.txt).
4
+ # Copyright (c) 2026 B4N1. All rights reserved.
5
+ require 'fiddle'
6
+ require 'fiddle/import'
7
+
8
+ module B4N1
9
+ module Boost
10
+ extend Fiddle::Importer
11
+
12
+ env_path = ENV['B4N1_BOOST_LIB_PATH']
13
+ lib_path = if env_path
14
+ resolved = File.expand_path(env_path)
15
+ unless resolved.end_with?('libb4n1_boost.so', 'libb4n1_boost.dylib', 'b4n1_boost.dll')
16
+ raise ArgumentError, "Invalid library filename in B4N1_BOOST_LIB_PATH"
17
+ end
18
+ resolved
19
+ else
20
+ require 'rbconfig'
21
+ os = RbConfig::CONFIG['host_os']
22
+ cpu = RbConfig::CONFIG['host_cpu']
23
+ slug, name =
24
+ if os =~ /linux/
25
+ [cpu =~ /aarch64|arm64/ ? 'linux-arm64' : 'linux-x64', 'libb4n1_boost.so']
26
+ elsif os =~ /darwin/
27
+ [cpu =~ /aarch64|arm64/ ? 'macos-arm64' : 'macos-x64', 'libb4n1_boost.dylib']
28
+ elsif os =~ /mswin|mingw|cygwin/
29
+ ['windows-x64', 'b4n1_boost.dll']
30
+ else
31
+ raise "Unsupported platform for b4n1-boost: #{os}/#{cpu}"
32
+ end
33
+ # 1) Native lib bundled in the gem (lib/native/<platform>/).
34
+ bundled = File.expand_path("lib/native/#{slug}/#{name}", __dir__)
35
+ # 2) Development fallback (running from the source repo).
36
+ dev = File.expand_path("../../target/release/#{name}", __dir__)
37
+ if File.exist?(bundled)
38
+ bundled
39
+ elsif File.exist?(dev)
40
+ dev
41
+ else
42
+ raise "b4n1-boost native library not found. Looked at #{bundled} " \
43
+ "and #{dev}. Set B4N1_BOOST_LIB_PATH or reinstall the gem."
44
+ end
45
+ end
46
+ dlload lib_path
47
+
48
+
49
+ extern 'int b4n1_boost_compress_gzip(void*, size_t, void**, size_t*, uint32_t)'
50
+ extern 'int b4n1_boost_compress_zstd(void*, size_t, void**, size_t*, int32_t)'
51
+ extern 'int b4n1_boost_decompress_zstd(void*, size_t, void**, size_t*)'
52
+ extern 'void b4n1_boost_free_buffer(void*, size_t)'
53
+ extern 'char* b4n1_boost_minify_html(char*)'
54
+ extern 'int b4n1_boost_json_validate(char*)'
55
+ extern 'void b4n1_boost_free_string(char*)'
56
+
57
+ class << self
58
+ def compress_gzip(data, level: 4)
59
+ return '' if data.empty?
60
+
61
+ out_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
62
+ out_len = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SIZE_T)
63
+
64
+ res = b4n1_boost_compress_gzip(data, data.bytesize, out_ptr, out_len, level)
65
+ raise 'Gzip compression failed' unless res.zero?
66
+
67
+ ptr_val = Fiddle::Pointer.new(out_ptr[0, Fiddle::SIZEOF_VOIDP].unpack1('J'))
68
+ len_val = out_len[0, Fiddle::SIZEOF_SIZE_T].unpack1('J')
69
+
70
+ result = ptr_val.to_str(len_val)
71
+ b4n1_boost_free_buffer(ptr_val, len_val)
72
+ result
73
+ end
74
+
75
+ def compress_zstd(data, level: 3)
76
+ return '' if data.empty?
77
+
78
+ out_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
79
+ out_len = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SIZE_T)
80
+
81
+ res = b4n1_boost_compress_zstd(data, data.bytesize, out_ptr, out_len, level)
82
+ raise 'Zstd compression failed' unless res.zero?
83
+
84
+ ptr_val = Fiddle::Pointer.new(out_ptr[0, Fiddle::SIZEOF_VOIDP].unpack1('J'))
85
+ len_val = out_len[0, Fiddle::SIZEOF_SIZE_T].unpack1('J')
86
+
87
+ result = ptr_val.to_str(len_val)
88
+ b4n1_boost_free_buffer(ptr_val, len_val)
89
+ result
90
+ end
91
+
92
+
93
+ def minify_html(html)
94
+ ptr = b4n1_boost_minify_html(html)
95
+ return html if ptr.null?
96
+
97
+ res = ptr.to_s
98
+ b4n1_boost_free_string(ptr)
99
+ res
100
+ end
101
+
102
+ def json_valid?(json)
103
+ b4n1_boost_json_validate(json) == 1
104
+ end
105
+ end
106
+ end
107
+ end
data/rack.rb ADDED
@@ -0,0 +1,53 @@
1
+ require_relative 'boost'
2
+
3
+ module B4N1
4
+ module Boost
5
+ # Rack / Rails Middleware for automatic HTML minification and Gzip compression
6
+ class RackMiddleware
7
+ def initialize(app, options = {})
8
+ @app = app
9
+ @minify_html = options.fetch(:minify_html, true)
10
+ @gzip_level = options.fetch(:gzip_level, 4)
11
+ end
12
+
13
+ def call(env)
14
+ status, headers, response = @app.call(env)
15
+ headers = headers.dup
16
+
17
+ # Collect response body
18
+ body_str = ""
19
+ response.each { |part| body_str << part }
20
+ response.close if response.respond_to?(:close)
21
+
22
+ content_type = headers['Content-Type'] || headers['content-type'] || ''
23
+
24
+ # Minify HTML if enabled
25
+ if @minify_html && content_type.include?('text/html')
26
+ begin
27
+ body_str = B4N1::Boost.minify_html(body_str)
28
+ rescue => _e
29
+ # Fail-safe
30
+ end
31
+ end
32
+
33
+ # Compress if requested
34
+ accept_encoding = env['HTTP_ACCEPT_ENCODING'] || ''
35
+ if accept_encoding.include?('gzip')
36
+ begin
37
+ compressed = B4N1::Boost.compress_gzip(body_str, @gzip_level)
38
+ if compressed && !compressed.empty?
39
+ headers['Content-Encoding'] = 'gzip'
40
+ headers['Content-Length'] = compressed.bytesize.to_s
41
+ return [status, headers, [compressed]]
42
+ end
43
+ rescue => _e
44
+ # Fallback
45
+ end
46
+ end
47
+
48
+ headers['Content-Length'] = body_str.bytesize.to_s
49
+ [status, headers, [body_str]]
50
+ end
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: b4n1-boost
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
5
+ platform: ruby
6
+ authors:
7
+ - B4N1 Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-10-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ description: Zero-copy Gzip/Zstd compression, HTML minification, and fast JSON validation
28
+ powered by b4n1-boost native C-ABI core.
29
+ email:
30
+ - dev@b4n1.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - EULA.txt
36
+ - LICENSE
37
+ - README.md
38
+ - boost.rb
39
+ - lib/native/linux-arm64/libb4n1_boost.so
40
+ - lib/native/linux-x64/libb4n1_boost.so
41
+ - lib/native/macos-arm64/libb4n1_boost.dylib
42
+ - lib/native/macos-x64/libb4n1_boost.dylib
43
+ - lib/native/windows-x64/b4n1_boost.dll
44
+ - rack.rb
45
+ homepage: https://github.com/B4N1-com/private-repos
46
+ licenses:
47
+ - BUSL-1.1
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - "."
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.7.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.3.5
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: High-performance native Rust boost layer for Ruby & Rack/Rails.
68
+ test_files: []