synvert 1.0.1 → 1.1.1

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: 72408c5d30fc643921f1bbcd25720f787c0a9e45abe437200ba96d79016065c1
4
- data.tar.gz: 986ad580a7d7c91a3309061571db7a52141533e4c6c276176a3348d76e0f8440
3
+ metadata.gz: fca31952aad5373170fb41622c3dc07c11aa605ae8d13fb8770229062f9543b8
4
+ data.tar.gz: b57362eedac41f759e397dd10cfb0641690844161ae36e26c5cfd4fbd926d70a
5
5
  SHA512:
6
- metadata.gz: 7d586039e691d1398bd1c9826ce51a6ea70d849c16ac4e578d591001b241a81eb306a5e2c22fda45ba03ca5d64b8e93e5b427f2fd047ee28192a41af8d855af6
7
- data.tar.gz: 70d8f01ed5d84977a9ad7d825ec90f1bd30612624852bd8c92922c26e68519996f302983777be333a110b914304d8ceffd094e9226553846c8deb3030132f3e4
6
+ metadata.gz: c7e6e5fe021673fd412a984595258134633d2b5d4612e6e9633568865b3e676d662b597024ab3d7cfcc2d285a8586736a0ca76db33d61c401fe62d7677c48b7c
7
+ data.tar.gz: 60f4d25764698275cb360ef222e07e3794e4bf33f0cde79fb73c87982f43df8516330b3552a3e6d331d77d773e3777ff62854c6c376054557ac2356717391b78
@@ -1,17 +1,10 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
- name: CI
1
+ name: Test & deploy documentation
9
2
 
10
3
  on:
11
4
  push:
12
- branches: [ master ]
5
+ branches: [ main ]
13
6
  pull_request:
14
- branches: [ master ]
7
+ branches: [ main ]
15
8
 
16
9
  jobs:
17
10
  test:
@@ -30,3 +23,24 @@ jobs:
30
23
  bundler-cache: true
31
24
  - name: Run tests
32
25
  run: bundle exec rake
26
+
27
+ deploy:
28
+ runs-on: ubuntu-latest
29
+ needs: test
30
+ name: Update gh-pages to docs
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+ - uses: actions/setup-node@v2
34
+ with:
35
+ node-version: 18
36
+ - name: Install required npm dependencies
37
+ run: npm install -g markdown-to-html
38
+ - name: Create docs
39
+ run: mkdir docs
40
+ - name: Generate docs
41
+ run: github-markdown README.md -s https://cdn.simplecss.org/simple-v1.css > docs/index.html
42
+ - name: Deploy
43
+ uses: peaceiris/actions-gh-pages@v3
44
+ with:
45
+ deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
46
+ publish_dir: ./docs
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.1 (2022-10-05)
4
+
5
+ * Fix get_last_snippet_name, eval snippet to get rewriter
6
+
7
+ ## 1.1.0 (2022-10-03))
8
+
9
+ * Fix sub snippet not found
10
+ * Support sub snippets in `test`
11
+
3
12
  ## 1.0.1 (2022-09-23)
4
13
 
