mongoid_markdown_extension 0.1.3 → 0.1.5

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
  SHA1:
3
- metadata.gz: fbede02899b1d4c8bd66910c2b516f6e117ceff7
4
- data.tar.gz: da1703662ae9332ba921ac3a90de4dd7513a0c95
3
+ metadata.gz: 123144dae792881275b9b36e956c437a510b2dfd
4
+ data.tar.gz: f315498dcd5199dffce976e7f594b67f4fad2d4a
5
5
  SHA512:
6
- metadata.gz: 84c43c1d41ccea21f286e7ad05906fa8bb895968461ae40b66c6d28a444c271e7448d74aceec09f0956459dcc2a26feaffb71879e11e5aa9187b1656f100eea3
7
- data.tar.gz: 5bed3cc8c737ec3c8b7e795258a4d9e56b9174e300494e38ab3039aa9739167de79bd01a52d6f965cfa2db86b904106b924f42d81f05e0b0e8789d7b04ff93c1
6
+ metadata.gz: 8696f00b293eee30fb6b21fa9a88beceb98ed4481512b19dcccc89f4f3a9ed481542c0c13d5bcdd8537ec53df3a01ff3c05cf18d0d8dbad44ede07c7d8b56bd1
7
+ data.tar.gz: 15137f9ca084cc5bc7566c020e13bbb4fd394f418113882103d09a4fc58b6d2bca9488d0b55093937f9076d3de48970f4af11b1694e6b0734a1bd233f1c838f6
data/.travis.yml CHANGED
@@ -1,8 +1,10 @@
1
+ sudo: false
1
2
  language: ruby
2
- cache: bundler
3
3
  script: 'bundle exec rake'
4
- sudo: false
5
-
4
+ rvm:
5
+ - 2.2.5
6
+ before_install:
7
+ - gem install bundler -v 1.12.5
6
8
  notifications:
7
9
  email:
8
10
  recipients:
data/README.md CHANGED
@@ -8,28 +8,34 @@
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- gem 'mongoid_markdown_extension'
11
+ ```ruby
12
+ gem 'mongoid_markdown_extension'
13
+ ```
12
14
 
13
15
  And then execute:
14
16
 
15
- $ bundle
17
+ ```sh
18
+ $ bundle
19
+ ```
16
20
 
17
21
  Or install it yourself as:
18
22
 
19
- $ gem install mongoid_markdown_extension
23
+ ```sh
24
+ $ gem install mongoid_markdown_extension
25
+ ```
20
26
 
21
27
  ## Configuration
22
28
 
23
29
  The defaults are as follows:
24
30
 
25
- ```Ruby
31
+ ```ruby
26
32
  extensions = {
27
- autolink: true
28
- footnotes: true
29
- highlight: true
30
- space_after_headers: true
31
- strikethrough: true
32
- superscript: true
33
+ autolink: true
34
+ footnotes: true
35
+ highlight: true
36
+ space_after_headers: true
37
+ strikethrough: true
38
+ superscript: true
33
39
  }
34
40
 
35
41
  render_options = {}
@@ -37,10 +43,11 @@ render_options = {}
37
43
 
38
44
  These can be overwritten with an initializer, for example `config/initializers/mongoid_markdown.rb`:
39
45
 
40
- ```Ruby
46
+ ```ruby
41
47
  MongoidMarkdownExtension::Markdown.configure do |c|
42
- c.extensions = { autolink: true }
43
- c.render_options = { filter_html: true }
48
+ c.extensions = { autolink: true }
49
+ c.render_class = CustomRenderer
50
+ c.render_options = { filter_html: true }
44
51
  end
45
52
  ```
46
53
 
@@ -50,13 +57,13 @@ See [Redcarpet documentation](https://github.com/vmg/redcarpet) for available ex
50
57
 
51
58
  Add to a Mongoid model:
52
59
 
53
- ```Ruby
60
+ ```ruby
54
61
  class MyModel
55
62
  include Mongoid::Document
56
63
  field :text, type: MongoidMarkdownExtension::Markdown
57
64
  end
58
65
  ```
59
-
66
+
60
67
  Use it:
61
68
 
