mbrao 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +5 -0
  4. data/doc/ActionView/Template/Handlers/MbraoTemplate.html +87 -20
  5. data/doc/ActionView/Template/Handlers.html +1 -1
  6. data/doc/HTML/Pipeline/KramdownFilter.html +1 -1
  7. data/doc/HTML/Pipeline.html +1 -1
  8. data/doc/HTML.html +1 -1
  9. data/doc/Mbrao/Author.html +337 -67
  10. data/doc/Mbrao/Content.html +1268 -444
  11. data/doc/Mbrao/ContentPublicInterface.html +24 -20
  12. data/doc/Mbrao/Exceptions/InvalidDate.html +1 -1
  13. data/doc/Mbrao/Exceptions/InvalidMetadata.html +1 -1
  14. data/doc/Mbrao/Exceptions/Parsing.html +1 -1
  15. data/doc/Mbrao/Exceptions/Rendering.html +1 -1
  16. data/doc/Mbrao/Exceptions/UnavailableLocalization.html +1 -1
  17. data/doc/Mbrao/Exceptions/Unimplemented.html +1 -1
  18. data/doc/Mbrao/Exceptions/UnknownEngine.html +1 -1
  19. data/doc/Mbrao/Exceptions.html +1 -1
  20. data/doc/Mbrao/Parser.html +11 -11
  21. data/doc/Mbrao/ParsingEngines/Base.html +25 -24
  22. data/doc/Mbrao/ParsingEngines/PlainText.html +17 -16
  23. data/doc/Mbrao/ParsingEngines.html +1 -1
  24. data/doc/Mbrao/PublicInterface/ClassMethods.html +312 -19
  25. data/doc/Mbrao/PublicInterface.html +1 -1
  26. data/doc/Mbrao/RenderingEngines/Base.html +7 -7
  27. data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +27 -15
  28. data/doc/Mbrao/RenderingEngines.html +1 -1
  29. data/doc/Mbrao/Validations/ClassMethods.html +21 -21
  30. data/doc/Mbrao/Validations.html +1 -1
  31. data/doc/Mbrao/Version.html +3 -3
  32. data/doc/Mbrao.html +1 -1
  33. data/doc/_index.html +1 -1
  34. data/doc/file.README.html +1 -1
  35. data/doc/index.html +1 -1
  36. data/doc/method_list.html +86 -62
  37. data/doc/top-level-namespace.html +1 -1
  38. data/lib/mbrao/author.rb +18 -4
  39. data/lib/mbrao/content.rb +93 -44
  40. data/lib/mbrao/integrations/rails.rb +12 -5
  41. data/lib/mbrao/parser.rb +23 -0
  42. data/lib/mbrao/parsing_engines/base.rb +12 -11
  43. data/lib/mbrao/parsing_engines/plain_text.rb +29 -23
  44. data/lib/mbrao/rendering_engines/base.rb +4 -4
  45. data/lib/mbrao/rendering_engines/html_pipeline.rb +7 -2
  46. data/lib/mbrao/version.rb +2 -2
  47. data/spec/mbrao/author_spec.rb +32 -16
  48. data/spec/mbrao/content_spec.rb +144 -85
  49. data/spec/mbrao/integrations/rails_spec.rb +14 -0
  50. data/spec/mbrao/parser_spec.rb +19 -19
  51. data/spec/mbrao/parsing_engines/base_spec.rb +12 -12
  52. data/spec/mbrao/parsing_engines/plain_text_spec.rb +21 -21
  53. data/spec/mbrao/rendering_engines/base_spec.rb +2 -2
  54. data/spec/mbrao/rendering_engines/html_pipeline_spec.rb +31 -31
  55. metadata +2 -2
@@ -7,100 +7,100 @@
7
7
  require "spec_helper"
8
8
 
9
9
  describe Mbrao::RenderingEngines::HtmlPipeline do
10
- let(:reference) { Mbrao::RenderingEngines::HtmlPipeline.new }
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
- reference.render("CONTENT")
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 { reference.render(::Mbrao::Content.create({locales: ["en"]}, "BODY"), {locales: ["it"]}) }.to raise_error(::Mbrao::Exceptions::UnavailableLocalization)
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 { reference.render("CONTENT") }.to raise_error(::Mbrao::Exceptions::Rendering)
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
- reference.render("CONTENT")
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
- reference.render("CONTENT", {}, {additional: true})
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
- reference.render("CONTENT", {kramdown: false})
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
- reference.render("CONTENT", {toc: false})
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
- reference.render("CONTENT", {links: false})
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
- reference.render("CONTENT", {emoji: false})
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
- reference.render("CONTENT", {image_max_width: false})
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(reference.default_pipeline).to eq([[:kramdown], [:table_of_contents, :toc], [:autolink, :links], [:emoji], [:image_max_width]])
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
- reference.default_pipeline = nil
72
- expect(reference.default_pipeline).to eq([[]])
71
+ subject.default_pipeline = nil
72
+ expect(subject.default_pipeline).to eq([[]])
73
73
 
74
- reference.default_pipeline = "A"
75
- expect(reference.default_pipeline).to eq([[:A]])
74
+ subject.default_pipeline = "A"
75
+ expect(subject.default_pipeline).to eq([[:A]])
76
76
 
77
- reference.default_pipeline = ["A", "B"]
78
- expect(reference.default_pipeline).to eq([[:A], [:B]])
77
+ subject.default_pipeline = ["A", "B"]
78
+ expect(subject.default_pipeline).to eq([[:A], [:B]])
79
79
 
80
- reference.default_pipeline = ["1", [["B", ["C"]]]]
81
- expect(reference.default_pipeline).to eq([[:"1"], [:B, :C]])
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(reference.default_options).to eq({gfm: true, asset_root: "/"})
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
- reference.instance_variable_set(:@default_options, {})
92
- expect(reference.default_options).to eq({})
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
- reference.default_options = {a: "b"}
99
- expect(reference.default_options).to eq({a: "b"})
100
- reference.default_options = 1
101
- expect(reference.default_options).to eq({})
102
- reference.default_options = nil
103
- expect(reference.default_options).to eq({})
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
- reference = HTML::Pipeline::KramdownFilter.new("\rCONTENT\r", {a: "b"}, {c: "d"})
117
- expect(reference.instance_variable_get(:@text)).to eq("CONTENT")
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.2.3
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-23 00:00:00.000000000 Z
11
+ date: 2013-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lazier