synvert-core 0.16.1 → 0.17.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/CHANGELOG.md +3 -1
- data/lib/synvert/core.rb +0 -3
- data/lib/synvert/core/rewriter/gem_spec.rb +7 -8
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/rewriter/action/replace_with_action_spec.rb +4 -4
- data/spec/synvert/core/rewriter/condition/if_exist_condition_spec.rb +2 -2
- data/spec/synvert/core/rewriter/condition/if_only_exist_condition_spec.rb +4 -4
- data/spec/synvert/core/rewriter/condition/unless_exist_condition_spec.rb +2 -2
- data/spec/synvert/core/rewriter/gem_spec_spec.rb +8 -9
- data/spec/synvert/core/rewriter/instance_spec.rb +16 -16
- data/spec/synvert/core/rewriter/scope/within_scope.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b73d8898436945c3266c9d0e4eec002491c3b031e1d571f94b3a59443142a9dd
|
4
|
+
data.tar.gz: c8afb1ce36ef5d3e826ebbc7ca10103175661e14f8ea1af1ae5a1a83b8714dbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7198c44b3696f0c0f640fe378ff3b9923799517998d6be38177096a552b33885bf5df6113d1aa1a0b68432bff79d0322587648d221bd6fbaebcf75ab8b2d32d
|
7
|
+
data.tar.gz: 39b8bf09735971e108b112b96b3377df988b82e891c76d5050fef978aec81bf340ff096463ac9416848fd9b8e412b95537377d0647d11a6028d5ab909cac4fa4
|
data/CHANGELOG.md
CHANGED
data/lib/synvert/core.rb
CHANGED
@@ -27,15 +27,14 @@ module Synvert::Core
|
|
27
27
|
# @raise [Synvert::Core::GemfileLockNotFound] raise if Gemfile.lock does not exist.
|
28
28
|
def match?
|
29
29
|
gemfile_lock_path = File.join(Configuration.instance.get(:path), 'Gemfile.lock')
|
30
|
-
if
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
30
|
+
# if Gemfile.lock does not exist, just ignore this check
|
31
|
+
return true unless File.exist?(gemfile_lock_path)
|
32
|
+
|
33
|
+
parser = Bundler::LockfileParser.new(File.read(gemfile_lock_path))
|
34
|
+
if spec = parser.specs.find { |spec| spec.name == @name }
|
35
|
+
Gem::Version.new(spec.version).send(OPERATORS[@operator], @version)
|
37
36
|
else
|
38
|
-
|
37
|
+
false
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
data/lib/synvert/core/version.rb
CHANGED
@@ -30,10 +30,10 @@ module Synvert::Core
|
|
30
30
|
source = " its(:size) { should == 1 }"
|
31
31
|
send_node = Parser::CurrentRuby.parse(source)
|
32
32
|
instance = double(current_node: send_node)
|
33
|
-
Rewriter::ReplaceWithAction.new(instance, "
|
33
|
+
Rewriter::ReplaceWithAction.new(instance, "describe '#size' do
|
34
34
|
subject { super().size }
|
35
35
|
it { {{body}} }
|
36
|
-
end"
|
36
|
+
end", autoindent: false)
|
37
37
|
}
|
38
38
|
|
39
39
|
it 'gets begin_pos' do
|
@@ -45,10 +45,10 @@ end""", autoindent: false)
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'gets rewritten_code' do
|
48
|
-
expect(subject.rewritten_code).to eq "
|
48
|
+
expect(subject.rewritten_code).to eq "describe '#size' do
|
49
49
|
subject { super().size }
|
50
50
|
it { should == 1 }
|
51
|
-
end"
|
51
|
+
end"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -5,12 +5,12 @@ require 'spec_helper'
|
|
5
5
|
module Synvert::Core
|
6
6
|
describe Rewriter::IfExistCondition do
|
7
7
|
let(:source) {
|
8
|
-
"
|
8
|
+
"
|
9
9
|
RSpec.configure do |config|
|
10
10
|
config.include EmailSpec::Helpers
|
11
11
|
config.include EmailSpec::Methods
|
12
12
|
end
|
13
|
-
"
|
13
|
+
"
|
14
14
|
}
|
15
15
|
let(:node) { Parser::CurrentRuby.parse(source) }
|
16
16
|
let(:instance) { double(:current_node => node) }
|
@@ -5,23 +5,23 @@ require 'spec_helper'
|
|
5
5
|
module Synvert::Core
|
6
6
|
describe Rewriter::IfOnlyExistCondition do
|
7
7
|
let(:source) {
|
8
|
-
"
|
8
|
+
"
|
9
9
|
RSpec.configure do |config|
|
10
10
|
config.include EmailSpec::Helpers
|
11
11
|
config.include EmailSpec::Methods
|
12
12
|
end
|
13
|
-
"
|
13
|
+
"
|
14
14
|
}
|
15
15
|
let(:node) { Parser::CurrentRuby.parse(source) }
|
16
16
|
let(:instance) { double(:current_node => node) }
|
17
17
|
|
18
18
|
describe '#process' do
|
19
19
|
it 'gets matching nodes' do
|
20
|
-
source = "
|
20
|
+
source = "
|
21
21
|
RSpec.configure do |config|
|
22
22
|
config.include EmailSpec::Helpers
|
23
23
|
end
|
24
|
-
"
|
24
|
+
"
|
25
25
|
node = Parser::CurrentRuby.parse(source)
|
26
26
|
instance = double(:current_node => node)
|
27
27
|
run = false
|
@@ -5,12 +5,12 @@ require 'spec_helper'
|
|
5
5
|
module Synvert::Core
|
6
6
|
describe Rewriter::UnlessExistCondition do
|
7
7
|
let(:source) {
|
8
|
-
"
|
8
|
+
"
|
9
9
|
RSpec.configure do |config|
|
10
10
|
config.include EmailSpec::Helpers
|
11
11
|
config.include EmailSpec::Methods
|
12
12
|
end
|
13
|
-
"
|
13
|
+
"
|
14
14
|
}
|
15
15
|
let(:node) { Parser::CurrentRuby.parse(source) }
|
16
16
|
let(:instance) { double(:current_node => node) }
|
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
module Synvert::Core
|
6
6
|
describe Rewriter::GemSpec do
|
7
|
-
let(:gemfile_lock_content) { "
|
7
|
+
let(:gemfile_lock_content) { "
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
@@ -14,41 +14,40 @@ GEM
|
|
14
14
|
slop (~> 3.4, >= 3.4.5)
|
15
15
|
rake (10.1.1)
|
16
16
|
slop (3.4.7)
|
17
|
-
|
18
|
-
}
|
17
|
+
"}
|
19
18
|
|
20
19
|
it 'returns true if version in Gemfile.lock is greater than definition' do
|
21
|
-
expect(File).to receive(:
|
20
|
+
expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
|
22
21
|
expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
|
23
22
|
gem_spec = Rewriter::GemSpec.new('ast', {gte: '1.0.0'})
|
24
23
|
expect(gem_spec).to be_match
|
25
24
|
end
|
26
25
|
|
27
26
|
it 'returns true if version in Gemfile.lock is equal to definition' do
|
28
|
-
expect(File).to receive(:
|
27
|
+
expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
|
29
28
|
expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
|
30
29
|
gem_spec = Rewriter::GemSpec.new('ast', '1.1.0')
|
31
30
|
expect(gem_spec).to be_match
|
32
31
|
end
|
33
32
|
|
34
33
|
it 'returns false if version in Gemfile.lock is less than definition' do
|
35
|
-
expect(File).to receive(:
|
34
|
+
expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
|
36
35
|
expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
|
37
36
|
gem_spec = Rewriter::GemSpec.new('ast', {gt: '1.2.0'})
|
38
37
|
expect(gem_spec).not_to be_match
|
39
38
|
end
|
40
39
|
|
41
40
|
it 'returns false if gem does not exist in Gemfile.lock' do
|
42
|
-
expect(File).to receive(:
|
41
|
+
expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(true)
|
43
42
|
expect(File).to receive(:read).with('./Gemfile.lock').and_return(gemfile_lock_content)
|
44
43
|
gem_spec = Rewriter::GemSpec.new('synvert', '1.0.0')
|
45
44
|
expect(gem_spec).not_to be_match
|
46
45
|
end
|
47
46
|
|
48
47
|
it 'raise Synvert::Core::GemfileLockNotFound if Gemfile.lock does not exist' do
|
49
|
-
expect(File).to receive(:
|
48
|
+
expect(File).to receive(:exist?).with('./Gemfile.lock').and_return(false)
|
50
49
|
gem_spec = Rewriter::GemSpec.new('ast', '1.1.0')
|
51
|
-
expect
|
50
|
+
expect(gem_spec).to be_match
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end
|
@@ -114,20 +114,20 @@ module Synvert::Core
|
|
114
114
|
replace_with 'create {{arguments}}'
|
115
115
|
end
|
116
116
|
end
|
117
|
-
input = "
|
117
|
+
input = "
|
118
118
|
it 'uses factory_girl' do
|
119
119
|
user = FactoryGirl.create :user
|
120
120
|
post = FactoryGirl.create :post, user: user
|
121
121
|
assert post.valid?
|
122
122
|
end
|
123
|
-
"
|
124
|
-
output = "
|
123
|
+
"
|
124
|
+
output = "
|
125
125
|
it 'uses factory_girl' do
|
126
126
|
user = create :user
|
127
127
|
post = create :post, user: user
|
128
128
|
assert post.valid?
|
129
129
|
end
|
130
|
-
"
|
130
|
+
"
|
131
131
|
expect(Dir).to receive(:glob).with('./spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb'])
|
132
132
|
expect(File).to receive(:read).with('spec/models/post_spec.rb').and_return(input)
|
133
133
|
expect(File).to receive(:write).with('spec/models/post_spec.rb', output)
|
@@ -142,16 +142,16 @@ end
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|
145
|
-
input = "
|
145
|
+
input = "
|
146
146
|
RSpec.configure do |config|
|
147
147
|
config.include FactoryGirl::Syntax::Methods
|
148
148
|
end
|
149
|
-
"
|
150
|
-
output = "
|
149
|
+
"
|
150
|
+
output = "
|
151
151
|
RSpec.configure do |config|
|
152
152
|
config.include FactoryGirl::Syntax::Methods
|
153
153
|
end
|
154
|
-
"
|
154
|
+
"
|
155
155
|
expect(Dir).to receive(:glob).with('./spec/spec_helper.rb').and_return(['spec/spec_helper.rb'])
|
156
156
|
expect(File).to receive(:read).with('spec/spec_helper.rb').and_return(input)
|
157
157
|
expect(File).not_to receive(:write).with('spec/spec_helper.rb', output)
|
@@ -166,16 +166,16 @@ end
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
end
|
169
|
-
input = "
|
169
|
+
input = "
|
170
170
|
RSpec.configure do |config|
|
171
171
|
config.include FactoryGirl::Syntax::Methods
|
172
172
|
end
|
173
|
-
"
|
174
|
-
output = "
|
173
|
+
"
|
174
|
+
output = "
|
175
175
|
RSpec.configure do |config|
|
176
176
|
config.include FactoryGirl::Syntax::Methods
|
177
177
|
end
|
178
|
-
"
|
178
|
+
"
|
179
179
|
expect(Dir).to receive(:glob).with('./spec/spec_helper.rb').and_return(['spec/spec_helper.rb']).twice
|
180
180
|
expect(File).to receive(:read).with('spec/spec_helper.rb').and_return(input).once
|
181
181
|
expect(File).not_to receive(:write).with('spec/spec_helper.rb', output)
|
@@ -189,20 +189,20 @@ end
|
|
189
189
|
replace_with 'create {{arguments}}'
|
190
190
|
end
|
191
191
|
end
|
192
|
-
input = "
|
192
|
+
input = "
|
193
193
|
it 'uses factory_girl' do
|
194
194
|
user = FactoryGirl.create :user
|
195
195
|
post = FactoryGirl.create :post, user: user
|
196
196
|
assert post.valid?
|
197
197
|
end
|
198
|
-
"
|
199
|
-
output = "
|
198
|
+
"
|
199
|
+
output = "
|
200
200
|
it 'uses factory_girl' do
|
201
201
|
user = create :user
|
202
202
|
post = create :post, user: user
|
203
203
|
assert post.valid?
|
204
204
|
end
|
205
|
-
"
|
205
|
+
"
|
206
206
|
expect(Dir).to receive(:glob).with('./spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb']).twice
|
207
207
|
expect(File).to receive(:read).with('spec/models/post_spec.rb').and_return(input)
|
208
208
|
expect(File).to receive(:write).with('spec/models/post_spec.rb', output)
|
@@ -8,13 +8,13 @@ module Synvert::Core
|
|
8
8
|
rewriter = Rewriter.new('foo', 'bar')
|
9
9
|
Rewriter::Instance.new(rewriter, 'file pattern')
|
10
10
|
}
|
11
|
-
let(:source) {"
|
11
|
+
let(:source) {"
|
12
12
|
describe Post do
|
13
13
|
it 'gets post' do
|
14
14
|
FactoryGirl.create :post
|
15
15
|
end
|
16
16
|
end
|
17
|
-
"
|
17
|
+
"
|
18
18
|
}
|
19
19
|
let(:node) { Parser::CurrentRuby.parse(source) }
|
20
20
|
before do
|
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.17.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-01-
|
11
|
+
date: 2021-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|