xlsxrb 0.1.0 → 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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +83 -4
  3. data/lib/xlsxrb/version.rb +1 -1
  4. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2c0205aacdd92c016133af19ecd2cb6adfb9891e2e37fdbbdbc40eea1c7c6e1
4
- data.tar.gz: eebd75e5893fb6d2e8435cfbeba2858098b3c99b3ed091ec73477c5e5482a884
3
+ metadata.gz: 3ded1e540cdab22988eb7c5bfcfe9951a6a24ccae3f1d631962d174780dc5562
4
+ data.tar.gz: 9757007ef792b32b665e0a291d5fa242053a49ae1c48e91e8471bfb19ed4f235
5
5
  SHA512:
6
- metadata.gz: 8dd84504dbe911d8a208e256648a2ff54209831e03cdc5dab185d1697c9283ad6e09dd0e144f9822c27eaba01445734bc76f86cda6f2f20cc3016a8060b769f2
7
- data.tar.gz: 640e167013287ff3a27cfd75601d279bfe57d2fb212d3646ae5e50c21ff4b5e3e4f06bb09a3c583af08714f023f41cb5f1ec304f600a2b0cf37268e0f72f3e85
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. Synchronize latest lib/xlsxrb.rb to staging bundle directory before packing
203
- FileUtils.mkdir_p(File.dirname(packed_wasm_path))
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,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xlsxrb
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsxrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - niku
@@ -123,6 +123,7 @@ metadata:
123
123
  homepage_uri: https://github.com/niku/xlsxrb
124
124
  source_code_uri: https://github.com/niku/xlsxrb
125
125
  changelog_uri: https://github.com/niku/xlsxrb/blob/main/CHANGELOG.md
126
+ documentation_uri: https://niku.github.io/xlsxrb/
126
127
  rubygems_mfa_required: 'true'
127
128
  rdoc_options: []
128
129
  require_paths:
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  - !ruby/object:Gem::Version
139
140
  version: '0'
140
141
  requirements: []
141
- rubygems_version: 4.0.10
142
+ rubygems_version: 4.0.6
142
143
  specification_version: 4
143
144
  summary: A streaming-capable, fast, low-memory XLSX reader/writer.
144
145
  test_files: []