browser_app_base 0.2.0 → 0.2.1
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 +4 -4
- data/Gemfile +3 -6
- data/README.md +32 -1
- data/README_ja.md +351 -0
- data/bin/create_browser_app.rb +0 -1
- data/bin/ruby-lsp +27 -0
- data/bin/ruby-lsp-check +27 -0
- data/bin/ruby-lsp-launcher +27 -0
- data/bin/ruby-lsp-test-exec +27 -0
- data/browser_app_base.gemspec +2 -0
- data/lib/browser_app_base/version.rb +1 -1
- data/lib/template/config/browser.json +2 -2
- data/lib/template/config.ru +0 -2
- data/lib/template/js/main.js +2 -2
- data/lib/template/server_app_base.rb +2 -1
- data/lib/template/start.rb +7 -5
- metadata +39 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3a2860c691d1d3804149cd68211e0d2ddbc05dd6bc198c27af21c9dc31b82be
|
|
4
|
+
data.tar.gz: d315366358a5e02d9180a207c950b8872bf230c07d8b6f4bbaefed7fd9db8483
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f786c2046c321408bb51c353df8fe672735b00ed40feae90e38331d3dee32e1535ce476770028af4ceafbccf14bdd5e40e34eddc44136405c02382dd92bec43
|
|
7
|
+
data.tar.gz: b606cef5fb889cecf391b90dbe829fd6d0d94424958831b79f3ed1c556f9b9adf4b4045347c62f7222df68ea77f83bce42e22184e511cd7249e4a1a3615b9ea4
|
data/Gemfile
CHANGED
|
@@ -5,12 +5,9 @@ source "https://rubygems.org"
|
|
|
5
5
|
# Specify your gem's dependencies in browser_app_base.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem "rack", "
|
|
9
|
-
|
|
8
|
+
gem "rack", ">= 3.0"
|
|
9
|
+
gem "rackup"
|
|
10
10
|
gem "rake", "~> 13.0"
|
|
11
|
-
|
|
12
11
|
gem "rspec", ">= 0"
|
|
13
|
-
|
|
14
12
|
gem "rack-test"
|
|
15
|
-
|
|
16
|
-
gem "sinatra"
|
|
13
|
+
gem "sinatra"
|
data/README.md
CHANGED
|
@@ -18,6 +18,13 @@ On Windows, the Edge browser is used by default.
|
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
+
## Latest Changes
|
|
22
|
+
- Added support for Rack 3
|
|
23
|
+
- Added ruby-lsp environment
|
|
24
|
+
- Added Docker test environment for Ubuntu
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
21
28
|
## Installation
|
|
22
29
|
|
|
23
30
|
Add this line to your application's Gemfile:
|
|
@@ -281,6 +288,30 @@ This image displays the detailed setting screen, allowing you to edit individual
|
|
|
281
288
|
|
|
282
289
|
---
|
|
283
290
|
|
|
291
|
+
## Docker Test Environment
|
|
292
|
+
|
|
293
|
+
A Docker-based test environment is available for testing the application on Ubuntu.
|
|
294
|
+
This setup uses X11 forwarding to display the browser window on your host machine.
|
|
295
|
+
|
|
296
|
+
```shell
|
|
297
|
+
$ cd test/docker/ubuntu
|
|
298
|
+
$ docker-compose up -d
|
|
299
|
+
$ docker exec -it ubuntu bash
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
For Ubuntu 24.04:
|
|
303
|
+
```shell
|
|
304
|
+
$ docker-compose -f docker-compose-24.04.yml up -d
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Inside the container:
|
|
308
|
+
```shell
|
|
309
|
+
$ cd /work
|
|
310
|
+
$ rake
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
284
315
|
## Running Tests
|
|
285
316
|
|
|
286
317
|
From v0.1.9, RSpec-based testing is supported.
|
|
@@ -294,7 +325,7 @@ bundle exec rake
|
|
|
294
325
|
or
|
|
295
326
|
|
|
296
327
|
```sh
|
|
297
|
-
bundle exec rspec
|
|
328
|
+
RACK_ENV=test bundle exec rspec
|
|
298
329
|
```
|
|
299
330
|
|
|
300
331
|
RSpec tasks are defined in the `Rakefile`, so `rake` will automatically run all tests.
|
data/README_ja.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# BrowserAppBase
|
|
2
|
+
|
|
3
|
+
WindowsおよびLinux向けのブラウザベースデスクトップアプリケーションのテンプレートです。
|
|
4
|
+
|
|
5
|
+
LinuxではデフォルトでChromeブラウザが使用されます。
|
|
6
|
+
WindowsではデフォルトでEdgeブラウザが使用されます。
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 機能
|
|
11
|
+
|
|
12
|
+
- クロスプラットフォームのブラウザベースデスクトップアプリテンプレート(Windows/Linux)
|
|
13
|
+
- シンプルなアプリ生成コマンド (`create_browser_app`)
|
|
14
|
+
- `setting.json` による柔軟なアプリケーション設定
|
|
15
|
+
- ブラウザUIとRubyバックエンド間の通信
|
|
16
|
+
- RSpecベースのテストフレームワーク(v0.1.9以降)
|
|
17
|
+
- OSごとの簡単なブラウザ設定
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 最新の変更点
|
|
22
|
+
- Rack 3 をサポートしました
|
|
23
|
+
- ruby-lspの環境を追加しました
|
|
24
|
+
- Ubuntu用のDockerテスト環境を追加しました
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## インストール
|
|
29
|
+
|
|
30
|
+
アプリケーションのGemfileに以下の行を追加します:
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
gem 'browser_app_base'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
そして実行します:
|
|
37
|
+
|
|
38
|
+
$ bundle install
|
|
39
|
+
|
|
40
|
+
または、直接インストールします:
|
|
41
|
+
|
|
42
|
+
$ gem install browser_app_base
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 使い方
|
|
47
|
+
|
|
48
|
+
create_browser_app [options]
|
|
49
|
+
-d, --dir dir_name アプリケーションのディレクトリ
|
|
50
|
+
-a, --app app_name アプリケーション名
|
|
51
|
+
-h, --help コマンドのヘルプ
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## アプリケーションテンプレートの作成
|
|
56
|
+
|
|
57
|
+
$ create_browser_app -d /path/to/test/ -a MyApp
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## アプリケーションコードの追加
|
|
62
|
+
|
|
63
|
+
$ cd /path/to/test/
|
|
64
|
+
$ vi my_app.rb
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
class MyApp < AppMainBase
|
|
68
|
+
def start(argv)
|
|
69
|
+
super
|
|
70
|
+
# ここにアプリケーションコードを追加
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def stop()
|
|
74
|
+
super
|
|
75
|
+
# ここにアプリケーションコードを追加
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## UIアプリケーションのサンプル
|
|
83
|
+
|
|
84
|
+
index.html
|
|
85
|
+
css/index.css
|
|
86
|
+
js/main.js
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## アプリケーションの起動
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
$ /path/to/test/bin/start_my_app.rb
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+

|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## ブラウザの設定
|
|
101
|
+
|
|
102
|
+
WindowsまたはLinux用にブラウザを設定します。
|
|
103
|
+
|
|
104
|
+
${home}/${app_name}/config/browser.json
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"chrome_win": "start msedge",
|
|
109
|
+
"chrome_win_": "start chrome",
|
|
110
|
+
"chrome_linux": "/bin/google-chrome"
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## ブラウザアプリケーションからRubyアプリケーションへのメッセージ送信
|
|
117
|
+
|
|
118
|
+
`send_message` 関数を使用します。
|
|
119
|
+
|
|
120
|
+
main.jsのサンプル:
|
|
121
|
+
```javascript
|
|
122
|
+
$("#exec").click(function () {
|
|
123
|
+
send_message("exec:" + $("#upFile").val());
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Rubyアプリケーションからブラウザアプリケーションへのメッセージ送信
|
|
130
|
+
|
|
131
|
+
`app_send` 関数を使用します。
|
|
132
|
+
|
|
133
|
+
my_app_sample.rbのサンプル:
|
|
134
|
+
```ruby
|
|
135
|
+
class MyApp < AppMainBase
|
|
136
|
+
def start(argv)
|
|
137
|
+
# ポップアップメッセージ
|
|
138
|
+
app_send("popup:message string")
|
|
139
|
+
|
|
140
|
+
# ログメッセージ
|
|
141
|
+
yield "log message"
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## アプリケーションの設定
|
|
149
|
+
|
|
150
|
+
`setting.json` を変更することで設定を追加できます。
|
|
151
|
+
|
|
152
|
+
${home}/${app_name}/config/setting.json
|
|
153
|
+
|
|
154
|
+
設定例 (`setting.json`):
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"version": 0.1,
|
|
159
|
+
"setting_list": [
|
|
160
|
+
{
|
|
161
|
+
"name": "name1",
|
|
162
|
+
"value": "value1 2 3 4",
|
|
163
|
+
"type": "input",
|
|
164
|
+
"select": "",
|
|
165
|
+
"description": "Setting item 1"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "name2",
|
|
169
|
+
"value": true,
|
|
170
|
+
"type": "checkbox",
|
|
171
|
+
"select": "",
|
|
172
|
+
"description": "Check to enable"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"name": "name3",
|
|
176
|
+
"value": "3",
|
|
177
|
+
"type": "select",
|
|
178
|
+
"select": [
|
|
179
|
+
"1",
|
|
180
|
+
"2",
|
|
181
|
+
"3",
|
|
182
|
+
"4",
|
|
183
|
+
"5"
|
|
184
|
+
],
|
|
185
|
+
"description": "Select item"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"name": "name4",
|
|
189
|
+
"value": "value4",
|
|
190
|
+
"type": "input",
|
|
191
|
+
"select": "",
|
|
192
|
+
"description": "Setting item 4"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"name": "name5",
|
|
196
|
+
"value": "value5",
|
|
197
|
+
"type": "input",
|
|
198
|
+
"select": "",
|
|
199
|
+
"description": "Setting item 5"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"name": "name6",
|
|
203
|
+
"value": "value6",
|
|
204
|
+
"type": "input",
|
|
205
|
+
"select": "",
|
|
206
|
+
"description": "Setting item 6"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"name": "jaon_area",
|
|
210
|
+
"value": {
|
|
211
|
+
"DEBUG": true,
|
|
212
|
+
"VERSION": 1
|
|
213
|
+
},
|
|
214
|
+
"type": "textarea",
|
|
215
|
+
"select": "",
|
|
216
|
+
"description": "JSON string<br>Example:<br>{<br> \"DEBUG\": true,<br> \"VERSION\": 1<br>}"
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Rubyアプリケーションからは以下のように設定にアクセスできます:
|
|
223
|
+
|
|
224
|
+
```ruby
|
|
225
|
+
class MyApp < AppMainBase
|
|
226
|
+
def start(argv)
|
|
227
|
+
# 設定値へのアクセス
|
|
228
|
+
puts @config["name1"]
|
|
229
|
+
# jaon_areaへのハッシュとしてのアクセス
|
|
230
|
+
p @config["jaon_area"] # => {"DEBUG"=>true, "VERSION"=>1}
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### setting.jsonの `jaon_area` について
|
|
238
|
+
|
|
239
|
+
`setting.json` の `jaon_area` 項目を使用すると、設定値としてJSON文字列を入力できます。
|
|
240
|
+
このフィールドのタイプは `"textarea"` であり、追加の設定、フラグ、カスタムパラメータなどの柔軟な構造化データを保存することを目的としています。
|
|
241
|
+
|
|
242
|
+
**例:**
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"DEBUG": true,
|
|
246
|
+
"VERSION": 1
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
- このフィールドは設定画面で直接編集できます。
|
|
251
|
+
- 値は有効なJSON形式である必要があります。
|
|
252
|
+
- アプリケーションは必要に応じてこのデータを解析して使用できます。
|
|
253
|
+
|
|
254
|
+
**使用例:**
|
|
255
|
+
- デバッグモードの切り替え (`"DEBUG": true`)
|
|
256
|
+
- バージョンや環境情報の保存
|
|
257
|
+
- 高度な設定のための任意のキーバリューペアの保存
|
|
258
|
+
|
|
259
|
+
**Rubyアプリケーションでの使用方法:**
|
|
260
|
+
`@config["jaon_area"]` を介してRubyのハッシュとして `jaon_area` の値にアクセスできます。
|
|
261
|
+
例:
|
|
262
|
+
```ruby
|
|
263
|
+
class MyApp < AppMainBase
|
|
264
|
+
def start(argv)
|
|
265
|
+
debug_mode = @config["jaon_area"]["DEBUG"]
|
|
266
|
+
version = @config["jaon_area"]["VERSION"]
|
|
267
|
+
puts "Debug mode: #{debug_mode}, Version: #{version}"
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**注意:**
|
|
273
|
+
必ず有効なJSONを入力してください。フォーマットが正しくない場合、アプリケーションが設定を正しく読み込めない可能性があります。
|
|
274
|
+
|
|
275
|
+
**ヒント:**
|
|
276
|
+
- 実行時にアプリケーションが必要とする任意の構造化データを保存するために `jaon_area` を使用できます。
|
|
277
|
+
- これは機能フラグ、環境固有の設定、または単純な文字列や真偽値に収まらない高度な設定に便利です。
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 設定メニュー
|
|
282
|
+
以下の画像はアプリケーションの設定メニューを示しており、ここから様々な設定オプションにアクセスして変更できます。
|
|
283
|
+

|
|
284
|
+
|
|
285
|
+
設定画面
|
|
286
|
+
この画像は詳細な設定画面を表示しており、個々の設定項目を編集できます。
|
|
287
|
+

|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Dockerテスト環境
|
|
292
|
+
|
|
293
|
+
UbuntuでアプリケーションをテストするためのDockerベースのテスト環境が利用可能です。
|
|
294
|
+
この設定ではX11フォワーディングを使用して、ホストマシン上にブラウザウィンドウを表示します。
|
|
295
|
+
|
|
296
|
+
```shell
|
|
297
|
+
$ cd test/docker/ubuntu
|
|
298
|
+
$ docker-compose up -d
|
|
299
|
+
$ docker exec -it ubuntu bash
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Ubuntu 24.04の場合:
|
|
303
|
+
```shell
|
|
304
|
+
$ docker-compose -f docker-compose-24.04.yml up -d
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
コンテナ内での操作:
|
|
308
|
+
```shell
|
|
309
|
+
$ cd /work
|
|
310
|
+
$ rake
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## テストの実行
|
|
316
|
+
|
|
317
|
+
v0.1.9からRSpecベースのテストがサポートされています。
|
|
318
|
+
依存関係をインストールした後、以下のコマンドでテストを実行できます:
|
|
319
|
+
|
|
320
|
+
```sh
|
|
321
|
+
bundle install
|
|
322
|
+
bundle exec rake
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
または
|
|
326
|
+
|
|
327
|
+
```sh
|
|
328
|
+
RACK_ENV=test bundle exec rspec
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
RSpecタスクは `Rakefile` で定義されているため、`rake` コマンドですべてのテストが自動的に実行されます。
|
|
332
|
+
テストコードは `spec/` ディレクトリの下に配置してください。
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## 開発
|
|
337
|
+
|
|
338
|
+
このgemをローカルマシンにインストールするには、`bundle exec rake install` を実行します。
|
|
339
|
+
新しいバージョンをリリースするには、`version.rb` でバージョン番号を更新し、`bundle exec rake release` を実行します。これによりバージョンのgitタグが作成され、gitコミットと作成されたタグがプッシュされ、`.gem` ファイルが [rubygems.org](https://rubygems.org) にプッシュされます。
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## コントリビューション
|
|
344
|
+
|
|
345
|
+
バグレポートとプルリクエストはGitHubの [https://github.com/kuwayama1971/BrowserAppBase](https://github.com/kuwayama1971/BrowserAppBase) で歓迎します。
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## ライセンス
|
|
350
|
+
|
|
351
|
+
このgemは [MIT License](https://opensource.org/licenses/MIT) の条件の下でオープンソースとして利用可能です。
|
data/bin/create_browser_app.rb
CHANGED
data/bin/ruby-lsp
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env ruby3.2
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'ruby-lsp' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
12
|
+
|
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
|
14
|
+
|
|
15
|
+
if File.file?(bundle_binstub)
|
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
|
17
|
+
load(bundle_binstub)
|
|
18
|
+
else
|
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require "rubygems"
|
|
25
|
+
require "bundler/setup"
|
|
26
|
+
|
|
27
|
+
load Gem.bin_path("ruby-lsp", "ruby-lsp")
|
data/bin/ruby-lsp-check
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env ruby3.2
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'ruby-lsp-check' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
12
|
+
|
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
|
14
|
+
|
|
15
|
+
if File.file?(bundle_binstub)
|
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
|
17
|
+
load(bundle_binstub)
|
|
18
|
+
else
|
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require "rubygems"
|
|
25
|
+
require "bundler/setup"
|
|
26
|
+
|
|
27
|
+
load Gem.bin_path("ruby-lsp", "ruby-lsp-check")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env ruby3.2
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'ruby-lsp-launcher' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
12
|
+
|
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
|
14
|
+
|
|
15
|
+
if File.file?(bundle_binstub)
|
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
|
17
|
+
load(bundle_binstub)
|
|
18
|
+
else
|
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require "rubygems"
|
|
25
|
+
require "bundler/setup"
|
|
26
|
+
|
|
27
|
+
load Gem.bin_path("ruby-lsp", "ruby-lsp-launcher")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env ruby3.2
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'ruby-lsp-test-exec' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
12
|
+
|
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
|
14
|
+
|
|
15
|
+
if File.file?(bundle_binstub)
|
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
|
17
|
+
load(bundle_binstub)
|
|
18
|
+
else
|
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require "rubygems"
|
|
25
|
+
require "bundler/setup"
|
|
26
|
+
|
|
27
|
+
load Gem.bin_path("ruby-lsp", "ruby-lsp-test-exec")
|
data/browser_app_base.gemspec
CHANGED
|
@@ -30,6 +30,8 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
|
|
31
31
|
# Uncomment to register a new dependency of your gem
|
|
32
32
|
# spec.add_dependency "example-gem", "~> 1.0"
|
|
33
|
+
spec.add_dependency "rack", ">= 3.0"
|
|
34
|
+
spec.add_dependency "rackup"
|
|
33
35
|
spec.add_dependency "sinatra"
|
|
34
36
|
spec.add_dependency "sinatra-contrib"
|
|
35
37
|
spec.add_dependency "sinatra-websocket"
|
data/lib/template/config.ru
CHANGED
data/lib/template/js/main.js
CHANGED
|
@@ -430,10 +430,10 @@ function openFile(file) {
|
|
|
430
430
|
$(document).ready(function () {
|
|
431
431
|
|
|
432
432
|
// サーバに接続
|
|
433
|
-
server_connect("ws://localhost:
|
|
433
|
+
server_connect("ws://localhost:36539/wsserver")
|
|
434
434
|
window.onload = function (e) {
|
|
435
435
|
// サーバに接続
|
|
436
|
-
//server_connect("ws://localhost:
|
|
436
|
+
//server_connect("ws://localhost:36539/wsserver")
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
// menu
|
|
@@ -41,7 +41,8 @@ class AppMainBase
|
|
|
41
41
|
|
|
42
42
|
# 履歴の保存
|
|
43
43
|
def add_history(file, history_data, max = 10)
|
|
44
|
-
|
|
44
|
+
home_dir = @config&.key?(:home_dir) ? @config[:home_dir] : ($home_dir || "./")
|
|
45
|
+
history_dir = home_dir + "history/"
|
|
45
46
|
path = File.join(history_dir, file)
|
|
46
47
|
begin
|
|
47
48
|
buf = File.read(path)
|
data/lib/template/start.rb
CHANGED
|
@@ -75,10 +75,7 @@ end
|
|
|
75
75
|
port = get_unused_port
|
|
76
76
|
puts "port=#{port}"
|
|
77
77
|
|
|
78
|
-
# config.ru
|
|
79
|
-
buf = File.binread("config.ru").toutf8
|
|
80
|
-
buf.gsub!(/port [0-9]+/, "port #{port}")
|
|
81
|
-
File.binwrite("config.ru", buf)
|
|
78
|
+
# config.ruの編集は不要(port引数で渡すように変更)
|
|
82
79
|
|
|
83
80
|
# main.jsの編集
|
|
84
81
|
buf = File.binread("js/main.js").toutf8
|
|
@@ -122,7 +119,12 @@ begin
|
|
|
122
119
|
}
|
|
123
120
|
|
|
124
121
|
# start web server
|
|
125
|
-
Rack
|
|
122
|
+
if Rack.release >= "3"
|
|
123
|
+
require "rackup"
|
|
124
|
+
Rackup::Server.start(:Port => port, :config => "config.ru", :server => "thin")
|
|
125
|
+
else
|
|
126
|
+
Rack::Server.start(:Port => port, :config => "config.ru", :server => "thin")
|
|
127
|
+
end
|
|
126
128
|
rescue
|
|
127
129
|
puts $!
|
|
128
130
|
puts $@
|
metadata
CHANGED
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: browser_app_base
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- masataka kuwayama
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rack
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '3.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '3.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rackup
|
|
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'
|
|
13
41
|
- !ruby/object:Gem::Dependency
|
|
14
42
|
name: sinatra
|
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,6 +113,10 @@ email:
|
|
|
85
113
|
- masataka.kuwayama@gmail.com
|
|
86
114
|
executables:
|
|
87
115
|
- create_browser_app.rb
|
|
116
|
+
- ruby-lsp
|
|
117
|
+
- ruby-lsp-check
|
|
118
|
+
- ruby-lsp-launcher
|
|
119
|
+
- ruby-lsp-test-exec
|
|
88
120
|
- start_sample.rb
|
|
89
121
|
extensions: []
|
|
90
122
|
extra_rdoc_files: []
|
|
@@ -95,8 +127,13 @@ files:
|
|
|
95
127
|
- Gemfile
|
|
96
128
|
- LICENSE.txt
|
|
97
129
|
- README.md
|
|
130
|
+
- README_ja.md
|
|
98
131
|
- Rakefile
|
|
99
132
|
- bin/create_browser_app.rb
|
|
133
|
+
- bin/ruby-lsp
|
|
134
|
+
- bin/ruby-lsp-check
|
|
135
|
+
- bin/ruby-lsp-launcher
|
|
136
|
+
- bin/ruby-lsp-test-exec
|
|
100
137
|
- bin/start_sample.rb
|
|
101
138
|
- browser_app_base.gemspec
|
|
102
139
|
- img/app.png
|