defmastership 1.0.15 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitlab-ci.yml +34 -3
  4. data/.rubocop.yml +14 -6
  5. data/Rakefile +29 -15
  6. data/bin/defmastership +4 -4
  7. data/defmastership.gemspec +32 -27
  8. data/features/export.feature +70 -1
  9. data/lib/defmastership/batch_modifier.rb +1 -1
  10. data/lib/defmastership/change_ref_line_modifier.rb +3 -0
  11. data/lib/defmastership/change_ref_modifier.rb +2 -0
  12. data/lib/defmastership/csv_formatter.rb +4 -4
  13. data/lib/defmastership/document.rb +15 -9
  14. data/lib/defmastership/modifier_base.rb +10 -3
  15. data/lib/defmastership/parsing_state.rb +3 -1
  16. data/lib/defmastership/version.rb +1 -1
  17. data/lib/defmastership.rb +11 -16
  18. data/spec/spec_helper.rb +2 -2
  19. data/spec/unit/{defmastership → def_mastership}/batch_modifier_spec.rb +5 -4
  20. data/spec/unit/{defmastership → def_mastership}/change_ref_line_modifier_spec.rb +11 -4
  21. data/spec/unit/{defmastership → def_mastership}/change_ref_modifier_spec.rb +1 -1
  22. data/spec/unit/{defmastership → def_mastership}/csv_formatter_body_spec.rb +1 -1
  23. data/spec/unit/{defmastership → def_mastership}/csv_formatter_header_spec.rb +1 -1
  24. data/spec/unit/{defmastership → def_mastership}/csv_formatter_spec.rb +11 -8
  25. data/spec/unit/{defmastership → def_mastership}/definition_parser_spec.rb +1 -1
  26. data/spec/unit/{defmastership → def_mastership}/definition_spec.rb +1 -1
  27. data/spec/unit/{defmastership → def_mastership}/document_spec.rb +99 -44
  28. data/spec/unit/def_mastership/parsing_state_spec.rb +62 -0
  29. data/spec/unit/{defmastership → def_mastership}/rename_included_files_line_modifier_spec.rb +7 -3
  30. data/spec/unit/{defmastership → def_mastership}/rename_included_files_modifier_spec.rb +1 -1
  31. data/spec/unit/{defmastership → def_mastership}/update_def_checksum_line_modifier_spec.rb +7 -3
  32. data/spec/unit/{defmastership → def_mastership}/update_def_checksum_modifier_spec.rb +1 -1
  33. data/spec/unit/{defmastership → def_mastership}/update_def_version_line_modifier_spec.rb +7 -3
  34. data/spec/unit/{defmastership → def_mastership}/update_def_version_modifier_spec.rb +3 -3
  35. data/spec/unit/{defmastership_spec.rb → def_mastership_spec.rb} +1 -1
  36. metadata +64 -35
  37. data/spec/unit/defmastership/parsing_state_spec.rb +0 -48
  38. /data/spec/unit/{defmastership/comment_filter_spec.rb → def_mastership/string_spec.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 615339b09506e076db9c98a773e115daaa9914bafebef1029af8c4c9e8266dc0
4
- data.tar.gz: 14b7cf352d495dc847cdd9fbdfff6abd821ebc0e6a8f6f2334ecb16c7bc87de2
3
+ metadata.gz: 29225577d47450033d4ea2c9715ab51cb2025318ff26da38435c11900ff0cb52
4
+ data.tar.gz: a36cb1eb3b8c45cb14b74200d43163edd1907bcfe7ed2a54d15f4f1ebd341454
5
5
  SHA512:
6
- metadata.gz: ebd3eb769920a15442d8a048e55b5fb124aa4a5c2916a85378d5d9f07c20b29b160c94b12e783d5d4a4f89f9aa5d80342065d533b66c6972de74eb1adaecbc59
7
- data.tar.gz: ad72f426a240eda86b517a9d5e7bd8f28cc037acef3a7a391880a2e9c4e4432309a962b810086aed081c97bdc63a2fd4709dd4de261828e520bd93649b7cb55e
6
+ metadata.gz: bb97db7204c4665f53c5f57e03737e31a88373a928ce4157f912938b84feff1b3b7f260365fa210bab905b47eb87c336e259e91d1a77d73ace80e84f8152d464
7
+ data.tar.gz: 4c359dbf1017c365d9c00faf7617233e3793093dba327d39982cebd7dabd68a7b5af0a999568c91775cd16a2a8af9cc544a67fdf3acedf92d65120269c372d18
data/.gitignore CHANGED
@@ -4,3 +4,4 @@
4
4
  defmastership-0.0.1.gem
5
5
  /Gemfile.lock
6
6
  /pkg/
7
+ /.ruby-version
data/.gitlab-ci.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  default:
2
- image: ruby:2.5
2
+ image: ruby:3.2
3
3
  before_script:
4
4
  - apt-get update
5
5
  - ruby -v
@@ -7,14 +7,45 @@ default:
7
7
  - gem install bundler --no-document
8
8
  - bundle install --jobs $(nproc) "${FLAGS[@]}"
9
9
 
10
- cucumber:
10
+ bdd:
11
11
  script:
12
12
  - bundle exec rake features
13
13
 
14
- rspec:
14
+ unit tests:
15
15
  script:
16
16
  - bundle exec rake spec
17
17
 
18
18
  rubocop:
19
19
  script:
20
20
  - bundle exec rake rubocop
21
+
22
+ bdd ruby2.7:
23
+ image: ruby:2.7
24
+ script:
25
+ - bundle exec rake features
26
+
27
+ bdd ruby3.0:
28
+ image: ruby:3.0
29
+ script:
30
+ - bundle exec rake features
31
+
32
+ bdd ruby3.1:
33
+ image: ruby:3.1
34
+ script:
35
+ - bundle exec rake features
36
+
37
+ unit tests ruby2.7:
38
+ image: ruby:2.7
39
+ script:
40
+ - bundle exec rake spec
41
+
42
+ unit tests ruby3.0:
43
+ image: ruby:3.0
44
+ script:
45
+ - bundle exec rake spec
46
+
47
+ unit tests ruby3.1:
48
+ image: ruby:3.1
49
+ script:
50
+ - bundle exec rake spec
51
+
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.5
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) 2020 Jerome Arbez-Gindre'
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: false
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: false
63
+ Enabled: true
59
64
 
