eu-licence-validator 0.1.19
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 +7 -0
- data/lib/eu_licence_validator/version.rb +5 -0
- data/lib/eu_licence_validator.rb +56 -0
- data/wasm/core.wasm +0 -0
- metadata +64 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2ecf94b2a7ca89a51b32498d6c8ce017c8234ae8ddd738e4918f7f722c74db6b
|
|
4
|
+
data.tar.gz: 5568158c5bc42b8d72b84748f7e9a9a61e2855f9c94eb25fdbeced6f420e5e1d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 1ef319396c318910db2a59e59897db784ef73d51fc0bfd6ea6a08452b363e89d32ee6a72f4ee277bcd9a0eab48441bb7628a08c7c4963848f41a27269105408f
|
|
7
|
+
data.tar.gz: ed3f17df444b561bd988c6b81aed9f88a8e6ecd9bb245f7418591455e352409665191b37ec35dd392df3fb21ff64f7c4ef1974eb34969a7c9877eb9dd2bb0b89
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require_relative "eu_licence_validator/version"
|
|
2
|
+
require "wasmtime"
|
|
3
|
+
|
|
4
|
+
module EU
|
|
5
|
+
module LicenceValidator
|
|
6
|
+
WASM_PATH = File.expand_path("../wasm/core.wasm", __dir__)
|
|
7
|
+
|
|
8
|
+
@engine = Wasmtime::Engine.new
|
|
9
|
+
@module = Wasmtime::Module.from_file(@engine, WASM_PATH)
|
|
10
|
+
@linker = Wasmtime::Linker.new(@engine)
|
|
11
|
+
|
|
12
|
+
@linker.func_new("wasi_snapshot_preview1", "proc_exit", [:i32], []) do |code|
|
|
13
|
+
raise Wasmtime::WasiExit.new(code)
|
|
14
|
+
end
|
|
15
|
+
@linker.func_new("wasi_snapshot_preview1", "fd_write", [:i32, :i32, :i32, :i32], [:i32]) { |_fd, _ptr, _n, _ret| 0 }
|
|
16
|
+
@linker.func_new("wasi_snapshot_preview1", "random_get", [:i32, :i32], [:i32]) { |_ptr, _len| 0 }
|
|
17
|
+
|
|
18
|
+
@store = Wasmtime::Store.new(@engine)
|
|
19
|
+
@instance = @linker.instantiate(@store, @module)
|
|
20
|
+
|
|
21
|
+
begin
|
|
22
|
+
@instance.invoke("_start")
|
|
23
|
+
rescue Wasmtime::WasiExit, SystemExit
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class << self
|
|
27
|
+
def valid?(plate, country_code)
|
|
28
|
+
exports = @instance.exports
|
|
29
|
+
|
|
30
|
+
p_ptr, p_len = write_string(exports, plate)
|
|
31
|
+
c_ptr, c_len = write_string(exports, country_code)
|
|
32
|
+
|
|
33
|
+
validate = exports["validate"].to_func
|
|
34
|
+
dealloc = exports["dealloc"].to_func
|
|
35
|
+
result = validate.call(p_ptr, p_len, c_ptr, c_len)
|
|
36
|
+
dealloc.call(p_ptr)
|
|
37
|
+
dealloc.call(c_ptr)
|
|
38
|
+
result == 1
|
|
39
|
+
end
|
|
40
|
+
alias is_valid valid?
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def write_string(exports, str)
|
|
45
|
+
bytes = str.encode("UTF-8").bytes
|
|
46
|
+
alloc = exports["alloc"].to_func
|
|
47
|
+
ptr = alloc.call(bytes.length)
|
|
48
|
+
return [0, 0] if ptr == 0 && bytes.empty?
|
|
49
|
+
|
|
50
|
+
memory = exports["memory"].to_memory
|
|
51
|
+
memory.write(ptr, bytes.pack("C*"))
|
|
52
|
+
[ptr, bytes.length]
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
data/wasm/core.wasm
ADDED
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: eu-licence-validator
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.19
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- TrueJacobG
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-07-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: wasmtime
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '46.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '46.0'
|
|
27
|
+
description: European licence plate validation. Single Go core compiled to WebAssembly,
|
|
28
|
+
bundled for Ruby.
|
|
29
|
+
email:
|
|
30
|
+
- jakubgradzewicz1309@gmail.com
|
|
31
|
+
executables: []
|
|
32
|
+
extensions: []
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- lib/eu_licence_validator.rb
|
|
36
|
+
- lib/eu_licence_validator/version.rb
|
|
37
|
+
- wasm/core.wasm
|
|
38
|
+
homepage: https://github.com/TrueJacobG/eu-licence-validator
|
|
39
|
+
licenses:
|
|
40
|
+
- MIT
|
|
41
|
+
metadata:
|
|
42
|
+
homepage_uri: https://github.com/TrueJacobG/eu-licence-validator
|
|
43
|
+
source_code_uri: https://github.com/TrueJacobG/eu-licence-validator
|
|
44
|
+
changelog_uri: https://github.com/TrueJacobG/eu-licence-validator/blob/main/CHANGELOG.md
|
|
45
|
+
post_install_message:
|
|
46
|
+
rdoc_options: []
|
|
47
|
+
require_paths:
|
|
48
|
+
- lib
|
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '3.0'
|
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '0'
|
|
59
|
+
requirements: []
|
|
60
|
+
rubygems_version: 3.0.3.1
|
|
61
|
+
signing_key:
|
|
62
|
+
specification_version: 4
|
|
63
|
+
summary: European licence plate validation (shared Go/Wasm core).
|
|
64
|
+
test_files: []
|