nexmo_markdown_renderer 0.1.0 → 0.1.1

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: cf72d97b82f7c671efe8a44e8699732332a3e59c3cbb7df3b6f87ec37a790a5d
4
- data.tar.gz: 91763b45e66bf134adb6c4297b0967625a355ff0054686bfb6b70fb680f0e7f8
3
+ metadata.gz: 0a7ee181316166581904d3090d0921bdd910fd04f3b82c3f0c79466c18c9161b
4
+ data.tar.gz: 47df143beda5e33479d632ad8de13e6b9af55103fe581d1d368ec75101c6bacf
5
5
  SHA512:
6
- metadata.gz: 5b60124cae98030eea13ec9498733c234dee46cf704238ee3252d70743a2a96e705983100c66c97a6d0ddad7fa4f3046b37aea5912805c32bd8396016efe8698
7
- data.tar.gz: '0458dfbbaf465ea60949c8e359d7db9bc3df2acbd9a2c5eba484015ce179c6225e4e647810508c38fbf578674eb31c630f92512437f05e66fd22e7d9410ff0d3'
6
+ metadata.gz: 9d394cb2a18d09357457307975ce286ec1d933cb38012ff735c342f211d1b381dda8707b5e012a5eee45c28caf57085bf52ab8d485005fff631a2dfc9044bc87
7
+ data.tar.gz: ecdeb294a4f147299e62863dc0120acc626e07d93eaa2433a2df67db42ba4dca81a4d09c782a353ee992aef26aa6be43409d5cfc7f37dca7f82e55166fca27c3
@@ -6,6 +6,7 @@ require 'nokogiri'
6
6
  require 'open-uri'
7
7
  require 'active_model'
8
8
  require 'i18n'
9
+ require_relative 'nexmo_markdown_renderer/config/load_config'
9
10
  require_relative 'nexmo_markdown_renderer/initializers/redcarpet'
10
11
  require_relative 'nexmo_markdown_renderer/initializers/i18n'
11
12
  require_relative 'nexmo_markdown_renderer/core_ext/string'
@@ -0,0 +1,9 @@
1
+ module Nexmo
2
+ module Markdown
3
+ class Config
4
+ def self.docs_base_path
5
+ @docs_base_path ||= (defined?(Rails) && Rails.application != nil && Rails.application.configuration.docs_base_path) || ENV.fetch('DOCS_BASE_PATH', '.')
6
+ end
7
+ end
8
+ end
9
+ end
@@ -6,12 +6,12 @@ module Nexmo
6
6
  config = YAML.safe_load($1)
7
7
 
8
8
  if config['config']
9
- configs = YAML.load_file("#{ENV['DOCS_BASE_PATH']}/config/code_examples.yml")
9
+ configs = YAML.load_file("#{Nexmo::Markdown::Config.docs_base_path}/config/code_examples.yml")
10
10
  config = config['config'].split('.').inject(configs) { |h, k| h[k] }
11
11
  end
12
12
 
13
- code = File.read("#{ENV['DOCS_BASE_PATH']}/#{config['source']}")
14
- language = File.extname("#{ENV['DOCS_BASE_PATH']}/#{config['source']}")[1..-1]
13
+ code = File.read("#{Nexmo::Markdown::Config.docs_base_path}/#{config['source']}")
14
+ language = File.extname("#{Nexmo::Markdown::Config.docs_base_path}/#{config['source']}")[1..-1]
15
15
  lexer = language_to_lexer(language)
16
16
 
17
17
  total_lines = code.lines.count
@@ -59,4 +59,4 @@ module Nexmo
59
59
  end
60
60
 
61
61
  end
62
- end
62
+ end
@@ -66,7 +66,7 @@ module Nexmo
66
66
  end
67
67
 
68
68
  def generate_code_block(language, input, unindent)
69
- filename = "#{ENV['DOCS_BASE_PATH']}/#{input['source']}"
69
+ filename = "#{Nexmo::Markdown::Config.docs_base_path}/#{input['source']}"
70
70
  return '' unless input
