synvert-core 0.44.1 → 0.45.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/.github/workflows/main.yml +32 -0
- data/CHANGELOG.md +2 -1
- data/README.md +1 -1
- data/lib/synvert/core/rewriter.rb +2 -3
- data/lib/synvert/core/rewriter/instance.rb +2 -6
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/rewriter/gem_spec_spec.rb +12 -13
- metadata +3 -3
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79cd6bc1c9d3e69d97ee47a276165412326be82a0d87f4527742c6d6c2acdca8
|
4
|
+
data.tar.gz: efa16f88a2a075aa33b3dc5aba653e8c188317840a5a0af75dfba87878a4c7d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51115212e46d96e19fc611a565535246e0fa25d43b8ad6d8830c7e149571b0ff682621ba9525a2d9ab0250d1a98afde7f02d5d8f414457d00fcbbd5bf5352372
|
7
|
+
data.tar.gz: a6b3c930b1183abd25ee03e5c371a5a937f22e686e975f8de48afb882ff82deb8b43432ada7ff85254c2f04e7be1081bca8b7cd4af475cc94ad1250fd8c02846
|
@@ -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
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Synvert::Core
|
2
2
|
|
3
|
-
|
3
|
+

|
4
4
|
[](https://coveralls.io/r/xinminlabs/synvert-core)
|
5
5
|
[](http://badge.fury.io/rb/synvert-core)
|
6
6
|
|
@@ -245,13 +245,12 @@ module Synvert::Core
|
|
245
245
|
# It creates a [Synvert::Core::Rewriter::Instance] to rewrite code.
|
246
246
|
#
|
247
247
|
# @param file_pattern [String] pattern to find files, e.g. spec/**/*_spec.rb
|
248
|
-
# @param options [Hash] instance options.
|
249
248
|
# @param block [Block] the block to rewrite code in the matching files.
|
250
|
-
def within_files(file_pattern,
|
249
|
+
def within_files(file_pattern, &block)
|
251
250
|
return if @sandbox
|
252
251
|
|
253
252
|
if (!@ruby_version || @ruby_version.match?) && (!@gem_spec || @gem_spec.match?)
|
254
|
-
Rewriter::Instance.new(self, file_pattern,
|
253
|
+
Rewriter::Instance.new(self, file_pattern, &block).process
|
255
254
|
end
|
256
255
|
end
|
257
256
|
|
@@ -64,20 +64,16 @@ module Synvert::Core
|
|
64
64
|
# @return current filename
|
65
65
|
attr_accessor :current_node, :current_file
|
66
66
|
|
67
|
-
DEFAULT_OPTIONS = { sort_by: 'begin_pos' }.freeze
|
68
|
-
|
69
67
|
# Initialize an instance.
|
70
68
|
#
|
71
69
|
# @param rewriter [Synvert::Core::Rewriter]
|
72
70
|
# @param file_pattern [String] pattern to find files, e.g. spec/**/*_spec.rb
|
73
|
-
# @param options [Hash] instance options, it includes :sort_by.
|
74
71
|
# @param block [Block] block code to find nodes, match conditions and rewrite code.
|
75
72
|
# @return [Synvert::Core::Rewriter::Instance]
|
76
|
-
def initialize(rewriter, file_pattern,
|
73
|
+
def initialize(rewriter, file_pattern, &block)
|
77
74
|
@rewriter = rewriter
|
78
75
|
@actions = []
|
79
76
|
@file_pattern = file_pattern
|
80
|
-
@options = DEFAULT_OPTIONS.merge(options)
|
81
77
|
@block = block
|
82
78
|
rewriter.helpers.each { |helper| singleton_class.send(:define_method, helper[:name], &helper[:block]) }
|
83
79
|
end
|
@@ -107,7 +103,7 @@ module Synvert::Core
|
|
107
103
|
end
|
108
104
|
|
109
105
|
if @actions.length > 0
|
110
|
-
@actions.sort_by! { |action| action.
|
106
|
+
@actions.sort_by! { |action| [action.begin_pos, action.end_pos] }
|
111
107
|
conflict_actions = get_conflict_actions
|
112
108
|
@actions.reverse_each do |action|
|
113
109
|
source[action.begin_pos...action.end_pos] = action.rewritten_code
|
data/lib/synvert/core/version.rb
CHANGED
@@ -4,19 +4,18 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
module Synvert::Core
|
6
6
|
describe Rewriter::GemSpec do
|
7
|
-
let(:gemfile_lock_content) {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
'
|
19
|
-
}
|
7
|
+
let(:gemfile_lock_content) { <<~EOS }
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (1.1.0)
|
12
|
+
parser (2.1.7)
|
13
|
+
ast (~> 1.1)
|
14
|
+
slop (~> 3.4, >= 3.4.5)
|
15
|
+
rake (10.1.1)
|
16
|
+
slop (3.4.7)
|
17
|
+
EOS
|
18
|
+
before { allow(File).to receive(:exist?).with(File.join(ENV['HOME'], '.gem/specs')).and_return(false) }
|
20
19
|
|
21
20
|
it 'returns true if version in Gemfile.lock is greater than definition' do
|
22
21
|
expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synvert-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.45.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-07-
|
11
|
+
date: 2021-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -129,9 +129,9 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".github/workflows/main.yml"
|
132
133
|
- ".gitignore"
|
133
134
|
- ".rspec"
|
134
|
-
- ".travis.yml"
|
135
135
|
- CHANGELOG.md
|
136
136
|
- Gemfile
|
137
137
|
- Guardfile
|