defmastership 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +4 -0
  4. data/.rubocop.yml +63 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +140 -0
  7. data/README.rdoc +6 -0
  8. data/Rakefile +53 -0
  9. data/bin/defmastership +99 -0
  10. data/config/devtools.yml +2 -0
  11. data/config/flay.yml +3 -0
  12. data/config/flog.yml +2 -0
  13. data/config/mutant.yml +6 -0
  14. data/config/reek.yml +106 -0
  15. data/config/rubocop.yml +44 -0
  16. data/config/yardstick.yml +2 -0
  17. data/defmastership.gemspec +37 -0
  18. data/defmastership.rdoc +5 -0
  19. data/features/changeref.feature +296 -0
  20. data/features/defmastership.feature +8 -0
  21. data/features/export.feature +275 -0
  22. data/features/step_definitions/defmastership_steps.rb +8 -0
  23. data/features/support/env.rb +18 -0
  24. data/lib/defmastership.rb +15 -0
  25. data/lib/defmastership/batch_changer.rb +40 -0
  26. data/lib/defmastership/comment_filter.rb +42 -0
  27. data/lib/defmastership/constants.rb +77 -0
  28. data/lib/defmastership/csv_formatter.rb +42 -0
  29. data/lib/defmastership/csv_formatter_body.rb +34 -0
  30. data/lib/defmastership/csv_formatter_header.rb +35 -0
  31. data/lib/defmastership/definition.rb +41 -0
  32. data/lib/defmastership/document.rb +153 -0
  33. data/lib/defmastership/project_ref_changer.rb +27 -0
  34. data/lib/defmastership/ref_changer.rb +102 -0
  35. data/lib/defmastership/version.rb +6 -0
  36. data/spec/spec_helper.rb +35 -0
  37. data/spec/unit/defmastership/batch_changer_spec.rb +108 -0
  38. data/spec/unit/defmastership/comment_filter_spec.rb +121 -0
  39. data/spec/unit/defmastership/csv_formatter_body_spec.rb +167 -0
  40. data/spec/unit/defmastership/csv_formatter_header_spec.rb +100 -0
  41. data/spec/unit/defmastership/csv_formatter_spec.rb +171 -0
  42. data/spec/unit/defmastership/definition_spec.rb +110 -0
  43. data/spec/unit/defmastership/document_spec.rb +398 -0
  44. data/spec/unit/defmastership/project_ref_changer_spec.rb +79 -0
  45. data/spec/unit/defmastership/ref_changer_spec.rb +205 -0
  46. data/spec/unit/defmastership_spec.rb +7 -0
  47. metadata +234 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 86de2f3ea5bbabfae9ed3e773349016d3a122919091bb04d2134dc2de25799a2
