builder_quill_content 0.1.2 → 0.1.3

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: a2ec3f0ee541302574c92d357c52171813cfbdf405962f65ca229ab09f7a5253
4
- data.tar.gz: 5e44ce1c2dc121e074e2e6dbfd2147377bddbc6b2903db73bd1b07a81d143c3c
3
+ metadata.gz: 9e023af34330b25deb4a0bed2dd70414fac750e402db0444f2716f10d956ccdf
4
+ data.tar.gz: d8fea6d216a75af9320b539327420ab5467fcfc66c2482af858c249b49172dc2
5
5
  SHA512:
6
- metadata.gz: 7fc5ab54a2de0371ca472f7cc2fc1460bded3494f3a85a140fe8518f88faba21cbc426a621334366d7a67a1f8520f47afad3cfb36a2bb884fdd4ee8dea2c0609
7
- data.tar.gz: df40c78f9bca9bf7fa5edd7cb08ba7f5234fbce315a71269579609544ad5b120b8e028d9da10b897530e88a330f29a22029ad933e3382e1ffbaa908eee4ad057
6
+ metadata.gz: dff753fd24aae483d6a82fbcd73fb973c9fffbc30eb8d42ebf79058639f6bd84eb303f39e287394eb3ab8d9ee5f2411925e98450825a9b878663abb61de0f78f
7
+ data.tar.gz: 8788aa0e659704fa80cf82421fbf03fbb3127dd2c64782d78c0c189701005eac4bb76fdcad5d70c76ba0887e2b04f4ec79122f3ab3bbfdc349db986ff73d6d62
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ builder_quill_content (0.1.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (12.3.3)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ builder_quill_content!
16
+ rake (~> 12.0)
17
+
18
+ BUNDLED WITH
19
+ 2.1.2
data/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/builder_quill_content`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
@@ -22,7 +20,15 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ```ruby
24
+ include BuilderQuillContent
25
+ ```
26
+
27
+ then
28
+
29
+ ```ruby
30
+ to_html(quill_content)
31
+ ```
26
32
 
27
33
  ## Development
28
34
 
@@ -32,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
38
 
33
39
  ## Contributing
34
40
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/builder_quill_content. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/builder_quill_content/blob/master/CODE_OF_CONDUCT.md).
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/michaelt0520/builder_quill_content. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/michaelt0520/builder_quill_content/blob/master/CODE_OF_CONDUCT.md).
36
42
 
37
43
 
38
44
  ## License
@@ -41,4 +47,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
41
47
 
42
48
  ## Code of Conduct
43
49
 
44
- Everyone interacting in the BuilderQuillContent project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/builder_quill_content/blob/master/CODE_OF_CONDUCT.md).
50
+ Everyone interacting in the BuilderQuillContent project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/michaelt0520/builder_quill_content/blob/master/CODE_OF_CONDUCT.md).
@@ -1,3 +1,3 @@
1
1
  module BuilderQuillContent
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,6 +1,5 @@
1
1
  require "builder_quill_content/version"
2
2
  require "json"
3
- require "convert_inline"
4
3
 
5
4
  module BuilderQuillContent
6
5
  class Error < StandardError; end
@@ -25,6 +24,8 @@ module BuilderQuillContent
25
24
  end
26
25
 
27
26
  content.gsub('</ul><ul>', '')
27
+ rescue JSON::ParserError
28
+ 'No content'
28
29
  end
29
30
 
30
31
  def end_of_line(content, line, attributes)
@@ -0,0 +1,69 @@
1
+ class ConvertInline
2
+ class Error < StandardError; end
3
+ # Your code goes here...
4
+
5
+ attr_accessor :node, :insert, :attributes
6
+
7
+ def initialize(node)
8
+ @node = node
9
+ @insert = @node['insert']
10
+ @attributes = @node['attributes']
11
+ end
12
+
13
+ def convert
14
+ return @insert if @insert.is_a?(String) && @attributes.nil?
15
+
16
+ content = ''
17
+
18
+ if @insert.is_a?(String)
19
+ @attributes.keys.each { |attr| content += send(attr) }
20
+ else
21
+ content = @insert.keys.first == 'wk-image' ? image : embed(@insert.keys.first)
22
+ end
23
+
24
+ content
25
+ end
26
+
27
+ private
28
+
29
+ def italic
30
+ "<em>#{@insert}</em>"
31
+ end
32
+
33
+ def bold
34
+ "<strong>#{@insert}</strong>"
35
+ end
36
+
37
+ def header
38
+ "<h#{@attributes['header']}>#{@insert}</h#{@attributes['header']}>"
39
+ end
40
+
41
+ def blockquote
42
+ "<blockquote>#{@insert}</blockquote>"
43
+ end
44
+
45
+ def link
46
+ '<a href="' + @attributes['link'] + '" target="_blank">' + @insert + '</a>'
47
+ end
48
+
49
+ def list
50
+ "<ul><li>#{@insert}</li></ul>"
51
+ end
52
+
53
+ def embed(key)
54
+ return '<hr>' if key == 'wk-divider'
55
+
56
+ '<div data-id="' + key + '" data-src="' + @insert[key] + '"></div>'
57
+ end
58
+
59
+ def image
60
+ img_src = @insert['wk-image']['src']
61
+ img_cap = @insert['wk-image']['caption']
62
+ img_alt = @attributes['alt']
63
+
64
+ '<figure class="post-content-image-container">
65
+ <img class="post-content-image lazy" data-src="' + img_src + '" alt="' + img_alt + '">
66
+ <figcaption class="post-image-caption u-text-center">' + img_cap + '</figcaption>
67
+ </figure>'
68
+ end
69
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: builder_quill_content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Tran
@@ -20,6 +20,7 @@ files:
20
20
  - ".gitignore"
21
21
  - CODE_OF_CONDUCT.md
22
22
  - Gemfile
23
+ - Gemfile.lock
23
24
  - LICENSE.txt
24
25
  - README.md
25
26
  - Rakefile
@@ -28,6 +29,7 @@ files:
28
29
  - builder_quill_content.gemspec
29
30
  - lib/builder_quill_content.rb
30
31
  - lib/builder_quill_content/version.rb
32
+ - lib/convert_inline.rb
31
33
  homepage: https://github.com/michaelt0520/builder_quill_content
32
34
  licenses:
33
35
  - MIT