coreutils-wasm 1.0.0

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: a271d6f528a786685d21a08bd7f54d8004a98ddc879a1aa238e0a3cec7abe470
4
+ data.tar.gz: e4e9b233ee13a2d2ab4bb771a638fb08d633a017ec9aab87f9b329d7025c9da2
5
+ SHA512:
6
+ metadata.gz: b4f1c045e53050c8a445fd30320e77ed0ebfb058d10a633e42ed2a2d67f8ed9dd887a0f3f29e2a9194e1f71a7f532dace6c37e21b4c9ac3937b7e7c6b301115a
7
+ data.tar.gz: b46ed7493b0e048c46482fdea77d413fd35e2b9af7cba6719982cafcf1af60146ebc84274aa8b184c7afaa1e7f62ec72f486f8fd861011dbe46cb7c884fc440f
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nathan Himpens
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 ADDED
@@ -0,0 +1,145 @@
1
+ # CoreutilsWasm
2
+
3
+ GNU Coreutils compiled to WebAssembly.
4
+
5
+ This gem provides the WASM binary for GNU coreutils. It includes 100+ commands like `ls`, `cat`, `head`, `tail`, `wc`, `cp`, `mv`, `rm`, etc.
6
+
7
+ **This gem only provides the WASM binary.** You choose how to run it with your preferred WebAssembly runtime.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'coreutils-wasm'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ```bash
20
+ bundle install
21
+ ```
22
+
23
+ Or install it yourself:
24
+
25
+ ```bash
26
+ gem install coreutils-wasm
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ### Get the WASM binary path or bytes
32
+
33
+ ```ruby
34
+ require 'coreutils_wasm'
35
+
36
+ # Get the file path (useful for CLI runtimes)
37
+ wasm_path = CoreutilsWasm.wasm_path
38
+ # => "/path/to/gems/coreutils-wasm-1.0.0/wasm/coreutils.wasm"
39
+
40
+ # Get as binary string
41
+ wasm_bytes = CoreutilsWasm.wasm_bytes
42
+
43
+ # Get file size
44
+ wasm_size = CoreutilsWasm.wasm_size
45
+ # => 4705003
46
+
47
+ # Check if file exists
48
+ CoreutilsWasm.wasm_exists?
49
+ # => true
50
+ ```
51
+
52
+ ### List available commands
53
+
54
+ ```ruby
55
+ CoreutilsWasm.commands
56
+ # => ["arch", "base32", "base64", "basename", "cat", "chmod", "cp", "ls", ...]
57
+ ```
58
+
59
+ ## Running with different runtimes
60
+
61
+ ### With Wasmer CLI
62
+
63
+ ```bash
64
+ # Install wasmer
65
+ curl https://get.wasmer.io -sSfL | sh
66
+
67
+ # Run a command
68
+ wasmer run $(ruby -r coreutils_wasm -e "puts CoreutilsWasm.wasm_path") -- ls -la
69
+ ```
70
+
71
+ ### With Wasmtime CLI
72
+
73
+ ```bash
74
+ # Install wasmtime
75
+ curl https://wasmtime.dev/install.sh -sSf | bash
76
+
77
+ # Run a command
78
+ wasmtime $(ruby -r coreutils_wasm -e "puts CoreutilsWasm.wasm_path") -- ls -la
79
+ ```
80
+
81
+ ### With wasmer gem (Ruby runtime)
82
+
83
+ ```ruby
84
+ require 'wasmer'
85
+ require 'coreutils_wasm'
86
+
87
+ # Load the WASM binary
88
+ wasm_bytes = CoreutilsWasm.wasm_bytes
89
+ store = Wasmer::Store.new
90
+ module_ = Wasmer::Module.new store, wasm_bytes
91
+
92
+ # Create WASI environment
93
+ wasi_env = Wasmer::Wasi::StateBuilder.new("ls")
94
+ .argument("-la")
95
+ .preopen_directory(".")
96
+ .finalize
97
+
98
+ # Instantiate with WASI imports
99
+ import_object = wasi_env.generate_import_object(store, module_)
100
+ instance = Wasmer::Instance.new(module_, import_object)
101
+
102
+ # Run
103
+ wasi_env.start(instance)
104
+ ```
105
+
106
+ ### With shell execution
107
+
108
+ ```ruby
109
+ require 'coreutils_wasm'
110
+
111
+ # Simple shell execution with wasmer
112
+ def run_coreutils(command, *args)
113
+ wasm = CoreutilsWasm.wasm_path
114
+ `wasmer run #{wasm} -- #{command} #{args.join(' ')}`
115
+ end
116
+
117
+ puts run_coreutils('ls', '-la')
118
+ puts run_coreutils('cat', 'Gemfile')
119
+ ```
120
+
121
+ ## Available Commands
122
+
123
+ This binary includes all GNU coreutils commands:
124
+
125
+ `arch`, `base32`, `base64`, `baseenc`, `basename`, `cat`, `chcon`, `chgrp`, `chmod`, `chown`, `chroot`, `cksum`, `comm`, `cp`, `csplit`, `cut`, `date`, `dd`, `df`, `dircolors`, `dirname`, `du`, `echo`, `env`, `expand`, `expr`, `factor`, `false`, `fmt`, `fold`, `groups`, `hashsum`, `head`, `hostid`, `hostname`, `id`, `install`, `join`, `kill`, `link`, `ln`, `logname`, `ls`, `mkdir`, `mkfifo`, `mknod`, `mktemp`, `more`, `mv`, `nice`, `nl`, `nohup`, `nproc`, `numfmt`, `od`, `paste`, `pathchk`, `pinky`, `pr`, `printenv`, `printf`, `ptx`, `pwd`, `readlink`, `realpath`, `relpath`, `rm`, `rmdir`, `runcon`, `seq`, `shred`, `shuf`, `sleep`, `sort`, `split`, `stat`, `stdbuf`, `sum`, `sync`, `tac`, `tail`, `tee`, `test`, `timeout`, `touch`, `tr`, `true`, `truncate`, `tsort`, `tty`, `uname`, `unexpand`, `uniq`, `unlink`, `uptime`, `users`, `wc`, `who`, `whoami`, `yes`
126
+
127
+ **Note:** `grep` is not included as it's not part of GNU coreutils.
128
+
129
+ ## Development
130
+
131
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
132
+
133
+ ## Contributing
134
+
135
+ Bug reports and pull requests are welcome on GitHub at https://github.com/NathanHimpens/coreutils-wasm.
136
+
137
+ ## License
138
+
139
+ MIT
140
+
141
+ ## Credits
142
+
143
+ - [GNU Coreutils](https://www.gnu.org/software/coreutils/)
144
+ - [uutils/coreutils](https://github.com/uutils/coreutils) - Rust implementation compiled to WASM
145
+ - [Wasmer](https://wasmer.io/) - Original WASM package source
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CoreutilsWasm
4
+ module Commands
5
+ # All available coreutils commands
6
+ ALL = %w[
7
+ arch base32 base64 baseenc basename cat chcon chgrp chmod chown chroot
8
+ cksum comm cp csplit cut date dd df dircolors dirname du echo env expand
9
+ expr factor false fmt fold groups hashsum head hostid hostname id install
10
+ join kill link ln logname ls mkdir mkfifo mknod mktemp more mv nice nl
11
+ nohup nproc numfmt od paste pathchk pinky pr printenv printf ptx pwd
12
+ readlink realpath relpath rm rmdir runcon seq shred shuf sleep sort split
13
+ stat stdbuf sum sync tac tail tee test timeout touch tr true truncate
14
+ tsort tty uname unexpand uniq unlink uptime users wc who whoami yes
15
+ ].freeze
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CoreutilsWasm
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "coreutils_wasm/version"
4
+ require_relative "coreutils_wasm/commands"
5
+
6
+ # CoreutilsWasm provides GNU coreutils WASM binaries
7
+ #
8
+ # This gem only provides the WASM binary. You choose how to run it
9
+ # with your preferred WebAssembly runtime (wasmer, wasmtime, etc.)
10
+ module CoreutilsWasm
11
+ class Error < StandardError; end
12
+
13
+ class << self
14
+ # Get the absolute path to the coreutils WASM binary
15
+ # @return [String] Absolute path to coreutils.wasm
16
+ def wasm_path
17
+ @wasm_path ||= File.expand_path("../wasm/coreutils.wasm", __dir__)
18
+ end
19
+
20
+ # Get the raw WASM binary as a string of bytes
21
+ # @return [String] Binary string containing the WASM binary
22
+ def wasm_bytes
23
+ File.binread(wasm_path)
24
+ end
25
+
26
+ # Get the WASM file size in bytes
27
+ # @return [Integer] Size in bytes
28
+ def wasm_size
29
+ File.size(wasm_path)
30
+ end
31
+
32
+ # Check if the WASM binary exists
33
+ # @return [Boolean]
34
+ def wasm_exists?
35
+ File.exist?(wasm_path)
36
+ end
37
+
38
+ # List of all available commands in this binary
39
+ # @return [Array<String>]
40
+ def commands
41
+ Commands::ALL
42
+ end
43
+ end
44
+ end
Binary file
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coreutils-wasm
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Himpens
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: bundler
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '13.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '13.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rubocop
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.0'
68
+ description: Provides GNU coreutils commands (ls, cat, head, tail, wc, etc.) running
69
+ in a WebAssembly sandbox via Wasmer CLI.
70
+ email:
71
+ - nathan@example.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - LICENSE
77
+ - README.md
78
+ - lib/coreutils_wasm.rb
79
+ - lib/coreutils_wasm/commands.rb
80
+ - lib/coreutils_wasm/version.rb
81
+ - wasm/coreutils.wasm
82
+ homepage: https://github.com/NathanHimpens/coreutils-wasm
83
+ licenses:
84
+ - MIT
85
+ metadata:
86
+ homepage_uri: https://github.com/NathanHimpens/coreutils-wasm
87
+ source_code_uri: https://github.com/NathanHimpens/coreutils-wasm
88
+ changelog_uri: https://github.com/NathanHimpens/coreutils-wasm/blob/main/CHANGELOG.md
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.7.0
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.6.7
104
+ specification_version: 4
105
+ summary: GNU Coreutils compiled to WebAssembly for Ruby
106
+ test_files: []