browser_app_base 0.1.7 → 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: d99935b3e8a652b13309546171cbdd48bcc40fe46f7c8fbff390915bf4976a18
4
- data.tar.gz: 984d50bd717125964f7acabede3c85ae4575a22c038be730c01726b846074ea1
3
+ metadata.gz: 54f5d83ea13920bcfc80e7ecd82c099c5749847535fb593de2f36ff942027555
4
+ data.tar.gz: 0a692e22ea4182825b0e6dd35c9c483c8e8d41ebbf9387155fcd4b53900b1f29
5
5
  SHA512:
6
- metadata.gz: 7df328e13a5a604583e773390c6f5e3932fc458a25aa23aa22fa7462faa84d8b08b6c3061191d0d744b839c977d236a4d005a2f5ba09469c0dea7848ed51e037
7
- data.tar.gz: 53bebadb08ca3550c22f23862c94a93f9d2b55bc6264adf23e871452e49e32a2f60cbd1c99a7f9da0a0f571ac001ca35022ca2f756679041fe23c77dd9c78442
6
+ metadata.gz: d2be55260153ca5ea4ff173c72c5a368c5fc020ad426247bb4bdb6d40e875b1a83b56c2d61234a671ed4e650ea79e48bd5bfa0aa3038ba0681405e435d66d721
7
+ data.tar.gz: 06ba92962030bef3b58a5fb44ea8aa1c6596741fe82a12d40cbcf8bd1d040ddeeaf6e717046714ab76ae7623954b118edaa127ae6cbe0e9a8999770eb0a66db5
data/README.md CHANGED
@@ -2,7 +2,21 @@
2
2
 
3
3
  Windows and Linux browser-based desktop application templates.
4
4
 
5
- You need a Chrome browser to run it.
5
+ On Linux, the Chrome browser is used by default.
6
+ On Windows, the Edge browser is used by default.
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
+ ---
6
20
 
7
21
  ## Installation
8
22
 
@@ -20,6 +34,8 @@ Or install it yourself as:
20
34
 
21
35
  $ gem install browser_app_base
22
36
 
37
+ ---
38
+
23
39
  ## Usage
24
40
 
25
41
  create_browser_app [options]
@@ -27,72 +43,87 @@ Or install it yourself as:
27
43
  -a, --app app_name application name
28
44
  -h, --help command help
29
45
 
46
+ ---
47
+
48
+ ## Create app template
30
49
 
31
- ## Create app templat
50
+ $ create_browser_app -d /path/to/test/ -a MyApp
32
51
 
33
- $ create_browser_app -d ~/test/ -a MyApp
52
+ ---
34
53
 
35
- ## add application code
36
- $ cd ~/test/
54
+ ## Add application code
55
+
56
+ $ cd /path/to/test/
37
57
  $ vi my_app.rb
38
58
 
39
59
  ```ruby
40
- class MyApp < AppMainBase
41
- def start(argv)
42
- super
43
- # add application code
44
- end
45
-
46
- def stop()
47
- super
48
- # add application code
49
- end
50
- 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
51
71
  ```
52
72
 
53
- ui application sample
73
+ ---
74
+
75
+ ## UI application sample
54
76
 
55
77
  index.html
56
78
  css/index.css
57
79
  js/main.js
58
80
 
81
+ ---
82
+
59
83
  ## Start application
60
84
 
61
85
  ```shell
62
- $ /tmp/test/bin/start_my_app.rb
86
+ $ /path/to/test/bin/start_my_app.rb
63
87
  ```
64
88
 
65
89
  ![app](img/app.png)
66
90
 
67
- ## browser setting
91
+ ---
68
92
 
69
- ${home}/${app_nane}/config/browser.json
70
- Set the path for your Windows or Linux Chrome browser
93
+ ## Browser setting
94
+
95
+ Configure your browser for Windows or Linux.
96
+
97
+ ${home}/${app_name}/config/browser.json
71
98
 
72
99
  ```json
73
100
  {
74
- "chrome_win": "start chrome",
101
+ "chrome_win": "start msedge",
102
+ "chrome_win_": "start chrome",
75
103
  "chrome_linux": "/bin/google-chrome"
76
104
  }
77
105
  ```
78
106
 
79
- ## Send a message from your browser application to your ruby application
107
+ ---
80
108
 
81
- Use the send_message function
109
+ ## Send a message from your browser application to your Ruby application
82
110
 
