synvert-core 1.9.0 → 1.9.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: aa46b311ec4eb71e3a23d060e1a23dcceffe1b0ddea066a64043aea29635d143
4
- data.tar.gz: 7dd8b27cfc88e3d98a876da7592e1df466e00a6c1b79309d34abc475e287b5a7
3
+ metadata.gz: 737e801df5a1d686045b99ff8038cd64bd2d39e96813fec4abdedb4473b6f943
4
+ data.tar.gz: 4adcef7e1eaff7297f35ce5b4df40a3d3edbe447c1354c2a0e7c5e279ec2b60f
5
5
  SHA512:
6
- metadata.gz: 46b2babf63c196c428173cac102fc55d7968e8bfee9ba484a8c25ffa3c2da711502c172a5c60ae84155e0fef7ab1e2bcad1b70367f36612550bceee010f2ac43
7
- data.tar.gz: ca19136ae935ab915d498ab71fb286b9cf30469dbc4503e5f5fb754863cefaa290e1a833b35cedfa0b2533bf64d55987d031514be60b32884145b8df8cc42de7
6
+ metadata.gz: 1ad2b3a8e7baa9d158e9a7bdbb0dbc9f46b5924ccd7c18867c41ba40192b2e3b57ae500e25edfdf7d0735161abb953bdb833aacbb0e2403321d692c1ae070dd1
7
+ data.tar.gz: aafdeaa9f19a732c6386bec43c3fafbd56398d9f543e316875d3fa7038a91b1fdc153c1d2c530259a2b8fb137fcecd1ff9ab936723d5bfbdd0cf71d7fd175d28
@@ -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:
@@ -29,3 +22,22 @@ jobs:
29
22
  bundler-cache: true
30
23
  - name: Run tests
31
24
  run: bundle exec rake
25
+
26
+ deploy:
27
+ runs-on: ubuntu-latest
28
+ needs: test
29
+ name: Update gh-pages to docs
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - uses: actions/setup-ruby@v1
33
+ with:
34
+ ruby-version: '3.1'
35
+ - name: Install required gem dependencies
36
+ run: gem install yard redcarpet github-markup --no-document
37
+ - name: Build YARD Ruby Documentation
38
+ run: yardoc --output-dir docs
39
+ - name: Deploy
40
+ uses: peaceiris/actions-gh-pages@v3
41
+ with:
42
+ deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
43
+ publish_dir: ./docs
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup-provider=redcarpet
2
+ --markup=markdown
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.9.2 (2022-10-03)
4
+
5
+ * Fix `test` in sub_snippets
6
+
7
+ ## 1.9.1 (2022-09-23)
8
+
9
+ * Read / write absolute path
10
+
3
11
  ## 1.9.0 (2022-09-20)
4
12
 
5
13
  * Add `noop` dsl
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.9.0)
4
+ synvert-core (1.9.2)
5
5
  activesupport (< 7.0.0)
6
6
  erubis
7
7
  node_mutation
@@ -49,10 +49,10 @@ GEM
49
49
  method_source (1.0.0)
50
50
  minitest (5.16.3)
51
51
  nenv (0.3.0)
52
- node_mutation (1.4.0)
52
+ node_mutation (1.4.4)
53
53
  activesupport (< 7.0.0)
54
54
  erubis
55
- node_query (1.6.0)
55
+ node_query (1.7.0)
56
56
  activesupport (< 7.0.0)
57
57
  notiffany (0.1.3)
58
58
  nenv (~> 0.1)
@@ -85,7 +85,7 @@ GEM
85
85
  thor (1.2.1)
86
86
  tzinfo (2.0.5)
87
87
  concurrent-ruby (~> 1.0)
88
- zeitwerk (2.6.0)
88
+ zeitwerk (2.6.1)
89
89
 
90
90
  PLATFORMS
91
91
  ruby
