structured_text_renderer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +27 -0
  5. data/.rubocop_todo.yml +35 -0
  6. data/.travis.yml +13 -0
  7. data/.yardopts +4 -0
  8. data/CHANGELOG.md +5 -0
  9. data/Gemfile +3 -0
  10. data/Gemfile.lock +110 -0
  11. data/Guardfile +24 -0
  12. data/LICENSE.txt +21 -0
  13. data/README.md +87 -0
  14. data/Rakefile +33 -0
  15. data/coverage/.last_run.json +5 -0
  16. data/coverage/.resultset.json +1366 -0
  17. data/coverage/.resultset.json.lock +0 -0
  18. data/coverage/assets/0.10.2/application.css +799 -0
  19. data/coverage/assets/0.10.2/application.js +1707 -0
  20. data/coverage/assets/0.10.2/colorbox/border.png +0 -0
  21. data/coverage/assets/0.10.2/colorbox/controls.png +0 -0
  22. data/coverage/assets/0.10.2/colorbox/loading.gif +0 -0
  23. data/coverage/assets/0.10.2/colorbox/loading_background.png +0 -0
  24. data/coverage/assets/0.10.2/favicon_green.png +0 -0
  25. data/coverage/assets/0.10.2/favicon_red.png +0 -0
  26. data/coverage/assets/0.10.2/favicon_yellow.png +0 -0
  27. data/coverage/assets/0.10.2/loading.gif +0 -0
  28. data/coverage/assets/0.10.2/magnify.png +0 -0
  29. data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  30. data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  31. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  32. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  33. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  34. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  35. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  36. data/coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  37. data/coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png +0 -0
  38. data/coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  39. data/coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png +0 -0
  40. data/coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png +0 -0
  41. data/coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  42. data/coverage/index.html +9110 -0
  43. data/doc/StructuredTextRenderer/BaseBlockRenderer.html +248 -0
  44. data/doc/StructuredTextRenderer/BaseInlineRenderer.html +242 -0
  45. data/doc/StructuredTextRenderer/BaseNodeRenderer.html +300 -0
  46. data/doc/StructuredTextRenderer/BoldRenderer.html +169 -0
  47. data/doc/StructuredTextRenderer/CodeRenderer.html +169 -0
  48. data/doc/StructuredTextRenderer/DocumentRenderer.html +242 -0
  49. data/doc/StructuredTextRenderer/EntryBlockRenderer.html +239 -0
  50. data/doc/StructuredTextRenderer/HeadingFiveRenderer.html +169 -0
  51. data/doc/StructuredTextRenderer/HeadingFourRenderer.html +169 -0
  52. data/doc/StructuredTextRenderer/HeadingOneRenderer.html +169 -0
  53. data/doc/StructuredTextRenderer/HeadingSixRenderer.html +169 -0
  54. data/doc/StructuredTextRenderer/HeadingThreeRenderer.html +169 -0
  55. data/doc/StructuredTextRenderer/HeadingTwoRenderer.html +169 -0
  56. data/doc/StructuredTextRenderer/HrRenderer.html +238 -0
  57. data/doc/StructuredTextRenderer/HyperlinkRenderer.html +254 -0
  58. data/doc/StructuredTextRenderer/ItalicRenderer.html +169 -0
  59. data/doc/StructuredTextRenderer/ListItemRenderer.html +169 -0
  60. data/doc/StructuredTextRenderer/NullRenderer.html +238 -0
  61. data/doc/StructuredTextRenderer/OrderedListRenderer.html +169 -0
  62. data/doc/StructuredTextRenderer/ParagraphRenderer.html +169 -0
  63. data/doc/StructuredTextRenderer/QuoteRenderer.html +169 -0
  64. data/doc/StructuredTextRenderer/Renderer.html +349 -0
  65. data/doc/StructuredTextRenderer/TextRenderer.html +254 -0
  66. data/doc/StructuredTextRenderer/UnderlineRenderer.html +169 -0
  67. data/doc/StructuredTextRenderer/UnorderedListRenderer.html +169 -0
  68. data/doc/StructuredTextRenderer.html +155 -0
  69. data/doc/_index.html +403 -0
  70. data/doc/class_list.html +51 -0
  71. data/doc/css/common.css +1 -0
  72. data/doc/css/full_list.css +58 -0
  73. data/doc/css/style.css +496 -0
  74. data/doc/file.CHANGELOG.html +77 -0
  75. data/doc/file.LICENSE.html +70 -0
  76. data/doc/file.README.html +171 -0
  77. data/doc/file_list.html +66 -0
  78. data/doc/frames.html +17 -0
  79. data/doc/index.html +171 -0
  80. data/doc/js/app.js +292 -0
  81. data/doc/js/full_list.js +216 -0
  82. data/doc/js/jquery.js +4 -0
  83. data/doc/method_list.html +147 -0
  84. data/doc/top-level-namespace.html +110 -0
  85. data/lib/structured_text_renderer/base_node_renderer.rb +18 -0
  86. data/lib/structured_text_renderer/block_renderers/base_block_renderer.rb +20 -0
  87. data/lib/structured_text_renderer/block_renderers/entry_block_renderer.rb +13 -0
  88. data/lib/structured_text_renderer/block_renderers/heading_five_renderer.rb +12 -0
  89. data/lib/structured_text_renderer/block_renderers/heading_four_renderer.rb +12 -0
  90. data/lib/structured_text_renderer/block_renderers/heading_one_renderer.rb +12 -0
  91. data/lib/structured_text_renderer/block_renderers/heading_six_renderer.rb +12 -0
  92. data/lib/structured_text_renderer/block_renderers/heading_three_renderer.rb +12 -0
  93. data/lib/structured_text_renderer/block_renderers/heading_two_renderer.rb +12 -0
  94. data/lib/structured_text_renderer/block_renderers/hr_renderer.rb +11 -0
  95. data/lib/structured_text_renderer/block_renderers/hyperlink_renderer.rb +15 -0
  96. data/lib/structured_text_renderer/block_renderers/list_item_renderer.rb +12 -0
  97. data/lib/structured_text_renderer/block_renderers/ordered_list_renderer.rb +12 -0
  98. data/lib/structured_text_renderer/block_renderers/paragraph_renderer.rb +12 -0
  99. data/lib/structured_text_renderer/block_renderers/quote_renderer.rb +12 -0
  100. data/lib/structured_text_renderer/block_renderers/unordered_list_renderer.rb +12 -0
  101. data/lib/structured_text_renderer/block_renderers.rb +18 -0
  102. data/lib/structured_text_renderer/document_renderers/document_renderer.rb +13 -0
  103. data/lib/structured_text_renderer/document_renderers.rb +1 -0
  104. data/lib/structured_text_renderer/null_renderer.rb +19 -0
  105. data/lib/structured_text_renderer/renderer.rb +46 -0
  106. data/lib/structured_text_renderer/text_renderers/base_inline_renderer.rb +17 -0
  107. data/lib/structured_text_renderer/text_renderers/bold_renderer.rb +12 -0
  108. data/lib/structured_text_renderer/text_renderers/code_renderer.rb +12 -0
  109. data/lib/structured_text_renderer/text_renderers/italic_renderer.rb +12 -0
  110. data/lib/structured_text_renderer/text_renderers/text_renderer.rb +19 -0
  111. data/lib/structured_text_renderer/text_renderers/underline_renderer.rb +12 -0
  112. data/lib/structured_text_renderer/text_renderers.rb +5 -0
  113. data/lib/structured_text_renderer/version.rb +4 -0
  114. data/lib/structured_text_renderer.rb +2 -0
  115. data/spec/lib/structured_text_renderer/block_renderers/base_block_renderer_spec.rb +26 -0
  116. data/spec/lib/structured_text_renderer/block_renderers/entry_block_renderer_spec.rb +15 -0
  117. data/spec/lib/structured_text_renderer/block_renderers/heading_five_renderer_spec.rb +24 -0
  118. data/spec/lib/structured_text_renderer/block_renderers/heading_four_renderer_spec.rb +24 -0
  119. data/spec/lib/structured_text_renderer/block_renderers/heading_one_renderer_spec.rb +24 -0
  120. data/spec/lib/structured_text_renderer/block_renderers/heading_six_renderer_spec.rb +24 -0
  121. data/spec/lib/structured_text_renderer/block_renderers/heading_three_renderer_spec.rb +24 -0
  122. data/spec/lib/structured_text_renderer/block_renderers/heading_two_renderer_spec.rb +24 -0
  123. data/spec/lib/structured_text_renderer/block_renderers/hr_renderer_spec.rb +13 -0
  124. data/spec/lib/structured_text_renderer/block_renderers/hyperlink_renderer_spec.rb +24 -0
  125. data/spec/lib/structured_text_renderer/block_renderers/list_item_renderer_spec.rb +24 -0
  126. data/spec/lib/structured_text_renderer/block_renderers/ordered_list_renderer_spec.rb +56 -0
  127. data/spec/lib/structured_text_renderer/block_renderers/paragraph_renderer_spec.rb +24 -0
  128. data/spec/lib/structured_text_renderer/block_renderers/quote_renderer_spec.rb +25 -0
  129. data/spec/lib/structured_text_renderer/block_renderers/unordered_list_renderer_spec.rb +56 -0
  130. data/spec/lib/structured_text_renderer/document_renderers/document_renderer_spec.rb +42 -0
  131. data/spec/lib/structured_text_renderer/null_renderer_spec.rb +19 -0
  132. data/spec/lib/structured_text_renderer/renderer_spec.rb +308 -0
  133. data/spec/lib/structured_text_renderer/text_renderers/base_inline_renderer_spec.rb +11 -0
  134. data/spec/lib/structured_text_renderer/text_renderers/bold_renderer_spec.rb +11 -0
  135. data/spec/lib/structured_text_renderer/text_renderers/code_renderer_spec.rb +11 -0
  136. data/spec/lib/structured_text_renderer/text_renderers/italic_renderer_spec.rb +11 -0
  137. data/spec/lib/structured_text_renderer/text_renderers/text_renderer_spec.rb +53 -0
  138. data/spec/lib/structured_text_renderer/text_renderers/underline_renderer_spec.rb +11 -0
  139. data/spec/spec_helper.rb +82 -0
  140. data/structured_text_renderer.gemspec +30 -0
  141. metadata +361 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d51d294c923676f4c5663d139b9b33a6f4e1991c454777d4ea7294352d8bdcf2
