browser_app_base 0.1.8 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb0eb570025887ea6e618a27467df3ca7f8bea72481786a1b6bc41fe7b3b5a86
4
- data.tar.gz: 70c09c0eda44c4d8d0dbfe3ea26f907cc06c609415fafd5ab6dc35661a7b8176
3
+ metadata.gz: 54f5d83ea13920bcfc80e7ecd82c099c5749847535fb593de2f36ff942027555
4
+ data.tar.gz: 0a692e22ea4182825b0e6dd35c9c483c8e8d41ebbf9387155fcd4b53900b1f29
5
5
  SHA512:
6
- metadata.gz: 5114a8aecabd7b9434635a0d4368bdcf40f8fc1da03f4171a089a69f5158b0ea04ec4348269eef6096ef66b4cc44a611828278c781b32972f7146f5d1e8b38f5
7
- data.tar.gz: 5aeadef51294e212916da7141fe05df0a942c3c0626706e7d08c57cf27de4c88685f08ab2534b15b71cdf2ada3a2a084b79eb1814be7b15e77e38b1c0b52dea8
6
+ metadata.gz: d2be55260153ca5ea4ff173c72c5a368c5fc020ad426247bb4bdb6d40e875b1a83b56c2d61234a671ed4e650ea79e48bd5bfa0aa3038ba0681405e435d66d721
7
+ data.tar.gz: 06ba92962030bef3b58a5fb44ea8aa1c6596741fe82a12d40cbcf8bd1d040ddeeaf6e717046714ab76ae7623954b118edaa127ae6cbe0e9a8999770eb0a66db5
data/README.md CHANGED
@@ -2,9 +2,22 @@
2
2
 
3
3
  Windows and Linux browser-based desktop application templates.
4
4
 
5
- On Linux, the Chrome browser is used by default.
5
+ On Linux, the Chrome browser is used by default.
6
6
  On Windows, the Edge browser is used by default.
7
7
 
8
+ ---
9
+
10
+ ## Features
11
+
12
+ - Cross-platform browser-based desktop app template (Windows/Linux)
13
+ - Simple app generation command (`create_browser_app`)
14
+ - Flexible application settings via `setting.json`
15
+ - Communication between browser UI and Ruby backend
16
+ - RSpec-based test framework (from v0.1.9)
17
+ - Easy browser configuration for each OS
18
+
19
+ ---
20
+
8
21
  ## Installation
9
22
 
10
23
  Add this line to your application's Gemfile:
@@ -21,6 +34,8 @@ Or install it yourself as:
21
34
 
22
35
  $ gem install browser_app_base
23
36
 
37
+ ---
38
+
24
39
  ## Usage
25
40
 
26
41
  create_browser_app [options]
@@ -28,35 +43,43 @@ Or install it yourself as:
28
43
  -a, --app app_name application name
29
44
  -h, --help command help
30
45
 
46
+ ---
31
47
 
32
- ## Create app templat
48
+ ## Create app template
33
49
 
34
50
  $ create_browser_app -d /path/to/test/ -a MyApp
35
51
 
36
- ## add application code
52
+ ---
53
+
54
+ ## Add application code
55
+
37
56
  $ cd /path/to/test/
38
57
  $ vi my_app.rb
39
58
 
40
59
  ```ruby
41
- class MyApp < AppMainBase
42
- def start(argv)
43
- super
44
- # add application code
45
- end
46
-
47
- def stop()
48
- super
49
- # add application code
50
- end
51
- end
60
+ class MyApp < AppMainBase
61
+ def start(argv)
62
+ super
63
+ # add application code
64
+ end
65
+
66
+ def stop()
67
+ super
68
+ # add application code
69
+ end
70
+ end
52
71
  ```
53
72
 
54
- ui application sample
73
+ ---
74
+
75
+ ## UI application sample
55
76
 
56
77
  index.html
57
78
  css/index.css
58
79
  js/main.js
59
80
 
81
+ ---
82
+
60
83
  ## Start application
61
84
 
62
85
  ```shell
@@ -65,10 +88,13 @@ $ /path/to/test/bin/start_my_app.rb
65
88
 
66
89
  ![app](img/app.png)
67
90
 
68
- ## browser setting
91
+ ---
92
+
93
+ ## Browser setting
94
+
69
95
  Configure your browser for Windows or Linux.
70
96
 
71
- ${home}/${app_nane}/config/browser.json
97
+ ${home}/${app_name}/config/browser.json
72
98
 
73
99
  ```json
74
100
  {
@@ -78,23 +104,26 @@ Configure your browser for Windows or Linux.
78
104
  }
