storyblok-richtext-renderer 0.0.4 → 0.0.5

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: 5fde7858d8ae51cd43a128f5912421b4e7ffb0d8bc51013c9e142d9400d0885f
4
- data.tar.gz: 5ee6a07e5b4c27dd06aa628ff461c1679b3e74a3acd250ecbefc93c9834643c3
3
+ metadata.gz: 96eba1d749133206e8768a6c9528c4635f2868e2f6d461a863f3c98006ea2d64
4
+ data.tar.gz: fbd427b3f00e8298614f4671f6c5397189bfbc5728cc23e8bb4aa8e7c82a36dc
5
5
  SHA512:
6
- metadata.gz: 000f0080b59c4f29b55dc5d629612df2d8c5ae5e6c01a273cddd7573b7b43b9023fec0a7024c4aad4c13771790f34f70bea19e32baad9a2a0b17e94c6f32aa08
7
- data.tar.gz: 3fa6b77ce266c573a3211746f7113a4dabac3d443f9b7d179310ebb476a1f17759871546c25a7a118bbee2bb44f523e5008bf2e0b5a76e30ed4ddc9a72100671
6
+ metadata.gz: 5ffe34e0ff0d9ac6b86dd029b3b2881b343f4a5db9be0829ad3e1fb68fd570cd511c7a1f98ce71d46fa771129c012fb4ac8bd605ee18cd134017e41adbc4736c
7
+ data.tar.gz: 68cabb69cfa002d3e22b079da76c31bfe4db12b283edd521cb777c78c04875a56cce35bcc2c079ffc96b8a50b50bcade084116e350fad19d6a09b62db74a4b45
@@ -10,6 +10,7 @@ module Storyblok
10
10
  require_relative "html_renderer/marks/code"
11
11
  require_relative "html_renderer/marks/italic"
12
12
  require_relative "html_renderer/marks/link"
13
+ require_relative "html_renderer/marks/styled"
13
14
  require_relative "html_renderer/nodes/node"
14
15
  require_relative "html_renderer/nodes/bullet_list"
15
16
  require_relative "html_renderer/nodes/code_block"
@@ -34,7 +35,8 @@ module Storyblok
34
35
  Storyblok::Richtext::Marks::Strong,
35
36
  Storyblok::Richtext::Marks::Code,
36
37
  Storyblok::Richtext::Marks::Italic,
37
- Storyblok::Richtext::Marks::Link
38
+ Storyblok::Richtext::Marks::Link,
39
+ Storyblok::Richtext::Marks::Styled
38
40
  ]