4
+ data.tar.gz: 38103cd1b5ed95db1638932d859e9e8d8e5f292b1c19ec9d1819dbf05cd82349
5
+ SHA512:
6
+ metadata.gz: dc77f8c124c2dc9d1dfc1a96355091223f94e44bb5ead763d0fa0ad58bd66038bbde2f132a6626bc598d63573753584f4e452b2092348f8947bd7cb9843337b1
7
+ data.tar.gz: 6d6c075c0a1980e50b034a919ac7c96ba09ab79cbc5ca55f09c2861662b96c0489008aefea8d38ce46a51a637c835f9a5449cfaba29f97cd8b9f1b4a6379d5ee
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ pkg
2
+ doc/
3
+ .yardoc/
4
+ coverage
5
+ Gemfile.lock
6
+ .idea
7
+ *.DS_Store
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,27 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Encoding:
4
+ Enabled: false
5
+
6
+ Metrics/ClassLength:
7
+ CountComments: false
8
+
9
+ Metrics/MethodLength:
10
+ CountComments: false
11
+
12
+ AllCops:
13
+ Exclude:
14
+ - structured_text_renderer.gemspec
15
+ - spec/**/*
16
+ - Guardfile
17
+ - Gemfile
18
+ - Rakefile
19
+
20
+ Metrics/ClassLength:
21
+ Max: 250
22
+
23
+ Style/MutableConstant:
24
+ Enabled: false
25
+
26
+ Style/SignalException:
27
+ EnforcedStyle: 'semantic'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,35 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-02-02 13:30:13 -0300 using RuboCop version 0.36.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 6
10
+ Metrics/AbcSize:
11
+ Max: 38
12
+
13
+ # Offense count: 5
14
+ Metrics/CyclomaticComplexity:
15
+ Max: 8
16
+
17
+ # Offense count: 1
18
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
19
+ # URISchemes: http, https
20
+ Metrics/LineLength:
21
+ Max: 142
22
+
23
+ # Offense count: 12
24
+ # Configuration parameters: CountComments.
25
+ Metrics/MethodLength:
26
+ Max: 27
27
+
28
+ # Offense count: 2
29
+ # Configuration parameters: CountComments.
30
+ Metrics/ModuleLength:
31
+ Max: 499
32
+
33
+ # Offense count: 4
34
+ Metrics/PerceivedComplexity:
35
+ Max: 8
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.4.0
4
+ - 2.3.1
5
+ - 2.2.1
6
+ notifications:
7
+ slack:
8
+ secure: Zr3mKCiTb0vaTD4MPtTG8BbyYyErFuoxioM25QyrqePKVkDFeZC1MtGmg5klQQrJiWTKZPa/zB8NAHYkoUxg9I+z15JK0hYfz9KRubEpCrXCaqTC9Vzq88kJ3LN8YsTyBF66izaBH2KLsOfaJRxwplFzZqgpg4GG2DUBPtrGtes=
9
+ before_install: gem install bundler -v 1.10.6
10
+ script: bundle exec rake rspec_rubocop
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: jruby
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --no-private
2
+ -
3
+ CHANGELOG.md
4
+ LICENSE.txt
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # CHANGELOG
2
+
3
+ ## v0.0.1
4
+
5
+ * Initial Release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,110 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ structured_text_renderer (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.0)
10
+ coderay (1.1.2)
11
+ diff-lcs (1.3)
12
+ docile (1.3.1)
13
+ ffi (1.9.25)
14
+ formatador (0.2.5)
15
+ guard (2.14.2)
16
+ formatador (>= 0.2.4)
17
+ listen (>= 2.7, < 4.0)
18
+ lumberjack (>= 1.0.12, < 2.0)
19
+ nenv (~> 0.1)
20
+ notiffany (~> 0.0)
21
+ pry (>= 0.9.12)
22
+ shellany (~> 0.0)
23
+ thor (>= 0.18.1)
24
+ guard-compat (1.2.1)
25
+ guard-rspec (4.7.3)
26
+ guard (~> 2.1)
27
+ guard-compat (~> 1.1)
28
+ rspec (>= 2.99.0, < 4.0)
29
+ guard-rubocop (1.3.0)
30
+ guard (~> 2.0)
31
+ rubocop (~> 0.20)
32
+ guard-yard (2.2.1)
33
+ guard (>= 1.1.0)
34
+ yard (>= 0.7.0)
35
+ json (2.1.0)
36
+ listen (3.1.5)
37
+ rb-fsevent (~> 0.9, >= 0.9.4)
38
+ rb-inotify (~> 0.9, >= 0.9.7)
39
+ ruby_dep (~> 1.2)
40
+ lumberjack (1.0.13)
41
+ method_source (0.9.0)
42
+ nenv (0.3.0)
43
+ notiffany (0.1.1)
44
+ nenv (~> 0.1)
45
+ shellany (~> 0.0)
46
+ parallel (1.12.1)
47
+ parser (2.5.1.2)
48
+ ast (~> 2.4.0)
49
+ powerpack (0.1.2)
50
+ pry (0.11.3)
51
+ coderay (~> 1.1.0)
52
+ method_source (~> 0.9.0)
53
+ rainbow (2.2.2)
54
+ rake
55
+ rake (10.5.0)
56
+ rb-fsevent (0.10.3)
57
+ rb-inotify (0.9.10)
58
+ ffi (>= 0.5.0, < 2)
59
+ rspec (3.8.0)
60
+ rspec-core (~> 3.8.0)
61
+ rspec-expectations (~> 3.8.0)
62
+ rspec-mocks (~> 3.8.0)
63
+ rspec-core (3.8.0)
64
+ rspec-support (~> 3.8.0)
65
+ rspec-expectations (3.8.1)
66
+ diff-lcs (>= 1.2.0, < 2.0)
67
+ rspec-support (~> 3.8.0)
68
+ rspec-mocks (3.8.0)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.8.0)
71
+ rspec-support (3.8.0)
72
+ rubocop (0.49.1)
73
+ parallel (~> 1.10)
74
+ parser (>= 2.3.3.1, < 3.0)
75
+ powerpack (~> 0.1)
76
+ rainbow (>= 1.99.1, < 3.0)
77
+ ruby-progressbar (~> 1.7)
78
+ unicode-display_width (~> 1.0, >= 1.0.1)
79
+ ruby-progressbar (1.10.0)
80
+ ruby_dep (1.5.0)
81
+ rubygems-tasks (0.2.4)
82
+ shellany (0.0.1)
83
+ simplecov (0.16.1)
84
+ docile (~> 1.1)
85
+ json (>= 1.8, < 3)
86
+ simplecov-html (~> 0.10.0)
87
+ simplecov-html (0.10.2)
88
+ thor (0.20.0)
89
+ unicode-display_width (1.4.0)
90
+ yard (0.9.16)
91
+
92
+ PLATFORMS
93
+ ruby
94
+
95
+ DEPENDENCIES
96
+ bundler (~> 1.5)
97
+ guard
98
+ guard-rspec
99
+ guard-rubocop
100
+ guard-yard
101
+ rake (< 11.0)
102
+ rspec (~> 3)
103
+ rubocop (~> 0.49.1)
104
+ rubygems-tasks (~> 0.2)
105
+ simplecov
106
+ structured_text_renderer!
107
+ yard
108
+
109
+ BUNDLED WITH
110
+ 1.16.3
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ group :green_red_refactor, halt_on_fail: true do
2
+ guard :rspec, cmd: "bundle exec rspec" do
3
+ require "guard/rspec/dsl"
4
+ dsl = Guard::RSpec::Dsl.new(self)
5
+
6
+ # Feel free to open issues for suggestions and improvements
7
+
8
+ # RSpec files
9
+ rspec = dsl.rspec
10
+ watch(rspec.spec_helper) { rspec.spec_dir }
11
+ watch(rspec.spec_support) { rspec.spec_dir }
12
+ watch(rspec.spec_files)
13
+
14
+ # Ruby files
15
+ ruby = dsl.ruby
16
+ dsl.watch_spec_files_for(ruby.lib_files)
17
+ end
18
+
19
+ guard :yard, cmd: "yard doc" do
20
+ end
21
+
22
+ guard :rubocop, cmd: "rubocop" do
23
+ end
24
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Contentful GmbH - David Litvak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Contentful Structured Text Renderer
2
+
3
+ [Contentful](https://www.contentful.com) provides a content infrastructure for digital teams to power content in websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship digital products faster.
4
+
5
+ This library provides rendering capabilities for the `StructuredText` field type. It is recommended to be used alongside the [Contentful Delivery SDK](https://www.github.com/contentful/contentful.rb).
6
+ By default this library will serialize `StructuredText` fields into it's corresponding HTML representation. All behaviour can be overridden to serialize to different formats.
7
+
8
+ ## Installation
9
+
10
+ Install Contentful Structured Text Renderer from RubyGems:
11
+
12
+ ```bash
13
+ gem install structured_text_renderer
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ Create a renderer:
19
+
20
+ ```ruby
21
+ require 'structured_text_renderer'
22
+
23
+ renderer = StructuredTextRenderer::Renderer.new
24
+ ```
25
+
26
+ Render your document:
27
+
28
+ ```ruby
29
+ renderer.render(document)
30
+ ```
31
+
32
+ ## Using different renderers
33
+
34
+ There are many cases in which HTML serialization is not what you want.
35
+ Therefore, all renderers are overridable when creating a `StructuredTextRenderer`.
36
+
37
+ Also, if you're planning to embed entries within your structured text, overriding the `'embedded-entry-block'` mapping is a must,
38
+ as by default it only does `<div>#{entry.to_s}</div>`.
39
+
40
+ You can override the configuration like follows:
41
+
42
+ ```ruby
43
+ renderer = StructuredTextRenderer::Renderer.new(
44
+ 'embedded-entry-block' => MyEntryBlockRenderer
45
+ )
46
+ ```
47
+
48
+ Where `MyEntryBlockRenderer` requires to have a `#render(node)` method and needs to return a string.
49
+
50
+ An example entry renderer, assuming our entry has 2 fields called `name` and `description` could be:
51
+
52
+ ```ruby
53
+ class MyEntryBlockRenderer < StructuredTextRenderer::BaseNodeRenderer
54
+ def render(node)
55
+ entry = node['data']
56
+
57
+ "<div class='my-entry'><h3>#{entry.name}</h3><p><small>#{entry.description}</p></small></div>"
58
+ end
59
+ end
60
+ ```
61
+
62
+ ## Dealing with unknown node types
63
+
64
+ By default, this gem will treat all unknown node types as errors and will raise an exception letting the user know which node mapping is missing.
65
+ If you wish to remove this behaviour then replace the `nil` key of the mapping with a NullRenderer that returns an empty string, or something similar.
66
+
67
+ An example would be like follows:
68
+
69
+ ```ruby
70
+ class SilentNullRenderer < StructuredTextRenderer::BaseNodeRenderer
71
+ def render(node)
72
+ ""
73
+ end
74
+ end
75
+
76
+ renderer = StructuredTextRenderer::Renderer.new(
77
+ nil => SilentNullRenderer
78
+ )
79
+ ```
80
+
81
+ ## License
82
+
83
+ Copyright (c) 2018 Contentful GmbH. See [LICENSE](./LICENSE) for further details.
84
+
85
+ ## Contributing
86
+
87
+ Feel free to improve this tool by submitting a Pull Request.
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ require 'rubygems'
2
+
3
+ begin
4
+ require 'bundler'
5
+ rescue LoadError => e
6
+ warn e.message
7
+ warn 'Run `gem install bundler` to install Bundler.'
8
+ exit -1
9
+ end
10
+
11
+ begin
12
+ Bundler.setup(:development)
13
+ rescue Bundler::BundlerError => e
14
+ warn e.message
15
+ warn 'Run `bundle install` to install missing gems.'
16
+ exit e.status_code
17
+ end
18
+
19
+ require 'rake'
20
+
21
+ require 'rubygems/tasks'
22
+ Gem::Tasks.new
23
+
24
+ require 'rspec/core/rake_task'
25
+ RSpec::Core::RakeTask.new
26
+
27
+ require 'rubocop/rake_task'
28
+ RuboCop::RakeTask.new
29
+
30
+ task rspec_rubocop: %w(spec rubocop)
31
+
32
+ task test: :spec
33
+ task default: :spec
@@ -0,0 +1,5 @@
1
+ {
2
+ "result": {
3
+ "covered_percent": 100.0
4
+ }
5
+ }