asciidoctor-requirements 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 301514808e1331f3da304cffbe9cd23c0b3360525288f5b60072b38883362afa
4
+ data.tar.gz: 2f64fe4edfc0191bdd578f43a4a01955480d4494790dcbbf6bcd77a930a233c0
5
+ SHA512:
6
+ metadata.gz: dd004f1c6c936bb12865054e8293520f40f504de28d9f1d439eb4a1c4a69e29d5834f7bcd278b39f6bb3250221009c6297cf9e4f3bb728b0d869b37c3a3c7d77
7
+ data.tar.gz: 2b7cd1e195dc4bd496c0b309d8efeea22f005d9c63c0e62e0d33574de7ebc561610725a5d0fce3d7446409fc3fa6721b98dfb649cee04748e997881f81c298c0
data/README.adoc ADDED
@@ -0,0 +1,35 @@
1
+ = Asciidoctor::Requirements
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ 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/requirements`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ == Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ == Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ == Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ == Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/asciidoctor-requirements.
32
+
33
+ == License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,118 @@
1
+ require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
2
+ require 'yaml'
3
+
4
+ # An asciidoctor extension that transforms a yaml block in a formatted requirement
5
+ module AsciidoctorRequirements
6
+ module Asciidoctor
7
+
8
+ class RequirementBlock < ::Asciidoctor::Extensions::BlockProcessor
9
+ use_dsl
10
+
11
+ named :requirement
12
+ on_context :example
13
+ parse_content_as :raw
14
+
15
+ def process(parent, reader, attrs)
16
+ raw_data = reader.readlines.join("\n")
17
+ yaml_req = YAML.load(raw_data)
18
+
19
+ req_create_section(parent, yaml_req, attrs)
20
+ req_create_description(parent, yaml_req, attrs)
21
+ req_create_tabs_table(parent, yaml_req, attrs)
22
+ req_create_rationale(parent, yaml_req, attrs)
23
+ req_create_break(parent)
24
+
25
+ parent
26
+
27
+ end
28
+
29
+ def req_create_section(parent, yaml, attrs)
30
+ if yaml["title"].nil?
31
+ raise "Title missing in requirement yaml.\n" + req_usage()
32
+ end
33
+
34
+ if yaml["rev"].nil?
35
+ raise "Revision missing in requirement yaml.\n" + req_usage()
36
+ end
37
+
38
+ if yaml["id"].nil?
39
+ raise "id missing in requirement yaml.\n" + req_usage()
40
+ end
41
+
42
+ section_title = String(parent.document.attributes["reqprefix"] + "_" +yaml["id"] + "_" + yaml["rev"] + " : " + yaml["title"])
43
+
44
+ parent << create_section(parent, section_title, {})
45
+ end
46
+
47
+ def req_create_description(parent, yaml, attrs)
48
+ if yaml["description"].nil?
49
+ raise "Description missing in requirement yaml.\n" + req_usage()
50
+ end
51
+
52
+ description_text = "[.lead]\n" + yaml["description"]
53
+
54
+ parse_content(parent, description_text, {})
55
+ end
56
+
57
+ def req_create_rationale(parent, yaml, attrs)
58
+ if yaml["rationale"].nil?
59
+ return
60
+ end
61
+
62
+ table_delimiter = "|==="
63
+ rationale = "[cols='.^1,6', frame=none, grid=none]\n" + table_delimiter + "\ns|Rationale a|[.rationale]\n" + yaml["rationale"].strip + "\n" + table_delimiter
64
+
65
+ parse_content(parent, rationale, {})
66
+ end
67
+
68
+ def req_create_tabs_table(parent, yaml, attrs)
69
+ if yaml["tags"].empty?
70
+ return ""
71
+ end
72
+
73
+ tag_lines = ""
74
+ table_delimiter = "|==="
75
+
76
+ yaml["tags"].each do |k, v|
77
+ tag_lines += "|" + k + "|" + v + "\n"
78
+ end
79
+
80
+ tag_lines = "[%autowidth.stretch]\n" + table_delimiter + "\n" + tag_lines + table_delimiter
81
+
82
+ parse_content(parent, tag_lines, {})
83
+ end
84
+
85
+ def req_create_break(parent)
86
+ parse_content(parent, "'''", {})
87
+ end
88
+
89
+ def req_usage()
90
+ usage = '
91
+ USAGE :
92
+
93
+ [requirement]
94
+ ====
95
+ id: "0170"
96
+ rev: a
97
+ status: valid
98
+ title: Document Capability
99
+ description: The STRS platform provider shall describe, in the HID document, the reconfigurability behavior and capability of each reconfigurable component.
100
+ rationale: |
101
+ Waveform developers need to know the features and limitations of the platform for their applications.
102
+ Once the radio has been procured, NASA has the knowledge to procure or produce new or additional modules using HID information.
103
+ Also, future module replacement or additions will be possible without designing a new platform.
104
+
105
+
106
+ tags:
107
+ key1: value1
108
+ key2: value2
109
+ ====
110
+
111
+ '
112
+
113
+
114
+ usage
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,3 @@
1
+ module AsciidoctorRequirements
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,6 @@
1
+ RUBY_ENGINE == 'opal' ? (require 'asciidoctor-requirements/extension') : (require_relative 'asciidoctor-requirements/extension')
2
+
3
+ # Register the extensions to asciidoctor
4
+ Asciidoctor::Extensions.register do
5
+ block AsciidoctorRequirements::Asciidoctor::RequirementBlock
6
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asciidoctor-requirements
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - clemnjord
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: asciidoctor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.20
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.20
33
+ - !ruby/object:Gem::Dependency
34
+ name: yaml
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.2.1
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.2.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: asciidoctor-pdf
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.3'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.3.8
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '2.3'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.3.8
67
+ - !ruby/object:Gem::Dependency
68
+ name: asciidoctor-diagram
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '2.2'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '2.2'
81
+ description: An asciidoctor extension that transforms a yaml block in a formatted
82
+ requirement.
83
+ email:
84
+ executables: []
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - README.adoc
89
+ - lib/asciidoctor-requirements.rb
90
+ - lib/asciidoctor-requirements/extension.rb
91
+ - lib/asciidoctor-requirements/version.rb
92
+ homepage: https://github.com/clemnjord/asciidoctor-requirements
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 2.6.0
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubygems_version: 3.4.10
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: An asciidoctor extension that transforms a yaml block in a formatted requirement.
115
+ test_files: []