defmastership 1.0.1 → 1.0.6

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.gitlab-ci.yml +20 -0
  4. data/.rubocop.yml +5 -4
  5. data/Gemfile +1 -0
  6. data/LICENSE +22 -0
  7. data/Rakefile +2 -2
  8. data/bin/defmastership +25 -17
  9. data/cucumber.yml +2 -0
  10. data/defmastership.gemspec +18 -11
  11. data/features/changeref.feature +82 -129
  12. data/features/export.feature +102 -31
  13. data/features/modify.feature +143 -0
  14. data/features/rename_included_files.feature +121 -0
  15. data/features/step_definitions/defmastership_steps.rb +1 -0
  16. data/features/support/env.rb +1 -0
  17. data/lib/defmastership.rb +12 -3
  18. data/lib/defmastership/batch_modifier.rb +33 -0
  19. data/lib/defmastership/{ref_changer.rb → change_ref_line_modifier.rb} +19 -35
  20. data/lib/defmastership/change_ref_modifier.rb +15 -0
  21. data/lib/defmastership/comment_filter.rb +1 -0
  22. data/lib/defmastership/constants.rb +15 -1
  23. data/lib/defmastership/csv_formatter.rb +19 -18
  24. data/lib/defmastership/csv_formatter_body.rb +12 -6
  25. data/lib/defmastership/csv_formatter_header.rb +12 -10
  26. data/lib/defmastership/definition.rb +12 -0
  27. data/lib/defmastership/definition_parser.rb +46 -0
  28. data/lib/defmastership/document.rb +44 -75
  29. data/lib/defmastership/filters.rb +30 -0
  30. data/lib/defmastership/line_modifier_base.rb +29 -0
  31. data/lib/defmastership/modifier_base.rb +29 -0
  32. data/lib/defmastership/rename_included_files_line_modifier.rb +126 -0
  33. data/lib/defmastership/rename_included_files_modifier.rb +30 -0
  34. data/lib/defmastership/version.rb +2 -1
  35. data/spec/spec_helper.rb +2 -0
  36. data/spec/unit/defmastership/batch_modifier_spec.rb +115 -0
  37. data/spec/unit/defmastership/{ref_changer_spec.rb → change_ref_line_modifier_spec.rb} +49 -26
  38. data/spec/unit/defmastership/change_ref_modifier_spec.rb +76 -0
  39. data/spec/unit/defmastership/comment_filter_spec.rb +9 -4
  40. data/spec/unit/defmastership/csv_formatter_body_spec.rb +62 -37
  41. data/spec/unit/defmastership/csv_formatter_header_spec.rb +47 -22
  42. data/spec/unit/defmastership/csv_formatter_spec.rb +67 -105
  43. data/spec/unit/defmastership/definition_parser_spec.rb +63 -0
  44. data/spec/unit/defmastership/definition_spec.rb +31 -4
  45. data/spec/unit/defmastership/document_spec.rb +113 -35
  46. data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +203 -0
  47. data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +67 -0
  48. data/spec/unit/defmastership_spec.rb +1 -0
  49. metadata +44 -17
  50. data/Gemfile.lock +0 -140
  51. data/lib/defmastership/batch_changer.rb +0 -40
  52. data/lib/defmastership/project_ref_changer.rb +0 -27
  53. data/spec/unit/defmastership/batch_changer_spec.rb +0 -108
  54. data/spec/unit/defmastership/project_ref_changer_spec.rb +0 -79
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require('defmastership')
4
- require('yaml')
5
-
6
- RSpec.describe(DefMastership::ProjectRefChanger) do
7
- subject(:projectrefchanger) do
8
- described_class.new(
9
- 'fake yaml config',
10
- {
11
- 'file1.adoc' => "file1 line1\nfile1 line2",
12
- 'file2.adoc' => "file2 line1\nfile2 line2"
13
- }
14
- )
15
- end
16
-
17
- describe '.new' do
18
- it { is_expected.not_to(be(nil)) }
19
- it { is_expected.to(have_attributes(yaml_config: 'fake yaml config')) }
20
-
21
- it do
22
- expect(projectrefchanger).to(have_attributes(adoc_texts:
23
- {
24
- 'file1.adoc' => "file1 line1\nfile1 line2",
25
- 'file2.adoc' => "file2 line1\nfile2 line2"
26
- }))
27
- end
28
-
29
- it { is_expected.to(have_attributes(changes: nil)) }
30
- end
31
-
32
- describe '#replace_all' do
33
- let(:batch_changer) { instance_double(DefMastership::BatchChanger, 'batch_changer') }
34
- let(:config_hash) { instance_double(Hash, 'config_hash') }
35
-
36
- before do
37
- allow(DefMastership::BatchChanger).to(receive(:from_h).with('fake yaml config').and_return(batch_changer))
38
- allow(batch_changer).to(receive(:replace).with(:refdef, "file1 line1\n").and_return("new file1 line1\n"))
39
- allow(batch_changer).to(receive(:replace).with(:refdef, 'file1 line2').and_return('new file1 line2'))
40
- allow(batch_changer).to(receive(:replace).with(:refdef, "file2 line1\n").and_return("new file2 line1\n"))
41
- allow(batch_changer).to(receive(:replace).with(:refdef, 'file2 line2').and_return('new file2 line2'))
42
- allow(batch_changer).to(receive(:replace).with(:irefs, "new file1 line1\n").and_return("new2 file1 line1\n"))
43
- allow(batch_changer).to(receive(:replace).with(:irefs, 'new file1 line2').and_return('new2 file1 line2'))
44
- allow(batch_changer).to(receive(:replace).with(:irefs, "new file2 line1\n").and_return("new2 file2 line1\n"))
45
- allow(batch_changer).to(receive(:replace).with(:irefs, 'new file2 line2').and_return('new2 file2 line2'))
46
- allow(batch_changer).to(receive(:to_h).and_return(config_hash))
47
- allow(batch_changer).to(receive(:changes).and_return('pouet'))
48
- allow(config_hash).to(receive(:to_yaml).with(no_args).and_return('new fake yaml config'))
49
- projectrefchanger.replace_all
50
- end
51
-
52
- it { expect(DefMastership::BatchChanger).to(have_received(:from_h).with('fake yaml config')) }
53
-
54
- it { expect(batch_changer).to(have_received(:replace).with(:refdef, "file1 line1\n")) }
55
- it { expect(batch_changer).to(have_received(:replace).with(:refdef, 'file1 line2')) }
56
- it { expect(batch_changer).to(have_received(:replace).with(:refdef, "file2 line1\n")) }
57
- it { expect(batch_changer).to(have_received(:replace).with(:refdef, 'file2 line2')) }
58
- it { expect(batch_changer).to(have_received(:replace).with(:irefs, "new file1 line1\n")) }
59
- it { expect(batch_changer).to(have_received(:replace).with(:irefs, 'new file1 line2')) }
60
- it { expect(batch_changer).to(have_received(:replace).with(:irefs, "new file2 line1\n")) }
61
- it { expect(batch_changer).to(have_received(:replace).with(:irefs, 'new file2 line2')) }
62
-
63
- it { expect(batch_changer).to(have_received(:to_h)) }
64
-
65
- it { expect(config_hash).to(have_received(:to_yaml).with(no_args)) }
66
-
67
- it { expect(projectrefchanger).to(have_attributes(yaml_config: 'new fake yaml config')) }
68
-
69
- it do
70
- expect(projectrefchanger).to(have_attributes(adoc_texts: {
71
- 'file1.adoc' => "new2 file1 line1\nnew2 file1 line2",
72
- 'file2.adoc' => "new2 file2 line1\nnew2 file2 line2"
73
- }))
74
- end
75
-
76
- it { expect(batch_changer).to(have_received(:changes)) }
77
- it { expect(projectrefchanger).to(have_attributes(changes: 'pouet')) }
78
- end
79
- end