metanorma-plugin-glossarist 0.1.0 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91df61d3e70bbb70519cd36984e7edf0ec4fb3758a8d650690991db6b865f4c4
4
- data.tar.gz: d8729435c15a4402525c16d426014d0ce88f4ac6f1414781792331665490ae6e
3
+ metadata.gz: 161c43940a2841d4b92f05cb5b48cfab1f3eef3db02854b5dc88396e34aa9225
4
+ data.tar.gz: 377080e6303ad8e0afb736969e40f7fcbe8b48f354c96e6f82ffa2614a09c603
5
5
  SHA512:
6
- metadata.gz: eccf04cfaf2dbe3de1acda9c7a3a7ad3855b80fde9937c2486601c59c45ebea2f4f6e486507f6612b236344536936057a993e4f75cf544982d820f903fb1f2b2
7
- data.tar.gz: b790fa9ac8144256d48a0ab038a3e316a46ebb48f8b3f35b2628147ce35b2557ffc6a43964b08011673331c8f947efcc2b9ddab8e71e8f51ba8bceb177b3e6dd
6
+ metadata.gz: 3e2ade62ab37bcdc546ac357af61fb1245135733b85fac794c2503bb4f3d98fd09c6af2e12897f45d489ae5ff83e89468b419268fb3653d5fa1b4e8fd0eee459
7
+ data.tar.gz: 5626f96664c0e759a874f6efd5eb69a3ba4069958e470f3cacc2e2ecc980be99e7070f39b22c04a2a55476f535aee9b197a2ef3e503982fda7779491325a0781
@@ -1,3 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
1
3
  name: rake
2
4
 
3
5
  on:
@@ -8,6 +10,6 @@ on:
8
10
 
9
11
  jobs:
10
12
  rake:
11
- uses: metanorma/metanorma-build-scripts/.github/workflows/generic-rake.yml@main
13
+ uses: metanorma/ci/.github/workflows/generic-rake.yml@main
12
14
  secrets:
13
15
  pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -1,3 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
1
3
  name: release
2
4
 
3
5
  on:
@@ -8,14 +10,15 @@ on:
8
10
  Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
9
11
  required: true
10
12
  default: 'skip'
11
- push:
12
- tags: [ v* ]
13
+ repository_dispatch:
14
+ types: [ do-release ]
13
15
 
14
16
  jobs:
15
17
  release:
16
- uses: metanorma/metanorma-build-scripts/.github/workflows/rubygems-release.yml@main
18
+ uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
17
19
  with:
18
20
  next_version: ${{ github.event.inputs.next_version }}
19
- event_name: ${{ github.event_name }}
20
21
  secrets:
21
22
  rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
23
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
24
+
data/.gitignore CHANGED
@@ -11,5 +11,4 @@
11
11
  .rspec_status
12
12
  Gemfile.lock
13
13
 
14
- .hound.yml
15
- .rubocop*
14
+ .rubocop-https--*
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ ruby:
4
+ enabled: true
5
+ config_file: .rubocop.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
+
6
+ # local repo-specific modifications
7
+ # ...
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.5
@@ -59,20 +59,23 @@ module Metanorma
59
59
  # format
60
60
  def initialize(config = {})
61
61
  super
62
- @document = Document.new
62
+ @config = config
63
63
  @datasets = {}
64
64
  @rendered_bibliographies = {}
65
65
  end
66
66
 
67
67
  def process(document, reader)
68
68
  input_lines = reader.readlines.to_enum
69
+
69
70
  file_system = ::Liquid::LocalFileSystem.new(
70
71
  relative_file_path(document, ""),
71
72
  )
72
73
 
74
+ @config[:file_system] = file_system
75
+
73
76
  processed_doc = prepare_document(document, input_lines)
74
77
  Asciidoctor::Reader.new(
75
- processed_doc.render_liquid(file_system: file_system).split("\n"),
78
+ processed_doc.to_s.split("\n"),
76
79
  )
77
80
  end
78
81
 