60
65
  RSpec/FilePath :
61
- Enabled: false
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/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
+ require('cucumber')
5
+ require('cucumber/rake/task')
4
6
  require('rake/clean')
7
+ require('rdoc/task')
5
8
  require('rubygems')
6
9
  require('rubygems/package_task')
7
- require('rdoc/task')
8
- require('cucumber')
9
- require('cucumber/rake/task')
10
10
 
11
11
  Rake::RDocTask.new do |rd|
12
12
  rd.main = 'README.rdoc'
@@ -14,40 +14,54 @@ Rake::RDocTask.new do |rd|
14
14
  rd.title = 'Your application title'
15
15
  end
16
16
 
17
- spec = eval(::File.read('defmastership.gemspec'))
17
+ spec = eval(File.read('defmastership.gemspec'))
18
18
 
19
19
  Gem::PackageTask.new(spec)
20
20
  CUKE_RESULTS = 'features_results.html'
21
21
  CLEAN << CUKE_RESULTS
22
22
 
23
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']
24
+ Cucumber::Rake::Task.new(:features) do |t|
25
+ opts = ['features'] +
26
+ ['--format', 'html'] +
27
+ ['-o', CUKE_RESULTS] +
28
+ ['--format', 'progress'] +
29
+ ['-x']
30
+ opts += ['--tags', ENV.fetch('TAGS').split.join(' or ')] if ENV['TAGS']
27
31
  t.cucumber_opts = opts
28
32
  t.fork = false
29
33
  end
30
34
 
31
35
  desc('Run features tagged as work-in-progress (@wip)')
32
- ::Cucumber::Rake::Task.new('features:wip') do |t|
33
- tag_opts = ' --tags ~@pending' \
34
- ' --tags @wip'
35
- t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} "\
36
- "--format pretty -x -s#{tag_opts}"
36
+ Cucumber::Rake::Task.new('features:wip') do |t|
37
+ t.cucumber_opts = ['features'] +
38
+ ['--format', 'html'] +
39
+ ['-o', CUKE_RESULTS] +
40
+ ['--format', 'pretty'] +
41
+ ['-x'] +
42
+ ['-s'] +
43
+ ['--tags', '@wip and not @pending']
37
44
  t.fork = false
38
45
  end
39
46
 
47
+ desc('Test all features')
40
48
  task(cucumber: :features)
