synvert 0.16.0 → 0.18.2

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: 1d737afecd60f57b9f37667899020a9a228af5ea1aa6e195686e4da8c5e201ea
4
- data.tar.gz: 070115ee46ab5de7a6dd3b24bf39ed4a62a5f5b00c7b1a897f7378cc2b379f39
3
+ metadata.gz: ae02af3473efd275bf61585a71f0cde8285693f4ed15014a3afab3a7498b8c8f
4
+ data.tar.gz: 73b85f14f2c3570738497d7ac510783a0ab36f0cdae1759018686c2322e9f514
5
5
  SHA512:
6
- metadata.gz: 7ddc5f29a5f0dc24a13ed097e0814f4a4eed585185420010b6fdbfcdc5822d4b1ba769a094d46e61f494c10866c58b83126f6fda4c768814a9ace2a7b9b3c5c1
7
- data.tar.gz: 0dc29b3b96c5aaeaf3479d28e1fe7f33b2a95f76205665bd6c4ec6122d16949e829713f9dd0ff6d92170c4c01e8cbe4d2de52fa5399459c7bb3f0fdd4edad616
6
+ metadata.gz: f324a07a94f4ad0bc6c1d88cd371da740e2946e78341271d6ecafde027df38129c74c7cba34e0196004978595c95c26edc5eaea932f6624c8e606b073a7dcdfb
7
+ data.tar.gz: 47b0279a18f02bced81b8381dd74e9b8f58d56c55ba3a9eab205ffa310f56791bafe9d9ca65cd2ab87a8874c0651d7d1af2512c478c1e61d6b22eab23b99ce88
@@ -0,0 +1,32 @@
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
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.5', '2.6', '2.7', '3.0']
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - name: Set up Ruby
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby-version }}
30
+ bundler-cache: true
31
+ - name: Run tests
32
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.18.2 (2021-08-12)
4
+
5
+ * Require `fileutils`
6
+
7
+ ## 0.18.1 (2021-07-23)
8
+
9
+ * Fix `affected_files` is Set
10
+
11
+ ## 0.18.0 (2021-07-14)
12
+
13
+ * Execute a snippet
14
+
15
+ ## 0.17.0 (2021-04-19)
16
+
17
+ * Run `git checkout .` before `git pull --rebase`
18
+
3
19
  ## 0.16.0 (2021-03-24)
4
20
 
5
21
  * Add `ruby_version` and `gem_spec` to json output
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Synvert
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/xinminlabs/synvert.svg)](http://travis-ci.org/xinminlabs/synvert)
3
+ <img src="https://xinminlabs.github.io/synvert/img/logo_96.png" alt="logo" width="32" height="32" />
4
+
5
+ ![Main workflow](https://github.com/xinminlabs/synvert/actions/workflows/main.yml/badge.svg)
4
6
  [![Coverage Status](https://coveralls.io/repos/xinminlabs/synvert/badge.svg?branch=master)](https://coveralls.io/r/xinminlabs/synvert)
5
7
  [![Gem Version](https://badge.fury.io/rb/synvert.svg)](http://badge.fury.io/rb/synvert)
6
8
 
@@ -22,6 +24,12 @@ Install it using rubygems
22
24
  $ gem install synvert
23
25
  ```
24
26
 
27
+ then run
28
+
29
+ ```
30
+ $ synvert --sync
31
+ ```
32
+
25
33
  ## Usage
26
34
 
27
35
  ```
@@ -39,10 +47,6 @@ Usage: synvert [project_path]
39
47
 
40
48
  e.g.
41
49
 
42
- ```
43
- $ synvert --sync
44
- ```
45
-
46
50
  ```
47
51
  $ synvert -r factory_girl/use_short_syntax,rails/upgrade_3_2_to_4_0 ~/Sites/railsbp/rails-bestpractices.com
48
52
  ```
@@ -61,7 +65,7 @@ $ docker run -v <your project path>:/app xinminlabs/awesomecode-synvert synvert
61
65
 
62
66
  ## Documentation
63
67
 
64
- [http://xinminlabs.github.io/synvert/][3]
68
+ [https://xinminlabs.github.io/synvert/][3]
65
69
 
66
70
  ## Contributing
67
71
 
@@ -73,4 +77,4 @@ $ docker run -v <your project path>:/app xinminlabs/awesomecode-synvert synvert
73
77
 
74
78
  [1]: https://github.com/xinminlabs/synvert-core/
75
79
  [2]: https://github.com/xinminlabs/synvert-snippets/
76
- [3]: http://xinminlabs.github.io/synvert/
80
+ [3]: https://xinminlabs.github.io/synvert/
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
@@ -242,7 +247,29 @@ module Synvert
242
247
  group, name = snippet_name.split('/')
243
248
  rewriter = Core::Rewriter.call group, name
244
249
  output = {
245
- affected_files: rewriter.affected_files.union(rewriter.sub_snippets.sum([], &:affected_files)).to_a,
250
+ affected_files: rewriter.affected_files.union(rewriter.sub_snippets.sum(Set.new, &:affected_files)).to_a,
251
+ warnings: rewriter.warnings.union(rewriter.sub_snippets.sum([], &:warnings)),
252
+ todo: rewriter.todo
253
+ }
254
+ puts JSON.generate(output)
255
+ end
256
+ end
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(Set.new, &:affected_files)).to_a,
246
273
  warnings: rewriter.warnings.union(rewriter.sub_snippets.sum([], &:warnings)),
247
274
  todo: rewriter.todo
248
275
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'open-uri'
4
4
  require 'json'
5
+ require 'fileutils'
5
6
 
6
7
  module Synvert
7
8
  # Manage synvert snippets.
@@ -19,7 +20,7 @@ module Synvert
19
20
  def sync
20
21
  if File.exist?(@snippets_path)
21
22
  FileUtils.cd @snippets_path
22
- Kernel.system('git pull --rebase')
23
+ Kernel.system('git checkout .; git pull --rebase')
23
24
  else
24
25
  Kernel.system("git clone https://github.com/xinminlabs/synvert-snippets.git #{@snippets_path}")
25
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Synvert
4
- VERSION = '0.16.0'
4
+ VERSION = '0.18.2'
5
5
  end
@@ -27,7 +27,7 @@ module Synvert
27
27
 
28
28
  it 'git pull snippets' do
29
29
  FileUtils.mkdir snippets_path
30
- expect(Kernel).to receive(:system).with('git pull --rebase')
30
+ expect(Kernel).to receive(:system).with('git checkout .; git pull --rebase')
31
31
  snippet.sync
32
32
  FileUtils.cd File.dirname(__FILE__)
33
33
  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.51.0'
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.16.0
4
+ version: 0.18.2
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-03-24 00:00:00.000000000 Z
11
+ date: 2021-08-12 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.51.0
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.51.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -88,9 +88,9 @@ executables:
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
+ - ".github/workflows/main.yml"
91
92
  - ".gitignore"
92
93
  - ".rspec"
93
- - ".travis.yml"
94
94
  - CHANGELOG.md
95
95
  - Gemfile
96
96
  - LICENSE.txt
@@ -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.2.22
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: synvert = syntax + convert.
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3
4
- - 2.4
5
- - 2.5
6
- - 2.6
7
- - 2.7
8
- - 3.0