asciidoctor-defmastership 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cb46c0579286b760f1486d9458034fdabfef220e34cacae49c574f20c5e2c093
4
+ data.tar.gz: 5f18f5ca0b93543c936fcbdd8269e53aa0bbebdc13c80cae8cb152f236c9f3f8
5
+ SHA512:
6
+ metadata.gz: 0d4a76c605cea45280dff495d465e6121bac39b24e26625f9476c0dcf3823e2fbe25fa2d287e2f8494ab9d6b708d109e7f1424211ed1f1c13c47d9f3419e1bc9
7
+ data.tar.gz: 777021aef8fca7a5402ba60d012f10b8d395c85dafa4ef44897068f84da03808a594ff613b6e7ba854c2ee1e0d1c0b76ed80c5fa4036f59c7276485483137308
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ /measurements
13
+ *.csv
14
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,66 @@
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.3
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: # not available in rubocop 0.81
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
+ Layout/LineLength:
46
+ Max: 120 # default for rubocop later than 0.81
47
+
48
+ # Security/Eval :
49
+ # Exclude:
50
+ # - 'Rakefile'
51
+
52
+ Style/ConstantVisibility :
53
+ Exclude:
54
+ # there is one unique explicit constant visibility for all
55
+ # constants
56
+ - 'lib/asciidoctor/defmastership/extension.rb'
57
+
58
+ # # rubocop-rspec options
59
+ # RSpec/MessageExpectation :
60
+ # Enabled: false
61
+
62
+ RSpec/FilePath :
63
+ Enabled: false
64
+
65
+ # RSpec/NestedGroups:
66
+ # Max: 4
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.5
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source('https://rubygems.org')
4
+ gemspec
@@ -0,0 +1,132 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ asciidoctor-defmastership (1.0.0)
5
+ asciidoctor (~> 2.0)
6
+ defmastership (>= 1.0.2, < 2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ aasm (5.1.1)
12
+ concurrent-ruby (~> 1.0)
13
+ activesupport (6.0.3.3)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 0.7, < 2)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ zeitwerk (~> 2.2, >= 2.2.2)
19
+ aruba (1.0.3)
20
+ childprocess (>= 2.0, < 5.0)
21
+ contracts (~> 0.16.0)
22
+ cucumber (>= 2.4, < 6.0)
23
+ ffi (~> 1.9)
24
+ rspec-expectations (~> 3.4)
25
+ thor (~> 1.0)
26
+ asciidoctor (2.0.10)
27
+ ast (2.4.1)
28
+ builder (3.2.4)
29
+ childprocess (4.0.0)
30
+ concurrent-ruby (1.1.7)
31
+ contracts (0.16.0)
32
+ cucumber (5.1.1)
33
+ builder (~> 3.2, >= 3.2.4)
34
+ cucumber-core (~> 8.0, >= 8.0.1)
35
+ cucumber-create-meta (~> 2.0, >= 2.0.2)
36
+ cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
37
+ cucumber-gherkin (~> 15.0, >= 15.0.2)
38
+ cucumber-html-formatter (~> 9.0, >= 9.0.0)
39
+ cucumber-messages (~> 13.0, >= 13.0.1)
40
+ cucumber-wire (~> 4.0, >= 4.0.1)
41
+ diff-lcs (~> 1.4, >= 1.4.4)
42
+ multi_test (~> 0.1, >= 0.1.2)
43
+ sys-uname (~> 1.2, >= 1.2.1)
44
+ cucumber-core (8.0.1)
45
+ cucumber-gherkin (~> 15.0, >= 15.0.2)
46
+ cucumber-messages (~> 13.0, >= 13.0.1)
47
+ cucumber-tag-expressions (~> 2.0, >= 2.0.4)
48
+ cucumber-create-meta (2.0.2)
49
+ cucumber-messages (~> 13.0, >= 13.0.1)
50
+ sys-uname (~> 1.2, >= 1.2.1)
51
+ cucumber-cucumber-expressions (10.3.0)
52
+ cucumber-gherkin (15.0.2)
53
+ cucumber-messages (~> 13.0, >= 13.0.1)
54
+ cucumber-html-formatter (9.0.0)
55
+ cucumber-messages (~> 13.0, >= 13.0.1)
56
+ cucumber-messages (13.1.0)
57
+ protobuf-cucumber (~> 3.10, >= 3.10.8)
58
+ cucumber-tag-expressions (2.0.4)
59
+ cucumber-wire (4.0.1)
60
+ cucumber-core (~> 8.0, >= 8.0.1)
61
+ cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
62
+ cucumber-messages (~> 13.0, >= 13.0.1)
63
+ defmastership (1.0.2)
64
+ aasm (~> 5)
65
+ asciidoctor (~> 2)
66
+ gli (~> 2)
67
+ diff-lcs (1.4.4)
68
+ ffi (1.13.1)
69
+ gli (2.19.2)
70
+ i18n (1.8.5)
71
+ concurrent-ruby (~> 1.0)
72
+ jaro_winkler (1.5.4)
73
+ middleware (0.1.0)
74
+ minitest (5.14.2)
75
+ multi_test (0.1.2)
76
+ parallel (1.19.2)
77
+ parser (2.7.1.4)
78
+ ast (~> 2.4.1)
79
+ protobuf-cucumber (3.10.8)
80
+ activesupport (>= 3.2)
81
+ middleware
82
+ thor
83
+ thread_safe
84
+ rainbow (3.0.0)
85
+ rake (13.0.1)
86
+ rexml (3.2.4)
87
+ rspec (3.9.0)
88
+ rspec-core (~> 3.9.0)
89
+ rspec-expectations (~> 3.9.0)
90
+ rspec-mocks (~> 3.9.0)
91
+ rspec-core (3.9.2)
92
+ rspec-support (~> 3.9.3)
93
+ rspec-expectations (3.9.2)
94
+ diff-lcs (>= 1.2.0, < 2.0)
95
+ rspec-support (~> 3.9.0)
96
+ rspec-mocks (3.9.1)
97
+ diff-lcs (>= 1.2.0, < 2.0)
98
+ rspec-support (~> 3.9.0)
99
+ rspec-support (3.9.3)
100
+ rubocop (0.81.0)
101
+ jaro_winkler (~> 1.5.1)
102
+ parallel (~> 1.10)
103
+ parser (>= 2.7.0.1)
104
+ rainbow (>= 2.2.2, < 4.0)
105
+ rexml
106
+ ruby-progressbar (~> 1.7)
107
+ unicode-display_width (>= 1.4.0, < 2.0)
108
+ rubocop-rspec (1.41.0)
109
+ rubocop (>= 0.68.1)
110
+ ruby-progressbar (1.10.1)
111
+ sys-uname (1.2.1)
112
+ ffi (>= 1.0.0)
113
+ thor (1.0.1)
114
+ thread_safe (0.3.6)
115
+ tzinfo (1.2.7)
116
+ thread_safe (~> 0.1)
117
+ unicode-display_width (1.7.0)
118
+ zeitwerk (2.4.0)
119
+
120
+ PLATFORMS
121
+ ruby
122
+
123
+ DEPENDENCIES
124
+ aruba
125
+ asciidoctor-defmastership!
126
+ rake
127
+ rspec
128
+ rubocop (= 0.81)
129
+ rubocop-rspec (~> 1)
130
+
131
+ BUNDLED WITH
132
+ 2.1.4
@@ -0,0 +1,35 @@
1
+ # Asciidoctor::DefMastership
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/asciidoctor/defmastership`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'asciidoctor-defmastership'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install asciidoctor-defmastership
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/asciidoctor-defmastership.
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('bundler/gem_tasks')
4
+ require('rspec/core/rake_task')
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ require('rubocop/rake_task')
8
+
9
+ ::RuboCop::RakeTask.new
10
+
11
+ task(default: %i[spec rubocop])
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require('asciidoctor/defmastership/version')
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.required_ruby_version = '>= 2.3'
9
+ spec.name = 'asciidoctor-defmastership'
10
+ spec.version = Asciidoctor::DefMastership::VERSION
11
+ spec.authors = ['Jérôme Arbez-Gindre']
12
+ spec.email = ['jeromearbezgindre@gmail.com']
13
+ spec.licenses = 'Nonstandard'
14
+
15
+ spec.summary = %(asciidoctor extension to handle applicable
16
+ definition references)
17
+
18
+ spec.description = %(asciidoctor-defmastership allows to define
19
+ applicable definitions references, link to other references
20
+ (internal or external))
21
+
22
+ spec.homepage = 'https://gitlab.com/jjag/asciidoctor-defmastership/'
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that
26
+ # have been added into git.
27
+ spec.files =
28
+ Dir.chdir(File.expand_path(__dir__)) do
29
+ `git ls-files -z`.split("\x0").reject do |f|
30
+ f.match(%r{^(test|spec|features)/})
31
+ end
32
+ end
33
+ spec.require_paths = ['lib']
34
+
35
+ spec.add_development_dependency('aruba')
36
+ spec.add_development_dependency('rake')
37
+ spec.add_development_dependency('rspec')
38
+ spec.add_development_dependency('rubocop', '0.81')
39
+ spec.add_development_dependency('rubocop-rspec', '~> 1')
40
+
41
+ spec.add_dependency('asciidoctor', '~> 2.0')
42
+ spec.add_dependency('defmastership', '>= 1.0.2', '< 2.0')
43
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require('bundler/setup')
5
+ require('asciidoctor/defmastership')
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require 'pry'
12
+ # Pry.start
13
+
14
+ require('irb')
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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
@@ -0,0 +1,151 @@
1
+ inherit_from: ../.rubocop.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.5.0
5
+
6
+ Metrics/BlockLength:
7
+ Exclude:
8
+ # Ignore RSpec DSL
9
+ - spec/**/*
10
+ # Ignore gemspec DSL
11
+ - '*.gemspec'
12
+
13
+ Naming/FileName:
14
+ Exclude:
15
+ - Rakefile
16
+
17
+ # Avoid parameter lists longer than five parameters.
18
+ ParameterLists:
19
+ Max: 3
20
+ CountKeywordArgs: true
21
+
22
+ # Avoid more than `Max` levels of nesting.
23
+ BlockNesting:
24
+ Max: 3
25
+
26
+ # Align with the style guide.
27
+ CollectionMethods:
28
+ PreferredMethods:
29
+ collect: 'map'
30
+ inject: 'reduce'
31
+ find: 'detect'
32
+ find_all: 'select'
33
+
34
+ # Do not force public/protected/private keyword to be indented at the same
35
+ # level as the def keyword. My personal preference is to outdent these keywords
36
+ # because I think when scanning code it makes it easier to identify the
37
+ # sections of code and visually separate them. When the keyword is at the same
38
+ # level I think it sort of blends in with the def keywords and makes it harder
39
+ # to scan the code and see where the sections are.
40
+ AccessModifierIndentation:
41
+ Enabled: false
42
+
43
+ # Limit line length
44
+ LineLength:
45
+ Max: 80
46
+
47
+ # Disable documentation checking until a class needs to be documented once
48
+ Documentation:
49
+ Enabled: false
50
+
51
+ # Do not always use &&/|| instead of and/or.
52
+ AndOr:
53
+ Enabled: false
54
+
55
+ # Do not favor modifier if/unless usage when you have a single-line body
56
+ IfUnlessModifier:
57
+ Enabled: false
58
+
59
+ # Allow case equality operator (in limited use within the specs)
60
+ CaseEquality:
61
+ Enabled: false
62
+
63
+ # Constants do not always have to use SCREAMING_SNAKE_CASE
64
+ ConstantName:
65
+ Enabled: false
66
+
67
+ # Not all trivial readers/writers can be defined with attr_* methods
68
+ TrivialAccessors:
69
+ Enabled: false
70
+
71
+ # Allow empty lines around class body
72
+ EmptyLinesAroundClassBody:
73
+ Enabled: false
74
+
75
+ # Allow empty lines around module body
76
+ EmptyLinesAroundModuleBody:
77
+ Enabled: false
78
+
79
+ # Allow empty lines around block body
80
+ EmptyLinesAroundBlockBody:
81
+ Enabled: false
82
+
83
+ # Allow multiple line operations to not require indentation
84
+ MultilineOperationIndentation:
85
+ Enabled: false
86
+
87
+ # Prefer String#% over Kernel#sprintf
88
+ FormatString:
89
+ Enabled: false
90
+
91
+ # Use square brackets for literal Array objects
92
+ PercentLiteralDelimiters:
93
+ PreferredDelimiters:
94
+ '%': '{}'
95
+ '%i': '[]'
96
+ '%q': ()
97
+ '%Q': ()
98
+ '%r': '{}'
99
+ '%s': ()
100
+ '%w': '[]'
101
+ '%W': '[]'
102
+ '%x': ()
103
+
104
+ # Align if/else blocks with the variable assignment
105
+ EndAlignment:
106
+ EnforcedStyleAlignWith: variable
107
+
108
+ # Do not always align parameters when it is easier to read
109
+ AlignParameters:
110
+ Exclude:
111
+ - spec/**/*_spec.rb
112
+
113
+ # Prefer #kind_of? over #is_a?
114
+ ClassCheck:
115
+ EnforcedStyle: kind_of?
116
+
117
+ # Do not prefer double quotes to be used when %q or %Q is more appropriate
118
+ UnneededPercentQ:
119
+ Enabled: false
120
+
121
+ # Allow a maximum ABC score
122
+ Metrics/AbcSize:
123
+ Max: 20.1
124
+
125
+ # Do not prefer lambda.call(...) over lambda.(...)
126
+ LambdaCall:
127
+ Enabled: false
128
+
129
+ # Allow additional spaces
130
+ ExtraSpacing:
131
+ Enabled: false
132
+
133
+ # All objects can still be mutated if their eigenclass is patched
134
+ RedundantFreeze:
135
+ Enabled: false
136
+
137
+ # Prefer using `fail` when raising and `raise` when reraising
138
+ SignalException:
139
+ EnforcedStyle: semantic
140
+
141
+ Style/FrozenStringLiteralComment:
142
+ Enabled: false
143
+
144
+ Style/CommentedKeyword:
145
+ Enabled: false
146
+
147
+ Style/MixinGrouping:
148
+ Enabled: false
149
+
150
+ Layout/MultilineMethodCallIndentation:
151
+ EnforcedStyle: indented
@@ -0,0 +1,2 @@
1
+ ---
2
+ threshold: 100
@@ -0,0 +1,2 @@
1
+ :eref-implements-prefix: Participate to:
2
+ :eref-implements-url: ./the_other_document.html
@@ -0,0 +1 @@
1
+ /example.html
@@ -0,0 +1,57 @@
1
+ :toc: left
2
+ :tag-performance-color: green
3
+ :tag-chabada-color: fuchsia
4
+ :attr-verifiedby-prefix: Verified by:
5
+
6
+ include::.config.adoc[]
7
+
8
+ = My beautiful document
9
+
10
+ == Document content
11
+ == Requirements
12
+
13
+ [define, requirement, TOTO-0001, [performance]]
14
+ --
15
+ The system shall allow to do lots of things:
16
+
17
+ * toto
18
+ * titi
19
+ --
20
+ defs:attribute[verifiedby, Test compliqué]
21
+
22
+ [define, requirement, TOTO-0002, [performance, chabada]]
23
+ --
24
+ The system shall allow to do these things too:
25
+
26
+ * pouet
27
+ * tagada
28
+ * being able to reference defs:iref[TOTO-0001] and defs:iref[TOTO-0243]
29
+ * having also external reference as below
30
+ --
31
+
32
+ defs:eref[implements, [SYSTEM-0012, SYSTEM-0014]]
33
+
34
+ [define, requirement, TOTO-0003]
35
+ The system shall be nice.
36
+ And Also funny.
37
+ --
38
+ Not included !
39
+ --
40
+
41
+ ////
42
+ Pouet tagada
43
+ ////
44
+
45
+
46
+
47
+
48
+ // [define, requirement, TOTO_0030]
49
+ // --
50
+ // The system shall allow to do eat chocolates from:
51
+
52
+ // * Switzerland
53
+ // * Belgium
54
+ // --
55
+
56
+ link:rspec_results.html[Unit tests results]
57
+ link:coverage/index.html[Coverage analysis]
@@ -0,0 +1 @@
1
+ bundle exec asciidoctor --trace -a linkcss -a stylesheet=definition.css -a stylesdir=../../asciidoctor-stylesheet-factory/stylesheets -r ../lib/asciidoctor/defmastership.rb example.adoc
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ if RUBY_ENGINE == 'opal'
4
+ require('asciidoctor/defmastership/extension')
5
+ else
6
+ require_relative('defmastership/extension')
7
+ end
8
+
9
+ Asciidoctor::Extensions.register do
10
+ preprocessor Asciidoctor::DefMastership::Preprocessor
11
+ end
@@ -0,0 +1,141 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('asciidoctor/extensions') unless RUBY_ENGINE == 'opal'
4
+
5
+ # An extension that allow to define applicable definitions
6
+ #
7
+ # Usage
8
+ # :tag-mylabel-color: yellow
9
+ # :tag-otherlabel-color: red
10
+ #
11
+ #
12
+ # [define, requirement, TOTO-0001, [mylabel, otherlabel]]
13
+ # --
14
+ # The system shall allow to do lots of things.
15
+ # --
16
+ #
17
+ # or
18
+ #
19
+ # [define, requirement, TOTO-0001]
20
+ # This shall be nice.
21
+ #
22
+ require('defmastership/constants')
23
+
24
+ module Asciidoctor
25
+ module DefMastership
26
+ # Preprocessor to replace adoc statements
27
+ class Preprocessor < Asciidoctor::Extensions::Preprocessor
28
+ EREF_CONFIG_REGEXP = ::DefMastership::DMRegexp::EREF_CONFIG
29
+ DEFINITION_REGEXP = ::DefMastership::DMRegexp::DEFINITION
30
+ EREF_DEF_REGEXP = ::DefMastership::DMRegexp::EREF_DEF
31
+ IREF_DEF_REGEXP = ::DefMastership::DMRegexp::IREF_DEF
32
+ ATTR_CONFIG_REGEXP = ::DefMastership::DMRegexp::ATTR_CONFIG
33
+ ATTR_SET_REGEXP = ::DefMastership::DMRegexp::ATTR_SET
34
+
35
+ private_constant :EREF_CONFIG_REGEXP,
36
+ :DEFINITION_REGEXP,
37
+ :EREF_DEF_REGEXP,
38
+ :IREF_DEF_REGEXP,
39
+ :ATTR_CONFIG_REGEXP,
40
+ :ATTR_SET_REGEXP
41
+
42
+ Filter = Struct.new(:regex, :apply)
43
+
44
+ FILTERS = [
45
+ Filter.new(EREF_CONFIG_REGEXP, :set_eref_url_if_any),
46
+ Filter.new(DEFINITION_REGEXP, :build_definition),
47
+ Filter.new(EREF_DEF_REGEXP, :build_external_ref),
48
+ Filter.new(IREF_DEF_REGEXP, :build_internal_ref),
49
+ Filter.new(ATTR_SET_REGEXP, :attribute_setting)
50
+ ].freeze
51
+
52
+ private_constant :FILTERS
53
+
54
+ # class initialization
55
+ def initialize(config = {})
56
+ super(config)
57
+ # This is a preprocessor: we need to parse tag attributes
58
+ @parsing_is_enabled = true
59
+ @has_url = {}
60
+ end
61
+
62
+ # process the document
63
+ def process(_document, reader)
64
+ return reader if reader.eof?
65
+
66
+ reader.unshift_lines(parse_and_replace(reader.read_lines))
67
+ reader
68
+ end
69
+
70
+ private
71
+
72
+ def parse_and_replace(lines)
73
+ parsing_is_enabled = true
74
+ lines.reduce([]) do |new_lines, line|
75
+ parsing_is_enabled = !parsing_is_enabled if line == '....'
76
+ filter = FILTERS.find { |onefilter| line.match(onefilter.regex) }
77
+ if filter && parsing_is_enabled
78
+ new_lines + __send__(filter.apply, line, Regexp.last_match)
79
+ else
80
+ new_lines + [line]
81
+ end
82
+ end
83
+ end
84
+
85
+ def set_eref_url_if_any(line, matches)
86
+ @has_url[matches[:refname]] = true if matches[:symb] == 'url' && matches[:value] != 'none'
87
+ [line]
88
+ end
89
+
90
+ def build_definition(_line, matches)
91
+ definition_lines = []
92
+ if matches[:labels]
93
+ labels_str = labels_strings(matches[:labels]).join(' ')
94
+ definition_lines << ".#{matches[:reference]} #{labels_str}"
95
+ else
96
+ definition_lines << ".#{matches[:reference]}"
97
+ end
98
+ definition_lines <<
99
+ "[\##{matches[:reference]}.define.#{matches[:type]}]"
100
+ definition_lines
101
+ end
102
+
103
+ def labels_strings(labels)
104
+ labels_strs = []
105
+ labels.split(/\s*,\s*/).reject(&:empty?).each do |label|
106
+ labels_strs << "[.tag.{tag-#{label}-color}]\##{label}\#"
107
+ end
108
+ labels_strs
109
+ end
110
+
111
+ def build_link(ref, matches)
112
+ if @has_url[matches[:refname]]
113
+ "link:{eref-#{matches[:refname]}-url}\##{ref}\[#{ref}]"
114
+ else
115
+ ref
116
+ end
117
+ end
118
+
119
+ def build_external_ref(_line, matches)
120
+ extrefs = matches[:extrefs].split(/\s*,\s*/)
121
+ new_line = "[.external_reference]\#{eref-#{matches[:refname]}-prefix} "
122
+ extref_line = extrefs.map { |ref| build_link(ref, matches) }
123
+ @has_url[matches[:refname]]
124
+ [new_line + extref_line.join(', ') + '.#']
125
+ end
126
+
127
+ def build_internal_ref(line, _matches)
128
+ [line.gsub(IREF_DEF_REGEXP) do
129
+ "<<#{Regexp.last_match[:intref]},#{Regexp.last_match[:intref]}>>"
130
+ end]
131
+ end
132
+
133
+ def attribute_setting(_line, matches)
134
+ [
135
+ '[.attribute]',
136
+ "{attr-#{matches[:attr]}-prefix} #{matches[:value]}."
137
+ ]
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Asciidoctor
4
+ module DefMastership
5
+ VERSION = '1.0.0'
6
+ public_constant :VERSION
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asciidoctor-defmastership
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jérôme Arbez-Gindre
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aruba
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: '0.81'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: '0.81'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: asciidoctor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: defmastership
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.0.2
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: '2.0'
107
+ type: :runtime
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: 1.0.2
114
+ - - "<"
115
+ - !ruby/object:Gem::Version
116
+ version: '2.0'
117
+ description: |-
118
+ asciidoctor-defmastership allows to define
119
+ applicable definitions references, link to other references
120
+ (internal or external)
121
+ email:
122
+ - jeromearbezgindre@gmail.com
123
+ executables: []
124
+ extensions: []
125
+ extra_rdoc_files: []
126
+ files:
127
+ - ".gitignore"
128
+ - ".rspec"
129
+ - ".rubocop.yml"
130
+ - ".travis.yml"
131
+ - Gemfile
132
+ - Gemfile.lock
133
+ - README.md
134
+ - Rakefile
135
+ - asciidoctor-defmastership.gemspec
136
+ - bin/console
137
+ - bin/setup
138
+ - config/devtools.yml
139
+ - config/flay.yml
140
+ - config/flog.yml
141
+ - config/mutant.yml
142
+ - config/reek.yml
143
+ - config/rubocop.yml
144
+ - config/yardstick.yml
145
+ - example/.config.adoc
146
+ - example/.gitignore
147
+ - example/example.adoc
148
+ - example/howto.sh
149
+ - lib/asciidoctor/defmastership.rb
150
+ - lib/asciidoctor/defmastership/extension.rb
151
+ - lib/asciidoctor/defmastership/version.rb
152
+ homepage: https://gitlab.com/jjag/asciidoctor-defmastership/
153
+ licenses:
154
+ - Nonstandard
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '2.3'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubygems_version: 3.1.2
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: asciidoctor extension to handle applicable definition references
175
+ test_files: []