defmastership 1.0.16 → 1.0.18
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/.gitignore +1 -0
- data/.gitlab-ci.yml +50 -7
- data/.rubocop.yml +14 -6
- data/Gemfile +51 -1
- data/Rakefile +16 -47
- data/bin/defmastership +12 -9
- data/config/mutant.yml +23 -3
- data/defmastership.gemspec +22 -27
- data/features/definition_checksum.feature +31 -1
- data/features/export.feature +43 -1
- data/features/rename_included_files.feature +28 -0
- data/lib/defmastership/batch_modifier.rb +17 -12
- data/lib/defmastership/change_ref_modifier.rb +89 -5
- data/lib/defmastership/comment_filter.rb +1 -1
- data/lib/defmastership/constants.rb +5 -4
- data/lib/defmastership/csv_formatter.rb +20 -16
- data/lib/defmastership/csv_formatter_body.rb +18 -15
- data/lib/defmastership/csv_formatter_header.rb +1 -1
- data/lib/defmastership/definition.rb +58 -19
- data/lib/defmastership/document.rb +109 -74
- data/lib/defmastership/matching_line.rb +17 -0
- data/lib/defmastership/modifier.rb +42 -0
- data/lib/defmastership/modifier_factory.rb +12 -0
- data/lib/defmastership/parsing_state.rb +15 -9
- data/lib/defmastership/rename_included_files_modifier.rb +172 -5
- data/lib/defmastership/set_join_hack.rb +11 -0
- data/lib/defmastership/update_def_checksum_modifier.rb +8 -13
- data/lib/defmastership/update_def_modifier.rb +49 -0
- data/lib/defmastership/update_def_version_modifier.rb +56 -15
- data/lib/defmastership/version.rb +1 -1
- data/lib/defmastership.rb +7 -17
- data/spec/spec_helper.rb +4 -2
- data/spec/unit/{defmastership → def_mastership}/batch_modifier_spec.rb +42 -39
- data/spec/unit/{defmastership/change_ref_line_modifier_spec.rb → def_mastership/change_ref_modifier_spec.rb} +44 -66
- data/spec/unit/{defmastership → def_mastership}/csv_formatter_body_spec.rb +61 -32
- data/spec/unit/{defmastership → def_mastership}/csv_formatter_header_spec.rb +2 -2
- data/spec/unit/{defmastership → def_mastership}/csv_formatter_spec.rb +81 -86
- data/spec/unit/{defmastership → def_mastership}/definition_parser_spec.rb +2 -2
- data/spec/unit/{defmastership → def_mastership}/definition_spec.rb +17 -7
- data/spec/unit/{defmastership → def_mastership}/document_spec.rb +108 -53
- data/spec/unit/def_mastership/matching_line_spec.rb +37 -0
- data/spec/unit/def_mastership/modifier_factory_spec.rb +37 -0
- data/spec/unit/def_mastership/modifier_spec.rb +83 -0
- data/spec/unit/{defmastership → def_mastership}/parsing_state_spec.rb +16 -16
- data/spec/unit/{defmastership/rename_included_files_line_modifier_spec.rb → def_mastership/rename_included_files_modifier_spec.rb} +72 -36
- data/spec/unit/{defmastership/comment_filter_spec.rb → def_mastership/string_spec.rb} +1 -1
- data/spec/unit/def_mastership/update_def_checksum_modifier_spec.rb +107 -0
- data/spec/unit/def_mastership/update_def_modifier_spec.rb +119 -0
- data/spec/unit/def_mastership/update_def_version_modifier_spec.rb +159 -0
- data/spec/unit/{defmastership_spec.rb → def_mastership_spec.rb} +1 -1
- data/tasks/console.rake +8 -0
- data/tasks/package.task +9 -0
- data/tasks/smelling_code.rake +38 -0
- data/tasks/test.rake +45 -0
- metadata +37 -145
- data/lib/defmastership/change_ref_line_modifier.rb +0 -82
- data/lib/defmastership/line_modifier_base.rb +0 -29
- data/lib/defmastership/modifier_base.rb +0 -29
- data/lib/defmastership/rename_included_files_line_modifier.rb +0 -126
- data/lib/defmastership/update_def_checksum_line_modifier.rb +0 -38
- data/lib/defmastership/update_def_version_line_modifier.rb +0 -58
- data/spec/unit/defmastership/change_ref_modifier_spec.rb +0 -76
- data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +0 -67
- data/spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb +0 -78
- data/spec/unit/defmastership/update_def_checksum_modifier_spec.rb +0 -75
- data/spec/unit/defmastership/update_def_version_line_modifier_spec.rb +0 -127
- data/spec/unit/defmastership/update_def_version_modifier_spec.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 995e93909012fff3a4dcbeb55605d6e8754e24c3868f63d3000ed1c6674809c7
|
4
|
+
data.tar.gz: 94ae5225d555eb837017ebe243a69bfec21feb0882d14a3329b48f2b016c1ba2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48169bb5cfc6bea00209d60619cace40a45471e2ff6c2b2543cd8846ca001daac2e6a865c18cf20b95ed5e6102b36328302d91b577a69952acf7e3bc0d79c209
|
7
|
+
data.tar.gz: 00265e2ed2fc50f527ffba937dd2dae5d3d9f2189c2ada4b451f2504dbfdb96efffa73e1b8e18981055ea43c45458bc9df93479630ec014f2e9ec7b8bafd5cc5
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
default:
|
2
|
-
image: ruby:2
|
2
|
+
image: ruby:3.2
|
3
3
|
before_script:
|
4
4
|
- apt-get update
|
5
5
|
- ruby -v
|
@@ -7,14 +7,57 @@ default:
|
|
7
7
|
- gem install bundler --no-document
|
8
8
|
- bundle install --jobs $(nproc) "${FLAGS[@]}"
|
9
9
|
|
10
|
-
|
10
|
+
bdd:
|
11
11
|
script:
|
12
|
-
- bundle exec rake features
|
12
|
+
- bundle exec rake test:features
|
13
13
|
|
14
|
-
|
14
|
+
unit tests:
|
15
15
|
script:
|
16
|
-
- bundle exec rake spec
|
16
|
+
- bundle exec rake test:spec
|
17
17
|
|
18
|
-
|
18
|
+
code_quality:
|
19
19
|
script:
|
20
|
-
- bundle exec rake
|
20
|
+
- bundle exec rake quality:all
|
21
|
+
|
22
|
+
bdd ruby2.7:
|
23
|
+
image: ruby:2.7
|
24
|
+
before_script:
|
25
|
+
- apt-get update
|
26
|
+
- ruby -v
|
27
|
+
- which ruby
|
28
|
+
- gem install bundler -v 2.4.22 --no-document
|
29
|
+
- bundle install --jobs $(nproc) "${FLAGS[@]}"
|
30
|
+
script:
|
31
|
+
- bundle exec rake test:features
|
32
|
+
|
33
|
+
bdd ruby3.0:
|
34
|
+
image: ruby:3.0
|
35
|
+
script:
|
36
|
+
- bundle exec rake test:features
|
37
|
+
|
38
|
+
bdd ruby3.1:
|
39
|
+
image: ruby:3.1
|
40
|
+
script:
|
41
|
+
- bundle exec rake test:features
|
42
|
+
|
43
|
+
unit tests ruby2.7:
|
44
|
+
image: ruby:2.7
|
45
|
+
before_script:
|
46
|
+
- apt-get update
|
47
|
+
- ruby -v
|
48
|
+
- which ruby
|
49
|
+
- gem install bundler -v 2.4.22 --no-document
|
50
|
+
- bundle install --jobs $(nproc) "${FLAGS[@]}"
|
51
|
+
script:
|
52
|
+
- bundle exec rake test:spec
|
53
|
+
|
54
|
+
unit tests ruby3.0:
|
55
|
+
image: ruby:3.0
|
56
|
+
script:
|
57
|
+
- bundle exec rake test:spec
|
58
|
+
|
59
|
+
unit tests ruby3.1:
|
60
|
+
image: ruby:3.1
|
61
|
+
script:
|
62
|
+
- bundle exec rake test:spec
|
63
|
+
|
data/.rubocop.yml
CHANGED
@@ -10,17 +10,19 @@
|
|
10
10
|
# See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
|
11
11
|
|
12
12
|
require:
|
13
|
+
- rubocop-performance
|
13
14
|
- rubocop-rspec
|
15
|
+
- rubocop-rake
|
14
16
|
|
15
17
|
AllCops:
|
16
|
-
TargetRubyVersion: 2.
|
18
|
+
TargetRubyVersion: 2.7
|
17
19
|
EnabledByDefault: true
|
18
20
|
DisplayCopNames: true
|
19
21
|
|
20
22
|
Style/Copyright:
|
21
23
|
Enabled: true
|
22
24
|
Notice: 'Copyright (\(c\) )?202[0-9] Jerome Arbez-Gindre'
|
23
|
-
AutocorrectNotice: '# Copyright (c)
|
25
|
+
AutocorrectNotice: '# Copyright (c) 2023 Jerome Arbez-Gindre'
|
24
26
|
|
25
27
|
Lint/ConstantResolution: # Not available ins rubocop 0.81
|
26
28
|
Enabled: false
|
@@ -29,7 +31,10 @@ Style/DocumentationMethod:
|
|
29
31
|
Enabled: false
|
30
32
|
|
31
33
|
Style/StringHashKeys :
|
32
|
-
Enabled:
|
34
|
+
Enabled: true
|
35
|
+
Exclude:
|
36
|
+
- '*.gemspec'
|
37
|
+
- 'spec/**/*'
|
33
38
|
|
34
39
|
Style/MissingElse:
|
35
40
|
EnforcedStyle: case
|
@@ -55,14 +60,17 @@ Style/ConstantVisibility :
|
|
55
60
|
|
56
61
|
# rubocop-rspec options
|
57
62
|
RSpec/MessageExpectation :
|
58
|
-
Enabled:
|
63
|
+
Enabled: true
|
59
64
|
|
60
65
|
RSpec/FilePath :
|
61
|
-
Enabled:
|
66
|
+
Enabled: true
|
62
67
|
|
63
68
|
RSpec/NestedGroups:
|
64
69
|
Max: 4
|
65
70
|
|
66
71
|
Layout/RedundantLineBreak:
|
67
72
|
Enabled: false
|
68
|
-
|
73
|
+
|
74
|
+
Layout/EndOfLine:
|
75
|
+
EnforcedStyle: lf
|
76
|
+
|
data/Gemfile
CHANGED
@@ -1,5 +1,55 @@
|
|
1
1
|
# Copyright (c) 2020 Jerome Arbez-Gindre
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
source
|
4
|
+
source 'https://rubygems.org'
|
5
|
+
|
5
6
|
gemspec
|
7
|
+
|
8
|
+
ruby RUBY_VERSION
|
9
|
+
|
10
|
+
group :development do
|
11
|
+
# cucumber steps for command line tests
|
12
|
+
gem 'aruba', '~> 2.2'
|
13
|
+
# bdd
|
14
|
+
gem 'cucumber', '~> 9.1'
|
15
|
+
|
16
|
+
if RUBY_VERSION >= '3.0'
|
17
|
+
# mutation testing
|
18
|
+
plan = 'oss'
|
19
|
+
key = '7oac4dMz95cTUuFPtGDfTDSQep6ZhdGW'
|
20
|
+
source "https://#{plan}:#{key}@gem.mutant.dev" do
|
21
|
+
# license needed
|
22
|
+
gem 'mutant-license', '~> 0.1.1'
|
23
|
+
end
|
24
|
+
# mutation testing
|
25
|
+
gem 'mutant-rspec', '~> 0.11'
|
26
|
+
end
|
27
|
+
|
28
|
+
# to parse and execute Rakefile
|
29
|
+
gem 'rake', '~> 13.1'
|
30
|
+
# tdd
|
31
|
+
gem 'rspec', '~> 3.13'
|
32
|
+
# # to test performances
|
33
|
+
# gem 'rspec-benchmark', '~> 0.6.0'
|
34
|
+
# code needs to be clean
|
35
|
+
gem 'rubocop', '~> 1.62.0'
|
36
|
+
# code needs to be clean
|
37
|
+
gem 'rubocop-performance', '~> 1.20.0'
|
38
|
+
# test code needs to be clean
|
39
|
+
gem 'rubocop-rspec', '~> 2.27.0'
|
40
|
+
# Rakefiels need to be clean
|
41
|
+
gem 'rubocop-rake', '~> 0.6'
|
42
|
+
if RUBY_VERSION >= '3.0'
|
43
|
+
# detect selling code
|
44
|
+
gem 'reek', '~> 6.3'
|
45
|
+
end
|
46
|
+
# What is tdd without code coverage ?
|
47
|
+
gem 'simplecov', '~> 0.22', '< 0.23'
|
48
|
+
# # to document code
|
49
|
+
# gem 'yard', '~> 0.9.5'
|
50
|
+
end
|
51
|
+
|
52
|
+
group :debugging do
|
53
|
+
# Sometimes, we need to debug
|
54
|
+
gem 'pry', '~> 0.14.0'
|
55
|
+
end
|
data/Rakefile
CHANGED
@@ -1,53 +1,22 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2023 Jerome Arbez-Gindre
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
require('bundler/gem_tasks')
|
4
5
|
require('rake/clean')
|
5
|
-
require('rubygems')
|
6
|
-
require('rubygems/package_task')
|
7
|
-
require('rdoc/task')
|
8
|
-
require('cucumber')
|
9
|
-
require('cucumber/rake/task')
|
10
|
-
|
11
|
-
Rake::RDocTask.new do |rd|
|
12
|
-
rd.main = 'README.rdoc'
|
13
|
-
rd.rdoc_files.include('README.rdoc', 'lib/**/*.rb', 'bin/**/*')
|
14
|
-
rd.title = 'Your application title'
|
15
|
-
end
|
16
|
-
|
17
|
-
spec = eval(::File.read('defmastership.gemspec'))
|
18
|
-
|
19
|
-
Gem::PackageTask.new(spec)
|
20
|
-
CUKE_RESULTS = 'features_results.html'
|
21
|
-
CLEAN << CUKE_RESULTS
|
22
|
-
|
23
|
-
desc('Run features')
|
24
|
-
::Cucumber::Rake::Task.new(:features) do |t|
|
25
|
-
opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
|
26
|
-
opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
|
27
|
-
t.cucumber_opts = opts
|
28
|
-
t.fork = false
|
29
|
-
end
|
30
6
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
7
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
8
|
+
|
9
|
+
desc 'Continous integration tasks'
|
10
|
+
task :ci do
|
11
|
+
[
|
12
|
+
'test:spec',
|
13
|
+
'test:features',
|
14
|
+
:rubocop
|
15
|
+
].each do |name|
|
16
|
+
puts "\n=== Running #{name}...\n"
|
17
|
+
Rake::Task[name].invoke
|
18
|
+
puts "\n=== Running #{name} -> Done\n"
|
19
|
+
end
|
38
20
|
end
|
39
21
|
|
40
|
-
task
|
41
|
-
task(wip: 'features:wip')
|
42
|
-
|
43
|
-
require('bundler/gem_tasks')
|
44
|
-
|
45
|
-
require('rspec/core/rake_task')
|
46
|
-
|
47
|
-
::RSpec::Core::RakeTask.new(:spec)
|
48
|
-
|
49
|
-
require('rubocop/rake_task')
|
50
|
-
|
51
|
-
::RuboCop::RakeTask.new
|
52
|
-
|
53
|
-
task(default: %i[spec features rubocop])
|
22
|
+
task default: :ci
|
data/bin/defmastership
CHANGED
@@ -55,9 +55,9 @@ module DefMastership
|
|
55
55
|
|
56
56
|
c.action do |_global_options, options, args|
|
57
57
|
my_doc = DefMastership::Document.new
|
58
|
-
my_doc.parse_file_with_preprocessor(args
|
58
|
+
my_doc.parse_file_with_preprocessor(args.first)
|
59
59
|
|
60
|
-
output_file = args
|
60
|
+
output_file = args.first.sub(/\.adoc$/, '.csv')
|
61
61
|
|
62
62
|
DefMastership::CSVFormatter.new(my_doc, options['separator']).export_to(output_file)
|
63
63
|
|
@@ -65,9 +65,12 @@ module DefMastership
|
|
65
65
|
my_doc.definitions.each do |definition|
|
66
66
|
next if definition.wrong_explicit_checksum.nil?
|
67
67
|
|
68
|
-
warn(
|
68
|
+
warn(
|
69
|
+
"warning: #{definition.reference} has a wrong explicit " \
|
70
|
+
"checksum (should be #{definition.sha256_short})"
|
71
|
+
)
|
69
72
|
end
|
70
|
-
exit 1 unless options[:
|
73
|
+
exit 1 unless options[:'no-fail']
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|
@@ -87,16 +90,16 @@ module DefMastership
|
|
87
90
|
c.action do |_global_options, options, args|
|
88
91
|
changer = BatchModifier.new(
|
89
92
|
YAML.load_file(options[:'modifications-file']),
|
90
|
-
args.
|
93
|
+
args.to_h { |afile| [afile, File.read(afile)] }
|
91
94
|
)
|
92
95
|
|
93
|
-
changer.apply(options[:modifications])
|
96
|
+
changer.apply(options[:modifications].split(/\s*,\s*/).map(&:to_sym))
|
94
97
|
|
95
|
-
changer.
|
96
|
-
File.
|
98
|
+
changer.adoc_sources.each do |adoc_filename, adoc_text|
|
99
|
+
File.write(adoc_filename, adoc_text)
|
97
100
|
end
|
98
101
|
|
99
|
-
File.
|
102
|
+
File.write(options[:'modifications-file'], changer.config.to_yaml)
|
100
103
|
|
101
104
|
unless options['changes-summary'].nil?
|
102
105
|
CSV.open(options['changes-summary'], 'wb') do |csv|
|
data/config/mutant.yml
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
---
|
2
2
|
includes:
|
3
|
-
- lib
|
4
|
-
integration:
|
3
|
+
- lib
|
4
|
+
integration:
|
5
|
+
name: rspec
|
5
6
|
requires:
|
6
|
-
-
|
7
|
+
- defmastership
|
8
|
+
matcher:
|
9
|
+
subjects:
|
10
|
+
- 'DefMastership*'
|
11
|
+
# ignore:
|
12
|
+
# - 'DefMastership::BatchModifier*'
|
13
|
+
# - 'DefMastership::CSVFormatter*'
|
14
|
+
# - 'DefMastership::CSVFormatterBody*'
|
15
|
+
# - 'DefMastership::CSVFormatterHeader*'
|
16
|
+
# - 'DefMastership::ChangeRefModifier*'
|
17
|
+
# - 'DefMastership::Definition*'
|
18
|
+
# - 'DefMastership::Document*'
|
19
|
+
# - 'DefMastership::Modifier*'
|
20
|
+
# - 'DefMastership::ModifierFactory*'
|
21
|
+
# - 'DefMastership::ParsingState*'
|
22
|
+
# - 'DefMastership::RenameIncludedFilesModifier*'
|
23
|
+
# - 'DefMastership::UpdateDefChecksumModifier*'
|
24
|
+
# - 'DefMastership::UpdateDefModifier*'
|
25
|
+
# - 'DefMastership::UpdateDefVersionModifier*'
|
26
|
+
# fail_fast: true
|
data/defmastership.gemspec
CHANGED
@@ -14,31 +14,26 @@ require(
|
|
14
14
|
)
|
15
15
|
)
|
16
16
|
|
17
|
-
Gem::Specification.new do |
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
s.add_development_dependency('rubocop-rspec', '~> 2.0')
|
40
|
-
s.add_development_dependency('simplecov', '~> 0')
|
41
|
-
s.add_runtime_dependency('aasm', '~> 5')
|
42
|
-
s.add_runtime_dependency('asciidoctor', '~> 2')
|
43
|
-
s.add_runtime_dependency('gli', '~> 2')
|
17
|
+
Gem::Specification.new do |spec|
|
18
|
+
spec.metadata = {
|
19
|
+
'rubygems_mfa_required' => 'true'
|
20
|
+
}
|
21
|
+
spec.required_ruby_version = '>= 2.7'
|
22
|
+
spec.name = 'defmastership'
|
23
|
+
spec.version = DefMastership::VERSION
|
24
|
+
spec.author = 'Jérôme Arbez-Gindre'
|
25
|
+
spec.email = 'jeromearbezgindre@gmail.com'
|
26
|
+
spec.licenses = ['MIT']
|
27
|
+
spec.homepage = 'https://gitlab.com/jjag/defmastership/'
|
28
|
+
spec.platform = Gem::Platform::RUBY
|
29
|
+
spec.summary = 'Handling of references and definitions with asciidoctor'
|
30
|
+
spec.files = `git ls-files`.split("\n")
|
31
|
+
spec.require_paths << 'lib'
|
32
|
+
spec.extra_rdoc_files = ['README.rdoc', 'defmastership.rdoc']
|
33
|
+
spec.rdoc_options << '--title defmastership' << '--main README.rdoc' << '-ri'
|
34
|
+
spec.bindir = 'bin'
|
35
|
+
spec.executables << 'defmastership'
|
36
|
+
spec.add_runtime_dependency('aasm', '~> 5')
|
37
|
+
spec.add_runtime_dependency('asciidoctor', '~> 2')
|
38
|
+
spec.add_runtime_dependency('gli', '~> 2')
|
44
39
|
end
|
@@ -213,7 +213,7 @@ Feature: definition checksum
|
|
213
213
|
And the stdout should not contain anything
|
214
214
|
And the stderr should not contain anything
|
215
215
|
|
216
|
-
Scenario: Checksum
|
216
|
+
Scenario: Checksum takes into account variables in ref modification
|
217
217
|
Given a file named "modifications.yml" with:
|
218
218
|
"""
|
219
219
|
---
|
@@ -243,6 +243,36 @@ Feature: definition checksum
|
|
243
243
|
And the stdout should not contain anything
|
244
244
|
And the stderr should not contain anything
|
245
245
|
|
246
|
+
Scenario: Checksum does not take into account bad variables definition
|
247
|
+
Given a file named "modifications.yml" with:
|
248
|
+
"""
|
249
|
+
---
|
250
|
+
:update_requirement_checksum:
|
251
|
+
:type: update_def_checksum
|
252
|
+
:config:
|
253
|
+
:def_type: requirement
|
254
|
+
"""
|
255
|
+
And a file named "thedoc.adoc" with:
|
256
|
+
"""
|
257
|
+
:variable:multiline
|
258
|
+
[define, requirement, TOTO-0001]
|
259
|
+
--
|
260
|
+
Exemple of {variable} requirement.
|
261
|
+
Second line.
|
262
|
+
--
|
263
|
+
"""
|
264
|
+
When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
|
265
|
+
Then the file "thedoc.adoc" should contain:
|
266
|
+
"""
|
267
|
+
[define, requirement, TOTO-0001(~2e7dd73e)]
|
268
|
+
--
|
269
|
+
Exemple of {variable} requirement.
|
270
|
+
Second line.
|
271
|
+
--
|
272
|
+
"""
|
273
|
+
And the stdout should not contain anything
|
274
|
+
And the stderr should not contain anything
|
275
|
+
|
246
276
|
Scenario: Checksum keep explicit version in ref modification
|
247
277
|
Given a file named "modifications.yml" with:
|
248
278
|
"""
|
data/features/export.feature
CHANGED
@@ -201,7 +201,7 @@ Feature: The extract command
|
|
201
201
|
And the stdout should not contain anything
|
202
202
|
And the stderr should not contain anything
|
203
203
|
|
204
|
-
Scenario: Extract one definition with external ref to CSV
|
204
|
+
Scenario: Extract one definition with external ref to CSV
|
205
205
|
Given a file named "toto.adoc" with:
|
206
206
|
"""
|
207
207
|
:eref-implements-prefix: Participate to:
|
@@ -224,6 +224,27 @@ Feature: The extract command
|
|
224
224
|
And the stdout should not contain anything
|
225
225
|
And the stderr should not contain anything
|
226
226
|
|
227
|
+
Scenario: Extract one definition with missing external ref to CSV
|
228
|
+
Given a file named "toto.adoc" with:
|
229
|
+
"""
|
230
|
+
:eref-implements-prefix: Participate to:
|
231
|
+
:eref-implements-url: ./the_other_document.html
|
232
|
+
[define, requirement, TOTO-0001]
|
233
|
+
--
|
234
|
+
Exemple of multiline requirement.
|
235
|
+
Second line.
|
236
|
+
--
|
237
|
+
"""
|
238
|
+
When I successfully run `defmastership export toto.adoc`
|
239
|
+
Then the file "toto.csv" should contain:
|
240
|
+
"""
|
241
|
+
Type,Reference,Value,Checksum,Participate to:
|
242
|
+
requirement,TOTO-0001,"Exemple of multiline requirement.
|
243
|
+
Second line.",~b86dcbde,
|
244
|
+
"""
|
245
|
+
And the stdout should not contain anything
|
246
|
+
And the stderr should not contain anything
|
247
|
+
|
227
248
|
Scenario: Extract one definition with external ref without url to CSV
|
228
249
|
Given a file named "toto.adoc" with:
|
229
250
|
"""
|
@@ -313,6 +334,27 @@ Feature: The extract command
|
|
313
334
|
And the stdout should not contain anything
|
314
335
|
And the stderr should not contain anything
|
315
336
|
|
337
|
+
Scenario: Extract one definition with missing attributes to CSV
|
338
|
+
Given a file named "toto.adoc" with:
|
339
|
+
"""
|
340
|
+
:attr-verifiedby-prefix: Verified by:
|
341
|
+
:attr-criticity-prefix: Criticity:
|
342
|
+
[define, requirement, TOTO-0001]
|
343
|
+
One single line.
|
344
|
+
|
345
|
+
something else.
|
346
|
+
defs:attribute[verifiedby, Beautiful Test]
|
347
|
+
"""
|
348
|
+
When I successfully run `defmastership export toto.adoc`
|
349
|
+
And the stdout should not contain anything
|
350
|
+
Then the file "toto.csv" should contain:
|
351
|
+
"""
|
352
|
+
Type,Reference,Value,Checksum,Verified by:,Criticity:
|
353
|
+
requirement,TOTO-0001,One single line.,~554b0ff5,Beautiful Test,
|
354
|
+
"""
|
355
|
+
And the stdout should not contain anything
|
356
|
+
And the stderr should not contain anything
|
357
|
+
|
316
358
|
Scenario: Extract one definition with example in it
|
317
359
|
Given a file named "toto.adoc" with:
|
318
360
|
"""
|
@@ -58,6 +58,34 @@ Feature: The rename_included_files command
|
|
58
58
|
And the file "any_path/one_file.png" should not exist
|
59
59
|
And the file "any_path/TOTO-WHATEVER-123_one_file.png" should exist
|
60
60
|
|
61
|
+
Scenario: change the filename with options in include macro
|
62
|
+
Given a file named "modifications.yml" with:
|
63
|
+
"""
|
64
|
+
---
|
65
|
+
:rename_included_png:
|
66
|
+
:type: rename_included_files
|
67
|
+
:config:
|
68
|
+
:from_regexp: (?<origin>.*\.png)
|
69
|
+
:to_template: "%<reference>s_%<origin>s"
|
70
|
+
"""
|
71
|
+
And a file named "thedoc.adoc" with:
|
72
|
+
"""
|
73
|
+
[define, requirement, TOTO-WHATEVER-123]
|
74
|
+
include::any_path/one_file.png[leveloffset=offset,lines=ranges]
|
75
|
+
"""
|
76
|
+
And a directory named "any_path"
|
77
|
+
And an empty file named "any_path/one_file.png"
|
78
|
+
When I successfully run `defmastership modify --modifications rename_included_png thedoc.adoc`
|
79
|
+
Then the stdout should not contain anything
|
80
|
+
And the stderr should not contain anything
|
81
|
+
And the file "thedoc.adoc" should contain:
|
82
|
+
"""
|
83
|
+
[define, requirement, TOTO-WHATEVER-123]
|
84
|
+
include::any_path/TOTO-WHATEVER-123_one_file.png[leveloffset=offset,lines=ranges]
|
85
|
+
"""
|
86
|
+
And the file "any_path/one_file.png" should not exist
|
87
|
+
And the file "any_path/TOTO-WHATEVER-123_one_file.png" should exist
|
88
|
+
|
61
89
|
Scenario: change the filename with variable in path
|
62
90
|
Given a file named "modifications.yml" with:
|
63
91
|
"""
|
@@ -4,32 +4,37 @@
|
|
4
4
|
module DefMastership
|
5
5
|
# Change references from temporary to definitive with multiple RefChangers
|
6
6
|
class BatchModifier
|
7
|
-
attr_reader :config, :
|
7
|
+
attr_reader :config, :adoc_sources, :changes
|
8
8
|
|
9
|
-
def initialize(config,
|
9
|
+
def initialize(config, adoc_sources)
|
10
10
|
@config = config
|
11
|
-
@
|
11
|
+
@adoc_sources = adoc_sources
|
12
12
|
@changes = []
|
13
13
|
end
|
14
14
|
|
15
15
|
def apply(modifs)
|
16
|
-
modifs.
|
16
|
+
modifs.each do |modif|
|
17
17
|
modifier = modifier_from(modif)
|
18
|
-
@
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
@adoc_sources = modifier.do_modifications(adoc_sources)
|
19
|
+
config.fetch(modif)[:config] = modifier.config
|
20
|
+
|
21
|
+
collect_changes(modifier, modif)
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
25
|
private
|
27
26
|
|
28
27
|
def modifier_from(modif)
|
29
|
-
|
28
|
+
config_modif_sym = config[modif]
|
29
|
+
raise(ArgumentError, "#{modif} is not a known modification") unless config_modif_sym
|
30
|
+
|
31
|
+
ModifierFactory.from_config(config_modif_sym)
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
def collect_changes(modifier, modif)
|
35
|
+
modifier.changes.reduce(changes) do |acc, change|
|
36
|
+
acc << ([modif.to_s] + change)
|
37
|
+
end
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|