49
+
50
+ desc('Test only WIP features')
41
51
  task(wip: 'features:wip')
42
52
 
43
53
  require('bundler/gem_tasks')
44
54
 
45
55
  require('rspec/core/rake_task')
46
56
 
47
- ::RSpec::Core::RakeTask.new(:spec)
57
+ RSpec::Core::RakeTask.new(:spec)
48
58
 
49
59
  require('rubocop/rake_task')
50
60
 
51
- ::RuboCop::RakeTask.new
61
+ RuboCop::RakeTask.new do |task|
62
+ task.requires << 'rubocop-performance'
63
+ task.requires << 'rubocop-rspec'
64
+ task.requires << 'rubocop-rake'
65
+ end
52
66
 
53
- task(default: %i[spec features rubocop])
67
+ task(default: %i[rubocop spec features])
data/bin/defmastership CHANGED
@@ -67,7 +67,7 @@ module DefMastership
67
67
 
68
68
  warn("warning: #{definition.reference} has a wrong explicit checksum (should be #{definition.sha256})")
69
69
  end
70
- exit 1 unless options[:"no-fail"]
70
+ exit 1 unless options[:'no-fail']
71
71
  end
72
72
  end
73
73
  end
@@ -87,16 +87,16 @@ module DefMastership
87
87
  c.action do |_global_options, options, args|
88
88
  changer = BatchModifier.new(
89
89
  YAML.load_file(options[:'modifications-file']),
90
- args.map { |afile| [afile, File.open(afile).read] }.to_h
90
+ args.to_h { |afile| [afile, File.read(afile)] }
91
91
  )
92
92
 
93
93
  changer.apply(options[:modifications])
94
94
 
95
95
  changer.adoc_texts.each do |adoc_file, adoc_text|
96
- File.open(adoc_file, 'w') { |f| f.write(adoc_text) }
96
+ File.write(adoc_file, adoc_text)
97
97
  end
98
98
 
99
- File.open(options[:'modifications-file'], 'w') { |f| f.write(changer.config.to_yaml) }
99
+ File.write(options[:'modifications-file'], changer.config.to_yaml)
100
100
 
101
101
  unless options['changes-summary'].nil?
102
102
  CSV.open(options['changes-summary'], 'wb') do |csv|
@@ -14,31 +14,36 @@ require(
14
14
  )
15
15
  )
16
16
 
17
- Gem::Specification.new do |s|
18
- s.required_ruby_version = '>= 2.5'
19
- s.name = 'defmastership'
20
- s.version = DefMastership::VERSION
21
- s.author = 'Jérôme Arbez-Gindre'
22
- s.email = 'jeromearbezgindre@gmail.com'
23
- s.licenses = ['MIT']
24
- s.homepage = 'https://gitlab.com/jjag/defmastership/'
25
- s.platform = Gem::Platform::RUBY
26
- s.summary = 'Handling of references and definitions with asciidoctor'
27
- s.files = `git ls-files`.split("\n")
28
- s.require_paths << 'lib'
29
- s.extra_rdoc_files = ['README.rdoc', 'defmastership.rdoc']
30
- s.rdoc_options << '--title defmastership' << '--main README.rdoc' << '-ri'
31
- s.bindir = 'bin'
32
- s.executables << 'defmastership'
33
- s.add_development_dependency('aruba', '~> 1')
34
- s.add_development_dependency('rake', '~> 13')
35
- s.add_development_dependency('rdoc', '~> 6')
36
- s.add_development_dependency('rspec', '~> 3')
37
- s.add_development_dependency('rubocop', '1.13')
38
- s.add_development_dependency('rubocop-rake', '~> 0.5')
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_development_dependency('aruba', '~> 2')
37
+ spec.add_development_dependency('cucumber', '~> 8')
38
+ spec.add_development_dependency('rake', '~> 13')
39
+ spec.add_development_dependency('rdoc', '~> 6')
40
+ spec.add_development_dependency('rspec', '~> 3')
41
+ spec.add_development_dependency('rubocop', '1.50')
42
+ spec.add_development_dependency('rubocop-performance', '~> 1.17')
43
+ spec.add_development_dependency('rubocop-rake', '~> 0.6')
44
+ spec.add_development_dependency('rubocop-rspec', '~> 2.22')
45
+ spec.add_development_dependency('simplecov', '~> 0')
46
+ spec.add_runtime_dependency('aasm', '~> 5')
47
+ spec.add_runtime_dependency('asciidoctor', '~> 2')
48
+ spec.add_runtime_dependency('gli', '~> 2')
44
49
  end