39
41
  @nodes = [
40
42
  Storyblok::Richtext::Nodes::HorizontalRule,
@@ -0,0 +1,17 @@
1
+ module Storyblok::Richtext
2
+ module Marks
3
+ class Styled < Mark
4
+
5
+ def matching
6
+ @node['type'] === 'styled'
7
+ end
8
+
9
+ def tag
10
+ [{
11
+ tag: "span",
12
+ attrs: @node['attrs']
13
+ }]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
1
  module Storyblok
2
2
  module Richtext
3
3
  # Gem Version
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.5'
5
5
  end
6
6
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lib/storyblok/richtext'
4
+
5
+ describe 'richtext' do
6
+ it 'styled mark to add span with red class' do
7
+ doc = {
8
+ 'type' => 'doc',
9
+ 'content' => [
10
+ {
11
+ 'text' => 'red text',
12
+ 'type' => 'text',
13
+ 'marks' => [
14
+ {
15
+ 'type' => 'styled',
16
+ 'attrs' => {
17
+ 'class' => 'red'
18
+ }
19
+ }
20
+ ]
21
+ }
22
+ ]
23
+ }
24
+
25
+ renderer = Storyblok::Richtext::HtmlRenderer.new
26
+ expect(renderer.render(doc)).to eq('<span class="red">red text</span>')
27
+ end
28
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
+ # have no way to turn it off -- the option exists only for backwards
44
+ # compatibility in RSpec 3). It causes shared context metadata to be
45
+ # inherited by the metadata hash of host groups and examples, rather than
46
+ # triggering implicit auto-inclusion in groups with matching metadata.
47
+ config.shared_context_metadata_behavior = :apply_to_host_groups
48
+
49
+ # The settings below are suggested to provide a good initial experience
50
+ # with RSpec, but feel free to customize to your heart's content.
51
+ # # This allows you to limit a spec run to individual examples or groups
52
+ # # you care about by tagging them with `:focus` metadata. When nothing
53
+ # # is tagged with `:focus`, all examples get run. RSpec also provides
54
+ # # aliases for `it`, `describe`, and `context` that include `:focus`
55
+ # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
+ # config.filter_run_when_matching :focus
57
+ #
58
+ # # Allows RSpec to persist some state between runs in order to support
59
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
60
+ # # you configure your source control system to ignore this file.
61
+ # config.example_status_persistence_file_path = "spec/examples.txt"
62
+ #
63
+ # # Limits the available syntax to the non-monkey patched syntax that is
64
+ # # recommended. For more details, see:
65
+ # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
+ # config.disable_monkey_patching!
69
+ #
70
+ # # This setting enables warnings. It's recommended, but in some cases may
71
+ # # be too noisy due to issues in dependencies.
72
+ # config.warnings = true
73
+ #
74
+ # # Many RSpec users commonly either run the entire suite or an individual
75
+ # # file, and it's useful to allow more verbose output when running an
76
+ # # individual spec file.
77
+ # if config.files_to_run.one?
78
+ # # Use the documentation formatter for detailed output,
79
+ # # unless a formatter has already been configured
80
+ # # (e.g. via a command-line flag).
81
+ # config.default_formatter = "doc"
82
+ # end
83
+ #
84
+ # # Print the 10 slowest examples and example groups at the
85
+ # # end of the spec run, to help surface which specs are running
86
+ # # particularly slow.
87
+ # config.profile_examples = 10
88
+ #
89
+ # # Run specs in random order to surface order dependencies. If you find an
90
+ # # order dependency and want to debug it, you can fix the order by providing
91
+ # # the seed, which is printed after each run.
92
+ # # --seed 1234
93
+ # config.order = :random
94
+ #
95
+ # # Seed global randomization in this process using the `--seed` CLI option.
96
+ # # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # # test failures related to randomization by passing the same `--seed` value
98
+ # # as the one that triggered the failure.
99
+ # Kernel.srand config.seed
100
+ end
data/storyblok.gemspec CHANGED
@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.test_files = gem.files.grep(%r{^spec/})
16
16
  gem.require_paths = ['lib']
17
17
 
18
- gem.add_development_dependency 'bundler', '~> 1.5'
18
+ gem.add_development_dependency 'bundler', '~> 2'
19
19
  gem.add_development_dependency 'rspec', '~> 3'
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storyblok-richtext-renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Storyblok (Alexander Feiglstorfer)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-09 00:00:00.000000000 Z
11
+ date: 2019-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: '2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -50,11 +50,13 @@ files:
50
50
  - ".gitignore"
51
51
  - ".ruby-version"
52
52
  - Gemfile
53
+ - Gemfile.lock
53
54
  - README.md
54
55
  - lib/.DS_Store
55
56
  - lib/storyblok/.DS_Store
56
57
  - lib/storyblok/richtext.rb
57
58
  - lib/storyblok/richtext/html_renderer.rb
59
+ - lib/storyblok/richtext/html_renderer/.DS_Store
58
60
  - lib/storyblok/richtext/html_renderer/marks/bold.rb
59
61
  - lib/storyblok/richtext/html_renderer/marks/code.rb
60
62
  - lib/storyblok/richtext/html_renderer/marks/italic.rb
@@ -62,7 +64,9 @@ files:
62
64
  - lib/storyblok/richtext/html_renderer/marks/mark.rb
63
65
  - lib/storyblok/richtext/html_renderer/marks/strike.rb
64
66
  - lib/storyblok/richtext/html_renderer/marks/strong.rb
67
+ - lib/storyblok/richtext/html_renderer/marks/styled.rb
65
68
  - lib/storyblok/richtext/html_renderer/marks/underline.rb
69
+ - lib/storyblok/richtext/html_renderer/nodes/.DS_Store
66
70
  - lib/storyblok/richtext/html_renderer/nodes/blockquote.rb
67
71
  - lib/storyblok/richtext/html_renderer/nodes/blok.rb
68
72
  - lib/storyblok/richtext/html_renderer/nodes/bullet_list.rb
@@ -77,6 +81,8 @@ files:
77
81
  - lib/storyblok/richtext/html_renderer/nodes/paragraph.rb
78
82
  - lib/storyblok/richtext/html_renderer/nodes/text.rb
79
83
  - lib/storyblok/richtext/version.rb
84
+ - spec/richtext_spec.rb
85
+ - spec/spec_helper.rb
80
86
  - storyblok.gemspec
81
87
  homepage: https://github.com/storyblok/storyblok-ruby-richtext-renderer
82
88
  licenses:
@@ -102,4 +108,6 @@ rubygems_version: 2.7.6
102
108
  signing_key:
103
109
  specification_version: 4
104
110
  summary: Storyblok richtext renderer
105
- test_files: []
111
+ test_files:
112
+ - spec/richtext_spec.rb
113
+ - spec/spec_helper.rb