opal-httpget 0.1.0
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/examples/compile/Gemfile +10 -0
- data/examples/compile/Gemfile.lock +26 -0
- data/examples/compile/app.rb +8 -0
- data/examples/compile/config.ru +4 -0
- data/examples/compile/public/Gemfile +11 -0
- data/examples/compile/public/Gemfile.lock +30 -0
- data/examples/compile/public/Rakefile +16 -0
- data/examples/compile/public/test.jpg +0 -0
- data/examples/compile/public/test.js +27805 -0
- data/examples/compile/public/test.json +110 -0
- data/examples/compile/public/test.rb +11 -0
- data/examples/compile/views/test.erb +12 -0
- data/examples/server/Gemfile +6 -0
- data/examples/server/Gemfile.lock +41 -0
- data/examples/server/app/application.rb +6 -0
- data/examples/server/config.ru +8 -0
- data/examples/server/package-lock.json +11 -0
- data/examples/server/test.jpg +0 -0
- data/examples/server/test.json +110 -0
- data/lib/jquery-3.6.0.min.js +2 -0
- data/lib/opal/.httpget.rb.swp +0 -0
- data/lib/opal/httpget/example.rb +11 -0
- data/lib/opal/httpget/version.rb +7 -0
- data/lib/opal/httpget.rb +78 -0
- data/opal-httpget.gemspec +40 -0
- metadata +108 -0
data/lib/opal/httpget.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
|
4
|
+
if RUBY_ENGINE == "opal"
|
5
|
+
puts "Ruby engine is opal"
|
6
|
+
require_relative "httpget/version"
|
7
|
+
require 'jquery-3.6.0.min'
|
8
|
+
require 'opal-jquery'
|
9
|
+
else
|
10
|
+
puts "Ruby engine is ruby"
|
11
|
+
require_relative "httpget/version"
|
12
|
+
# require_relative '../jquery-3.6.0.min.js'
|
13
|
+
require "opal"
|
14
|
+
require 'opal-jquery'
|
15
|
+
end
|
16
|
+
|
17
|
+
module Opal
|
18
|
+
module Httpget
|
19
|
+
class Error < StandardError; end
|
20
|
+
|
21
|
+
class Sender
|
22
|
+
attr_reader :response_text
|
23
|
+
|
24
|
+
def initialize()
|
25
|
+
@response_text = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def get(file, &next_proc)
|
29
|
+
|
30
|
+
ans = ""
|
31
|
+
|
32
|
+
%x{
|
33
|
+
// リクエスト定義
|
34
|
+
var request = new XMLHttpRequest()
|
35
|
+
request.open('GET', file, true)
|
36
|
+
request.responseType = 'text'
|
37
|
+
|
38
|
+
// ロード時は変数ansへ受け渡し
|
39
|
+
request.onload = () => {
|
40
|
+
ans = request.responseText
|
41
|
+
}
|
42
|
+
|
43
|
+
// ロード完了したらjsonパースして、画像をプリロード。そしてサイトのメインプログラム実行
|
44
|
+
request.onloadend = () => {
|
45
|
+
#{
|
46
|
+
@response_text = ans
|
47
|
+
yield self
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
// 読み込みエラー時の処理はここに書くらしいです
|
52
|
+
request.onerror = () => {}
|
53
|
+
|
54
|
+
request.send()
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
module_function
|
60
|
+
|
61
|
+
## 画像プリロードの構文。参考: https://www.webdesignleaves.com/wp/jquery/1355/
|
62
|
+
def mypreload(files)
|
63
|
+
%x{
|
64
|
+
for(var i = 0; i< files.length; i++){
|
65
|
+
$("<img>").attr("src", files[i]);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
## ここで、先に画像ファイルを読み込む。
|
71
|
+
def preload_images(files, &next_proc)
|
72
|
+
imnum, targetnum = 0, files.length
|
73
|
+
mypreload(files)
|
74
|
+
yield
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/opal/httpget/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "opal-httpget"
|
7
|
+
spec.version = Opal::Httpget::VERSION
|
8
|
+
spec.authors = ["showata"]
|
9
|
+
spec.email = ["shun_yamaguchi_tc@live.jp"]
|
10
|
+
|
11
|
+
spec.summary = "HTTP get request sender for opal."
|
12
|
+
spec.description = "HTTP get request sender for opal."
|
13
|
+
spec.homepage = "https://github.com/show-o-atakun/opal-httpget"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/show-o-atakun/opal-httpget"
|
21
|
+
## spec.metadata["changelog_uri"] = "https://github.com/show-o-atakun/easy_sheet_io_gemspec"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency "opal"
|
33
|
+
spec.add_dependency "opal-jquery"
|
34
|
+
|
35
|
+
# Uncomment to register a new dependency of your gem
|
36
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
37
|
+
|
38
|
+
# For more information and examples about making a new gem, checkout our
|
39
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opal-httpget
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- showata
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: opal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: opal-jquery
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: HTTP get request sender for opal.
|
42
|
+
email:
|
43
|
+
- shun_yamaguchi_tc@live.jp
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- CODE_OF_CONDUCT.md
|
51
|
+
- Gemfile
|
52
|
+
- Gemfile.lock
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/console
|
57
|
+
- bin/setup
|
58
|
+
- examples/compile/Gemfile
|
59
|
+
- examples/compile/Gemfile.lock
|
60
|
+
- examples/compile/app.rb
|
61
|
+
- examples/compile/config.ru
|
62
|
+
- examples/compile/public/Gemfile
|
63
|
+
- examples/compile/public/Gemfile.lock
|
64
|
+
- examples/compile/public/Rakefile
|
65
|
+
- examples/compile/public/test.jpg
|
66
|
+
- examples/compile/public/test.js
|
67
|
+
- examples/compile/public/test.json
|
68
|
+
- examples/compile/public/test.rb
|
69
|
+
- examples/compile/views/test.erb
|
70
|
+
- examples/server/Gemfile
|
71
|
+
- examples/server/Gemfile.lock
|
72
|
+
- examples/server/app/application.rb
|
73
|
+
- examples/server/config.ru
|
74
|
+
- examples/server/package-lock.json
|
75
|
+
- examples/server/test.jpg
|
76
|
+
- examples/server/test.json
|
77
|
+
- lib/jquery-3.6.0.min.js
|
78
|
+
- lib/opal/.httpget.rb.swp
|
79
|
+
- lib/opal/httpget.rb
|
80
|
+
- lib/opal/httpget/example.rb
|
81
|
+
- lib/opal/httpget/version.rb
|
82
|
+
- opal-httpget.gemspec
|
83
|
+
homepage: https://github.com/show-o-atakun/opal-httpget
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata:
|
87
|
+
homepage_uri: https://github.com/show-o-atakun/opal-httpget
|
88
|
+
source_code_uri: https://github.com/show-o-atakun/opal-httpget
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 2.3.0
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubygems_version: 3.2.3
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: HTTP get request sender for opal.
|
108
|
+
test_files: []
|