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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 252c2e9347770f9363ca9d317d574fa6e1d9faad4826d2853816a669ad13dab1
4
- data.tar.gz: 1d19aac0f1dac17a84dd4a85bcbb8606d9391afeb9c4493eff516cf2b5ed948f
3
+ metadata.gz: 79cd6bc1c9d3e69d97ee47a276165412326be82a0d87f4527742c6d6c2acdca8
4
+ data.tar.gz: efa16f88a2a075aa33b3dc5aba653e8c188317840a5a0af75dfba87878a4c7d3
5
5
  SHA512:
6
- metadata.gz: 795910a3044cc4cdbf02e0412a5784235b7c8fc0892a1243cf58677c53d09e1cdf097d7f56cf8f818864de0eab6ec65d829c59e2ba246e1d1150bdd3fd5e2b40
7
- data.tar.gz: fc2f006fd4b269f598cd23d05ebfcf72b098ce4a7ccfaa1a5d6004517d058caabea1005e999d2ccaf92a73bae34941b4bc8b37124db98ae90a71730c7e749098
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
@@ -1,8 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
- # 0.44.1 (2021-07-19)
3
+ # 0.45.0 (2021-07-22)
4
4
 
5
5
  * Handle `nil` child node for `begin_pos` and `end_pos`
6
+ * Remove `Rewriter::Instance` options
6
7
 
7
8
  # 0.44.0 (2021-07-19)
8
9
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Synvert::Core
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/xinminlabs/synvert-core.png)](http://travis-ci.org/xinminlabs/synvert-core)
3
+ ![Main workflow](https://github.com/xinminlabs/synvert-core/actions/workflows/main.yml/badge.svg)
4
4
  [![Coverage Status](https://coveralls.io/repos/xinminlabs/synvert-core/badge.png?branch=master)](https://coveralls.io/r/xinminlabs/synvert-core)
5
5
  [![Gem Version](https://badge.fury.io/rb/synvert-core.png)](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, options = {}, &block)
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, options, &block).process
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, options = {}, &block)
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.send(@options[:sort_by]) }
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '0.44.1'
5
+ VERSION = '0.45.0'
6
6
  end
7
7
  end
@@ -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
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- ast (1.1.0)
13
- parser (2.1.7)
14
- ast (~> 1.1)
15
- slop (~> 3.4, >= 3.4.5)
16
- rake (10.1.1)
17
- slop (3.4.7)
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.44.1
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-18 00:00:00.000000000 Z
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
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