79
105
  ```
80
106
 
81
- ## Send a message from your browser application to your ruby application
107
+ ---
108
+
109
+ ## Send a message from your browser application to your Ruby application
82
110
 
83
- Use the send_message function.
111
+ Use the `send_message` function.
84
112
 
85
- main.js sample
113
+ main.js sample:
86
114
  ```javascript
87
115
  $("#exec").click(function () {
88
116
  send_message("exec:" + $("#upFile").val());
89
117
  });
90
-
91
118
  ```
92
119
 
93
- ## Send a message from the ruby application to the browser application
120
+ ---
121
+
122
+ ## Send a message from the Ruby application to the browser application
94
123
 
95
- Use the app_send function.
124
+ Use the `app_send` function.
96
125
 
97
- my_app_sample.rb sample
126
+ my_app_sample.rb sample:
98
127
  ```ruby
99
128
  class MyApp < AppMainBase
100
129
  def start(argv)
@@ -103,100 +132,189 @@ class MyApp < AppMainBase
103
132
 
104
133
  # log message
105
134
  yield "log message"
106
- end
135
+ end
107
136
  end
108
137
  ```
109
138
 
110
- ## Application Setting
111
- You can add settings by modifying setting.json.
139
+ ---
140
+
141
+ ## Application Setting
142
+
143
+ You can add settings by modifying `setting.json`.
112
144
 
113
- ${home}/${app_nane}/config/setting.json
145
+ ${home}/${app_name}/config/setting.json
114
146
 
147
+ Example (`setting.json`):
115
148
 
116
149
  ```json
117
- [
118
- {
119
- "name": "name1",
120
- "value": "value1 2 3 4",
121
- "type": "input",
122
- "select": "",
123
- "description": "設定項目1"
124
- },
125
- {
126
- "name": "name2",
127
- "value": true,
128
- "type": "checkbox",
129
- "select": "",
130
- "description": "有効にする場合はチェック"
131
- },
132
- {
133
- "name": "name3",
134
- "value": "2",
135
- "type": "select",
136
- "select": [
137
- "1",
138
- "2",
139
- "3",
140
- "4",
141
- "5"
142
- ],
143
- "description": "選択項目"
144
- },
145
- {
146
- "name": "name4",
147
- "value": "value4",
148
- "type": "input",
149
- "select": "",
150
- "description": "設定項目4"
151
- },
152
- {
153
- "name": "name5",
154
- "value": "value5",
155
- "type": "input",
156
- "select": "",
157
- "description": "設定項目5"
158
- },
159
- {
160
- "name": "name6",
161
- "value": "value6",
162
- "type": "input",
163
- "select": "",
164
- "description": "設定項目6"
165
- }
166
- ]
150
+ {
151
+ "version": 0.1,
152
+ "setting_list": [
153
+ {
154
+ "name": "name1",
155
+ "value": "value1 2 3 4",
156
+ "type": "input",
157
+ "select": "",
158
+ "description": "Setting item 1"
159
+ },
160
+ {
161
+ "name": "name2",
162
+ "value": true,
163
+ "type": "checkbox",
164
+ "select": "",
165
+ "description": "Check to enable"
166
+ },
167
+ {
168
+ "name": "name3",
169
+ "value": "3",
170
+ "type": "select",
171
+ "select": [
172
+ "1",
173
+ "2",
174
+ "3",
175
+ "4",
176
+ "5"
177
+ ],
178
+ "description": "Select item"
179
+ },
180
+ {
181
+ "name": "name4",
182
+ "value": "value4",
183
+ "type": "input",
184
+ "select": "",
185
+ "description": "Setting item 4"
186
+ },
187
+ {
188
+ "name": "name5",
189
+ "value": "value5",
190
+ "type": "input",
191
+ "select": "",
192
+ "description": "Setting item 5"
193
+ },
194
+ {
195
+ "name": "name6",
196
+ "value": "value6",
197
+ "type": "input",
198
+ "select": "",
199
+ "description": "Setting item 6"
200
+ },
201
+ {
202
+ "name": "jaon_area",
203
+ "value": {
204
+ "DEBUG": true,
205
+ "VERSION": 1
206
+ },
207
+ "type": "textarea",
208
+ "select": "",
209
+ "description": "JSON string<br>Example:<br>{<br> \"DEBUG\": true,<br> \"VERSION\": 1<br>}"
210
+ }
211
+ ]
212
+ }
167
213
  ```
168
- You can access the settings from your Ruby application like this:
214
+
215
+ You can access the settings from your Ruby application like this:
169
216
 
170
217
  ```ruby
171
218
  class MyApp < AppMainBase
172
219
  def start(argv)