@@ -130,7 +130,7 @@ Feature: The extract command
130
130
  ----
131
131
  """
132
132
  When I successfully run `defmastership export toto.adoc`
133
- Then the file "toto.csv" should contain:
133
+ Then the file "toto.csv" should not contain:
134
134
  """
135
135
  something_else
136
136
  """
@@ -312,3 +312,72 @@ Feature: The extract command
312
312
  """
313
313
  And the stdout should not contain anything
314
314
  And the stderr should not contain anything
315
+
316
+ Scenario: Extract one definition with example in it
317
+ Given a file named "toto.adoc" with:
318
+ """
319
+ [define, requirement, TOTO-0001]
320
+ --
321
+ [example]
322
+ ----
323
+ [define, requirement, TOTO-002]
324
+ not a real definition
325
+ ----
326
+ --
327
+ """
328
+ When I successfully run `defmastership export toto.adoc`
329
+ Then the file "toto.csv" should contain:
330
+ """
331
+ Type,Reference,Value,Checksum
332
+ requirement,TOTO-0001,"[example]
333
+ ----
334
+ [define, requirement, TOTO-002]
335
+ not a real definition
336
+ ----",~8f20a443
337
+ """
338
+ And the stdout should not contain anything
339
+ And the stderr should not contain anything
340
+
341
+ Scenario: Extract one definition with single line comment in it
342
+ Given a file named "toto.adoc" with:
343
+ """
344
+ [define, requirement, TOTO-0001]
345
+ --
346
+ // comment
347
+ --
348
+ """
349
+ When I successfully run `defmastership export toto.adoc`
350
+ Then the file "toto.csv" should contain:
351
+ """
352
+ Type,Reference,Value,Checksum
353
+ requirement,TOTO-0001,// comment,~b0b506c3
354
+ """
355
+ And the stdout should not contain anything
356
+ And the stderr should not contain anything
357
+
358
+ Scenario: Extract one definition with multi line comment or literal in it
359
+ Given a file named "toto.adoc" with:
360
+ """
361
+ [define, requirement, TOTO-0001]
362
+ --
363
+ ////
364
+ multiline comment
365
+ ////
366
+ ....
367
+ literal
368
+ ....
369
+ --
370
+ """
371
+ When I successfully run `defmastership export toto.adoc`
372
+ Then the file "toto.csv" should contain:
373
+ """
374
+ Type,Reference,Value,Checksum
375
+ requirement,TOTO-0001,"////
376
+ multiline comment
377
+ ////
378
+ ....
379
+ literal
380
+ ....",~7eb3c490
381
+ """
382
+ And the stdout should not contain anything
383
+ And the stderr should not contain anything
@@ -18,7 +18,7 @@ module DefMastership
18
18
  @adoc_texts = modifier.do_modifications(@adoc_texts)
19
19
  @config[modif.to_sym][:config] = modifier.config
20
20
  modifier.changes.each do |change|
21
- @changes << [modif] + change
21
+ @changes << ([modif] + change)
22
22
  end
23
23
  end
24
24
  end
@@ -1,6 +1,9 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'defmastership/constants'
5
+ require 'defmastership/line_modifier_base'
6
+
4
7
  module DefMastership
5
8
  # Change references from temporary to definitive with multiple RefChangers
6
9
  class ChangeRefLineModifier < LineModifierBase
@@ -1,6 +1,8 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'defmastership/modifier_base'
5
+
4
6
  module DefMastership
5
7
  # Change all refs of a given project
6
8
  class ChangeRefModifier < ModifierBase
@@ -2,8 +2,8 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require('csv')
5
- require('defmastership/csv_formatter_header')
6
5
  require('defmastership/csv_formatter_body')
6
+ require('defmastership/csv_formatter_header')
7
7
 
8
8
  module DefMastership
9
9
  # to export a CSV file
@@ -15,7 +15,7 @@ module DefMastership
15
15
 
16
16
  def export_to(output_file)
17
17
  column_list = build_column_list
18
- CSV.open(output_file, 'w:ISO-8859-1', { col_sep: @sep }) do |csv|
18
+ CSV.open(output_file, 'w:ISO-8859-1', col_sep: @sep) do |csv|
19
19
  csv << header(column_list)
20
20
  @doc.definitions.each { |definition| csv << body(definition, column_list) }