62
69
  ```Ruby
data/Rakefile CHANGED
@@ -6,4 +6,4 @@ Rake::TestTask.new do |t|
6
6
  t.pattern = 'test/*/*_test.rb'
7
7
  end
8
8
 
9
- task :default => :test
9
+ task default: :test
@@ -1,3 +1,3 @@
1
- require "mongoid_markdown_extension/inline_renderer"
2
- require "mongoid_markdown_extension/markdown"
3
- require "mongoid_markdown_extension/version"
1
+ require 'mongoid_markdown_extension/inline_renderer'
2
+ require 'mongoid_markdown_extension/markdown'
3
+ require 'mongoid_markdown_extension/version'
@@ -41,7 +41,7 @@ module MongoidMarkdownExtension
41
41
  end
42
42
 
43
43
  def paragraph(text)
44
- text + "<br /><br />"
44
+ text + '<br /><br />'
45
45
  end
46
46
  end
47
47
  end
@@ -32,11 +32,12 @@ module MongoidMarkdownExtension
32
32
 
33
33
  def markdown_renderer
34
34
  Redcarpet::Markdown.new(
35
- Redcarpet::Render::HTML.new(self.class.configuration.render_options),
35
+ self.class.configuration.render_class.new(self.class.configuration.render_options),
36
36
  self.class.configuration.extensions
37
37
  )
38
38
  end
39
39
 
40
+ # TODO: how to combine custom render class with the InlineRenderer?
40
41
  def markdown_inline_renderer
41
42
  Redcarpet::Markdown.new(InlineRenderer, tables: false)
42
43
  end
@@ -83,6 +84,7 @@ module MongoidMarkdownExtension
83
84
 
84
85
  class Configuration
85
86
  attr_accessor :extensions
87
+ attr_accessor :render_class
86
88
  attr_accessor :render_options
87
89
 
88
90
  def initialize
@@ -94,9 +96,8 @@ module MongoidMarkdownExtension
94
96
  strikethrough: true,
95
97
  superscript: true
96
98
  }
99
+ @render_class = Redcarpet::Render::HTML
97
100
  @render_options = {}
98
101
  end
99
102
  end
100
-
101
- # ---------------------------------------------------------------------
102
103
  end
@@ -1,3 +1,3 @@
1
1
  module MongoidMarkdownExtension
2
- VERSION = "0.1.3"
2
+ VERSION = '0.1.5'.freeze
3
3
  end
@@ -4,24 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'mongoid_markdown_extension/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "mongoid_markdown_extension"
7
+ spec.name = 'mongoid_markdown_extension'
8
8
  spec.version = MongoidMarkdownExtension::VERSION
9
- spec.authors = ["Tomáš Celizna"]
10
- spec.email = ["tomas.celizna@gmail.com"]
11
- spec.description = %q{Custom field type for Mongoid that handles Markdown conversion via Redcarpet gem.}
12
- spec.summary = %q{Custom field type for Mongoid that handles Markdown conversion via Redcarpet gem.}
13
- spec.homepage = "https://github.com/tomasc/mongoid_markdown_extension"
14
- spec.license = "MIT"
9
+ spec.authors = ['Tomas Celizna']
10
+ spec.email = ['mail@tomascelizna.com']
11
+ spec.description = 'Custom field type for Mongoid that handles Markdown conversion via Redcarpet gem.'
12
+ spec.summary = 'Custom field type for Mongoid that handles Markdown conversion via Redcarpet gem.'
13
+ spec.homepage = 'https://github.com/tomasc/mongoid_markdown_extension'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency "redcarpet", ">= 3.1.2"
22
- spec.add_dependency "mongoid", ">= 4.0", "< 6.0"
21
+ spec.add_dependency 'redcarpet', '>= 3.1.2'
22
+ spec.add_dependency 'mongoid', '>= 4.0', '< 6.0'
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.6"
25
- spec.add_development_dependency "coveralls"
26
- spec.add_development_dependency "rake"
24
+ spec.add_development_dependency 'bundler', '~> 1.6'
25
+ spec.add_development_dependency 'coveralls'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
27
  end
@@ -7,6 +7,21 @@ class MongoidMarkdownExtensionTest
7
7
  field :body, type: MongoidMarkdownExtension::Markdown
8
8
  end
9
9
 
10
+ class CustomRenderer < Redcarpet::Render::HTML
11
+ def preprocess(doc)
12
+ doc.gsub(/\[button:(.*)\]\((.*)\)/) do
13
+ button_label = Regexp.last_match(1)
14
+ button_link = Regexp.last_match(2)
15
+
16
+ if button_label && button_link
17
+ "<a href='#{button_link}' class='button'>#{button_label}</a>"
18
+ else
19
+ button_label
20
+ end
21
+ end
22
+ end
23
+ end
24
+
10
25
  # ---------------------------------------------------------------------
11
26
 
12
27
  module MongoidMarkdownExtension
@@ -22,7 +37,15 @@ module MongoidMarkdownExtension
22
37
  end
23
38
  end
24
39
  it 'returns default values' do
25
- MongoidMarkdownExtension::Markdown.configuration.extensions.must_equal(autolink: true, footnotes: true, highlight: true, space_after_headers: true, strikethrough: true, superscript: true)
40
+ MongoidMarkdownExtension::Markdown.configuration.extensions.must_equal(
41
+ autolink: true,
42
+ footnotes: true,
43
+ highlight: true,
44
+ space_after_headers: true,
45
+ strikethrough: true,
46
+ superscript: true
47
+ )
48
+ MongoidMarkdownExtension::Markdown.configuration.render_class.must_equal Redcarpet::Render::HTML
26
49
  MongoidMarkdownExtension::Markdown.configuration.render_options.must_equal({})
27
50
  end
28
51
  end
data/test/test_helper.rb CHANGED
@@ -5,7 +5,7 @@ require 'minitest'
5
5
  require 'minitest/autorun'
6
6
  require 'minitest/spec'
7
7
 
8
- if ENV["CI"]
9
- require "coveralls"
8
+ if ENV['CI']
9
+ require 'coveralls'
10
10
  Coveralls.wear!
11
- end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_markdown_extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
- - Tomáš Celizna
7
+ - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-14 00:00:00.000000000 Z
11
+ date: 2016-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -76,20 +76,20 @@ dependencies:
76
76
  name: rake
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ">="
79
+ - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0'
81
+ version: '10.0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ">="
86
+ - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0'
88
+ version: '10.0'
89
89
  description: Custom field type for Mongoid that handles Markdown conversion via Redcarpet
90
90
  gem.
91
91
  email:
92
- - tomas.celizna@gmail.com
92
+ - mail@tomascelizna.com
93
93
  executables: []
94
94
  extensions: []
95
95
  extra_rdoc_files: []
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.4.6
131
+ rubygems_version: 2.4.5.1
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Custom field type for Mongoid that handles Markdown conversion via Redcarpet