5
14
  * Execute with EXECUTE_COMMAND
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert (1.0.1)
5
- synvert-core (>= 1.8.0)
4
+ synvert (1.1.1)
5
+ synvert-core (>= 1.9.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -33,10 +33,10 @@ GEM
33
33
  concurrent-ruby (~> 1.0)
34
34
  json (2.5.1)
35
35
  minitest (5.16.3)
36
- node_mutation (1.4.0)
36
+ node_mutation (1.4.4)
37
37
  activesupport (< 7.0.0)
38
38
  erubis
39
- node_query (1.6.0)
39
+ node_query (1.7.0)
40
40
  activesupport (< 7.0.0)
41
41
  parser (3.1.2.1)
42
42
  ast (~> 2.4.1)
@@ -64,7 +64,7 @@ GEM
64
64
  simplecov-html (~> 0.10.0)
65
65
  simplecov-html (0.10.2)
66
66
  sync (0.5.0)
67
- synvert-core (1.9.0)
67
+ synvert-core (1.9.2)
68
68
  activesupport (< 7.0.0)
69
69
  erubis
70
70
  node_mutation
@@ -82,7 +82,7 @@ GEM
82
82
  addressable (>= 2.8.0)
83
83
  crack (>= 0.3.2)
84
84
  hashdiff (>= 0.4.0, < 2.0.0)
85
- zeitwerk (2.6.0)
85
+ zeitwerk (2.6.1)
86
86
 
87
87
  PLATFORMS
88
88
  x86_64-darwin-20
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Synvert
1
+ # synvert-ruby
2
2
 
3
3
  <img src="https://synvert.net/img/logo_96.png" alt="logo" width="32" height="32" />
4
4
 
@@ -56,7 +56,7 @@ Usage: synvert-ruby [project_path]
56
56
  -v, --version show this version
57
57
  ```
58
58
 
59
- #### Sync snippets
59
+ ### Sync snippets
60
60
 
61
61
  [Official Snippets](https://github.com/xinminlabs/synvert-snippets-ruby) are available on github,
62
62
  you can sync them any time you want.
@@ -65,17 +65,17 @@ you can sync them any time you want.
65
65
  $ synvert-ruby --sync
66
66
  ```
67
67
 
68
- #### List snippets
68
+ ### List snippets
69
69
 
70
70
  List all available snippets
71
71
 
72
72
  ```
73
73
  $ synvert-ruby -l
74
74
 
75
- $ synvert-ruby --list --form json
75
+ $ synvert-ruby --list --format json
76
76
  ```
77
77
 
78
- #### Show a snippet
78
+ ### Show a snippet
79
79
 
80
80
  Describe what a snippet does.
81
81
 
@@ -83,7 +83,7 @@ Describe what a snippet does.
83
83
  $ synvert-ruby -s factory_bot/use_short_syntax
84
84
  ```
85
85
 
86
- #### Open a snippet
86
+ ### Open a snippet
87
87
 
88
88
  Open a snippet in your editor, editor is defined in
89
89
  `ENV['SNIPPET_EDITOR']` or `ENV['EDITOR']`
@@ -92,7 +92,7 @@ Open a snippet in your editor, editor is defined in
92
92
  $ synvert-ruby -o factory_bot/use_short_syntax
93
93
  ```
94
94
 
95
- #### Run a snippet
95
+ ### Run a snippet
96
96
 
97
97
  Run a snippet, analyze and then rewrite code.
98
98
 
@@ -130,7 +130,7 @@ Show processing files when running a snippet.
130
130
  $ synvert-ruby -r factory_bot/use_short_syntax --show-run-process ~/Sites/xinminlabs/synvert-core-ruby
131
131
  ```
132
132
 
133
- #### Generate a snippet
133
+ ### Generate a snippet
134
134
 
135
135
  Generate a new snippet
136
136
 
data/lib/synvert/cli.rb CHANGED
@@ -43,13 +43,16 @@ module Synvert
43
43
  when 'generate'
44
44
  generate_snippet
45
45
  when 'execute'
46
+ read_rewriters
46
47
  execute_snippet(@options[:execute_command])
47
48
  when 'test'
48
- group, name = get_snippet_name(@options[:snippet_name])
49
- test_snippet(group, name)
49
+ read_rewriters
50
+ rewriter = eval_snippet(@options[:snippet_name])
51
+ test_snippet(rewriter)
50
52
  when 'run'
51
- group, name = get_snippet_name(@options[:snippet_name])
52
- run_snippet(group, name)
53
+ read_rewriters
54
+ rewriter = eval_snippet(@options[:snippet_name])
55
+ run_snippet(rewriter)
53
56
  else
54
57
  # nothing to do
55
58
  end
@@ -230,41 +233,38 @@ module Synvert
230
233
  end
231
234
  end
232
235
 
233
- # get snippet name
234
- # it can get from explicit snippet name,
236
+ # eval snippet by name
237
+ # it can eval by explicit snippet name,
235
238
  # or from local path or http url.
236
- def get_snippet_name(snippet_name)
239
+ def eval_snippet(snippet_name)
237
240
  if /^http/.match?(snippet_name)
238
241
  uri = URI.parse(snippet_name)
239
242
  eval(uri.open.read)
240
- get_last_snippet_name
241
243
  elsif File.exists?(snippet_name)
242
- require(snippet_name)
243
- get_last_snippet_name
244
+ eval(File.read(snippet_name))
244
245
  else
245
246
  require(File.join(default_snippets_home, 'lib', "#{snippet_name}.rb"))
246
- snippet_name.split('/')
247
+ group, name = snippet_name.split('/')
248
+ Core::Rewriter.fetch(group, name)
247
249
  end
248
250
  end
249
251
 
250
- # get snippet name by user inputs
251
- def get_snippet_name_by_input(input)
252
- rewriter = eval(input)
253
- get_last_snippet_name
252
+ # eval snippet name by user input
253
+ def eval_snippet_name_by_input(input)
254
+ eval(input)
254
255
  end
255
256
 
256
257
  # run a snippet
257
- def run_snippet(group, name)
258
+ def run_snippet(rewriter)
259
+ rewriter.process
258
260
  if plain_output?
259
- puts "===== #{group}/#{name} started ====="
260
- rewriter = Core::Rewriter.call group, name
261
+ puts "===== #{rewriter.group}/#{rewriter.name} started ====="
261
262
  rewriter.warnings.each do |warning|
262
263
  puts '[Warn] ' + warning.message
263
264
  end
264
265
  puts rewriter.todo if rewriter.todo
265
- puts "===== #{group}/#{name} done ====="
266
+ puts "===== #{rewriter.group}/#{rewriter.name} done ====="
266
267
  elsif json_output?
267
- rewriter = Core::Rewriter.call group, name
268
268
  output = {
269
269
  affected_files: rewriter.affected_files.union(rewriter.sub_snippets.sum(Set.new, &:affected_files)).to_a,
270
270
  warnings: rewriter.warnings.union(rewriter.sub_snippets.sum([], &:warnings)),
@@ -275,19 +275,21 @@ module Synvert
275
275
  end
276
276
 
277
277
  # test a snippet
278
- def test_snippet(group, name)
279
- rewriter = Core::Rewriter.fetch(group, name)
278
+ def test_snippet(rewriter)
280
279
  results = rewriter.test
280
+ rewriter.sub_snippets.each do |sub_snippet|
281
+ results += sub_snippet.test_results
282
+ end
281
283
  puts JSON.generate(results)
282
284
  end
283
285
 
284
286
  # execute snippet
285
287
  def execute_snippet(execute_command)
286
- group, name = get_snippet_name_by_input(STDIN.read)
288
+ rewriter = eval_snippet_name_by_input(STDIN.read)
287
289
  if execute_command == 'test'
288
- test_snippet(group, name)
290
+ test_snippet(rewriter)
289
291
  else
290
- run_snippet(group, name)
292
+ run_snippet(rewriter)
291
293
  end
292
294
  end
293
295
 
@@ -350,12 +352,5 @@ module Synvert
350
352
  def json_output?
351
353
  @options[:format] == 'json'
352
354
  end
353
-
354
- # get the last registered snippet name
355
- def get_last_snippet_name
356
- group = Rewriter.availables.keys.last
357
- name = Rewriter.availables[group].keys.last
358
- return group, name
359
- end
360
355
  end
361
356
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Synvert
4
- VERSION = '1.0.1'
4
+ VERSION = '1.1.1'
5
5
  end
data/synvert-ruby.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-ruby --sync` first to sync snippets remotely.'
22
22
 
23
- spec.add_runtime_dependency 'synvert-core', '>= 1.8.0'
23
+ spec.add_runtime_dependency 'synvert-core', '>= 1.9.2'
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: 1.0.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-09-23 00:00:00.000000000 Z
11
+ date: 2022-10-05 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: 1.8.0
19
+ version: 1.9.2
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: 1.8.0
26
+ version: 1.9.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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.7
129
+ rubygems_version: 3.3.22
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: synvert = syntax + convert.