nexmo_markdown_renderer 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a77a40b7cc8162d5b8087bcf750f3cff31a5c0962991cb90d0f7d573ade580ec
4
- data.tar.gz: 0c15812da744a7215555c04a4d026b8fe3a61454952a98c4b17255c86fd08104
3
+ metadata.gz: 41ef7bc208bcb98d22e13d771819af665bedfd65c2c5b8b1516b50bdcd0f0ed7
4
+ data.tar.gz: 5e6507ad1e17a66325a07b45397654798dbe0ae556a1633989ec4615a6f0569a
5
5
  SHA512:
6
- metadata.gz: 6a37388e6c4173e69184d9836da5b7619a81439d49768bf3c08c89f84c53eb6257c1c142f91255fd2b0681c072dcfe37a9c94517ef210e356223a9e5ac56ac50
7
- data.tar.gz: b4cf624eb1215e4379f938ae1688d416a7fb3bbcb347650363afb3b1d7b81f8e5f76b8d12efd3ad7a83177398b32f1af8969f87532a3cc6d69586d66f6a91037
6
+ metadata.gz: ca682dbe30887f444fe7d858ab5090e3f1f3b07da8fdfd2b015adfff08a03dace1dd4f72d1d72266b8a787f4529e235839511237a5f0fd96966eaa7c51f5a453
7
+ data.tar.gz: 0df50b173c98b7b3e70c8f46790e224a3eabef5220edf0cd5c11909923c2ce1bfa018e065a4b971d49af84174dc26940d2cbc9e2e51cae20ecc6da410b7ff75b
@@ -0,0 +1,34 @@
1
+ module Nexmo
2
+ module Markdown
3
+ class SnippetVariablesFilter < Banzai::Filter
4
+ def call(input)
5
+ input.gsub(/```snippet_variables(.+?)```/m) do |_s|
6
+ config = YAML.safe_load(Regexp.last_match(1))
7
+
8
+ raise 'No variables provided' unless config
9
+ raise 'Must provide an array' unless config.is_a?(Array)
10
+
11
+ output = <<~HEREDOC
12
+ Key | Description
13
+ -- | --
14
+ HEREDOC
15
+ config.each do |key|
16
+ details = variables[key]
17
+ raise "#{key} is not a valid snippet variable" unless details
18
+ raise "#{key} does not have a description" unless details['description']
19
+
20
+ output += <<~HEREDOC
21
+ `#{key}` | #{details['description']}
22
+ HEREDOC
23
+ end
24
+
25
+ output
26
+ end
27
+ end
28
+
29
+ def variables
30
+ @variables ||= YAML.safe_load(File.read("#{Nexmo::Markdown::Config.docs_base_path}/config/code_snippet_variables.yml"))
31
+ end
32
+ end
33
+ end
34
+ end
@@ -29,6 +29,7 @@ module Nexmo
29
29
  ConceptListFilter.new(options),
30
30
  LanguageFilter,
31
31
  ColumnsFilter,
32
+ SnippetVariablesFilter,
32
33
  MarkdownFilter.new(options),
33
34
 
34
35
  # As HTML
@@ -1,7 +1,7 @@
1
1
  # :nocov:
2
2
  module Nexmo
3
3
  module Markdown
4
- VERSION = '0.5.1'
4
+ VERSION = '0.6.0'
5
5
  end
6
6
  end
7
7
  # :nocov:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexmo_markdown_renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nexmo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-17 00:00:00.000000000 Z
11
+ date: 2020-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: banzai
@@ -276,6 +276,7 @@ files:
276
276
  - lib/nexmo_markdown_renderer/filters/php_inliner_filter.rb
277
277
  - lib/nexmo_markdown_renderer/filters/relative_link_filter.rb
278
278
  - lib/nexmo_markdown_renderer/filters/screenshot_filter.rb
279
+ - lib/nexmo_markdown_renderer/filters/snippet_variables_filter.rb
279
280
  - lib/nexmo_markdown_renderer/filters/tab_filter.rb
280
281
  - lib/nexmo_markdown_renderer/filters/techio_filter.rb
281
282
  - lib/nexmo_markdown_renderer/filters/tooltip_filter.rb