defmastership 1.0.10 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/defmastership.gemspec +1 -1
- data/features/changeref.feature +33 -0
- data/features/export.feature +21 -0
- data/features/rename_included_files.feature +4 -0
- data/lib/defmastership.rb +1 -0
- data/lib/defmastership/change_ref_line_modifier.rb +6 -10
- data/lib/defmastership/comment_filter.rb +1 -34
- data/lib/defmastership/constants.rb +3 -6
- data/lib/defmastership/definition.rb +1 -1
- data/lib/defmastership/document.rb +4 -7
- data/lib/defmastership/filters.rb +0 -7
- data/lib/defmastership/parsing_state.rb +23 -0
- data/lib/defmastership/rename_included_files_line_modifier.rb +1 -1
- data/lib/defmastership/version.rb +1 -1
- data/spec/unit/defmastership/change_ref_line_modifier_spec.rb +15 -0
- data/spec/unit/defmastership/comment_filter_spec.rb +5 -119
- data/spec/unit/defmastership/parsing_state_spec.rb +48 -0
- data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +8 -8
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 615339b09506e076db9c98a773e115daaa9914bafebef1029af8c4c9e8266dc0
|
4
|
+
data.tar.gz: 14b7cf352d495dc847cdd9fbdfff6abd821ebc0e6a8f6f2334ecb16c7bc87de2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebd3eb769920a15442d8a048e55b5fb124aa4a5c2916a85378d5d9f07c20b29b160c94b12e783d5d4a4f89f9aa5d80342065d533b66c6972de74eb1adaecbc59
|
7
|
+
data.tar.gz: ad72f426a240eda86b517a9d5e7bd8f28cc037acef3a7a391880a2e9c4e4432309a962b810086aed081c97bdc63a2fd4709dd4de261828e520bd93649b7cb55e
|
data/.rubocop.yml
CHANGED
data/defmastership.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.add_development_dependency('rake', '~> 13')
|
35
35
|
s.add_development_dependency('rdoc', '~> 6')
|
36
36
|
s.add_development_dependency('rspec', '~> 3')
|
37
|
-
s.add_development_dependency('rubocop', '
|
37
|
+
s.add_development_dependency('rubocop', '1.13')
|
38
38
|
s.add_development_dependency('rubocop-rake', '~> 0.5')
|
39
39
|
s.add_development_dependency('rubocop-rspec', '~> 2.0')
|
40
40
|
s.add_development_dependency('simplecov', '~> 0')
|
data/features/changeref.feature
CHANGED
@@ -36,6 +36,39 @@ Feature: The changeref command
|
|
36
36
|
[define, requirement, TOTO-0123]
|
37
37
|
"""
|
38
38
|
|
39
|
+
Scenario: Change a definition with explicit checksum and version
|
40
|
+
Given a file named "modifications.yml" with:
|
41
|
+
"""
|
42
|
+
---
|
43
|
+
:toto:
|
44
|
+
:type: change_ref
|
45
|
+
:config:
|
46
|
+
:from_regexp: TOTO-TEMP-[X\d]{4}
|
47
|
+
:to_template: TOTO-%<next_ref>04d
|
48
|
+
:next_ref: 123
|
49
|
+
"""
|
50
|
+
And a file named "thedoc.adoc" with:
|
51
|
+
"""
|
52
|
+
[define, requirement, TOTO-TEMP-XXX1(a~12345678)]
|
53
|
+
"""
|
54
|
+
When I successfully run `defmastership modify --modifications toto thedoc.adoc`
|
55
|
+
Then the stdout should not contain anything
|
56
|
+
And the stderr should not contain anything
|
57
|
+
And the file "modifications.yml" should contain:
|
58
|
+
"""
|
59
|
+
---
|
60
|
+
:toto:
|
61
|
+
:type: change_ref
|
62
|
+
:config:
|
63
|
+
:from_regexp: TOTO-TEMP-[X\d]{4}
|
64
|
+
:to_template: TOTO-%<next_ref>04d
|
65
|
+
:next_ref: 124
|
66
|
+
"""
|
67
|
+
And the file "thedoc.adoc" should contain:
|
68
|
+
"""
|
69
|
+
[define, requirement, TOTO-0123(a~12345678)]
|
70
|
+
"""
|
71
|
+
|
39
72
|
Scenario: Change two definitions
|
40
73
|
Given a file named "modifications.yml" with:
|
41
74
|
"""
|
data/features/export.feature
CHANGED
@@ -116,6 +116,27 @@ Feature: The extract command
|
|
116
116
|
And the stdout should not contain anything
|
117
117
|
And the stderr should not contain anything
|
118
118
|
|
119
|
+
Scenario: Ignore definitions in example block
|
120
|
+
Given a file named "toto.adoc" with:
|
121
|
+
"""
|
122
|
+
[define, requirement, TOTO-0001]
|
123
|
+
--
|
124
|
+
Exemple of multiline requirement.
|
125
|
+
Second line.
|
126
|
+
--
|
127
|
+
----
|
128
|
+
[define, something_else, TOTO-0003]
|
129
|
+
only one line
|
130
|
+
----
|
131
|
+
"""
|
132
|
+
When I successfully run `defmastership export toto.adoc`
|
133
|
+
Then the file "toto.csv" should contain:
|
134
|
+
"""
|
135
|
+
something_else
|
136
|
+
"""
|
137
|
+
And the stdout should not contain anything
|
138
|
+
And the stderr should not contain anything
|
139
|
+
|
119
140
|
Scenario: Ignore definitions in commment block
|
120
141
|
Given a file named "toto.adoc" with:
|
121
142
|
"""
|
@@ -73,7 +73,9 @@ Feature: The rename_included_files command
|
|
73
73
|
:any: one
|
74
74
|
:path: two
|
75
75
|
[define, requirement, TOTO-WHATEVER-123]
|
76
|
+
--
|
76
77
|
include::{any}_{path}/one_file.png[]
|
78
|
+
--
|
77
79
|
"""
|
78
80
|
And a directory named "one_two"
|
79
81
|
And an empty file named "one_two/one_file.png"
|
@@ -85,7 +87,9 @@ Feature: The rename_included_files command
|
|
85
87
|
:any: one
|
86
88
|
:path: two
|
87
89
|
[define, requirement, TOTO-WHATEVER-123]
|
90
|
+
--
|
88
91
|
include::{any}_{path}/TOTO-WHATEVER-123_one_file.png[]
|
92
|
+
--
|
89
93
|
"""
|
90
94
|
And the file "one_two/one_file.png" should not exist
|
91
95
|
And the file "one_two/TOTO-WHATEVER-123_one_file.png" should exist
|
data/lib/defmastership.rb
CHANGED
@@ -6,6 +6,7 @@ require('defmastership/version')
|
|
6
6
|
# Add requires for other files you add to your project here, so
|
7
7
|
# you just need to require this one file in your bin file
|
8
8
|
require('defmastership/constants')
|
9
|
+
require('defmastership/parsing_state')
|
9
10
|
require('defmastership/definition')
|
10
11
|
require('defmastership/definition_parser')
|
11
12
|
require('defmastership/filters')
|
@@ -28,7 +28,7 @@ module DefMastership
|
|
28
28
|
to_template: '',
|
29
29
|
next_ref: 0
|
30
30
|
}
|
31
|
-
@
|
31
|
+
@parsing_state = ParsingState.new
|
32
32
|
end
|
33
33
|
|
34
34
|
def replace(method, line)
|
@@ -36,10 +36,10 @@ module DefMastership
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def replace_refdef(line)
|
39
|
-
if
|
40
|
-
line
|
41
|
-
else
|
39
|
+
if @parsing_state.enabled?(line)
|
42
40
|
do_replace_refdef(line)
|
41
|
+
else
|
42
|
+
line
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -66,21 +66,17 @@ module DefMastership
|
|
66
66
|
regexp_str =
|
67
67
|
"(?<before>#{REGEXP_FROM[const][:before]})" \
|
68
68
|
"(?<from>#{from})" \
|
69
|
+
"#{DMRegexp::DEF_VERSION_AND_CHECKSUM}" \
|
69
70
|
"(?<after>#{REGEXP_FROM[const][:after]})"
|
70
71
|
Regexp.new(regexp_str, Regexp::EXTENDED)
|
71
72
|
end
|
72
73
|
|
73
74
|
def text_with(match, replacement)
|
74
|
-
match[:before] + replacement + match[:after]
|
75
|
+
match[:before] + replacement + (match[:version_and_checksum] || '') + match[:after]
|
75
76
|
end
|
76
77
|
|
77
78
|
def hmerge(match)
|
78
79
|
@config.merge(match.names.map(&:to_sym).zip(match.captures).to_h)
|
79
80
|
end
|
80
|
-
|
81
|
-
def in_literal(line)
|
82
|
-
@in_literal ^= true if line.chomp == '....'
|
83
|
-
@in_literal
|
84
|
-
end
|
85
81
|
end
|
86
82
|
end
|
@@ -1,43 +1,10 @@
|
|
1
1
|
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Add a class to handled asciidoctor comments
|
5
|
-
module DefMastership
|
6
|
-
attr_reader :comment_filter
|
7
|
-
|
8
|
-
# Kind of proxy that Filters comments fome Asciidoctor document
|
9
|
-
class CommentFilter
|
10
|
-
def initialize
|
11
|
-
@in_multiline_comment = false
|
12
|
-
end
|
13
|
-
|
14
|
-
def accept?(line)
|
15
|
-
case line
|
16
|
-
when DMRegexp::SINGLE_LINE_COMMENT then false
|
17
|
-
when DMRegexp::MULTI_LINE_COMMENT_DELIM
|
18
|
-
@in_multiline_comment ^= true
|
19
|
-
false
|
20
|
-
else !@in_multiline_comment
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
@comment_filter = CommentFilter.new
|
26
|
-
|
27
|
-
def self.reset_comments
|
28
|
-
@comment_filter = CommentFilter.new
|
29
|
-
nil
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.comment_filter
|
33
|
-
@comment_filter
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
4
|
# adding a method to string to figure out if a string is commented or
|
38
5
|
# not.
|
39
6
|
class String
|
40
7
|
def commented?
|
41
|
-
!DefMastership.
|
8
|
+
!match(DefMastership::DMRegexp::SINGLE_LINE_COMMENT).nil?
|
42
9
|
end
|
43
10
|
end
|
@@ -6,8 +6,6 @@ module DefMastership
|
|
6
6
|
module DMRegexp
|
7
7
|
SINGLE_LINE_COMMENT = %r{^//[^/]}.freeze
|
8
8
|
|
9
|
-
MULTI_LINE_COMMENT_DELIM = %r{^////\s*$}.freeze
|
10
|
-
|
11
9
|
DEF_BEFORE_REF = <<~'BEF'
|
12
10
|
^\s*
|
13
11
|
\[\s*define\s*,
|
@@ -20,7 +18,9 @@ module DefMastership
|
|
20
18
|
(,\s*\[\s*(?<labels>.*?)\s*\])?\s*\]
|
21
19
|
AFT
|
22
20
|
|
23
|
-
DEF_VERSION_AND_CHECKSUM = '(
|
21
|
+
DEF_VERSION_AND_CHECKSUM = '(?<version_and_checksum>' \
|
22
|
+
'\((?<explicit_version>[^~]+)?(?<explicit_checksum>~[[:alnum:]]+)?\)' \
|
23
|
+
')?'
|
24
24
|
|
25
25
|
DEFINITION = Regexp.new(
|
26
26
|
"#{DEF_BEFORE_REF}(?<reference>[\\w:_-]+)#{DEF_VERSION_AND_CHECKSUM}#{DEF_AFTER_REF}",
|
@@ -39,7 +39,6 @@ module DefMastership
|
|
39
39
|
\s*(?<refname>[\w:_-]+)\s*,
|
40
40
|
\s*\[(?<extrefs>[^\]]+)\]\s*\]/x.freeze
|
41
41
|
BLOCK = /^--\s*$/.freeze
|
42
|
-
LITERAL_BLOCK = /^\.\.\.\.\s*$/.freeze
|
43
42
|
|
44
43
|
IREF_DEF_BEF = 'defs:iref\[\s*'
|
45
44
|
IREF_DEF_AFT = '\s*\]'
|
@@ -70,7 +69,6 @@ module DefMastership
|
|
70
69
|
)
|
71
70
|
|
72
71
|
public_constant :SINGLE_LINE_COMMENT,
|
73
|
-
:MULTI_LINE_COMMENT_DELIM,
|
74
72
|
:DEF_BEFORE_REF,
|
75
73
|
:DEF_AFTER_REF,
|
76
74
|
:DEFINITION,
|
@@ -79,7 +77,6 @@ module DefMastership
|
|
79
77
|
:EREF_CONFIG,
|
80
78
|
:EREF_DEF,
|
81
79
|
:BLOCK,
|
82
|
-
:LITERAL_BLOCK,
|
83
80
|
:IREF_DEF_BEF,
|
84
81
|
:IREF_DEF_AFT,
|
85
82
|
:IREF_DEF,
|
@@ -16,14 +16,16 @@ module DefMastership
|
|
16
16
|
@eref = {}
|
17
17
|
@iref = false
|
18
18
|
@attributes = {}
|
19
|
-
@in_literal = true
|
20
19
|
@variables = {}
|
20
|
+
@parsing_state = ParsingState.new
|
21
21
|
@definition_parser = DefinitionParser.new(self)
|
22
22
|
end
|
23
23
|
|
24
24
|
def parse(lines)
|
25
25
|
lines.reject(&:commented?).each do |line|
|
26
|
-
|
26
|
+
next unless @parsing_state.enabled?(line)
|
27
|
+
|
28
|
+
FILTERS.each do |filter|
|
27
29
|
next unless line.match(filter.regexp)
|
28
30
|
|
29
31
|
line = generate_event(filter.event, Regexp.last_match, line)
|
@@ -49,11 +51,6 @@ module DefMastership
|
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
|
-
def code_block_delimiter(_match, line)
|
53
|
-
@in_literal ^= true
|
54
|
-
line
|
55
|
-
end
|
56
|
-
|
57
54
|
def add_new_definition(match, line)
|
58
55
|
definition = Definition.new(match)
|
59
56
|
@labels.merge(definition.labels)
|
@@ -6,12 +6,6 @@ module DefMastership
|
|
6
6
|
Filter = Struct.new(:regexp, :event, :consumed_line)
|
7
7
|
private_constant :Filter
|
8
8
|
|
9
|
-
FILTERS_IN_LITERAL = [
|
10
|
-
Filter.new(DMRegexp::LITERAL_BLOCK, :code_block_delimiter, false),
|
11
|
-
Filter.new(DMRegexp::WHATEVER, :new_line, true)
|
12
|
-
].freeze
|
13
|
-
private_constant :FILTERS_IN_LITERAL
|
14
|
-
|
15
9
|
FILTERS = [
|
16
10
|
Filter.new(DMRegexp::VARIABLE_DEF, :new_variable_def, false),
|
17
11
|
Filter.new(DMRegexp::VARIABLE_USE, :new_variable_use, false),
|
@@ -22,7 +16,6 @@ module DefMastership
|
|
22
16
|
Filter.new(DMRegexp::ATTR_CONFIG, :new_attribute_conf, true),
|
23
17
|
Filter.new(DMRegexp::ATTR_SET, :new_attribute_value, false),
|
24
18
|
Filter.new(DMRegexp::BLOCK, :block_delimiter, true),
|
25
|
-
Filter.new(DMRegexp::LITERAL_BLOCK, :code_block_delimiter, true),
|
26
19
|
Filter.new(DMRegexp::EMPTY_LINE, :empty_line, false),
|
27
20
|
Filter.new(DMRegexp::WHATEVER, :new_line, true)
|
28
21
|
].freeze
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module DefMastership
|
5
|
+
# Allow to know if we need to parse the line or simply ignore it
|
6
|
+
class ParsingState
|
7
|
+
def initialize
|
8
|
+
@last_disabling_line = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def enabled?(line)
|
12
|
+
line = line.dup.chomp
|
13
|
+
if ['....', '////'].include?(line)
|
14
|
+
if @last_disabling_line == line
|
15
|
+
@last_disabling_line = nil
|
16
|
+
elsif @last_disabling_line.nil?
|
17
|
+
@last_disabling_line = line
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@last_disabling_line.nil?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -217,6 +217,21 @@ RSpec.describe(DefMastership::ChangeRefLineModifier) do
|
|
217
217
|
.to(eq('[define, whatever, TUTU]'))
|
218
218
|
end
|
219
219
|
|
220
|
+
it do
|
221
|
+
expect(refchanger.replace(:refdef, '[define, whatever, TEMP(a~12345678)]'))
|
222
|
+
.to(eq('[define, whatever, TUTU(a~12345678)]'))
|
223
|
+
end
|
224
|
+
|
225
|
+
it do
|
226
|
+
expect(refchanger.replace(:refdef, '[define, whatever, TEMP(~12345678)]'))
|
227
|
+
.to(eq('[define, whatever, TUTU(~12345678)]'))
|
228
|
+
end
|
229
|
+
|
230
|
+
it do
|
231
|
+
expect(refchanger.replace(:refdef, '[define, whatever, TEMP(a)]'))
|
232
|
+
.to(eq('[define, whatever, TUTU(a)]'))
|
233
|
+
end
|
234
|
+
|
220
235
|
it do
|
221
236
|
refchanger.replace(:refdef, '[define, whatever, TEMP]')
|
222
237
|
expect(refchanger.replace(:irefs, 'defs:iref[TEMP]'))
|
@@ -3,124 +3,10 @@
|
|
3
3
|
|
4
4
|
require('defmastership')
|
5
5
|
|
6
|
-
RSpec.describe(
|
7
|
-
|
8
|
-
it {
|
9
|
-
|
10
|
-
|
11
|
-
describe '#accept?' do
|
12
|
-
subject(:comment_filter) { described_class.new }
|
13
|
-
|
14
|
-
context 'when no comment' do
|
15
|
-
it do
|
16
|
-
expect(comment_filter.accept?('whatever')).to(be(true))
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'when single line comment' do
|
21
|
-
it do
|
22
|
-
expect(comment_filter.accept?('// whatever')).to(be(false))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when bat formated single line comment' do
|
27
|
-
it do
|
28
|
-
expect(comment_filter.accept?('///')).to(be(true))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'when starting multiline comment' do
|
33
|
-
it do
|
34
|
-
expect(comment_filter.accept?('////')).to(be(false))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when multiline comment' do
|
39
|
-
before do
|
40
|
-
comment_filter.accept?('////')
|
41
|
-
end
|
42
|
-
|
43
|
-
it do
|
44
|
-
expect(comment_filter.accept?('whatever')).to(be(false))
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when exiting multiline comment' do
|
49
|
-
before do
|
50
|
-
comment_filter.accept?('////')
|
51
|
-
comment_filter.accept?('something')
|
52
|
-
end
|
53
|
-
|
54
|
-
it do
|
55
|
-
expect(comment_filter.accept?('////')).to(be(false))
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'when end of multiline comment' do
|
60
|
-
before do
|
61
|
-
comment_filter.accept?('////')
|
62
|
-
comment_filter.accept?('something')
|
63
|
-
comment_filter.accept?('////')
|
64
|
-
end
|
65
|
-
|
66
|
-
it do
|
67
|
-
expect(comment_filter.accept?('whatever')).to(be(true))
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'String .commented?' do
|
73
|
-
let(:comment_filter) do
|
74
|
-
instance_double(described_class, 'comment_filter')
|
75
|
-
end
|
76
|
-
|
77
|
-
before do
|
78
|
-
allow(DefMastership).to(
|
79
|
-
receive(:comment_filter)
|
80
|
-
.and_return(comment_filter)
|
81
|
-
)
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'when not .commented?' do
|
85
|
-
before do
|
86
|
-
allow(comment_filter).to(receive(:accept?).with('blabla').and_return(true))
|
87
|
-
'blabla'.commented?
|
88
|
-
end
|
89
|
-
|
90
|
-
it { expect(DefMastership).to(have_received(:comment_filter)) }
|
91
|
-
|
92
|
-
it { expect(comment_filter).to(have_received(:accept?).with('blabla')) }
|
93
|
-
|
94
|
-
it { expect('blabla'.commented?).to(be(false)) }
|
95
|
-
end
|
96
|
-
|
97
|
-
context 'when .commented?' do
|
98
|
-
before do
|
99
|
-
allow(comment_filter).to(
|
100
|
-
receive(:accept?)
|
101
|
-
.with('blabla').and_return(false)
|
102
|
-
)
|
103
|
-
end
|
104
|
-
|
105
|
-
it do
|
106
|
-
expect('blabla'.commented?).to(be(true))
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe '#reset_comments' do
|
112
|
-
before do
|
113
|
-
'////'.commented?
|
114
|
-
end
|
115
|
-
|
116
|
-
it do
|
117
|
-
expect('whatever'.commented?).to(be(true))
|
118
|
-
end
|
119
|
-
|
120
|
-
it do
|
121
|
-
'////'.commented?
|
122
|
-
DefMastership.reset_comments
|
123
|
-
expect('whatever'.commented?).to(be(false))
|
124
|
-
end
|
6
|
+
RSpec.describe(String) do
|
7
|
+
context 'when .commented?' do
|
8
|
+
it { expect('blabla'.commented?).to(be(false)) }
|
9
|
+
it { expect('//blabla'.commented?).to(be(true)) }
|
10
|
+
it { expect('///blabla'.commented?).to(be(false)) }
|
125
11
|
end
|
126
12
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require('defmastership')
|
5
|
+
|
6
|
+
RSpec.describe(DefMastership::ParsingState) do
|
7
|
+
subject(:parsing_state) do
|
8
|
+
described_class.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.new' do
|
12
|
+
it { is_expected.not_to(be(nil)) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#enabled_with?' do
|
16
|
+
context 'when starting' do
|
17
|
+
it { expect(parsing_state.enabled?("whatever\n")).to(eq(true)) }
|
18
|
+
it { expect(parsing_state.enabled?("....\n")).to(eq(false)) }
|
19
|
+
it { expect(parsing_state.enabled?("////\n")).to(eq(false)) }
|
20
|
+
it { expect(parsing_state.enabled?('....')).to(eq(false)) }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when disabled' do
|
24
|
+
before { parsing_state.enabled?("....\n") }
|
25
|
+
|
26
|
+
it { expect(parsing_state.enabled?("whatever\n")).to(eq(false)) }
|
27
|
+
it { expect(parsing_state.enabled?("////\n")).to(eq(false)) }
|
28
|
+
it { expect(parsing_state.enabled?("....\n")).to(eq(true)) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with intricated disables starting with "...."' do
|
32
|
+
before do
|
33
|
+
["....\n", "////\n", "whatever\n"].each { |line| parsing_state.enabled?(line) }
|
34
|
+
end
|
35
|
+
|
36
|
+
it { expect(parsing_state.enabled?("----\n")).to(eq(false)) }
|
37
|
+
it { expect(parsing_state.enabled?("....\n")).to(eq(true)) }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with intricated disables starting with "////"' do
|
41
|
+
before do
|
42
|
+
["////\n", "....\n", "whatever\n"].each { |line| parsing_state.enabled?(line) }
|
43
|
+
end
|
44
|
+
|
45
|
+
it { expect(parsing_state.enabled?("////\n")).to(eq(true)) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -110,32 +110,32 @@ RSpec.describe(DefMastership::RenameIncludedFilesLineModifier) do
|
|
110
110
|
end
|
111
111
|
|
112
112
|
it do
|
113
|
-
expect(includeschanger.replace(
|
114
|
-
.to(eq(
|
113
|
+
expect(includeschanger.replace("include::orig[]\n"))
|
114
|
+
.to(eq("include::dest[]\n"))
|
115
115
|
end
|
116
116
|
|
117
117
|
it do
|
118
|
-
includeschanger.replace(
|
118
|
+
includeschanger.replace("include::orig[]\n")
|
119
119
|
expect(File).to(have_received(:rename).with('orig', 'dest'))
|
120
120
|
end
|
121
121
|
|
122
122
|
it do
|
123
|
-
includeschanger.replace(
|
123
|
+
includeschanger.replace("include::orig[]\n")
|
124
124
|
expect(includeschanger).to(have_attributes(changes: [%w[orig dest]]))
|
125
125
|
end
|
126
126
|
|
127
127
|
it do
|
128
|
-
expect(includeschanger.replace(
|
129
|
-
.to(eq(
|
128
|
+
expect(includeschanger.replace("include::toto/orig[]\n"))
|
129
|
+
.to(eq("include::toto/dest[]\n"))
|
130
130
|
end
|
131
131
|
|
132
132
|
it do
|
133
|
-
includeschanger.replace(
|
133
|
+
includeschanger.replace("include::toto/orig[]\n")
|
134
134
|
expect(File).to(have_received(:rename).with('toto/orig', 'toto/dest'))
|
135
135
|
end
|
136
136
|
|
137
137
|
it do
|
138
|
-
includeschanger.replace(
|
138
|
+
includeschanger.replace("include::toto/orig[]\n")
|
139
139
|
expect(includeschanger).to(have_attributes(changes: [%w[toto/orig toto/dest]]))
|
140
140
|
end
|
141
141
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defmastership
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jérôme Arbez-Gindre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aruba
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.13'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.13'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop-rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/defmastership/filters.rb
|
217
217
|
- lib/defmastership/line_modifier_base.rb
|
218
218
|
- lib/defmastership/modifier_base.rb
|
219
|
+
- lib/defmastership/parsing_state.rb
|
219
220
|
- lib/defmastership/rename_included_files_line_modifier.rb
|
220
221
|
- lib/defmastership/rename_included_files_modifier.rb
|
221
222
|
- lib/defmastership/update_def_checksum_line_modifier.rb
|
@@ -234,6 +235,7 @@ files:
|
|
234
235
|
- spec/unit/defmastership/definition_parser_spec.rb
|
235
236
|
- spec/unit/defmastership/definition_spec.rb
|
236
237
|
- spec/unit/defmastership/document_spec.rb
|
238
|
+
- spec/unit/defmastership/parsing_state_spec.rb
|
237
239
|
- spec/unit/defmastership/rename_included_files_line_modifier_spec.rb
|
238
240
|
- spec/unit/defmastership/rename_included_files_modifier_spec.rb
|
239
241
|
- spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb
|