@@ -356,9 +356,9 @@ module Synvert::Core
356
356
  def process_file(file_path)
357
357
  puts file_path if Configuration.show_run_process
358
358
 
359
- @current_file = file_path
359
+ @current_file = File.join(Configuration.root_path, file_path)
360
360
  while true
361
- source = read_source(file_path)
361
+ source = read_source(@current_file)
362
362
  @current_mutation = NodeMutation.new(source)
363
363
  begin
364
364
  node = parse_code(file_path, source)
@@ -378,7 +378,7 @@ module Synvert::Core
378
378
  result = @current_mutation.process
379
379
  if result.affected?
380
380
  @rewriter.add_affected_file(file_path)
381
- write_source(file_path, result.new_source)
381
+ write_source(@current_file, result.new_source)
382
382
  end
383
383
  break unless result.conflicted?
384
384
  rescue Parser::SyntaxError
@@ -392,11 +392,11 @@ module Synvert::Core
392
392
  #
393
393
  # @param file_path [String]
394
394
  def test_file(file_path)
395
- @current_file = file_path
396
- source = read_source(file_path)
395
+ @current_file = File.join(Configuration.root_path, file_path)
396
+ source = read_source(@current_file)
397
397
  @current_mutation = NodeMutation.new(source)
398
398
  begin
399
- node = parse_code(file_path, source)
399
+ node = parse_code(@current_file, source)
400
400
 
401
401
  process_with_node(node) do
402
402
  instance_eval(&@block)
@@ -74,11 +74,14 @@ module Synvert::Core
74
74
  # @param name [String] the rewriter name.
75
75
  # @param options [Hash]
76
76
  # @option options [Boolean] :run_instance (true) process the instance.
77
+ # @option options [String] :execute_command ('process') process or test the rewriter
77
78
  # @return [Synvert::Core::Rewriter] the registered rewriter.
78
79
  # @raise [Synvert::Core::RewriterNotFound] if the registered rewriter is not found.
79
- def call(group, name, options = { run_instance: true })
80
+ def call(group, name, options = { run_instance: true, execute_command: 'process' })
80
81
  rewriter = fetch(group, name)
81
- if options[:run_instance]
82
+ if options[:execute_command] == 'test'
83
+ rewriter.test
84
+ elsif options[:run_instance]
82
85
  rewriter.process
83
86
  else
84
87
  rewriter.process_with_sandbox
@@ -121,7 +124,9 @@ module Synvert::Core
121
124
  # @return [Rewriter::RubyVersion] the ruby version
122
125
  # @!attribute [r] gem_spec
123
126
  # @return [Rewriter::GemSpec] the gem spec
124
- attr_reader :group, :name, :sub_snippets, :helpers, :warnings, :affected_files, :ruby_version, :gem_spec
127
+ # @!attribute [r] test_results
128
+ # @return [Object] the test results
129
+ attr_reader :group, :name, :sub_snippets, :helpers, :warnings, :affected_files, :ruby_version, :gem_spec, :test_results
125
130
 
126
131
  # Initialize a Rewriter.
127
132
  # When a rewriter is initialized, it is already registered.
@@ -138,7 +143,7 @@ module Synvert::Core
138
143
  @warnings = []
139
144
  @affected_files = Set.new
140
145
  @redo_until_no_change = false
141
- @options = { run_instance: true, write_to_file: true }
146
+ @options = { run_instance: true, execute_command: 'process', write_to_file: true }
142
147
  @test_results = []
143
148
  self.class.register(@group, @name, self)
144
149
  end
@@ -165,6 +170,7 @@ module Synvert::Core
165
170
 
166
171
  def test
167
172
  @options[:write_to_file] = false
173
+ @options[:execute_command] = 'test'
168
174
  begin
169
175
  @affected_files = Set.new
170
176
  instance_eval(&@block)
@@ -174,6 +180,7 @@ module Synvert::Core
174
180
  end
175
181
  ensure
