bormashino 0.1.0 → 0.1.3

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: a039d1ebc67a8050439f8d2f1acd7932f9acfe1da61f865a412e3e74b33c5460
4
- data.tar.gz: b1b32026abc7293da26ed53b7f021b3501d5946ddfd3cd56759a910bb65dd00c
3
+ metadata.gz: 1c6c917023f14695a0b5ae88b3c50b8f2b37d9516d05c1427ed859d8d12c710f
4
+ data.tar.gz: c72487b632f901f7d40b68c979cbcf908e53ed2e98323707d0d4e7c0ab806438
5
5
  SHA512:
6
- metadata.gz: 7bde9f76ca33436380761a081ced2ee60d38d9dbb2abfe4e45ec5df7a847065e10cbb40315c271cd8f37e68ac3ab0ffe1ef2a1bc7eb9f47f50ab2d5cd4890b77
7
- data.tar.gz: aa23838aa5de924028dbe99765afc5969bbb6a23fd3b532c0274562eff335d279bb08a7ba9cfc4f3a2cf076c12b7268ed619c00a0285ec9d44cd10b9ebd56b2f
6
+ metadata.gz: 37c859264a65f0af907c3faaabb74cb2f96afe3daeb8de91d65ce1511bf4c41ccfc592f54b30616be68a6de910ef5696d23727befac12471eff45c89adbe235b
7
+ data.tar.gz: 2fa7b38d1018c9e0f7ab31fb41d84b0a5ff81a0decd16814ba213953cbbaf615a8227facfafb99947b96c4241e12f5be7e5717401efd02bc25797ab03fb225b7
@@ -0,0 +1,36 @@
1
+ require 'js'
2
+ require_relative 'ext/js'
3
+
4
+ module Bormashino
5
+ class Fetch
6
+ attr_accessor :resource, :init, :resolved_to
7
+
8
+ def initialize(resource:, resolved_to:, init: {})
9
+ @resource = resource
10
+ @init = init
11
+ @resolved_to = resolved_to
12
+ end
13
+
14
+ def run
15
+ raise 'No app is mounted' unless Bormashino::Server.mounted?
16
+
17
+ # rubocop:disable Style::DocumentDynamicEvalDefinition
18
+ JS.eval <<-ENDOFEVAL
19
+ fetch(
20
+ #{@resource.to_json},
21
+ #{@init.to_json}
22
+ ).then((r) => {
23
+ r.text().then((t) => {
24
+ window.bormashino.request(
25
+ 'post',
26
+ #{@resolved_to.to_json},
27
+ 'status=' + r.status +
28
+ '&payload=' + encodeURIComponent(t)
29
+ )
30
+ })
31
+ })
32
+ ENDOFEVAL
33
+ # rubocop:enable Style::DocumentDynamicEvalDefinition
34
+ end
35
+ end
36
+ 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.0'
4
+ VERSION = '0.1.3'
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.0
4
+ version: 0.1.3
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-04-30 00:00:00.000000000 Z
11
+ date: 2022-05-07 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