83
- main.js sample
111
+ Use the `send_message` function.
112
+
113
+ main.js sample:
84
114
  ```javascript
85
115
  $("#exec").click(function () {
86
116
  send_message("exec:" + $("#upFile").val());
87
117
  });
88
-
89
118
  ```
90
119
 
91
- ## Send a message from the ruby application to the browser application
120
+ ---
92
121
 
93
- Use the app_send function
122
+ ## Send a message from the Ruby application to the browser application
94
123
 
95
- my_app_sample.rb sample
124
+ Use the `app_send` function.
125
+
126
+ my_app_sample.rb sample:
96
127
  ```ruby
97
128
  class MyApp < AppMainBase
98
129
  def start(argv)
@@ -101,14 +132,19 @@ class MyApp < AppMainBase
101
132
 
102
133
  # log message
103
134
  yield "log message"
104
- end
135
+ end
105
136
  end
106
137
  ```
107
138
 
108
- ## Application Setting
139
+ ---
140
+
141
+ ## Application Setting
109
142
 
110
- ${home}/${app_nane}/config/setting.json
143
+ You can add settings by modifying `setting.json`.
111
144
 
145
+ ${home}/${app_name}/config/setting.json
146
+
147
+ Example (`setting.json`):
112
148
 
113
149
  ```json
114
150
  {
@@ -119,14 +155,14 @@ end
119
155
  "value": "value1 2 3 4",
120
156
  "type": "input",
121
157
  "select": "",
122
- "description": "設定項目1"
158
+ "description": "Setting item 1"
123
159
  },
124
160
  {
125
161
  "name": "name2",
126
162
  "value": true,
127
163
  "type": "checkbox",
128
164
  "select": "",
129
- "description": "有効にする場合はチェック"
165
+ "description": "Check to enable"
130
166
  },
131
167
  {
132
168
  "name": "name3",
@@ -139,61 +175,146 @@ end
139
175
  "4",
140
176
  "5"
141
177
  ],
142
- "description": "選択項目"
178
+ "description": "Select item"
143
179
  },
144
180
  {
145
181
  "name": "name4",
146
182
  "value": "value4",
147
183
  "type": "input",
148
184
  "select": "",
149
- "description": "設定項目4"
185
+ "description": "Setting item 4"
150
186
  },
151
187
  {
152
188
  "name": "name5",
153
189
  "value": "value5",
154
190
  "type": "input",
155
191
  "select": "",
156
- "description": "設定項目5"
192
+ "description": "Setting item 5"
157
193
  },
158
194
  {
159
195
  "name": "name6",
160
196
  "value": "value6",
161
197
  "type": "input",
162
198
  "select": "",
163
- "description": "設定項目6"
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>}"
164
210
  }
165
211
  ]
166
- }```
212
+ }
213
+ ```
214
+
215
+ You can access the settings from your Ruby application like this:
216
+
167
217
  ```ruby
168
218
  class MyApp < AppMainBase
169
219
  def start(argv)
170
- # popup message
171
- 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
+ ```
172
227
 
173
- # log message
174
- yield "log message"
175
- end
228
+ ---
176
229
 
177
- # read setting
178
- 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
179
262
  end
180
263
  ```
181
264
 
182
- Setting menu
183
- ![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.
184
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.
185
271
 
186
- Setting screen
272
+ ---
273
+
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.
187
280
  ![app](img/setting.png)
188
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
+
189
305
  ## Development
190
306
 
191
- 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
+ ---
192
311
 
193
312
  ## Contributing
194
313
 
195
- 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
+ ---
196
317
 
197
318
  ## License
198
319
 
199
- 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/bin/start_sample.rb CHANGED
@@ -17,7 +17,7 @@ Dir.mktmpdir { |tmpdir|
17
17
  Dir.glob("#{dir}/lib/*") do |f|
18
18
  if f =~ /config$/
19
19
  # configはhomeにコピー
20
- if !File.exists? "#{home_dir}/config"
20
+ if !File.exist? "#{home_dir}/config"
21
21
  puts "#{f} => #{home_dir}/"
22
22
  FileUtils.cp_r f, "#{home_dir}/"
23
23
  end
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.7"
4
+ VERSION = "0.1.9"
5
5
  end
@@ -1,4 +1,6 @@
1
1
  {
2
- "chrome_win": "start chrome",
3
- "chrome_linux": "google-chrome"
4
- }
2
+ "chrome_win": "start msedge",
3
+ "chrome_win_": "start chrome",
4
+ "chrome_linux_": "google-chrome",
5
+ "chrome_linux": "chromium-browser"
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