nexmo_markdown_renderer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +54 -0
  4. data/config/code_languages.yml +138 -0
  5. data/config/dynamic_content.yml +1 -0
  6. data/config/locales/en.yml +176 -0
  7. data/lib/nexmo_markdown_renderer.rb +28 -0
  8. data/lib/nexmo_markdown_renderer/cli.rb +13 -0
  9. data/lib/nexmo_markdown_renderer/core_ext/html.rb +7 -0
  10. data/lib/nexmo_markdown_renderer/core_ext/string.rb +14 -0
  11. data/lib/nexmo_markdown_renderer/filters/anchor_filter.rb +14 -0
  12. data/lib/nexmo_markdown_renderer/filters/audio_filter.rb +18 -0
  13. data/lib/nexmo_markdown_renderer/filters/block_escape_filter.rb +21 -0
  14. data/lib/nexmo_markdown_renderer/filters/break_filter.rb +10 -0
  15. data/lib/nexmo_markdown_renderer/filters/code_filter.rb +62 -0
  16. data/lib/nexmo_markdown_renderer/filters/code_snippet_filter.rb +187 -0
  17. data/lib/nexmo_markdown_renderer/filters/code_snippet_list_filter.rb +26 -0
  18. data/lib/nexmo_markdown_renderer/filters/code_snippets_filter.rb +170 -0
  19. data/lib/nexmo_markdown_renderer/filters/collapsible_filter.rb +27 -0
  20. data/lib/nexmo_markdown_renderer/filters/columns_filter.rb +47 -0
  21. data/lib/nexmo_markdown_renderer/filters/concept_list_filter.rb +30 -0
  22. data/lib/nexmo_markdown_renderer/filters/dynamic_content_filter.rb +28 -0
  23. data/lib/nexmo_markdown_renderer/filters/external_link_filter.rb +29 -0
  24. data/lib/nexmo_markdown_renderer/filters/frontmatter_filter.rb +11 -0
  25. data/lib/nexmo_markdown_renderer/filters/heading_filter.rb +57 -0
  26. data/lib/nexmo_markdown_renderer/filters/i18n/frontmatter_filter.rb +16 -0
  27. data/lib/nexmo_markdown_renderer/filters/i18n/smartling_converter_filter.rb +22 -0
  28. data/lib/nexmo_markdown_renderer/filters/icon_filter.rb +19 -0
  29. data/lib/nexmo_markdown_renderer/filters/indent_filter.rb +17 -0
  30. data/lib/nexmo_markdown_renderer/filters/inline_escape_filter.rb +14 -0
  31. data/lib/nexmo_markdown_renderer/filters/js_sequence_diagram_filter.rb +18 -0
  32. data/lib/nexmo_markdown_renderer/filters/label_filter.rb +29 -0
  33. data/lib/nexmo_markdown_renderer/filters/language_filter.rb +12 -0
  34. data/lib/nexmo_markdown_renderer/filters/markdown_filter.rb +81 -0
  35. data/lib/nexmo_markdown_renderer/filters/mermaid_filter.rb +29 -0
  36. data/lib/nexmo_markdown_renderer/filters/modal_filter.rb +37 -0
  37. data/lib/nexmo_markdown_renderer/filters/partial_filter.rb +29 -0
  38. data/lib/nexmo_markdown_renderer/filters/php_inliner_filter.rb +11 -0
  39. data/lib/nexmo_markdown_renderer/filters/screenshot_filter.rb +22 -0
  40. data/lib/nexmo_markdown_renderer/filters/tab_filter.rb +298 -0
  41. data/lib/nexmo_markdown_renderer/filters/techio_filter.rb +20 -0
  42. data/lib/nexmo_markdown_renderer/filters/tooltip_filter.rb +18 -0
  43. data/lib/nexmo_markdown_renderer/filters/unfreeze_filter.rb +16 -0
  44. data/lib/nexmo_markdown_renderer/filters/use_case_list_filter.rb +20 -0
  45. data/lib/nexmo_markdown_renderer/initializers/doc_finder.rb +5 -0
  46. data/lib/nexmo_markdown_renderer/initializers/i18n.rb +4 -0
  47. data/lib/nexmo_markdown_renderer/initializers/redcarpet.rb +7 -0
  48. data/lib/nexmo_markdown_renderer/markdown_renderer.rb +47 -0
  49. data/lib/nexmo_markdown_renderer/models/code_language.rb +79 -0
  50. data/lib/nexmo_markdown_renderer/models/code_snippet.rb +72 -0
  51. data/lib/nexmo_markdown_renderer/models/concept.rb +83 -0
  52. data/lib/nexmo_markdown_renderer/models/tutorial.rb +148 -0
  53. data/lib/nexmo_markdown_renderer/models/use_case.rb +81 -0
  54. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/android.rb +25 -0
  55. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/base.rb +12 -0
  56. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/curl.rb +29 -0
  57. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/dotnet.rb +23 -0
  58. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/java.rb +32 -0
  59. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/javascript.rb +23 -0
  60. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/kotlin.rb +25 -0
  61. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/objective_c.rb +25 -0
  62. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/php.rb +23 -0
  63. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/python.rb +23 -0
  64. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/ruby.rb +23 -0
  65. data/lib/nexmo_markdown_renderer/services/code_snippet_renderer/swift.rb +25 -0
  66. data/lib/nexmo_markdown_renderer/services/doc_finder.rb +119 -0
  67. data/lib/nexmo_markdown_renderer/views/code_snippets/_application_messages_dispatch.html.erb +9 -0
  68. data/lib/nexmo_markdown_renderer/views/code_snippets/_application_rtc.html.erb +28 -0
  69. data/lib/nexmo_markdown_renderer/views/code_snippets/_application_voice.html.erb +24 -0
  70. data/lib/nexmo_markdown_renderer/views/code_snippets/_code_only.html.erb +6 -0
  71. data/lib/nexmo_markdown_renderer/views/code_snippets/_configure_client.html.erb +20 -0
  72. data/lib/nexmo_markdown_renderer/views/code_snippets/_dependencies.html.erb +11 -0
  73. data/lib/nexmo_markdown_renderer/views/code_snippets/_write_code.html.erb +13 -0
  74. data/lib/nexmo_markdown_renderer/views/code_snippets/list/plain.html.erb +10 -0
  75. data/lib/nexmo_markdown_renderer/views/concepts/list/plain.html.erb +5 -0
  76. data/lib/nexmo_markdown_renderer/views/use_case/_index.html.erb +41 -0
  77. data/lib/nexmo_markdown_renderer/views/use_case/index.html.erb +48 -0
  78. data/lib/nexmo_markdown_renderer/views/use_case/list/plain.html.erb +5 -0
  79. data/lib/nexmo_markdown_renderer/views/use_case/show.html.erb +8 -0
  80. data/lib/version.rb +7 -0
  81. metadata +322 -0
