sscharter 0.8.0 → 0.9.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 +4 -4
- data/Gemfile.lock +10 -8
- data/lib/sscharter/chart.rb +1 -1
- data/lib/sscharter/cli.rb +40 -14
- data/lib/sscharter/version.rb +1 -1
- metadata +20 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd7619bb9674b4ec547ba0484ff931c1f39603ffa03fc0a32e826ef4e83adb46
|
4
|
+
data.tar.gz: 668322b1a02019b1ebfad49332cea047c8cd91f5f2de62be88a68dc64460a88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec041e5ebef20b6e9794a91b842ef7446305732564bdf6e8afd25e4d5a2281d9b6cbb37787a11cee7ce29d2a581aa31bbdf513bdb9f0661f5498e4b412ea26f9
|
7
|
+
data.tar.gz: 9e10bf1ef26b57f7cade038f5cc5cf290aa14b72050c6c3136f96a0c0511dff2ce43300a0b81fb66c0d75deda496ba1da4a13a174ff53f36b2ffb6cbc4f883ad
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sscharter (0.
|
4
|
+
sscharter (0.9.0)
|
5
|
+
base64
|
5
6
|
concurrent-ruby (~> 1.3)
|
6
7
|
em-websocket (~> 0.5)
|
7
8
|
filewatcher (~> 2.0)
|
8
9
|
launchy (~> 2.5)
|
9
|
-
rubyzip (~>
|
10
|
+
rubyzip (~> 3.1)
|
10
11
|
webrick (~> 1.8)
|
11
12
|
|
12
13
|
GEM
|
@@ -14,7 +15,8 @@ GEM
|
|
14
15
|
specs:
|
15
16
|
addressable (2.8.7)
|
16
17
|
public_suffix (>= 2.0.2, < 7.0)
|
17
|
-
|
18
|
+
base64 (0.3.0)
|
19
|
+
concurrent-ruby (1.3.5)
|
18
20
|
em-websocket (0.5.3)
|
19
21
|
eventmachine (>= 0.12.9)
|
20
22
|
http_parser.rb (~> 0)
|
@@ -24,11 +26,11 @@ GEM
|
|
24
26
|
http_parser.rb (0.8.0)
|
25
27
|
launchy (2.5.2)
|
26
28
|
addressable (~> 2.8)
|
27
|
-
minitest (5.25.
|
29
|
+
minitest (5.25.5)
|
28
30
|
module_methods (0.1.0)
|
29
|
-
public_suffix (6.0.
|
30
|
-
rake (13.
|
31
|
-
rubyzip (
|
31
|
+
public_suffix (6.0.2)
|
32
|
+
rake (13.3.0)
|
33
|
+
rubyzip (3.1.0)
|
32
34
|
webrick (1.9.1)
|
33
35
|
yard (0.9.37)
|
34
36
|
|
@@ -43,4 +45,4 @@ DEPENDENCIES
|
|
43
45
|
yard (~> 0.9)
|
44
46
|
|
45
47
|
BUNDLED WITH
|
46
|
-
2.
|
48
|
+
2.7.1
|
data/lib/sscharter/chart.rb
CHANGED
data/lib/sscharter/cli.rb
CHANGED
@@ -157,7 +157,7 @@ Sunniesnow::Charter::CLI::Subcommand.new :init, option_parser do |project_dir =
|
|
157
157
|
puts "Project initialized at #{project_dir}"
|
158
158
|
end
|
159
159
|
|
160
|
-
def build **opts
|
160
|
+
def build compression_level: Zip.default_compression, **opts, &block
|
161
161
|
return 1 unless config = Sunniesnow::Charter::CLI.config
|
162
162
|
dir = Sunniesnow::Charter::PROJECT_DIR
|
163
163
|
project_name = config[:project_name] || File.basename(dir)
|
@@ -166,17 +166,21 @@ def build **opts
|
|
166
166
|
sources_dir = File.join dir, config[:sources_dir] || 'src'
|
167
167
|
include_files = (config[:include] || []).map { File.join dir, _1 }
|
168
168
|
Sunniesnow::Charter.charts.clear
|
169
|
+
time = Time.now
|
169
170
|
Dir.glob File.join sources_dir, '*.rb' do |filename|
|
170
171
|
load filename
|
171
172
|
rescue Exception => e
|
172
173
|
puts "Error loading #{filename}:"
|
173
174
|
puts e.full_message
|
175
|
+
puts "Build aborted (took #{Time.now - time} seconds)"
|
174
176
|
return 1
|
175
177
|
end
|
178
|
+
puts "Built #{Sunniesnow::Charter.charts.size} chart(s) (took #{Time.now - time} seconds)"
|
179
|
+
time = Time.now
|
176
180
|
FileUtils.mkdir_p build_dir
|
177
181
|
build_filename = File.join build_dir, "#{project_name}.ssc"
|
178
182
|
FileUtils.rm build_filename if File.exist? build_filename
|
179
|
-
Zip::File.open build_filename, create: true do |zip_file|
|
183
|
+
Zip::File.open build_filename, compression_level:, create: true do |zip_file|
|
180
184
|
Dir.glob File.join files_dir, '**', '*' do |filename|
|
181
185
|
zip_file.add filename["#{files_dir}/".length..], filename
|
182
186
|
end
|
@@ -187,25 +191,33 @@ def build **opts
|
|
187
191
|
end
|
188
192
|
Sunniesnow::Charter.charts.each do |name, chart|
|
189
193
|
begin
|
190
|
-
|
194
|
+
sunniesnow_chart = chart.to_sunniesnow **opts
|
191
195
|
rescue => e
|
192
196
|
puts 'An error happened. Report if this is a bug of sscharter.'
|
193
197
|
puts e.full_message
|
194
198
|
return 2
|
195
199
|
end
|
200
|
+
block.(name, sunniesnow_chart) if block
|
196
201
|
zip_file.get_output_stream "#{name}.json" do |file|
|
197
|
-
file.write
|
202
|
+
file.write sunniesnow_chart.to_json
|
203
|
+
rescue => e
|
204
|
+
puts 'An error happened. Report if this is a bug of sscharter.'
|
205
|
+
puts e.full_message
|
206
|
+
return 2
|
198
207
|
end
|
199
208
|
end
|
209
|
+
zip_file.each { _1.time = Time.at 0 }
|
200
210
|
end
|
211
|
+
puts "Created #{project_name}.ssc (took #{Time.now - time} seconds)"
|
201
212
|
0
|
202
213
|
end
|
203
214
|
|
204
215
|
option_parser = OptionParser.new do |o|
|
205
216
|
o.banner = 'Usage: sscharter build'
|
217
|
+
o.on '--compression-level=LEVEL', Integer, 'Compression level (0-9)'
|
206
218
|
end
|
207
|
-
Sunniesnow::Charter::CLI::Subcommand.new :build, option_parser do
|
208
|
-
build production: true
|
219
|
+
Sunniesnow::Charter::CLI::Subcommand.new :build, option_parser do |compression_level: Zip.default_compression|
|
220
|
+
build compression_level:, production: true
|
209
221
|
end
|
210
222
|
|
211
223
|
option_parser = OptionParser.new do |o|
|
@@ -216,8 +228,17 @@ option_parser = OptionParser.new do |o|
|
|
216
228
|
o.on '--live-reload-port=PORT', Integer, 'live reload port number'
|
217
229
|
o.on '--[no-]production', 'Disable live reload'
|
218
230
|
o.on '--[no-]open-browser', 'Open browser'
|
231
|
+
o.on '--compression-level=LEVEL', Integer, 'Compression level (0-9)'
|
219
232
|
end
|
220
|
-
Sunniesnow::Charter::CLI::Subcommand.new :serve, option_parser do
|
233
|
+
Sunniesnow::Charter::CLI::Subcommand.new :serve, option_parser do |\
|
234
|
+
host: '0.0.0.0',
|
235
|
+
exposed_host: 'localhost',
|
236
|
+
port: 8011,
|
237
|
+
live_reload_port: 31108,
|
238
|
+
production: false,
|
239
|
+
open_browser: true,
|
240
|
+
compression_level: (production ? Zip.default_compression : 0)
|
241
|
+
|
|
221
242
|
return 1 unless config = Sunniesnow::Charter::CLI.config
|
222
243
|
dir = Sunniesnow::Charter::PROJECT_DIR
|
223
244
|
project_name = config[:project_name] || File.basename(dir)
|
@@ -263,18 +284,23 @@ Sunniesnow::Charter::CLI::Subcommand.new :serve, option_parser do |host: '0.0.0.
|
|
263
284
|
end
|
264
285
|
end
|
265
286
|
end
|
266
|
-
|
287
|
+
base_url = "http://#{exposed_host}:#{port}"
|
288
|
+
url = URI.join base_url, "#{project_name}.ssc"
|
267
289
|
filewatcher = Filewatcher.new [files_dir, sources_dir, *include_files]
|
268
290
|
Launchy.open "https://sunniesnow.github.io/game/?level-file=online&level-file-online=#{CGI.escape url}" if open_browser
|
269
|
-
build_proc = ->is_first do
|
291
|
+
build_proc = ->is_first, only_charts do
|
270
292
|
puts is_first ? 'Building...' : 'Rebuilding...'
|
271
|
-
|
272
|
-
|
273
|
-
|
293
|
+
build_result = build(live_reload_port:, production:, compression_level:) do |name, chart|
|
294
|
+
live_reload_clients.each { _1.send JSON.generate type: 'chartUpdate', name:, chart: } unless production
|
295
|
+
end
|
296
|
+
puts build_result == 0 ? is_first ? "Finished; access at #{url}" : 'Finished' : 'Failed'
|
297
|
+
live_reload_clients.each { _1.send JSON.generate type: 'update', onlyCharts: only_charts } unless production
|
274
298
|
end
|
275
299
|
filewatcher_thread = Thread.new do
|
276
|
-
build_proc.(true)
|
277
|
-
filewatcher.watch
|
300
|
+
build_proc.(true, false)
|
301
|
+
filewatcher.watch do |changes|
|
302
|
+
build_proc.(false, changes.all? { |filename, event| filename.start_with? sources_dir + '/' })
|
303
|
+
end
|
278
304
|
server.shutdown
|
279
305
|
EM.stop unless production
|
280
306
|
end
|
data/lib/sscharter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sscharter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ulysses Zhan
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rubyzip
|
@@ -16,14 +15,14 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '3.1'
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
25
|
+
version: '3.1'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: launchy
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +93,20 @@ dependencies:
|
|
94
93
|
- - "~>"
|
95
94
|
- !ruby/object:Gem::Version
|
96
95
|
version: '1.3'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: base64
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: minitest
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +149,6 @@ dependencies:
|
|
136
149
|
- - "~>"
|
137
150
|
- !ruby/object:Gem::Version
|
138
151
|
version: '0.9'
|
139
|
-
description:
|
140
152
|
email:
|
141
153
|
- ulysseszhan@gmail.com
|
142
154
|
executables:
|
@@ -162,7 +174,7 @@ licenses: []
|
|
162
174
|
metadata:
|
163
175
|
homepage_uri: https://github.com/sunniesnow/sscharter
|
164
176
|
source_code_uri: https://github.com/sunniesnow/sscharter
|
165
|
-
|
177
|
+
changelog_uri: https://github.com/sunniesnow/sscharter/releases
|
166
178
|
rdoc_options: []
|
167
179
|
require_paths:
|
168
180
|
- lib
|
@@ -177,8 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
189
|
- !ruby/object:Gem::Version
|
178
190
|
version: '0'
|
179
191
|
requirements: []
|
180
|
-
rubygems_version: 3.
|
181
|
-
signing_key:
|
192
|
+
rubygems_version: 3.6.9
|
182
193
|
specification_version: 4
|
183
194
|
summary: A Ruby DSL for writing Sunniesnow charts
|
184
195
|
test_files: []
|