nexmo_markdown_renderer 0.5.0 → 0.5.1

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: 4c9303cbd50b27ad02c68444daff15f65f3c3150f052bbfae839ee83e208f2f3
4
- data.tar.gz: 6598a455b0b1a5bc07e5f05b0425db82bcfd1d980f9a43e7b6455ec73e5c8258
3
+ metadata.gz: a77a40b7cc8162d5b8087bcf750f3cff31a5c0962991cb90d0f7d573ade580ec
4
+ data.tar.gz: 0c15812da744a7215555c04a4d026b8fe3a61454952a98c4b17255c86fd08104
5
5
  SHA512:
6
- metadata.gz: 5c2bb7bf7351edeee752c0ee34f93c7ac2610df41ad78aa0642b7070b3f5a3675254343c52285de3f879c195a5ff78c186f2e7bcee60a712661b4b704a2d25dc
7
- data.tar.gz: d82606e5cb6920496674fd3aba4888e5b874b5dcbdad38f35f6c24ccbe1ef24c8069acb84afb338477df6068404f9c4b283ad9fdb694652cb6d689329110cf56
6
+ metadata.gz: 6a37388e6c4173e69184d9836da5b7619a81439d49768bf3c08c89f84c53eb6257c1c142f91255fd2b0681c072dcfe37a9c94517ef210e356223a9e5ac56ac50
7
+ data.tar.gz: b4cf624eb1215e4379f938ae1688d416a7fb3bbcb347650363afb3b1d7b81f8e5f76b8d12efd3ad7a83177398b32f1af8969f87532a3cc6d69586d66f6a91037
@@ -3,20 +3,20 @@ module Nexmo
3
3
  class CodeSnippet
4
4
  include ActiveModel::Model
5
5
  attr_accessor :title, :product, :category, :navigation_weight, :document_path, :url
6
-
6
+
7
7
  def self.by_product(product)
8
8
  all.select do |block|
9
9
  block.product == product
10
10
  end
11
11
  end
12
-
12
+
13
13
  def self.all
14
14
  blocks = files.map do |document_path|
15
15
  document = File.read(document_path)
16
16
  product = extract_product(document_path)
17
-
17
+
18
18
  frontmatter = YAML.safe_load(document)
19
-
19
+
20
20
  Nexmo::Markdown::CodeSnippet.new({
21
21
  title: frontmatter['title'],
22
22
  navigation_weight: frontmatter['navigation_weight'] || 999,
@@ -26,47 +26,50 @@ module Nexmo
26
26
  url: generate_url(document_path),
27
27
  })
28
28
  end
29
-
29
+
30
30
  blocks.sort_by(&:navigation_weight)
31
31
  end
32
-
32
+
33
33
  def self.generate_url(path)
34
34
  '/' + path.gsub(%r{#{origin}/\w{2}/}, '').gsub('.md', '')
35
35
  end
36
-
36
+
37
37
  def self.extract_product(path)
38
38
  # Remove the prefix
39
39
  path = path.gsub!(%r{#{origin}/\w{2}/}, '')
40
-
40
+
41
41
  # Each file is in the form code-snippets/<title>.md, so let's remove everything after code-snippets
42
42
  path = path.gsub(%r{/code-snippets/.*}, '')
43
-
43
+
44
44
  path
45
45
  end
46
-
46
+
47
47
  def self.extract_category(path)
48
48
  # Remove the prefix
49
49
  path = path.gsub(%r{#{origin}/\w{2}/}, '')
50
-
50
+
51
51
  # Each file is in the form code-snippets/<title>.md, so let's capture everything after code-snippets
52
52
  path = path.gsub(%r{.*/code-snippets/(.*)$}, '\1')
53
-
53
+
54
54
  parts = path.split('/')
55
55
  parts = parts[0...-1]
56
-
56
+
57
57
  return nil if parts.empty?
58
-
58
+
59
59
  parts.join('/').tr('-', ' ').humanize
60
60
  end
61
-
61
+
62
62
  def self.files
63
- Dir.glob("#{origin}/**/code-snippets/**/*.md")
63
+ root = "#{origin}/#{::I18n.default_locale}"
64
+ Dir.glob("#{root}/**/code-snippets/**/*.md").map do |path|
65
+ DocFinder.find(root: origin, document: path.gsub(root, ''), language: ::I18n.locale).path
66
+ end
64
67
  end
65
-
68
+
66
69
  def self.origin
67
70
  "#{Nexmo::Markdown::Config.docs_base_path}/_documentation"
68
71
  end
69
72
  end
70
-
73
+
71
74
  end
72
75
  end
@@ -1,7 +1,7 @@
1
1
  # :nocov:
2
2
  module Nexmo
3
3
  module Markdown
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.1'
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.0
4
+ version: 0.5.1
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-05 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: banzai