176
182
  @options[:write_to_file] = true
183
+ @options[:execute_command] = 'process'
177
184
  end
178
185
  @test_results
179
186
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.9.0'
5
+ VERSION = '1.9.2'
6
6
  end
7
7
  end
@@ -213,8 +213,8 @@ module Synvert::Core
213
213
  end
214
214
  EOS
215
215
  expect(Dir).to receive(:glob).with('spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb'])
216
- expect(File).to receive(:read).with('spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
217
- expect(File).to receive(:write).with('spec/models/post_spec.rb', output)
216
+ expect(File).to receive(:read).with('./spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
217
+ expect(File).to receive(:write).with('./spec/models/post_spec.rb', output)
218
218
  instance.process
219
219
  end
220
220
 
@@ -238,8 +238,8 @@ module Synvert::Core
238
238
  end
239
239
  EOS
240
240
  expect(Dir).to receive(:glob).with('spec/spec_helper.rb').and_return(['spec/spec_helper.rb'])
241
- expect(File).to receive(:read).with('spec/spec_helper.rb', encoding: 'UTF-8').and_return(input)
242
- expect(File).not_to receive(:write).with('spec/spec_helper.rb', output)
241
+ expect(File).to receive(:read).with('./spec/spec_helper.rb', encoding: 'UTF-8').and_return(input)
242
+ expect(File).not_to receive(:write).with('./spec/spec_helper.rb', output)
243
243
  instance.process
244
244
  end
245
245
 
@@ -265,9 +265,9 @@ module Synvert::Core
265
265
  end
266
266
  EOS
267
267
  expect(Dir).to receive(:glob).with('spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb']).twice
268
- expect(File).to receive(:read).with('spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
269
- expect(File).to receive(:write).with('spec/models/post_spec.rb', output)
270
- expect(File).to receive(:read).with('spec/models/post_spec.rb', encoding: 'UTF-8').and_return(output)
268
+ expect(File).to receive(:read).with('./spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
269
+ expect(File).to receive(:write).with('./spec/models/post_spec.rb', output)
270
+ expect(File).to receive(:read).with('./spec/models/post_spec.rb', encoding: 'UTF-8').and_return(output)
271
271
  instance.process
272
272
  instance.process
273
273
  expect(rewriter.affected_files).to be_include('spec/models/post_spec.rb')
@@ -292,7 +292,7 @@ module Synvert::Core
292
292
  end
293
293
  EOS
294
294
  expect(Dir).to receive(:glob).with('spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb'])
295
- expect(File).to receive(:read).with('spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
295
+ expect(File).to receive(:read).with('./spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
296
296
  results = instance.test
297
297
  expect(results[0].file_path).to eq 'spec/models/post_spec.rb'
298
298
  expect(results[0].actions).to eq [
@@ -316,7 +316,7 @@ module Synvert::Core
316
316
  end
317
317
  EOS
318
318
  expect(Dir).to receive(:glob).with('spec/spec_helper.rb').and_return(['spec/spec_helper.rb'])
319
- expect(File).to receive(:read).with('spec/spec_helper.rb', encoding: 'UTF-8').and_return(input)
319
+ expect(File).to receive(:read).with('./spec/spec_helper.rb', encoding: 'UTF-8').and_return(input)
320
320
  result = instance.test
321
321
  expect(result[0].file_path).to eq 'spec/spec_helper.rb'
322
322
  expect(result[0].actions).to eq []
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: 1.9.0
4
+ version: 1.9.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: 2022-09-20 00:00:00.000000000 Z
11
+ date: 2022-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -104,6 +104,7 @@ files:
104
104
  - ".github/workflows/main.yml"
105
105
  - ".gitignore"
106
106
  - ".rspec"
107
+ - ".yardopts"
107
108
  - CHANGELOG.md
108
109
  - Gemfile
109
110
  - Gemfile.lock