xlsxrb 0.1.1 → 0.1.2
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/Rakefile +83 -4
- data/lib/xlsxrb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ded1e540cdab22988eb7c5bfcfe9951a6a24ccae3f1d631962d174780dc5562
|
|
4
|
+
data.tar.gz: 9757007ef792b32b665e0a291d5fa242053a49ae1c48e91e8471bfb19ed4f235
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 68ab59ce1086f06379241af5140d4c2dc69757bff606c385e90a13014c50cda15a54deeaf299d85f40f023c54081917ae5b2cd71408dcc48bcba6a7634e69eed
|
|
7
|
+
data.tar.gz: 6cfd71118b60aa30a94463902c5f808ebad242f32f6f6fe7b74f6e0733bd30de5db8f9e2e6b4149ec16df1bccd0e50f08d5e4aec6bcff58a8501f40ad350c7eb
|
data/Rakefile
CHANGED
|
@@ -184,6 +184,7 @@ task :wasm do
|
|
|
184
184
|
original_wasm_cache = File.expand_path("tmp/test_env/ruby.wasm", __dir__)
|
|
185
185
|
packed_wasm_path = File.expand_path("docs/wasm/ruby.wasm", __dir__)
|
|
186
186
|
wasm_bundle_dir = File.expand_path("tmp/wasm_bundle", __dir__)
|
|
187
|
+
bundle_assets_dir = File.expand_path("docs/wasm/bundle_assets", __dir__)
|
|
187
188
|
|
|
188
189
|
# 1. Download original base Wasm if not cached locally
|
|
189
190
|
unless File.exist?(original_wasm_cache)
|
|
@@ -199,11 +200,89 @@ task :wasm do
|
|
|
199
200
|
puts "Original ruby.wasm cached successfully."
|
|
200
201
|
end
|
|
201
202
|
|
|
202
|
-
# 2.
|
|
203
|
-
FileUtils.
|
|
203
|
+
# 2. Recreate and populate the staging bundle directories
|
|
204
|
+
FileUtils.rm_rf(wasm_bundle_dir)
|
|
205
|
+
FileUtils.rm_rf(bundle_assets_dir)
|
|
206
|
+
FileUtils.mkdir_p(wasm_bundle_dir)
|
|
207
|
+
FileUtils.mkdir_p(bundle_assets_dir)
|
|
208
|
+
|
|
209
|
+
# A. Write custom static stubs and gateways dynamically
|
|
210
|
+
File.write(File.join(bundle_assets_dir, "openssl.rb"), "# frozen_string_literal: true\n")
|
|
211
|
+
|
|
212
|
+
File.write(File.join(bundle_assets_dir, "opentelemetry.rb"), <<~RUBY)
|
|
213
|
+
# frozen_string_literal: true
|
|
214
|
+
module OpenTelemetry
|
|
215
|
+
def self.tracer_provider
|
|
216
|
+
@tracer_provider ||= Class.new {
|
|
217
|
+
def tracer(*args)
|
|
218
|
+
Class.new {
|
|
219
|
+
def in_span(*args)
|
|
220
|
+
yield Class.new { def record_exception(*args); end; def status=(*args); end }.new
|
|
221
|
+
end
|
|
222
|
+
}.new
|
|
223
|
+
end
|
|
224
|
+
}.new
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
RUBY
|
|
228
|
+
|
|
229
|
+
# Gateway for REXML
|
|
230
|
+
File.write(File.join(bundle_assets_dir, "rexml.rb"), "# frozen_string_literal: true\nrequire \"rexml/rexml\"\n")
|
|
231
|
+
|
|
232
|
+
# Resolve and copy host's rexml files
|
|
233
|
+
rexml_spec_path = $LOAD_PATH.find { |p| File.exist?(File.join(p, "rexml/rexml.rb")) }
|
|
234
|
+
if rexml_spec_path
|
|
235
|
+
FileUtils.cp_r(File.join(rexml_spec_path, "rexml"), bundle_assets_dir)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Gateway for strscan
|
|
239
|
+
File.write(File.join(bundle_assets_dir, "strscan.rb"), <<~RUBY)
|
|
240
|
+
# frozen_string_literal: true
|
|
241
|
+
begin
|
|
242
|
+
require "strscan.so"
|
|
243
|
+
rescue LoadError
|
|
244
|
+
end
|
|
245
|
+
require "strscan/strscan"
|
|
246
|
+
RUBY
|
|
247
|
+
|
|
248
|
+
# Resolve and copy host's strscan files
|
|
249
|
+
strscan_spec_path = $LOAD_PATH.find { |p| File.exist?(File.join(p, "strscan/strscan.rb")) }
|
|
250
|
+
if strscan_spec_path
|
|
251
|
+
FileUtils.mkdir_p(File.join(bundle_assets_dir, "strscan"))
|
|
252
|
+
FileUtils.cp(File.join(strscan_spec_path, "strscan/strscan.rb"), File.join(bundle_assets_dir, "strscan/strscan.rb"))
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# B. Copy necessary standard libraries dynamically from host's $LOAD_PATH
|
|
256
|
+
stdlib_files = [
|
|
257
|
+
"date.rb", "delegate.rb", "forwardable.rb", "securerandom.rb",
|
|
258
|
+
"random/formatter.rb", "set.rb", "tempfile.rb", "tmpdir.rb", "fileutils.rb"
|
|
259
|
+
]
|
|
260
|
+
stdlib_files.each do |name|
|
|
261
|
+
path = $LOAD_PATH.find { |p| File.exist?(File.join(p, name)) }
|
|
262
|
+
if path
|
|
263
|
+
dest_path = File.join(bundle_assets_dir, name)
|
|
264
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
|
265
|
+
FileUtils.cp(File.join(path, name), dest_path)
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# C. Patch tmpdir.rb to automatically create /tmp in Wasm virtual filesystem (since Wasm has no writable /tmp by default)
|
|
270
|
+
tmpdir_path = File.join(bundle_assets_dir, "tmpdir.rb")
|
|
271
|
+
if File.exist?(tmpdir_path)
|
|
272
|
+
File.open(tmpdir_path, "a") do |f|
|
|
273
|
+
f.puts "\nclass Dir\n def self.tmpdir\n Dir.mkdir(\"/tmp\") rescue nil unless File.directory?(\"/tmp\")\n \"/tmp\"\n end\nend\n"
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# D. Copy everything from bundle_assets_dir to wasm_bundle_dir
|
|
278
|
+
FileUtils.cp_r(File.join(bundle_assets_dir, "."), wasm_bundle_dir)
|
|
279
|
+
|
|
280
|
+
# E. Copy latest xlsxrb implementation files from lib/
|
|
204
281
|
FileUtils.cp(File.expand_path("lib/xlsxrb.rb", __dir__), File.join(wasm_bundle_dir, "xlsxrb.rb"))
|
|
282
|
+
FileUtils.cp_r(File.expand_path("lib/xlsxrb", __dir__), wasm_bundle_dir)
|
|
205
283
|
|
|
206
284
|
# 3. Compile custom ruby.wasm packaging staging libs
|
|
285
|
+
FileUtils.mkdir_p(File.dirname(packed_wasm_path))
|
|
207
286
|
puts "Building packed ruby.wasm from staging bundle..."
|
|
208
287
|
cmd = "bundle exec rbwasm pack #{original_wasm_cache} --dir #{wasm_bundle_dir}::/usr/local/lib/ruby/site_ruby -o #{packed_wasm_path}"
|
|
209
288
|
puts "Executing: #{cmd}"
|
|
@@ -259,9 +338,9 @@ namespace :doc do
|
|
|
259
338
|
desc "Build and preview RDoc documentation locally"
|
|
260
339
|
task preview: :doc do
|
|
261
340
|
require "webrick"
|
|
262
|
-
|
|
341
|
+
|
|
263
342
|
port = ENV.fetch("PORT", "8000").to_i
|
|
264
|
-
|
|
343
|
+
|
|
265
344
|
# Configure WEBrick to serve 'doc' directory
|
|
266
345
|
server = WEBrick::HTTPServer.new(
|
|
267
346
|
Port: port,
|
data/lib/xlsxrb/version.rb
CHANGED