synvert 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/synvert/cli.rb +21 -32
- data/lib/synvert/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fca31952aad5373170fb41622c3dc07c11aa605ae8d13fb8770229062f9543b8
|
4
|
+
data.tar.gz: b57362eedac41f759e397dd10cfb0641690844161ae36e26c5cfd4fbd926d70a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7e6e5fe021673fd412a984595258134633d2b5d4612e6e9633568865b3e676d662b597024ab3d7cfcc2d285a8586736a0ca76db33d61c401fe62d7677c48b7c
|
7
|
+
data.tar.gz: 60f4d25764698275cb360ef222e07e3794e4bf33f0cde79fb73c87982f43df8516330b3552a3e6d331d77d773e3777ff62854c6c376054557ac2356717391b78
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/synvert/cli.rb
CHANGED
@@ -47,12 +47,12 @@ module Synvert
|
|
47
47
|
execute_snippet(@options[:execute_command])
|
48
48
|
when 'test'
|
49
49
|
read_rewriters
|
50
|
-
|
51
|
-
test_snippet(
|
50
|
+
rewriter = eval_snippet(@options[:snippet_name])
|
51
|
+
test_snippet(rewriter)
|
52
52
|
when 'run'
|
53
53
|
read_rewriters
|
54
|
-
|
55
|
-
run_snippet(
|
54
|
+
rewriter = eval_snippet(@options[:snippet_name])
|
55
|
+
run_snippet(rewriter)
|
56
56
|
else
|
57
57
|
# nothing to do
|
58
58
|
end
|
@@ -233,41 +233,38 @@ module Synvert
|
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
|
-
#
|
237
|
-
# it can
|
236
|
+
# eval snippet by name
|
237
|
+
# it can eval by explicit snippet name,
|
238
238
|
# or from local path or http url.
|
239
|
-
def
|
239
|
+
def eval_snippet(snippet_name)
|
240
240
|
if /^http/.match?(snippet_name)
|
241
241
|
uri = URI.parse(snippet_name)
|
242
242
|
eval(uri.open.read)
|
243
|
-
get_last_snippet_name
|
244
243
|
elsif File.exists?(snippet_name)
|
245
|
-
|
246
|
-
get_last_snippet_name
|
244
|
+
eval(File.read(snippet_name))
|
247
245
|
else
|
248
246
|
require(File.join(default_snippets_home, 'lib', "#{snippet_name}.rb"))
|
249
|
-
snippet_name.split('/')
|
247
|
+
group, name = snippet_name.split('/')
|
248
|
+
Core::Rewriter.fetch(group, name)
|
250
249
|
end
|
251
250
|
end
|
252
251
|
|
253
|
-
#
|
254
|
-
def
|
255
|
-
|
256
|
-
get_last_snippet_name
|
252
|
+
# eval snippet name by user input
|
253
|
+
def eval_snippet_name_by_input(input)
|
254
|
+
eval(input)
|
257
255
|
end
|
258
256
|
|
259
257
|
# run a snippet
|
260
|
-
def run_snippet(
|
258
|
+
def run_snippet(rewriter)
|
259
|
+
rewriter.process
|
261
260
|
if plain_output?
|
262
|
-
puts "===== #{group}/#{name} started ====="
|
263
|
-
rewriter = Core::Rewriter.call group, name
|
261
|
+
puts "===== #{rewriter.group}/#{rewriter.name} started ====="
|
264
262
|
rewriter.warnings.each do |warning|
|
265
263
|
puts '[Warn] ' + warning.message
|
266
264
|
end
|
267
265
|
puts rewriter.todo if rewriter.todo
|
268
|
-
puts "===== #{group}/#{name} done ====="
|
266
|
+
puts "===== #{rewriter.group}/#{rewriter.name} done ====="
|
269
267
|
elsif json_output?
|
270
|
-
rewriter = Core::Rewriter.call group, name
|
271
268
|
output = {
|
272
269
|
affected_files: rewriter.affected_files.union(rewriter.sub_snippets.sum(Set.new, &:affected_files)).to_a,
|
273
270
|
warnings: rewriter.warnings.union(rewriter.sub_snippets.sum([], &:warnings)),
|
@@ -278,8 +275,7 @@ module Synvert
|
|
278
275
|
end
|
279
276
|
|
280
277
|
# test a snippet
|
281
|
-
def test_snippet(
|
282
|
-
rewriter = Core::Rewriter.fetch(group, name)
|
278
|
+
def test_snippet(rewriter)
|
283
279
|
results = rewriter.test
|
284
280
|
rewriter.sub_snippets.each do |sub_snippet|
|
285
281
|
results += sub_snippet.test_results
|
@@ -289,11 +285,11 @@ module Synvert
|
|
289
285
|
|
290
286
|
# execute snippet
|
291
287
|
def execute_snippet(execute_command)
|
292
|
-
|
288
|
+
rewriter = eval_snippet_name_by_input(STDIN.read)
|
293
289
|
if execute_command == 'test'
|
294
|
-
test_snippet(
|
290
|
+
test_snippet(rewriter)
|
295
291
|
else
|
296
|
-
run_snippet(
|
292
|
+
run_snippet(rewriter)
|
297
293
|
end
|
298
294
|
end
|
299
295
|
|
@@ -356,12 +352,5 @@ module Synvert
|
|
356
352
|
def json_output?
|
357
353
|
@options[:format] == 'json'
|
358
354
|
end
|
359
|
-
|
360
|
-
# get the last registered snippet name
|
361
|
-
def get_last_snippet_name
|
362
|
-
group = Rewriter.availables.keys.last
|
363
|
-
name = Rewriter.availables[group].keys.last
|
364
|
-
return group, name
|
365
|
-
end
|
366
355
|
end
|
367
356
|
end
|
data/lib/synvert/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synvert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: synvert-core
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
|
-
rubygems_version: 3.3.
|
129
|
+
rubygems_version: 3.3.22
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: synvert = syntax + convert.
|