21
21
  end
@@ -26,13 +26,13 @@ module DefMastership
26
26
  def header(column_list)
27
27
  header_formatter = CSVFormatterHeader.new(@doc)
28
28
  header_line = column_list.map { |part| header_formatter.public_send(part) }
29
- header_line.reduce(:+)
29
+ header_line.flatten
30
30
  end
31
31
 
32
32
  def body(definition, column_list)
33
33
  body_formatter = CSVFormatterBody.new(@doc)
34
34
  body_line = column_list.map { |part| body_formatter.public_send(part, definition) }
35
- body_line.reduce(:+)
35
+ body_line.flatten
36
36
  end
37
37
 
38
38
  def build_column_list
@@ -22,15 +22,11 @@ module DefMastership
22
22
  end
23
23
 
24
24
  def parse(lines)
25
- lines.reject(&:commented?).each do |line|
26
- next unless @parsing_state.enabled?(line)
27
-
28
- FILTERS.each do |filter|
29
- next unless line.match(filter.regexp)
30
-
31
- line = generate_event(filter.event, Regexp.last_match, line)
32
-
33
- break if filter.consumed_line
25
+ lines.each do |line|
26
+ if @parsing_state.enabled?(line)
27
+ apply_filters(line)
28
+ else
29
+ generate_event(:new_line, nil, line)
34
30
  end
35
31
  end
36
32
  end
@@ -113,6 +109,16 @@ module DefMastership
113
109
 
114
110
  private
115
111
 
112
+ def apply_filters(line)
113
+ FILTERS.each do |filter|
114
+ next unless line.match(filter.regexp)
115
+
116
+ line = generate_event(filter.event, Regexp.last_match, line)
117
+
118
+ break if filter.consumed_line
119
+ end
120
+ end
121
+
116
122
  def generate_event(event, match, line)
117
123
  if respond_to?(event)
118
124
  line = public_send(event, match, line)
@@ -16,14 +16,21 @@ module DefMastership
16
16
 
17
17
  adoc_texts =
18
18
  replacements.reduce(adoc_texts) do |texts, method|
19
- texts.transform_values do |text|
20
- text.lines.map { |line| line_modifier.public_send(method, line) }.join
21
- end
19
+ transform_values(texts, line_modifier, method)
22
20
  end
23
21
 
24
22
  @config = line_modifier.config
25
23
  @changes = line_modifier.changes
26
24
  adoc_texts
27
25
  end
26
+
27
+ private
28
+
29
+ def transform_values(texts, line_modifier, method)
30
+ texts.transform_values do |text|
31
+ text.lines.map { |line| line_modifier.public_send(method, line) }
32
+ .join
33
+ end
34
+ end
28
35
  end
29
36
  end
@@ -9,8 +9,10 @@ module DefMastership
9
9
  end
10
10
 
11
11
  def enabled?(line)
12
+ return false if line.match(DMRegexp::SINGLE_LINE_COMMENT)
13
+
12
14
  line = line.dup.chomp
13
- if ['....', '////'].include?(line)
15
+ if ['....', '----', '////'].include?(line)
14
16
  if @last_disabling_line == line
15
17
  @last_disabling_line = nil
16
18
  elsif @last_disabling_line.nil?
@@ -2,6 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module DefMastership
5
- VERSION = '1.0.15'
5
+ VERSION = '1.0.17'
6
6
  public_constant :VERSION
7
7
  end
data/lib/defmastership.rb CHANGED
@@ -5,27 +5,22 @@ require('defmastership/version')
5
5
 
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
+ require('defmastership/batch_modifier')
9
+ require('defmastership/change_ref_line_modifier')
10
+ require('defmastership/change_ref_modifier')
11
+ require('defmastership/comment_filter')
8
12
  require('defmastership/constants')
9
- require('defmastership/parsing_state')
13
+ require('defmastership/csv_formatter')
10
14
  require('defmastership/definition')
11
15
  require('defmastership/definition_parser')
12
- require('defmastership/filters')
13
16
  require('defmastership/document')
14
- require('defmastership/comment_filter')
15
- require('defmastership/csv_formatter')
16
-
17
- require('defmastership/modifier_base')
17
+ require('defmastership/filters')
18
18
  require('defmastership/line_modifier_base')
