synvert 0.17.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc982f230933521fb1b332728e9affea43b0245b7c0dacd501cce3050983ee90
4
- data.tar.gz: 9a370e4f362e8c40eb9cdb8eda9121234d81ded3966428c1d803d33a83099433
3
+ metadata.gz: fbc4490f4b48111cb658dbdf8d86f63f881a137fa40ef5c6050fa57d24392e09
4
+ data.tar.gz: d5ebc66ea45897622f6ed40e7838817c8dada422d92cd8898feadfb471d47bab
5
5
  SHA512:
6
- metadata.gz: 2f721c8e10e17347a5db3bc8f39a8fe178d16b77617de653f91edfc3887ee0f74d9076d3a7bcec6e6e7fe293d15378e461ab33f00a9cd92de1868e7aa405c2fd
7
- data.tar.gz: b3d976e148b2c33c5a104b1ab94fc8e4898729f07680971a1b6f08684a0f8fdf23d90b000d38d77f22c8b337829da4c1fea825a8b5c9ef8f2952e34e4a6d5f4c
6
+ metadata.gz: 8a48d72c516eb52854102bb8620585317295b188d50a0dfb1184e2f548eac20489713932a3fadbcd0e56526f5b8f97c045a2d8a783e4c56ed481c56619733151
7
+ data.tar.gz: ac409e15e3f22fd082f222c19542418af0d78573066302f293fd0b025108bda0e7eaa401eecba6ff0b4bac1a0ffeb2b9958865a960130859d26f79b51f025cd7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.18.0 (2021-07-14)
4
+
5
+ * Execute a snippet
6
+
3
7
  ## 0.17.0 (2021-04-19)
4
8
 
5
9
  * Run `git checkout .` before `git pull --rebase`
data/lib/synvert/cli.rb CHANGED
@@ -40,6 +40,8 @@ module Synvert
40
40
  sync_snippets
41
41
  when 'generate'
42
42
  generate_snippet
43
+ when 'execute'
44
+ execute_snippet
43
45
  else
44
46
  # run
45
47
  load_rewriters
@@ -94,6 +96,9 @@ module Synvert
94
96
  opts.on '--sync', 'sync snippets' do
95
97
  @options[:command] = 'sync'
96
98
  end
99
+ opts.on '--execute', 'execute snippet' do
100
+ @options[:command] = 'execute'
101
+ end
97
102
  opts.on '-r', '--run SNIPPET_NAME', 'run specified snippet, e.g. ruby/new_hash_syntax' do |snippet_name|
98
103
  @options[:snippet_name] = snippet_name
99
104
  end
@@ -250,6 +255,28 @@ module Synvert
250
255
  end
251
256
  end
252
257
 
258
+ # execute snippet
259
+ def execute_snippet
260
+ input = STDIN.read
261
+ if plain_output?
262
+ puts "===== execute started ====="
263
+ rewriter = eval(input)
264
+ rewriter.warnings.each do |warning|
265
+ puts '[Warn] ' + warning.message
266
+ end
267
+ puts rewriter.todo if rewriter.todo
268
+ puts "===== execute done ====="
269
+ elsif json_output?
270
+ rewriter = eval(input)
271
+ output = {
272
+ affected_files: rewriter.affected_files.union(rewriter.sub_snippets.sum([], &:affected_files)).to_a,
273
+ warnings: rewriter.warnings.union(rewriter.sub_snippets.sum([], &:warnings)),
274
+ todo: rewriter.todo
275
+ }
276
+ puts JSON.generate(output)
277
+ end
278
+ end
279
+
253
280
  # generate a new snippet
254
281
  def generate_snippet
255
282
  group, name = @options[:snippet_name].split('/')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Synvert
4
- VERSION = '0.17.0'
4
+ VERSION = '0.18.0'
5
5
  end
data/synvert.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ['lib']
21
21
  spec.post_install_message = 'Please run `synvert --sync` first to sync snippets remotely.'
22
22
 
23
- spec.add_runtime_dependency 'synvert-core', '>= 0.25.1'
23
+ spec.add_runtime_dependency 'synvert-core', '>= 0.42.1'
24
24
 
25
25
  spec.add_development_dependency 'bundler'
26
26
  spec.add_development_dependency 'rake'
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: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2021-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: synvert-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.25.1
19
+ version: 0.42.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.25.1
26
+ version: 0.42.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.1.4
126
+ rubygems_version: 3.1.6
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: synvert = syntax + convert.