mbrao 1.2.3 → 1.3.0
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 +4 -4
- data/.gitignore +3 -0
- data/CHANGELOG.md +5 -0
- data/doc/ActionView/Template/Handlers/MbraoTemplate.html +87 -20
- data/doc/ActionView/Template/Handlers.html +1 -1
- data/doc/HTML/Pipeline/KramdownFilter.html +1 -1
- data/doc/HTML/Pipeline.html +1 -1
- data/doc/HTML.html +1 -1
- data/doc/Mbrao/Author.html +337 -67
- data/doc/Mbrao/Content.html +1268 -444
- data/doc/Mbrao/ContentPublicInterface.html +24 -20
- data/doc/Mbrao/Exceptions/InvalidDate.html +1 -1
- data/doc/Mbrao/Exceptions/InvalidMetadata.html +1 -1
- data/doc/Mbrao/Exceptions/Parsing.html +1 -1
- data/doc/Mbrao/Exceptions/Rendering.html +1 -1
- data/doc/Mbrao/Exceptions/UnavailableLocalization.html +1 -1
- data/doc/Mbrao/Exceptions/Unimplemented.html +1 -1
- data/doc/Mbrao/Exceptions/UnknownEngine.html +1 -1
- data/doc/Mbrao/Exceptions.html +1 -1
- data/doc/Mbrao/Parser.html +11 -11
- data/doc/Mbrao/ParsingEngines/Base.html +25 -24
- data/doc/Mbrao/ParsingEngines/PlainText.html +17 -16
- data/doc/Mbrao/ParsingEngines.html +1 -1
- data/doc/Mbrao/PublicInterface/ClassMethods.html +312 -19
- data/doc/Mbrao/PublicInterface.html +1 -1
- data/doc/Mbrao/RenderingEngines/Base.html +7 -7
- data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +27 -15
- data/doc/Mbrao/RenderingEngines.html +1 -1
- data/doc/Mbrao/Validations/ClassMethods.html +21 -21
- data/doc/Mbrao/Validations.html +1 -1
- data/doc/Mbrao/Version.html +3 -3
- data/doc/Mbrao.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/method_list.html +86 -62
- data/doc/top-level-namespace.html +1 -1
- data/lib/mbrao/author.rb +18 -4
- data/lib/mbrao/content.rb +93 -44
- data/lib/mbrao/integrations/rails.rb +12 -5
- data/lib/mbrao/parser.rb +23 -0
- data/lib/mbrao/parsing_engines/base.rb +12 -11
- data/lib/mbrao/parsing_engines/plain_text.rb +29 -23
- data/lib/mbrao/rendering_engines/base.rb +4 -4
- data/lib/mbrao/rendering_engines/html_pipeline.rb +7 -2
- data/lib/mbrao/version.rb +2 -2
- data/spec/mbrao/author_spec.rb +32 -16
- data/spec/mbrao/content_spec.rb +144 -85
- data/spec/mbrao/integrations/rails_spec.rb +14 -0
- data/spec/mbrao/parser_spec.rb +19 -19
- data/spec/mbrao/parsing_engines/base_spec.rb +12 -12
- data/spec/mbrao/parsing_engines/plain_text_spec.rb +21 -21
- data/spec/mbrao/rendering_engines/base_spec.rb +2 -2
- data/spec/mbrao/rendering_engines/html_pipeline_spec.rb +31 -31
- metadata +2 -2
@@ -7,100 +7,100 @@
|
|
7
7
|
require "spec_helper"
|
8
8
|
|
9
9
|
describe Mbrao::RenderingEngines::HtmlPipeline do
|
10
|
-
|
10
|
+
subject{ Mbrao::RenderingEngines::HtmlPipeline.new }
|
11
11
|
|
12
12
|
describe "#render" do
|
13
13
|
it "should forward everything to the html-pipeline" do
|
14
14
|
pipeline = Object.new
|
15
15
|
expect(pipeline).to receive(:call).with("CONTENT").and_return({output: ""})
|
16
16
|
expect(::HTML::Pipeline).to receive(:new).with(an_instance_of(Array), an_instance_of(Hash)).and_return(pipeline)
|
17
|
-
|
17
|
+
subject.render("CONTENT")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should raise a specific exception if a locale is not available" do
|
21
|
-
expect {
|
21
|
+
expect { subject.render(::Mbrao::Content.create({locales: ["en"]}, "BODY"), {locales: ["it"]}) }.to raise_error(::Mbrao::Exceptions::UnavailableLocalization)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should raise an exception if anything goes wrong" do
|
25
25
|
allow(::HTML::Pipeline).to receive(:new).and_raise(ArgumentError.new("ERROR"))
|
26
|
-
expect {
|
26
|
+
expect { subject.render("CONTENT") }.to raise_error(::Mbrao::Exceptions::Rendering)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should have default options" do
|
30
30
|
filters = [:kramdown, :table_of_contents, :autolink, :emoji, :image_max_width].map {|f| ::Lazier.find_class(f, "::HTML::Pipeline::%CLASS%Filter", true) }
|
31
31
|
expect(::HTML::Pipeline).to receive(:new).with(filters, {gfm: true, asset_root: "/"}).and_call_original
|
32
|
-
|
32
|
+
subject.render("CONTENT")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should merge context to options" do
|
36
36
|
expect(::HTML::Pipeline).to receive(:new).with(an_instance_of(Array), {gfm: true, asset_root: "/", additional: true}).and_call_original
|
37
|
-
|
37
|
+
subject.render("CONTENT", {}, {additional: true})
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should restrict filter used" do
|
41
41
|
filters = [:table_of_contents, :autolink, :emoji, :image_max_width].map {|f| ::Lazier.find_class(f, "::HTML::Pipeline::%CLASS%Filter", true) }
|
42
42
|
expect(::HTML::Pipeline).to receive(:new).with(filters, an_instance_of(Hash)).and_call_original
|
43
|
-
|
43
|
+
subject.render("CONTENT", {kramdown: false})
|
44
44
|
|
45
45
|
filters = [:kramdown, :autolink, :emoji, :image_max_width].map {|f| ::Lazier.find_class(f, "::HTML::Pipeline::%CLASS%Filter", true) }
|
46
46
|
expect(::HTML::Pipeline).to receive(:new).with(filters, an_instance_of(Hash)).and_call_original
|
47
|
-
|
47
|
+
subject.render("CONTENT", {toc: false})
|
48
48
|
|
49
49
|
filters = [:kramdown, :table_of_contents, :emoji, :image_max_width].map {|f| ::Lazier.find_class(f, "::HTML::Pipeline::%CLASS%Filter", true) }
|
50
50
|
expect(::HTML::Pipeline).to receive(:new).with(filters, an_instance_of(Hash)).and_call_original
|
51
|
-
|
51
|
+
subject.render("CONTENT", {links: false})
|
52
52
|
|
53
53
|
filters = [:kramdown, :table_of_contents, :autolink, :image_max_width].map {|f| ::Lazier.find_class(f, "::HTML::Pipeline::%CLASS%Filter", true) }
|
54
54
|
expect(::HTML::Pipeline).to receive(:new).with(filters, an_instance_of(Hash)).and_call_original
|
55
|
-
|
55
|
+
subject.render("CONTENT", {emoji: false})
|
56
56
|
|
57
57
|
filters = [:kramdown, :table_of_contents, :autolink, :emoji].map {|f| ::Lazier.find_class(f, "::HTML::Pipeline::%CLASS%Filter", true) }
|
58
58
|
expect(::HTML::Pipeline).to receive(:new).with(filters, an_instance_of(Hash)).and_call_original
|
59
|
-
|
59
|
+
subject.render("CONTENT", {image_max_width: false})
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
describe "#default_pipeline" do
|
64
64
|
it "should return a default pipeline" do
|
65
|
-
expect(
|
65
|
+
expect(subject.default_pipeline).to eq([[:kramdown], [:table_of_contents, :toc], [:autolink, :links], [:emoji], [:image_max_width]])
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "#default_pipeline=" do
|
70
70
|
it "should set a correct pipeline" do
|
71
|
-
|
72
|
-
expect(
|
71
|
+
subject.default_pipeline = nil
|
72
|
+
expect(subject.default_pipeline).to eq([[]])
|
73
73
|
|
74
|
-
|
75
|
-
expect(
|
74
|
+
subject.default_pipeline = "A"
|
75
|
+
expect(subject.default_pipeline).to eq([[:A]])
|
76
76
|
|
77
|
-
|
78
|
-
expect(
|
77
|
+
subject.default_pipeline = ["A", "B"]
|
78
|
+
expect(subject.default_pipeline).to eq([[:A], [:B]])
|
79
79
|
|
80
|
-
|
81
|
-
expect(
|
80
|
+
subject.default_pipeline = ["1", [["B", ["C"]]]]
|
81
|
+
expect(subject.default_pipeline).to eq([[:"1"], [:B, :C]])
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "#default_options" do
|
86
86
|
it "should return a default hash" do
|
87
|
-
expect(
|
87
|
+
expect(subject.default_options).to eq({gfm: true, asset_root: "/"})
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should return the set hash" do
|
91
|
-
|
92
|
-
expect(
|
91
|
+
subject.instance_variable_set(:@default_options, {})
|
92
|
+
expect(subject.default_options).to eq({})
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
96
|
describe "#default_options=" do
|
97
97
|
it "should only assign if the value is an Hash" do
|
98
|
-
|
99
|
-
expect(
|
100
|
-
|
101
|
-
expect(
|
102
|
-
|
103
|
-
expect(
|
98
|
+
subject.default_options = {a: "b"}
|
99
|
+
expect(subject.default_options).to eq({a: "b"})
|
100
|
+
subject.default_options = 1
|
101
|
+
expect(subject.default_options).to eq({})
|
102
|
+
subject.default_options = nil
|
103
|
+
expect(subject.default_options).to eq({})
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
@@ -113,8 +113,8 @@ describe HTML::Pipeline::KramdownFilter do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should remove \r from the text" do
|
116
|
-
|
117
|
-
expect(
|
116
|
+
subject = HTML::Pipeline::KramdownFilter.new("\rCONTENT\r", {a: "b"}, {c: "d"})
|
117
|
+
expect(subject.instance_variable_get(:@text)).to eq("CONTENT")
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should use Kramdown with given options for building the result" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mbrao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shogun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lazier
|