71
71
  raise "CodeSnippetFilter - Could not load #{filename} for language #{language}" unless File.exist?(filename)
72
72
 
@@ -89,7 +89,7 @@ module Nexmo
89
89
  end
90
90
 
91
91
  def content_from_source
92
- source_path = "#{ENV['DOCS_BASE_PATH']}/#{@config['source']}/*.yml"
92
+ source_path = "#{Nexmo::Markdown::Config.docs_base_path}/#{@config['source']}/*.yml"
93
93
 
94
94
  files = Dir[source_path]
95
95
  raise "No .yml files found for #{@config['source']} code snippets" if files.empty?
@@ -11,7 +11,7 @@ module Nexmo
11
11
  end
12
12
 
13
13
  modals = modals.map do |modal|
14
- filename = "#{ENV['DOCS_BASE_PATH']}/#{modal[:document]}"
14
+ filename = "#{Nexmo::Markdown::Config.docs_base_path}/#{modal[:document]}"
15
15
  raise "Could not find modal #{filename}" unless File.exist? filename
16
16
 
17
17
  document = File.read(filename)
@@ -7,7 +7,7 @@ module Nexmo
7
7
  file_path = if config['source'].starts_with? 'app/views'
8
8
  config['source']
9
9
  else
10
- "#{ENV['DOCS_BASE_PATH']}/#{config['source']}"
10
+ "#{Nexmo::Markdown::Config.docs_base_path}/#{config['source']}"
11
11
  end
12
12
  content = File.read(file_path)
13
13
 
@@ -8,9 +8,9 @@ module Nexmo
8
8
  @config = YAML.safe_load($3)
9
9
 
10
10
  if tabbed_folder?
11
- raise "#{@config['source']} is not a directory" unless File.directory? "#{ENV['DOCS_BASE_PATH']}/#{@config['source']}"
11
+ raise "#{@config['source']} is not a directory" unless File.directory? "#{Nexmo::Markdown::Config.docs_base_path}/#{@config['source']}"
12
12
 
13
- @tabbed_config = YAML.safe_load(File.read("#{ENV['DOCS_BASE_PATH']}/#{@config['source']}/.config.yml"))
13
+ @tabbed_config = YAML.safe_load(File.read("#{Nexmo::Markdown::Config.docs_base_path}/#{@config['source']}/.config.yml"))
14
14
  @path = @config['source']
15
15
  validate_folder_config
16
16
  else
@@ -146,7 +146,7 @@ module Nexmo
146
146
  end
147
147
 
148
148
  def content_from_source
149
- source_path = "#{ENV['DOCS_BASE_PATH']}/#{@config['source']}"
149
+ source_path = "#{Nexmo::Markdown::Config.docs_base_path}/#{@config['source']}"
150
150
  source_path += '/*' if tabbed_code_examples?
151
151
  source_path += '/*.md' if tabbed_content?
152
152
 
@@ -165,7 +165,7 @@ module Nexmo
165
165
  end
166
166
 
167
167
  def content_from_folder
168
- source_path = "#{ENV['DOCS_BASE_PATH']}/#{@config['source']}"
168
+ source_path = "#{Nexmo::Markdown::Config.docs_base_path}/#{@config['source']}"
169
169
  source_path += '/*.md'
170
170
 
171
171
  files = Dir.glob(source_path)
@@ -182,9 +182,9 @@ module Nexmo
182
182
 
183
183
  def content_from_tabs
184
184
  @config['tabs'].map do |title, config|
185
- raise "Could not find content_from_tabs file: #{ENV['DOCS_BASE_PATH']}/#{@config['source']}" unless File.exist? "#{ENV['DOCS_BASE_PATH']}/#{@config['source']}"
185
+ raise "Could not find content_from_tabs file: #{Nexmo::Markdown::Config.docs_base_path}/#{@config['source']}" unless File.exist? "#{Nexmo::Markdown::Config.docs_base_path}/#{@config['source']}"
186
186
 
