bormashino 0.1.1 → 0.1.4

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: 7bce2e8e56f0ea232175228fcf6f0bf08411e86fc8fba54fd2605e3cf2aef006
4
- data.tar.gz: 4deb87017b0c90a2efdcfdaacea53d4d38f91ac2177ac65a8e5e9c75380a7a7d
3
+ metadata.gz: 746545a9c19d9636a66fe0f695a2960bf96ec9d549eb54eea02f8421033df62c
4
+ data.tar.gz: b5d32e291df6331f2a653ff27a795fc94893dc0d45ad9d793fc3999ce3fe7bd0
5
5
  SHA512:
6
- metadata.gz: 726ccaec4019d7a0c2ddfde142a0cec981d7b0c3691d1613a8a291650850696ef9d1f0eb5df9a0d22f11d37110f6bd7f9cf7c37bb3d33dec54e2cfe86947252b
7
- data.tar.gz: 5a8421e0cc26e1e9ee8b0acdf0bdde5afdec0502fe5edfb900ae4e79ebaa6bf665267842dd1b39b97d17524a1af782480a0660d7ca3126f1380f8c3db148580f
6
+ metadata.gz: 0a7e007e9615dd0b759c2b8cc30fbb4292c678a241db0bde8dd2ddb472c1f3640e839caac24d2b813ef4be547c01deb69319bc8ebaa61304f63bdc379833d022
7
+ data.tar.gz: ebbf53d4c6d772aea0fc4dff5ed9ac204fd0c0e0550eab18906cc8d5a4846a6e9586def616f7eafebc3ae2f4121fa75b6f36c5f7931b4563f638328190fabccc
@@ -0,0 +1,39 @@
1
+ require 'js'
2
+ require_relative 'ext/js'
3
+ require 'cgi'
4
+
5
+ module Bormashino
6
+ class Fetch
7
+ attr_accessor :resource, :init, :resolved_to, :options
8
+
9
+ def initialize(resource:, resolved_to:, init: {}, options: {})
10
+ @resource = resource
11
+ @init = init
12
+ @resolved_to = resolved_to
13
+ @options = options
14
+ end
15
+
16
+ def run
17
+ raise 'No mounted apps' unless Bormashino::Server.mounted?
18
+
19
+ # rubocop:disable Style::DocumentDynamicEvalDefinition
20
+ JS.eval <<-ENDOFEVAL
21
+ fetch(
22
+ #{@resource.to_json},
23
+ #{@init.to_json}
24
+ ).then((r) => {
25
+ r.text().then((t) => {
26
+ window.bormashino.request(
27
+ 'post',
28
+ #{@resolved_to.to_json},
29
+ 'status=' + r.status +
30
+ '&payload=' + encodeURIComponent(t) +
31
+ '&options=' + #{CGI.escape(@options.to_json).to_json}
32
+ )
33
+ })
34
+ })
35
+ ENDOFEVAL
36
+ # rubocop:enable Style::DocumentDynamicEvalDefinition
37
+ end
38
+ end
39
+ end
@@ -3,6 +3,10 @@ require 'stringio'
3
3
 
4
4
  module Bormashino
5
5
  module Server
6
+ def self.mounted?
7
+ !@app.nil?
8
+ end
9
+
6
10
  def self.mount(app_class)
7
11
  @app = app_class.new
8
12
  end
@@ -12,7 +16,7 @@ module Bormashino
12
16
 
13
17
  @app.call({
14
18
  'HTTP_HOST' => 'example.com:0',
15
- 'REQUEST_METHOD' => method,
19
+ 'REQUEST_METHOD' => method.upcase,
16
20
  'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
17
21
  'QUERY_STRING' => u.query,
18
22
  'PATH_INFO' => u.path,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bormashino
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.4'
5
5
  end
data/lib/bormashino.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require_relative 'bormashino/version'
2
- require_relative 'bormashino/utils'
3
2
  require_relative 'bormashino/server'
4
3
 
5
4
  module Bormashino
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.1
4
+ version: 0.1.4
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-01 00:00:00.000000000 Z
11
+ date: 2022-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_pure
@@ -72,13 +72,13 @@ files:
72
72
  - README.md
73
73
  - lib/bormashino.rb
74
74
  - lib/bormashino/ext/js.rb
75
+ - lib/bormashino/fetch.rb
75
76
  - lib/bormashino/local_storage.rb
76
77
  - lib/bormashino/mock/local_storage.rb
77
78
  - lib/bormashino/server.rb
78
79
  - lib/bormashino/stub/openssl.rb
79
80
  - lib/bormashino/stub/zlib.rb
80
81
  - lib/bormashino/tasks/bormashino.rake
81
- - lib/bormashino/utils.rb
82
82
  - lib/bormashino/version.rb
83
83
  homepage: https://github.com/keyasuda/bormashino
84
84
  licenses:
@@ -1,10 +0,0 @@
1
- require 'json/pure'
2
- require 'cgi'
3
-
4
- module Bormashino
5
- module Utils
6
- def self.to_rb_value(escaped_json)
7
- JSON.parse(CGI.unescape(escaped_json))
8
- end
9
- end
10
- end