@@ -0,0 +1,81 @@
1
+ module Nexmo
2
+ module Markdown
3
+ class UseCase
4
+ include ActiveModel::Model
5
+ attr_accessor :title, :description, :external_link, :products, :document_path, :languages, :root
6
+
7
+ def body
8
+ File.read(document_path)
9
+ end
10
+
11
+ def path
12
+ return external_link if external_link
13
+ path = document_path.relative_path_from(Nexmo::Markdown::UseCase.origin).sub("#{::I18n.locale}/", '')
14
+ "/use-cases/#{path}".gsub('.md', '')
15
+ end
16
+
17
+ def subtitle
18
+ normalized_products = products.map do |product|
19
+ normalise_product_title(product)
20
+ end
21
+
22
+ normalized_products.sort.to_sentence
23
+ end
24
+
25
+ def normalise_product_title(product)
26
+ return 'SMS' if product == 'messaging/sms'
27
+ return 'Voice' if product == 'voice/voice-api'
28
+ return 'Number Insight' if product == 'number-insight'
29
+ return 'Messages' if product == 'messages'
30
+ return 'Dispatch' if product == 'dispatch'
31
+ return 'Client SDK' if product == 'client-sdk'
32
+ return 'Subaccounts' if product == 'account/subaccounts'
33
+ product.camelcase
34
+ end
35
+
36
+ def self.by_product(product, use_cases = [])
37
+ use_cases = all if use_cases.empty?
38
+ use_cases.select do |use_case|
39
+ use_case.products.include? product
40
+ end
41
+ end
42
+
43
+ def self.by_language(language, use_cases = [])
44
+ language = language.downcase
45
+ use_cases = all if use_cases.empty?
46
+
47
+ use_cases.select do |use_case|
48
+ use_case.languages.map(&:downcase).include? language
49
+ end
50
+ end
51
+
52
+ def self.origin
53
+ Pathname.new("#{ENV['DOCS_BASE_PATH']}/_use_cases")
54
+ end
55
+
56
+ def self.all
57
+ files.map do |document_path|
58
+ document_path = Pathname.new(document_path)
59
+ document = File.read(document_path)
60
+ frontmatter = YAML.safe_load(document)
61
+
62
+ Nexmo::Markdown::UseCase.new({
63
+ title: frontmatter['title'],
64
+ description: frontmatter['description'],
65
+ external_link: frontmatter['external_link'],
66
+ products: frontmatter['products'].split(',').map(&:strip),
67
+ languages: frontmatter['languages'] || [],
68
+ document_path: document_path,
69
+ root: origin.to_s,
70
+ })
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ private_class_method def self.files
77
+ Dir.glob("#{origin}/**/*.md")
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,25 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Android < Base
5
+ def self.dependencies(_deps)
6
+ {
7
+ 'text' => 'See <a href="https://developer.nexmo.com/use-cases/client-sdk-android-add-sdk-to-your-app">How to Add the Nexmo Client SDK to your Android App</a>',
8
+ }
9
+ end
10
+
11
+ def self.run_command(_command, _filename, _file_path)
12
+ nil
13
+ end
14
+
15
+ def self.create_instructions(filename)
16
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
17
+ end
18
+
19
+ def self.add_instructions(_filename)
20
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_code')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Base
5
+ def self.inherited(base)
6
+ base.extend ActionView::Helpers::TranslationHelper
7
+ base.instance_variable_set :@virtual_path, "services.#{base.name.underscore.tr('/', '.')}"
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Curl < Base
5
+ def self.dependencies(deps)
6
+ dependencies = deps.map(&:upcase)
7
+ raise t('.only_permitted_dependency') unless dependencies.include?('JWT')
8
+ {
9
+ 'text' => t('.text'),
10
+ 'code' => 'export JWT=$(nexmo jwt:generate $PATH_TO_PRIVATE_KEY application_id=$NEXMO_APPLICATION_ID)',
11
+ }
12
+ end
13
+
14
+ def self.run_command(command, _filename, _file_path)
15
+ ::I18n.t('services.code_snippet_renderer.run_command', command: command)
16
+ end
17
+
18
+ def self.create_instructions(filename)
19
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
20
+ end
21
+
22
+ def self.add_instructions(filename)
23
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_file', file: filename)
24
+ end
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Dotnet < Base
5
+ def self.dependencies(deps)
6
+ { 'code' => "Install-Package #{deps.join(' ')}" }
7
+ end
8
+
9
+ def self.run_command(_command, _filename, _file_path)
10
+ nil
11
+ end
12
+
13
+ def self.create_instructions(filename)
14
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
15
+ end
16
+
17
+ def self.add_instructions(filename)
18
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_file', file: filename)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,32 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Java < Base
5
+ def self.dependencies(deps)
6
+ {
7
+ 'text' => t('services.code_snippet_renderer.add_instructions_to_file', file: 'build.gradle'),
8
+ 'code' => deps.map { |d| "compile '#{d.gsub('@latest', '5.2.1')}'" }.join('<br />'),
9
+ 'type' => 'groovy',
10
+ }
11
+ end
12
+
13
+ def self.run_command(_command, filename, file_path)
14
+ package = file_path.gsub('.repos/nexmo/nexmo-java-code-snippets/src/main/java/', '').tr('/', '.').gsub(filename, '')
15
+ file = filename.gsub('.java', '')
16
+ main = "#{package}#{filename.gsub('.java', '')}"
17
+ chomped_package = package.chomp('.')
18
+
19
+ ::I18n.t('.run_command', chomped_package: chomped_package, package: package, main: main, file: file)
20
+ end
21
+
22
+ def self.create_instructions(filename)
23
+ ::I18n.t('.create_instructions', file: filename.gsub('.java', ''))
24
+ end
25
+
26
+ def self.add_instructions(filename)
27
+ ::I18n.t('.add_instructions', file: filename.gsub('.java', ''))
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Javascript < Base
5
+ def self.dependencies(deps)
6
+ { 'code' => "npm install #{deps.join(' ')}" }
7
+ end
8
+
9
+ def self.run_command(command, _filename, _file_path)
10
+ ::I18n.t('services.code_snippet_renderer.run_command', command: command)
11
+ end
12
+
13
+ def self.create_instructions(filename)
14
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
15
+ end
16
+
17
+ def self.add_instructions(filename)
18
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_file', file: filename)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Kotlin < Base
5
+ def self.dependencies(_deps)
6
+ {
7
+ 'text' => 'See <a href="https://developer.nexmo.com/use-cases/client-sdk-android-add-sdk-to-your-app">How to Add the Nexmo Client SDK to your Android App</a>',
8
+ }
9
+ end
10
+
11
+ def self.run_command(_command, _filename, _file_path)
12
+ nil
13
+ end
14
+
15
+ def self.create_instructions(filename)
16
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
17
+ end
18
+
19
+ def self.add_instructions(_filename)
20
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_code')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class ObjectiveC < Base
5
+ def self.dependencies(_deps)
6
+ {
7
+ 'text' => 'See <a href="/client-sdk/setup/add-sdk-to-your-app/ios">How to Add the Nexmo Client SDK to your iOS App</a>',
8
+ }
9
+ end
10
+
11
+ def self.run_command(_command, _filename, _file_path)
12
+ nil
13
+ end
14
+
15
+ def self.create_instructions(filename)
16
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
17
+ end
18
+
19
+ def self.add_instructions(_filename)
20
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_code')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Php < Base
5
+ def self.dependencies(deps)
6
+ { 'code' => "composer require #{deps.join(' ')}" }
7
+ end
8
+
9
+ def self.run_command(command, _filename, _file_path)
10
+ ::I18n.t('services.code_snippet_renderer.run_command', command: command)
11
+ end
12
+
13
+ def self.create_instructions(filename)
14
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
15
+ end
16
+
17
+ def self.add_instructions(filename)
18
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_file', file: filename)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Python < Base
5
+ def self.dependencies(deps)
6
+ { 'code' => "pip install #{deps.join(' ')}" }
7
+ end
8
+
9
+ def self.run_command(command, _filename, _file_path)
10
+ ::I18n.t('services.code_snippet_renderer.run_command', command: command)
11
+ end
12
+
13
+ def self.create_instructions(filename)
14
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
15
+ end
16
+
17
+ def self.add_instructions(filename)
18
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_file', file: filename)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Ruby < Base
5
+ def self.dependencies(deps)
6
+ { 'code' => "gem install #{deps.join(' ')}" }
7
+ end
8
+
9
+ def self.run_command(command, _filename, _file_path)
10
+ ::I18n.t('services.code_snippet_renderer.run_command', command: command)
11
+ end
12
+
13
+ def self.create_instructions(filename)
14
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
15
+ end
16
+
17
+ def self.add_instructions(filename)
18
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_file', file: filename)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ module Nexmo
2
+ module Markdown
3
+ module CodeSnippetRenderer
4
+ class Swift < Base
5
+ def self.dependencies(_deps)
6
+ {
7
+ 'text' => 'See <a href="/client-sdk/setup/add-sdk-to-your-app/ios">How to Add the Nexmo Client SDK to your iOS App</a>',
8
+ }
9
+ end
10
+
11
+ def self.run_command(_command, _filename, _file_path)
12
+ nil
13
+ end
14
+
15
+ def self.create_instructions(filename)
16
+ ::I18n.t('services.code_snippet_renderer.create_instructions', filename: filename)
17
+ end
18
+
19
+ def self.add_instructions(_filename)
20
+ ::I18n.t('services.code_snippet_renderer.add_instructions_to_code')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,119 @@
1
+ module Nexmo
2
+ module Markdown
3
+ class DocFinder
4
+ class MissingDoc < StandardError; end
5
+
6
+ EXCLUSIONS = ['.', '..', ::I18n.default_locale.to_s].freeze
7
+
8
+ class << self
9
+ mattr_accessor :paths
10
+ mattr_accessor :dictionary
11
+ end
12
+
13
+ # rubocop:disable Metrics/ParameterLists
14
+ def self.find(root:, document:, language: nil, product: nil, code_language: nil, format: 'md', strip_root_and_language: false)
15
+ if strip_root_and_language
16
+ document = strip_root_and_language(root: root, language: "(#{language}|#{::I18n.default_locale})", document: document)
17
+ end
18
+ begin
19
+ if code_language.present?
20
+ linkable_code_language(
21
+ root: root,
22
+ language: language,
23
+ product: product,
24
+ document: document,
25
+ code_language: code_language,
26
+ format: format
27
+ )
28
+ else
29
+ non_linkable(
30
+ root: root,
31
+ language: language,
32
+ product: product,
33
+ document: document,
34
+ format: format
35
+ )
36
+ end
37
+ rescue KeyError => e
38
+ raise MissingDoc, e.message
39
+ end
40
+ end
41
+
42
+ def self.linkable_code_language(root:, language:, document:, product: nil, code_language: nil, format: nil)
43
+ key = [
44
+ build_key(root: root, product: product, document: "#{document}/#{code_language}", format: format),
45
+ build_key(root: root, product: product, document: document, format: format),
46
+ ].select { |k| dictionary.key?(k) }.first
47
+
48
+ available_language = dictionary.fetch(key).fetch(language, ::I18n.default_locale.to_s)
49
+ build_doc_path(root, key, available_language)
50
+ end
51
+
52
+ def self.non_linkable(root:, language:, document:, product: nil, format: nil)
53
+ key = build_key(root: root, product: product, document: document, format: format)
54
+ if root.starts_with?('app/views')
55
+ dictionary.fetch(key) && key
56
+ else
57
+ available_language = dictionary.fetch(key).fetch(language.to_s, ::I18n.default_locale.to_s)
58
+ build_doc_path(root, key, available_language)
59
+ end
60
+ end
61
+ # rubocop:enable Metrics/ParameterLists
62
+
63
+ def self.build_key(root:, document:, product: nil, format: nil)
64
+ path = if Pathname.new(document).extname.blank?
65
+ "#{root}/#{product}/#{document}.#{format}"
66
+ else
67
+ "#{root}/#{product}/#{document}"
68
+ end
69
+ path.gsub(%r{\/\/\/|\/\/}, '/')
70
+ end
71
+
72
+ def self.build_doc_path(root, doc, language)
73
+ doc.gsub(root, "#{root}/#{language}")
74
+ end
75
+
76
+ def self.configure
77
+ self.paths = []
78
+ self.dictionary = Hash.new { |hash, key| hash[key] = {} }
79
+
80
+ yield(self)
81
+
82
+ load_english
83
+ load_languages
84
+ end
85
+
86
+ def self.load_english
87
+ paths.each do |path|
88
+ if path.starts_with?('app/views')
89
+ Dir["#{path}/**/*.*"].each do |file|
90
+ dictionary[file][::I18n.default_locale.to_s] = ::I18n.default_locale.to_s
91
+ end
92
+ else
93
+ path_with_locale = "#{path}/#{::I18n.default_locale}"
94
+ Dir["#{path_with_locale}/**/{*.*,.config.yml}"].each do |file|
95
+ key = "#{path}/#{file.gsub("#{path_with_locale}/", '')}"
96
+ dictionary[key][::I18n.default_locale.to_s] = ::I18n.default_locale.to_s
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ def self.load_languages
103
+ paths.each do |path|
104
+ Dir.foreach(path).reject { |d| EXCLUSIONS.include? d }.each do |language|
105
+ Dir.glob("#{path}/#{language}/**/{*.*,.config.yml}").each do |file|
106
+ doc_name = strip_root_and_language(root: path, language: language, document: file)
107
+ key = "#{path}/#{doc_name}"
108
+ dictionary[key][language] = language
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ def self.strip_root_and_language(root:, language:, document:)
115
+ document.sub(%r{#{root}\/}, '').sub(%r{#{language}\/}, '')
116
+ end
117
+ end
118
+ end
119
+ end