187
- source = File.read("#{ENV['DOCS_BASE_PATH']}/#{@config['source']}")
187
+ source = File.read("#{Nexmo::Markdown::Config.docs_base_path}/#{@config['source']}")
188
188
 
189
189
  config.symbolize_keys.merge({
190
190
  id: SecureRandom.hex,
@@ -1,5 +1,5 @@
1
1
  Nexmo::Markdown::DocFinder.configure do |config|
2
- config.paths << "#{ENV['DOCS_BASE_PATH']}/_documentation"
3
- config.paths << "#{ENV['DOCS_BASE_PATH']}/_use_cases"
4
- config.paths << "#{ENV['DOCS_BASE_PATH']}/_tutorials"
2
+ config.paths << "#{Nexmo::Markdown::Config.docs_base_path}/_documentation"
3
+ config.paths << "#{Nexmo::Markdown::Config.docs_base_path}/_use_cases"
4
+ config.paths << "#{Nexmo::Markdown::Config.docs_base_path}/_tutorials"
5
5
  end
@@ -64,7 +64,7 @@ module Nexmo
64
64
  end
65
65
 
66
66
  def self.origin
67
- "#{ENV['DOCS_BASE_PATH']}/_documentation"
67
+ "#{Nexmo::Markdown::Config.docs_base_path}/_documentation"
68
68
  end
69
69
  end
70
70
 
@@ -2,8 +2,8 @@ module Nexmo
2
2
  module Markdown
3
3
  class Concept
4
4
  include ActiveModel::Model
5
-
6
- ORIGIN = "#{ENV['DOCS_BASE_PATH']}/_documentation".freeze
5
+
6
+ ORIGIN = "#{Nexmo::Markdown::Config.docs_base_path}/_documentation".freeze
7
7
 
8
8
  FILES = [
9
9
  Dir.glob("#{ORIGIN}/#{::I18n.default_locale}/**/guides/**/*.md"),
@@ -140,7 +140,7 @@ module Nexmo
140
140
  end
141
141
 
142
142
  def self.task_content_path
143
- "#{ENV['DOCS_BASE_PATH']}/_tutorials"
143
+ "#{Nexmo::Markdown::Config.docs_base_path}/_tutorials"
144
144
  end
145
145
  end
146
146
 
@@ -54,7 +54,7 @@ module Nexmo
54
54
  end
55
55
 
56
56
  def self.origin
57
- Pathname.new("#{ENV['DOCS_BASE_PATH']}/_use_cases")
57
+ Pathname.new("#{Nexmo::Markdown::Config.docs_base_path}/_use_cases")
58
58
  end
59
59
 
60
60
  def self.all
data/lib/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # :nocov:
2
2
  module Nexmo
3
3
  module Markdown
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.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.1.0
4
+ version: 0.1.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-03-11 00:00:00.000000000 Z
11
+ date: 2020-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: banzai
@@ -233,6 +233,7 @@ files:
233
233
  - config/dynamic_content.yml
234
234
  - config/locales/en.yml
235
235
  - lib/nexmo_markdown_renderer.rb
236
+ - lib/nexmo_markdown_renderer/config/load_config.rb
236
237
  - lib/nexmo_markdown_renderer/core_ext/string.rb
237
238
  - lib/nexmo_markdown_renderer/filters/anchor_filter.rb
238
239
  - lib/nexmo_markdown_renderer/filters/audio_filter.rb
@@ -328,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
328
329
  - !ruby/object:Gem::Version
329
330
  version: '0'
330
331
  requirements: []
331
- rubygems_version: 3.0.3
332
+ rubygems_version: 3.0.0
332
333
  signing_key:
333
334
  specification_version: 4
334
335
  summary: Middleware to render Markdown Documents in Nexmo Developer Platform.