19
- require('defmastership/batch_modifier')
20
-
21
- require('defmastership/change_ref_modifier')
22
- require('defmastership/change_ref_line_modifier')
23
-
24
- require('defmastership/rename_included_files_modifier')
19
+ require('defmastership/modifier_base')
20
+ require('defmastership/parsing_state')
25
21
  require('defmastership/rename_included_files_line_modifier')
26
-
27
- require('defmastership/update_def_checksum_modifier')
22
+ require('defmastership/rename_included_files_modifier')
28
23
  require('defmastership/update_def_checksum_line_modifier')
29
-
30
- require('defmastership/update_def_version_modifier')
24
+ require('defmastership/update_def_checksum_modifier')
31
25
  require('defmastership/update_def_version_line_modifier')
26
+ require('defmastership/update_def_version_modifier')
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
- require('bundler/setup')
5
- require('aruba/rspec')
6
4
  require('aasm/rspec')
5
+ require('aruba/rspec')
6
+ require('bundler/setup')
7
7
 
8
8
  # formatter = [SimpleCov::Formatter::HTMLFormatter]
9
9
  # SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(formatter)
@@ -31,7 +31,7 @@ RSpec.describe(DefMastership::BatchModifier) do
31
31
  end
32
32
 
33
33
  describe '.new' do
34
- it { is_expected.not_to(be(nil)) }
34
+ it { is_expected.not_to(be_nil) }
35
35
  it { is_expected.to(have_attributes(config: config)) }
36
36
 
37
37
  it do
@@ -114,9 +114,10 @@ RSpec.describe(DefMastership::BatchModifier) do
114
114
 
115
115
  context 'with wrong modification' do
116
116
  it do
117
- expect { batchmodifier.apply('wrong-modification') }.to(
118
- raise_error(ArgumentError, 'wrong-modification is not a known modification')
119
- )
117
+ expect { batchmodifier.apply('wrong-modification') }
118
+ .to(
119
+ raise_error(ArgumentError, 'wrong-modification is not a known modification')
120
+ )
120
121
  end
121
122
  end
122
123
  end
@@ -7,12 +7,16 @@ RSpec.describe(DefMastership::ChangeRefLineModifier) do
7
7
  subject(:refchanger) { described_class.new }
8
8
 
9
9
  describe '.new' do
10
- it { is_expected.not_to(be(nil)) }
10
+ it { is_expected.not_to(be_nil) }
11
11
  it { is_expected.to(have_attributes(from_regexp: '')) }
12
12
  it { is_expected.to(have_attributes(to_template: '')) }
13
13
  it { is_expected.to(have_attributes(next_ref: 0)) }
14
14
  it { is_expected.to(have_attributes(changes: [])) }
15
- it { expect { refchanger.user_defined_attribute }.to(raise_error(NoMethodError)) }
15
+
16
+ it do
17
+ expect { refchanger.user_defined_attribute }
18
+ .to(raise_error(NoMethodError))
19
+ end
16
20
  end
17
21
 
18
22
  describe '.from_config' do
@@ -24,7 +28,7 @@ RSpec.describe(DefMastership::ChangeRefLineModifier) do
24
28
  )
25
29
  end
26
30
 
27
- it { is_expected.not_to(be(nil)) }
31
+ it { is_expected.not_to(be_nil) }
28
32
  it { is_expected.to(have_attributes(from_regexp: 'Whatever.+')) }
29
33
  it { is_expected.to(have_attributes(to_template: 'Whatever')) }
30
34
  it { is_expected.to(have_attributes(next_ref: 17)) }
@@ -238,6 +242,9 @@ RSpec.describe(DefMastership::ChangeRefLineModifier) do
238
242
  .to(eq('defs:iref[TUTU]'))
239
243
  end
240
244
 
241
- it { expect { refchanger.replace(:pouet, 'whatever') }.to(raise_error(NoMethodError)) }
245
+ it do
246
+ expect { refchanger.replace(:pouet, 'whatever') }
247
+ .to(raise_error(NoMethodError))
248
+ end
242
249
  end
243
250
  end
@@ -18,7 +18,7 @@ RSpec.describe(DefMastership::ChangeRefModifier) do
18
18
  end
19
19
 
20
20
  describe '.new' do
21
- it { is_expected.not_to(be(nil)) }
21
+ it { is_expected.not_to(be_nil) }
22
22
  it { is_expected.to(have_attributes(config: 'fake config')) }
23
23
  it { is_expected.to(have_attributes(changes: [])) }
24
24
  end