173
- # popup message
174
- app_send("popup:message string")
220
+ # Access a setting value
221
+ puts @config["name1"]
222
+ # Access jaon_area as a hash
223
+ p @config["jaon_area"] # => {"DEBUG"=>true, "VERSION"=>1}
224
+ end
225
+ end
226
+ ```
175
227
 
176
- # log message
177
- yield "log message"
178
- end
228
+ ---
179
229
 
180
- # read setting
181
- puts @config["name1"]
230
+ ### About `jaon_area` in setting.json
231
+
232
+ The `jaon_area` item in `setting.json` allows you to input a JSON string as a setting value.
233
+ This field is of type `"textarea"` and is intended for storing flexible, structured data such as additional configuration, flags, or custom parameters.
234
+
235
+ **Example:**
236
+ ```json
237
+ {
238
+ "DEBUG": true,
239
+ "VERSION": 1
240
+ }
241
+ ```
242
+
243
+ - You can edit this field directly in the settings screen.
244
+ - The value must be valid JSON format.
245
+ - The application can parse and use this data as needed.
246
+
247
+ **Use cases:**
248
+ - Toggle debug mode (`"DEBUG": true`)
249
+ - Store version or environment information
250
+ - Save arbitrary key-value pairs for advanced configuration
251
+
252
+ **How to use in your Ruby application:**
253
+ You can access the `jaon_area` value as a Ruby hash via `@config["jaon_area"]`.
254
+ For example:
255
+ ```ruby
256
+ class MyApp < AppMainBase
257
+ def start(argv)
258
+ debug_mode = @config["jaon_area"]["DEBUG"]
259
+ version = @config["jaon_area"]["VERSION"]
260
+ puts "Debug mode: #{debug_mode}, Version: #{version}"
261
+ end
182
262
  end
183
263
  ```
184
264
 
185
- Setting menu
186
- ![app](img/setting_menu.png)
265
+ **Note:**
266
+ Be sure to enter valid JSON. If the format is incorrect, the application may not be able to read the settings properly.
267
+
268
+ **Tips:**
269
+ - You can use `jaon_area` to store any structured data your application needs at runtime.
270
+ - This is useful for feature flags, environment-specific settings, or any advanced configuration that doesn't fit into a simple string or boolean value.
187
271
 
272
+ ---
188
273
 
189
- Setting screen
274
+ ## Setting menu
275
+ The following image shows the application's setting menu, where you can access and modify various configuration options.
276
+ ![app](img/setting_menu.png)
277
+
278
+ Setting screen
279
+ This image displays the detailed setting screen, allowing you to edit individual configuration items.
190
280
  ![app](img/setting.png)
191
281
 
282
+ ---
283
+
284
+ ## Running Tests
285
+
286
+ From v0.1.9, RSpec-based testing is supported.
287
+ After installing dependencies, you can run tests with:
288
+
289
+ ```sh
290
+ bundle install
291
+ bundle exec rake
292
+ ```
293
+
294
+ or
295
+
296
+ ```sh
297
+ bundle exec rspec
298
+ ```
299
+
300
+ RSpec tasks are defined in the `Rakefile`, so `rake` will automatically run all tests.
301
+ Place your test code under the `spec/` directory.
302
+
303
+ ---
304
+
192
305
  ## Development
193
306
 
194
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
307
+ To install this gem onto your local machine, run `bundle exec rake install`.
308
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
309
+
310
+ ---
195
311
 
196
312
  ## Contributing
197
313
 
198
- Bug reports and pull requests are welcome on GitHub at https://github.com/kuwayama1971/BrowserAppBase.
314
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/kuwayama1971/BrowserAppBase](https://github.com/kuwayama1971/BrowserAppBase).
315
+
316
+ ---
199
317
 
200
318
  ## License
201
319
 
202
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
320
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/img/app.png CHANGED
Binary file
data/img/setting.png CHANGED
Binary file
data/img/setting_menu.png CHANGED
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrowserAppBase
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.9"
5
5
  end
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "chrome_win": "start msedge",
3
3
  "chrome_win_": "start chrome",
4
- "chrome_linux": "google-chrome"
4
+ "chrome_linux_": "google-chrome",
5
+ "chrome_linux": "chromium-browser"
5
6
  }
@@ -48,6 +48,16 @@
48
48
  "type": "input",
49
49
  "select": "",
50
50
  "description": "設定項目6"
51
+ },
52
+ {
53
+ "name": "jaon_area",
54
+ "value": {
55
+ "DEBUG": true,
56
+ "VERSION": 1
57
+ },
58
+ "type": "textarea",
59
+ "select": "",
60
+ "description": "Json文字列<br>例:<br>{<br> \"DEBUG\":true <br> \"VERSION\":1<br>}"
51
61
  }
52
62
  ]
53
- }
63
+ }
@@ -102,6 +102,6 @@ configure do
102
102
 
103
103
  end
104
104
 
105
- #\ --port 35983
105
+ #\ --port 34921
106
106
 
107
107
  run Sinatra::Application