bormashino 0.1.3 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c6c917023f14695a0b5ae88b3c50b8f2b37d9516d05c1427ed859d8d12c710f
4
- data.tar.gz: c72487b632f901f7d40b68c979cbcf908e53ed2e98323707d0d4e7c0ab806438
3
+ metadata.gz: 5a99890edb18fa7c816a6c559640b99eac3ef69431a4085565c3a2d71d0d9972
4
+ data.tar.gz: 5c6a2cde12f3e4d1150b4395f04d9e970078fd275dd8dd7beae11f7765610a50
5
5
  SHA512:
6
- metadata.gz: 37c859264a65f0af907c3faaabb74cb2f96afe3daeb8de91d65ce1511bf4c41ccfc592f54b30616be68a6de910ef5696d23727befac12471eff45c89adbe235b
7
- data.tar.gz: 2fa7b38d1018c9e0f7ab31fb41d84b0a5ff81a0decd16814ba213953cbbaf615a8227facfafb99947b96c4241e12f5be7e5717401efd02bc25797ab03fb225b7
6
+ metadata.gz: 4d3a8387730fa96251441d2d023749eedbabf757ecea260d887e1363595d4be06ab78c0733782d350f53071e32811f301a3ace964202ff76d344c1f1f36b44c9
7
+ data.tar.gz: b144c2b03fcca6e2ae0486c53a4e1223a06c33c0cfb005a4dc0885831519c687997e68cf616a981965f27d8e7d342d1370491979a838344883aae48fdbe82259
@@ -1,18 +1,20 @@
1
1
  require 'js'
2
2
  require_relative 'ext/js'
3
+ require 'cgi'
3
4
 
4
5
  module Bormashino
5
6
  class Fetch
6
- attr_accessor :resource, :init, :resolved_to
7
+ attr_accessor :resource, :init, :resolved_to, :options
7
8
 
8
- def initialize(resource:, resolved_to:, init: {})
9
+ def initialize(resource:, resolved_to:, init: {}, options: {})
9
10
  @resource = resource
10
11
  @init = init
11
12
  @resolved_to = resolved_to
13
+ @options = options
12
14
  end
13
15
 
14
16
  def run
15
- raise 'No app is mounted' unless Bormashino::Server.mounted?
17
+ raise 'No mounted apps' unless Bormashino::Server.mounted?
16
18
 
17
19
  # rubocop:disable Style::DocumentDynamicEvalDefinition
18
20
  JS.eval <<-ENDOFEVAL
@@ -25,7 +27,8 @@ module Bormashino
25
27
  'post',
26
28
  #{@resolved_to.to_json},
27
29
  'status=' + r.status +
28
- '&payload=' + encodeURIComponent(t)
30
+ '&payload=' + encodeURIComponent(t) +
31
+ '&options=' + #{CGI.escape(@options.to_json).to_json}
29
32
  )
30
33
  })
31
34
  })
@@ -1,8 +1,13 @@
1
1
  require 'fileutils'
2
2
  require 'uri'
3
+ require 'os'
4
+ require 'digest/md5'
3
5
 
4
6
  RUBY_RELEASE = 'https://github.com/ruby/ruby.wasm/releases/download/2022-04-25-a/ruby-head-wasm32-unknown-wasi-full-js.tar.gz'.freeze
5
7
  WASI_VFS_RELEASE = 'https://github.com/kateinoigakukun/wasi-vfs/releases/download/v0.1.1/wasi-vfs-cli-x86_64-unknown-linux-gnu.zip'.freeze
8
+ WASI_VFS_RELEASE_MAC_X86_64 = 'https://github.com/kateinoigakukun/wasi-vfs/releases/download/v0.1.1/wasi-vfs-cli-x86_64-apple-darwin.zip'.freeze
9
+ WASI_VFS_RELEASE_MAC_ARM64 = 'https://github.com/kateinoigakukun/wasi-vfs/releases/download/v0.1.1/wasi-vfs-cli-aarch64-apple-darwin.zip'.freeze
10
+
6
11
  RUBY_ROOT = File.basename(URI(RUBY_RELEASE).path).split('.').first.sub('ruby-', '')
7
12
  WASI_VFS = './wasi-vfs'.freeze
8
13
  TMP = 'tmp'.freeze
@@ -15,7 +20,19 @@ namespace :bormashino do
15
20
  FileUtils.rm(File.join(RUBY_ROOT, '/usr/local/lib/libruby-static.a'))
16
21
  FileUtils.rm_rf(File.join(RUBY_ROOT, '/usr/local/include'))
17
22
 
18
- system "curl -L '#{WASI_VFS_RELEASE}' | gzip -d > wasi-vfs"
23
+ case
24
+ when OS.linux?
25
+ system "curl -L '#{WASI_VFS_RELEASE}' | gzip -d > wasi-vfs"
26
+ when OS.mac?
27
+ if OS.host_cpu == 'x86_64'
28
+ system "curl -L -o wasi-vfs.zip '#{WASI_VFS_RELEASE_MAC_X86_64}'"
29
+ else
30
+ system "curl -L -o wasi-vfs.zip '#{WASI_VFS_RELEASE_MAC_ARM64}'"
31
+ end
32
+ system 'unzip wasi-vfs.zip'
33
+ system 'rm wasi-vfs.zip'
34
+ end
35
+
19
36
  system 'chmod u+x wasi-vfs'
20
37
  end
21
38
 
@@ -37,7 +54,7 @@ namespace :bormashino do
37
54
 
38
55
  desc 'pack済みのruby.wasmのMD5を取りファイル名につけてコピーし、import用のJSを出力する'
39
56
  task :digest, [:destination] do |_, args|
40
- digest = `md5sum tmp/ruby.wasm`.split.first
57
+ digest = Digest::MD5.file('tmp/ruby.wasm').hexdigest
41
58
  FileUtils.cp('tmp/ruby.wasm', "#{args[:destination]}/ruby.#{digest}.wasm")
42
59
  File.open(DIGEST, 'w') { |f|
43
60
  f.puts "export default rubyDigest = '#{digest}'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bormashino
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bormashino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenichiro Yasuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-07 00:00:00.000000000 Z
11
+ date: 2022-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_pure
@@ -58,6 +58,26 @@ dependencies:
58
58
  - - '='
59
59
  - !ruby/object:Gem::Version
60
60
  version: 0.0.4
61
+ - !ruby/object:Gem::Dependency
62
+ name: os
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.1'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 1.1.4
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '1.1'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 1.1.4
61
81
  description: ' With "Bormaŝino" you can build SPAs written in Ruby powered by Ruby
62
82
  WebAssembly build and Sinatra (or other rack-based web application frameworks).
63
83