@@ -80,6 +83,7 @@ module Metanorma
80
83
 
81
84
  def prepare_document(document, input_lines, end_mark = nil)
82
85
  liquid_doc = Document.new
86
+ liquid_doc.file_system = @config[:file_system]
83
87
 
84
88
  loop do
85
89
  current_line = input_lines.next
@@ -120,7 +124,10 @@ module Metanorma
120
124
  {% endwith_glossarist_context %}
121
125
  TEMPLATE
122
126
 
123
- liquid_doc.add_content(dataset_section)
127
+ liquid_doc.add_content(
128
+ dataset_section,
129
+ render: true,
130
+ )
124
131
  end
125
132
 
126
133
  def process_glossarist_block(document, liquid_doc, input_lines, match)
@@ -135,7 +142,10 @@ module Metanorma
135
142
  {% endwith_glossarist_context %}
136
143
  TEMPLATE
137
144
 
138
- liquid_doc.add_content(glossarist_section)
145
+ liquid_doc.add_content(
146
+ glossarist_section,
147
+ render: true,
148
+ )
139
149
  end
140
150
 
141
151
  def prepare_glossarist_block_params(document, match)
@@ -193,6 +203,7 @@ module Metanorma
193
203
  def concept_bibliography(concept)
194
204
  bibliography = concept["eng"]["sources"].map do |source|
195
205
  ref = source["origin"]["ref"]
206
+
196
207
  next if @rendered_bibliographies[ref]
197
208
 
198
209
  @rendered_bibliographies[ref] = ref.gsub(/[ \/:]/, '_')
@@ -4,23 +4,27 @@ module Metanorma
4
4
  module Plugin
5
5
  module Glossarist
6
6
  class Document
7
- attr_accessor :content, :bibliographies
7
+ attr_accessor :content, :bibliographies, :file_system
8
8
 
9
9
  def initialize
10
10
  @content = []
11
11
  @bibliographies = []
12
12
  end
13
13
 
14
- def add_content(content)
15
- @content << content
14
+ def add_content(content, options = {})
15
+ @content << if options[:render]
16
+ render_liquid(content)
17
+ else
18
+ content
19
+ end
16
20
  end
17
21
 
18
22
  def to_s
19
23
  @content.compact.join("\n")
20
24
  end
21
25
 
22
- def render_liquid(file_system)
23
- template = Liquid::Template.parse(to_s)
26
+ def render_liquid(file_content)
27
+ template = Liquid::Template.parse(file_content)
24
28
  template.registers[:file_system] = file_system
25
29
  template.render(strict_variables: false, error_mode: :warn)
26
30
  end
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Glossarist
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
@@ -9,4 +9,8 @@ module Metanorma
9
9
  # Your code goes here...
10
10
  end
11
11
  end
12
+
13
+ Asciidoctor::Extensions.register do
14
+ preprocessor Metanorma::Plugin::Glossarist::DatasetPreprocessor
15
+ end
12
16
  end
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.add_dependency "asciidoctor", "~> 2.0.0"
25
- spec.add_dependency "glossarist-new"
26
- spec.add_dependency "liquid", "~> 4"
25
+ spec.add_dependency "glossarist"
26
+ spec.add_dependency "liquid", "~> 5"
27
27
 
28
28
  spec.add_development_dependency "pry"
29
29
  spec.add_development_dependency "rake", "~> 12.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-plugin-glossarist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-15 00:00:00.000000000 Z
11
+ date: 2023-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: glossarist-new
28
+ name: glossarist
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4'
47
+ version: '5'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4'
54
+ version: '5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -104,7 +104,9 @@ files:
104
104
  - ".github/workflows/rake.yml"
105
105
  - ".github/workflows/release.yml"
106
106
  - ".gitignore"
107
+ - ".hound.yml"
107
108
  - ".rspec"
109
+ - ".rubocop.yml"
108
110
  - CODE_OF_CONDUCT.md
109
111
  - Gemfile
110
112
  - LICENSE.txt