4
+ data.tar.gz: e3d082d8d7f6ee8a22fe178c5eb9691cb6934dae4fff0c6288be0f17e6f94273
5
+ SHA512:
6
+ metadata.gz: 69e865bb1c8e5972d7aa12b5f6ce9203e9d27eadcfef7c3f2becb83b123920769a120e66896957bc26eb89efbe7e9a00389c5262d4d395e2bdb9602b0f3f335c
7
+ data.tar.gz: cad9f387a71e9668ba1af813865ba161c95daaa4937defa0c42ad41a72b7b3225ad0e3b7ccb5eeefa0553f33b2bd6e3aa6774567fe2bba6d6ea560952190de96
@@ -0,0 +1,4 @@
1
+ /*_results.html
2
+ /tmp
3
+ /coverage
4
+ defmastership-0.0.1.gem
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format documentation
2
+ --format html --out rspec_results.html
3
+ --color
4
+ --require spec_helper
@@ -0,0 +1,63 @@
1
+ # The behavior of RuboCop can be controlled via the .rubocop.yml
2
+ # configuration file. It makes it possible to enable/disable
3
+ # certain cops (checks) and to alter their behavior if they accept
4
+ # any parameters. The file can be placed either in your home
5
+ # directory or in some project directory.
6
+ #
7
+ # RuboCop will start looking for the configuration file in the directory
8
+ # where the inspected file is and continue its way up to the root directory.
9
+ #
10
+ # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
11
+
12
+ require:
13
+ - rubocop-rspec
14
+
15
+ AllCops:
16
+ TargetRubyVersion: 2.6
17
+ EnabledByDefault: true
18
+ DisplayCopNames: true
19
+
20
+ Style/Copyright:
21
+ Enabled: false
22
+ # AutocorrectNotice: 'Copyright 2020 by Jérôme Arbez-Gindre'
23
+
24
+ Lint/ConstantResolution:
25
+ Enabled: false
26
+
27
+ Style/DocumentationMethod:
28
+ Enabled: false
29
+
30
+ Style/StringHashKeys :
31
+ Enabled: false
32
+
33
+ Style/MissingElse:
34
+ EnforcedStyle: case
35
+
36
+ Metrics/ModuleLength :
37
+ Exclude:
38
+ - 'spec/**/*'
39
+
40
+ Metrics/BlockLength :
41
+ Exclude:
42
+ - 'spec/**/*'
43
+ - '*.gemspec'
44
+
45
+ Security/Eval :
46
+ Exclude:
47
+ - 'Rakefile'
48
+
49
+ Style/ConstantVisibility :
50
+ Exclude:
51
+ # there is one unique explicit constant visibility for all
52
+ # constants
53
+ - 'lib/defmastership/constants.rb'
54
+
55
+ # rubocop-rspec options
56
+ RSpec/MessageExpectation :
57
+ Enabled: false
58
+
59
+ RSpec/FilePath :
60
+ Enabled: false
61
+
62
+ RSpec/NestedGroups:
63
+ Max: 4
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source('https://rubygems.org')
4
+ gemspec
@@ -0,0 +1,140 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ defmastership (1.0.1)
5
+ aasm (~> 5)
6
+ asciidoctor (~> 2)
7
+ gli (~> 2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ aasm (5.1.1)
13
+ concurrent-ruby (~> 1.0)
14
+ activesupport (6.0.3.2)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ zeitwerk (~> 2.2, >= 2.2.2)
20
+ aruba (1.0.3)
21
+ childprocess (>= 2.0, < 5.0)
22
+ contracts (~> 0.16.0)
23
+ cucumber (>= 2.4, < 6.0)
24
+ ffi (~> 1.9)
25
+ rspec-expectations (~> 3.4)
26
+ thor (~> 1.0)
27
+ asciidoctor (2.0.10)
28
+ ast (2.4.1)
29
+ builder (3.2.4)
30
+ childprocess (4.0.0)
31
+ concurrent-ruby (1.1.7)
32
+ contracts (0.16.0)
33
+ cucumber (5.1.1)
34
+ builder (~> 3.2, >= 3.2.4)
35
+ cucumber-core (~> 8.0, >= 8.0.1)
36
+ cucumber-create-meta (~> 2.0, >= 2.0.2)
37
+ cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
38
+ cucumber-gherkin (~> 15.0, >= 15.0.2)
39
+ cucumber-html-formatter (~> 9.0, >= 9.0.0)
40
+ cucumber-messages (~> 13.0, >= 13.0.1)
41
+ cucumber-wire (~> 4.0, >= 4.0.1)
42
+ diff-lcs (~> 1.4, >= 1.4.4)
43
+ multi_test (~> 0.1, >= 0.1.2)
44
+ sys-uname (~> 1.2, >= 1.2.1)
45
+ cucumber-core (8.0.1)
46
+ cucumber-gherkin (~> 15.0, >= 15.0.2)
47
+ cucumber-messages (~> 13.0, >= 13.0.1)
48
+ cucumber-tag-expressions (~> 2.0, >= 2.0.4)
49
+ cucumber-create-meta (2.0.2)
50
+ cucumber-messages (~> 13.0, >= 13.0.1)
51
+ sys-uname (~> 1.2, >= 1.2.1)
52
+ cucumber-cucumber-expressions (10.3.0)
53
+ cucumber-gherkin (15.0.2)
54
+ cucumber-messages (~> 13.0, >= 13.0.1)
55
+ cucumber-html-formatter (9.0.0)
56
+ cucumber-messages (~> 13.0, >= 13.0.1)
57
+ cucumber-messages (13.0.1)
58
+ protobuf-cucumber (~> 3.10, >= 3.10.8)
59
+ cucumber-tag-expressions (2.0.4)
60
+ cucumber-wire (4.0.1)
61
+ cucumber-core (~> 8.0, >= 8.0.1)
62
+ cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
63
+ cucumber-messages (~> 13.0, >= 13.0.1)
64
+ diff-lcs (1.4.4)
65
+ docile (1.3.2)
66
+ ffi (1.13.1)
67
+ gli (2.19.2)
68
+ i18n (1.8.5)
69
+ concurrent-ruby (~> 1.0)
70
+ middleware (0.1.0)
71
+ minitest (5.14.2)
72
+ multi_test (0.1.2)
73
+ parallel (1.19.2)
74
+ parser (2.7.1.4)
75
+ ast (~> 2.4.1)
76
+ protobuf-cucumber (3.10.8)
77
+ activesupport (>= 3.2)
78
+ middleware
79
+ thor
80
+ thread_safe
81
+ rainbow (3.0.0)
82
+ rake (13.0.1)
83
+ rdoc (6.2.1)
84
+ regexp_parser (1.7.1)
85
+ rexml (3.2.4)
86
+ rspec (3.9.0)
87
+ rspec-core (~> 3.9.0)
88
+ rspec-expectations (~> 3.9.0)
89
+ rspec-mocks (~> 3.9.0)
90
+ rspec-core (3.9.2)
91
+ rspec-support (~> 3.9.3)
92
+ rspec-expectations (3.9.2)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.9.0)
95
+ rspec-mocks (3.9.1)
96
+ diff-lcs (>= 1.2.0, < 2.0)
97
+ rspec-support (~> 3.9.0)
98
+ rspec-support (3.9.3)
99
+ rubocop (0.90.0)
100
+ parallel (~> 1.10)
101
+ parser (>= 2.7.1.1)
102
+ rainbow (>= 2.2.2, < 4.0)
103
+ regexp_parser (>= 1.7)
104
+ rexml
105
+ rubocop-ast (>= 0.3.0, < 1.0)
106
+ ruby-progressbar (~> 1.7)
107
+ unicode-display_width (>= 1.4.0, < 2.0)
108
+ rubocop-ast (0.3.0)
109
+ parser (>= 2.7.1.4)
110
+ rubocop-rspec (1.43.2)
111
+ rubocop (~> 0.87)
112
+ ruby-progressbar (1.10.1)
113
+ simplecov (0.19.0)
114
+ docile (~> 1.1)
115
+ simplecov-html (~> 0.11)
116
+ simplecov-html (0.12.2)
117
+ sys-uname (1.2.1)
118
+ ffi (>= 1.0.0)
119
+ thor (1.0.1)
120
+ thread_safe (0.3.6)
121
+ tzinfo (1.2.7)
122
+ thread_safe (~> 0.1)
123
+ unicode-display_width (1.7.0)
124
+ zeitwerk (2.4.0)
125
+
126
+ PLATFORMS
127
+ ruby
128
+
129
+ DEPENDENCIES
130
+ aruba (~> 1)
131
+ defmastership!
132
+ rake (~> 13)
133
+ rdoc (~> 6)
134
+ rspec (~> 3)
135
+ rubocop (~> 0)
136
+ rubocop-rspec (~> 1)
137
+ simplecov (~> 0)
138
+
139
+ BUNDLED WITH
140
+ 2.1.4
@@ -0,0 +1,6 @@
1
+ = defmastership
2
+
3
+ Describe your project here
4
+
5
+ :include:defmastership.rdoc
6
+
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('rake/clean')
4
+ require('rubygems')
5
+ require('rubygems/package_task')
6
+ require('rdoc/task')
7
+ require('cucumber')
8
+ require('cucumber/rake/task')
9
+
10
+ Rake::RDocTask.new do |rd|
11
+ rd.main = 'README.rdoc'
12
+ rd.rdoc_files.include('README.rdoc', 'lib/**/*.rb', 'bin/**/*')
13
+ rd.title = 'Your application title'
14
+ end
15
+
16
+ spec = eval(::File.read('defmastership.gemspec'))
17
+
18
+ Gem::PackageTask.new(spec) do |pkg|
19
+ end
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
+
31
+ 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}"
37
+ t.fork = false
38
+ end
39
+
40
+ task(cucumber: :features)
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])
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require('asciidoctor')
5
+ require('csv')
6
+ require('defmastership')
7
+ require('gli')
8
+
9
+ module DefMastership
10
+ # The start of everything !
11
+ class App
12
+ extend GLI::App
13
+
14
+ program_desc 'Tool to handle Asciidoctor definition extension'
15
+
16
+ version DefMastership::VERSION
17
+
18
+ subcommand_option_handling :normal
19
+ arguments :strict
20
+
21
+ # desc 'Describe some switch here'
22
+ # switch [:s,:switch]
23
+
24
+ # desc 'Describe some flag here'
25
+ # default_value 'the default'
26
+ # arg_name 'The name of the argument'
27
+ # flag [:f,:flagname]
28
+
29
+ pre do |_global, _command, _options, _args|
30
+ # Pre logic here
31
+ # Return true to proceed; false to abort and not call the
32
+ # chosen command
33
+ # Use skips_pre before a command to skip this block
34
+ # on that command only
35
+ true
36
+ end
37
+
38
+ post do |_global, _command, _options, _args|
39
+ # Post logic here
40
+ # Use skips_post before a command to skip this
41
+ # block on that command only
42
+ end
43
+
44
+ on_error do |_exception|
45
+ # Error logic here
46
+ # return false to skip default error handling
47
+ true
48
+ end
49
+
50
+ desc 'Export the definition database in CSV'
51
+ arg_name 'asciidoctor_files'
52
+ command :export do |c|
53
+ c.action do |_global_options, _options, args|
54
+ doc = Asciidoctor.load_file(args[0], safe: :unsafe, parse: false)
55
+ # FIXME: also escape ifdef, ifndef, ifeval and endif directives
56
+ # FIXME: do this more carefully by reading line by line; if input
57
+ # differs by output by leading backslash, restore original line
58
+ lines = doc.reader.read_lines
59
+ my_doc = DefMastership::Document.new
60
+ my_doc.parse(lines)
61
+
62
+ output_file = args[0].sub(/\.adoc$/, '.csv')
63
+
64
+ DefMastership::CSVFormatter.new(my_doc).export_to(output_file)
65
+ end
66
+ end
67
+
68
+ desc 'Change temp references to definitive references'
69
+ arg_name 'asciidoctor_files'
70
+ command :changeref do |c|
71
+ c.flag(%i[change-summary s], default_value: 'changes.csv', desc: 'generates a change summary in a CSV file')
72
+
73
+ c.flag(%i[change-file f], default_value: 'changeref.yaml', desc: 'set the change specification file')
74
+
75
+ c.action do |_global_options, options, args|
76
+ ref_changer = ProjectRefChanger.new(
77
+ YAML.load_file(options['change-file']),
78
+ args.map { |afile| [afile, File.open(afile).read] }.to_h
79
+ )
80
+
81
+ ref_changer.replace_all
82
+
83
+ ref_changer.adoc_texts.each do |adoc_file, adoc_text|
84
+ File.open(adoc_file, 'w') { |f| f.write(adoc_text) }
85
+ end
86
+ File.open(options['change-file'], 'w') { |f| f.write(ref_changer.yaml_config) }
87
+
88
+ unless options['change-summary'].nil?
89
+ CSV.open(options['change-summary'], 'wb') do |csv|
90
+ csv << %w[Was Becomes]
91
+ ref_changer.changes.each { |row| csv << row }
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ exit(DefMastership::App.run(ARGV))
@@ -0,0 +1,2 @@
1
+ ---
2
+ unit_test_timeout: 0.2
@@ -0,0 +1,3 @@
1
+ ---
2
+ threshold: 8
3
+ total_score: 119
@@ -0,0 +1,2 @@
1
+ ---
2
+ threshold: 13.5
@@ -0,0 +1,6 @@
1
+ ---
2
+ includes:
3
+ - lib
4
+ integration: rspec
5
+ requires:
6
+ - devtools
@@ -0,0 +1,106 @@
1
+ ---
2
+ detectors:
3
+ Attribute:
4
+ enabled: false
5
+ exclude: []
6
+ BooleanParameter:
7
+ enabled: true
8
+ exclude: []
9
+ ClassVariable:
10
+ enabled: true
11
+ exclude: []
12
+ ControlParameter:
13
+ enabled: true
14
+ exclude: []
15
+ DataClump:
16
+ enabled: true
17
+ exclude: []
18
+ max_copies: 0
19
+ min_clump_size: 2
20
+ DuplicateMethodCall:
21
+ enabled: true
22
+ exclude: []
23
+ max_calls: 1
24
+ allow_calls: []
25
+ FeatureEnvy:
26
+ enabled: true
27
+ exclude: []
28
+ IrresponsibleModule:
29
+ enabled: true
30
+ exclude: []
31
+ LongParameterList:
32
+ enabled: true
33
+ exclude:
34
+ - Devtools::Config#self.attribute
35
+ max_params: 2
36
+ overrides: {}
37
+ LongYieldList:
38
+ enabled: true
39
+ exclude: []
40
+ max_params: 0
41
+ NestedIterators:
42
+ enabled: true
43
+ exclude: []
44
+ max_allowed_nesting: 1
45
+ ignore_iterators: []
46
+ NilCheck:
47
+ enabled: true
48
+ exclude: []
49
+ RepeatedConditional:
50
+ enabled: true
51
+ exclude: []
52
+ max_ifs: 1
53
+ TooManyConstants:
54
+ enabled: true
55
+ exclude:
56
+ - Devtools
57
+ TooManyInstanceVariables:
58
+ enabled: true
59
+ exclude: []
60
+ max_instance_variables: 2
61
+ TooManyMethods:
62
+ enabled: true
63
+ exclude: []
64
+ max_methods: 15
65
+ TooManyStatements:
66
+ enabled: true
67
+ exclude: []
68
+ max_statements: 5
69
+ UncommunicativeMethodName:
70
+ enabled: true
71
+ exclude: []
72
+ reject:
73
+ - '/^[a-z]$/'
74
+ - '/[0-9]$/'
75
+ - '/[A-Z]/'
76
+ accept: []
77
+ UncommunicativeModuleName:
78
+ enabled: true
79
+ exclude: []
80
+ reject:
81
+ - '/^.$/'
82
+ - '/[0-9]$/'
83
+ accept: []
84
+ UncommunicativeParameterName:
85
+ enabled: true
86
+ exclude: []
87
+ reject:
88
+ - '/^.$/'
89
+ - '/[0-9]$/'
90
+ - '/[A-Z]/'
91
+ accept: []
92
+ UncommunicativeVariableName:
93
+ enabled: true
94
+ exclude: []
95
+ reject:
96
+ - '/^.$/'
97
+ - '/[0-9]$/'
98
+ - '/[A-Z]/'
99
+ accept: []
100
+ UnusedParameters:
101
+ enabled: true
102
+ exclude: []
103
+ UtilityFunction:
104
+ enabled: true
105
+ exclude:
106
+ - Devtools::Project::Initializer::Rspec#require_files # intentional for deduplication