texttube 5.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,87 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require_relative "../lib/texttube.rb"
5
+ require_relative "../lib/texttube/filters/coderay.rb"
6
+
7
+ module TextTube
8
+ describe TextTube do
9
+
10
+ let(:coderayed){
11
+ %Q!<h2>Hello</h2>\n\n<p>This is some code:</p>\n\n<pre><code class="CodeRay">[<span class="integer">1</span>,<span class="integer">2</span>,<span class="integer">3</span>].map{|x| + <span class="integer">1</span> }\n</code></pre>\n\n<p>And this is the result:\n [2,3,4]</p>\n\n<p>Thankyou</p>\n!
12
+ }
13
+
14
+ let(:notrayed) {
15
+ "<h2>Hello</h2>\n\n<p>This is some code:</p>\n\n<pre><code>[1,2,3].map{|x| + 1 }\n</code></pre>\n\n<p>And this is the result:\n [2,3,4]</p>\n\n<p>Thankyou</p>\n"
16
+ }
17
+
18
+ describe Coderay do
19
+ context "Given some text" do
20
+ context "With some code to be rayed in it" do
21
+ context "That has a language hint" do
22
+ let(:content) { <<CODE
23
+ <pre><code>::::ruby
24
+ {"one" => 1 }
25
+ </code></pre>
26
+ CODE
27
+ }
28
+ let(:expected) { <<HTML
29
+ <pre><code class="CodeRay">{<span class="string"><span class="delimiter">"</span><span class="content">one</span><span class="delimiter">"</span></span> =&gt; <span class="integer">1</span> }</code></pre>
30
+ HTML
31
+ }
32
+ let(:wrong) { <<CODE
33
+ <pre><code>::::json
34
+ {"one" => 1 }
35
+ </code></pre>
36
+ CODE
37
+ }
38
+
39
+ subject { TextTube::Coderay.run content }
40
+ it { should_not be_nil }
41
+ it { should == expected }
42
+ it { should_not == TextTube::Coderay.run(wrong) }
43
+ end
44
+ context "That has no language hint" do
45
+ let(:content) { notrayed }
46
+ let(:expected) { coderayed }
47
+
48
+ subject { TextTube::Coderay.run content }
49
+ it { should_not be_nil }
50
+ it { should == expected }
51
+ end
52
+ context "That has a 'skip' language hint" do
53
+ let(:content) { <<CODE
54
+ <pre><code>::::skip
55
+ {"one" => 1 }
56
+ </code></pre>
57
+ CODE
58
+ }
59
+ let(:expected) { <<CODE
60
+ <pre><code>{"one" =&gt; 1 }</code></pre>
61
+ CODE
62
+ }
63
+
64
+ subject { TextTube::Coderay.run content }
65
+ it { should_not be_nil }
66
+ it { should == expected }
67
+ end
68
+ end # context
69
+
70
+ context "With no code to be rayed in it" do
71
+ let(:content) { %Q$The[UtterFAIL website](http://utterfail.info/ "UtterFAIL!") is good.$ }
72
+ let(:expected) { content }
73
+ subject { TextTube::Coderay.run content }
74
+ it { should_not be_nil }
75
+ it { should == expected }
76
+ end # context
77
+ end # context
78
+
79
+ context "Given no text" do
80
+ subject { TextTube::Coderay.run "" }
81
+ it { should_not be_nil }
82
+ it { should == "" }
83
+ end # context
84
+
85
+ end # describe Coderay
86
+ end # describe TextTube
87
+ end # module
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require_relative "../lib/texttube.rb"
5
+ require_relative "../lib/texttube/filters/embedding_audio.rb"
6
+
7
+
8
+ module TextTube
9
+ describe TextTube do
10
+
11
+ describe EmbeddingAudio do
12
+ context "Given some text" do
13
+ let(:content) { "[audio[a24.m4a|A24]]" }
14
+ let(:expected) {
15
+ %q[<div class='audio'><h3>A24</h3><audio preload='metadata' controls='controls'><source src='/streams/a24.m4a' type='audio/m4a' /><source src='/streams/a24.ogg' type='audio/ogg' />Your browser does not support HTML5, update your browser you fool!</audio></div>]
16
+ }
17
+ context "containing valid extended markdown for audio" do
18
+ context "with no options" do
19
+ subject { TextTube::EmbeddingAudio.run content }
20
+ it { should_not be_nil }
21
+ it { should be == expected }
22
+ end
23
+ context "with src_base given as an option" do
24
+ subject { TextTube::EmbeddingAudio.run content, {src_base: "/files/" } }
25
+ it { should_not be_nil }
26
+ it { should_not == expected }
27
+ it { should match(%r{^.+\ssrc\='/files/\S+?'\s.+$}) }
28
+ end
29
+ end
30
+ context "containing invalid extended markdown for audio" do
31
+ let(:content) { "audio[a24.m4a|A24]]" }
32
+ subject { TextTube::EmbeddingAudio.run content }
33
+ it { should_not be_nil }
34
+ it { should_not be == expected }
35
+ it { should == content }
36
+ end
37
+ end
38
+
39
+ end # describe
40
+
41
+ end # describe TextTube
42
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require_relative "../lib/texttube.rb"
3
+ require_relative "../lib/texttube/filters/inside_block.rb"
4
+
5
+ describe "InsideBlock" do
6
+ let(:content) { <<HTML
7
+ <div class='wrapper' id='sidebar' markdown='1'>
8
+ ## This is a sidebar ##
9
+
10
+ * Written
11
+ * in
12
+ * markdown
13
+
14
+ Sometimes this is useful.
15
+ </div>
16
+ HTML
17
+ }
18
+ let(:expected) { <<HTML
19
+ <div class="wrapper" id="sidebar">
20
+ <h2>This is a sidebar</h2>
21
+
22
+ <ul>
23
+ <li>Written</li>
24
+ <li>in</li>
25
+ <li>markdown</li>
26
+ </ul>
27
+
28
+
29
+ <p>Sometimes this is useful.</p>
30
+ </div>
31
+ HTML
32
+ }
33
+ subject { TextTube::InsideBlock.run content }
34
+ it { should == expected }
35
+ end
@@ -0,0 +1,97 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require_relative "../lib/texttube.rb"
5
+ require_relative "../lib/texttube/filters/link_reffing.rb"
6
+
7
+ module TextTube
8
+ describe LinkReffing do
9
+ context "Given some text" do
10
+ context "With a link to be reffed in it" do
11
+ shared_examples "outputting links" do
12
+ it { should_not be_nil }
13
+ it { should == expected }
14
+ end
15
+
16
+ let(:content) { "The UtterFAIL website[[http://utterfail.info|UtterFAIL!]] is good. My blog[[http://iainbarnett.me.uk|My blog]] is also good." }
17
+
18
+ context "and no options" do
19
+ subject { TextTube::LinkReffing.run content }
20
+ let(:expected) { s = <<HTML
21
+ The UtterFAIL website[&#8304;](#0 "Jump to reference") is good. My blog[&sup1;](#1 "Jump to reference") is also good.
22
+ <div markdown='1' id='reflinks'>
23
+ <a name="0"></a>&#91;0&#93; [http://utterfail.info](http://utterfail.info "http://utterfail.info") UtterFAIL!
24
+
25
+
26
+ <a name="1"></a>&#91;1&#93; [http://iainbarnett.me.uk](http://iainbarnett.me.uk "http://iainbarnett.me.uk") My blog
27
+
28
+ </div>
29
+ HTML
30
+ s.strip
31
+ }
32
+ include_examples "outputting links"
33
+ end
34
+ context "and an option not to ref the link (i.e. inline)" do
35
+ let(:expected) {
36
+ "The UtterFAIL website [UtterFAIL!](http://utterfail.info) is good. My blog [My blog](http://iainbarnett.me.uk) is also good."
37
+ }
38
+ subject {
39
+ TextTube::LinkReffing.run content, kind: :inline
40
+ }
41
+ include_examples "outputting links"
42
+ context "and use HTML" do
43
+ let(:expected) {
44
+ %Q$The UtterFAIL website <a href="http://utterfail.info">UtterFAIL!</a> is good. My blog <a href="http://iainbarnett.me.uk">My blog</a> is also good.$
45
+ }
46
+ subject {
47
+ TextTube::LinkReffing.run content, kind: :inline, format: :html
48
+ }
49
+ include_examples "outputting links"
50
+ end
51
+ end
52
+ context "and an option to output a link as HTML" do
53
+ let(:expected) { s = <<HTML
54
+ The UtterFAIL website<a href="#0" title="Jump to reference">&#8304;</a> is good. My blog<a href="#1" title="Jump to reference">&sup1;</a> is also good.
55
+ <div markdown='1' id='reflinks'>
56
+ <a name="0"></a>&#91;0&#93; [http://utterfail.info](http://utterfail.info "http://utterfail.info") UtterFAIL!
57
+
58
+
59
+ <a name="1"></a>&#91;1&#93; [http://iainbarnett.me.uk](http://iainbarnett.me.uk "http://iainbarnett.me.uk") My blog
60
+
61
+ </div>
62
+ HTML
63
+ s.strip
64
+ }
65
+ subject { TextTube::LinkReffing.run content, format: :html }
66
+ include_examples "outputting links"
67
+ end
68
+ context "and an option to not show the link at all" do
69
+ let(:expected) { s = <<HTML
70
+ The UtterFAIL website is good. My blog is also good.
71
+ HTML
72
+ s.strip
73
+ }
74
+ subject {
75
+ TextTube::LinkReffing.run content, kind: :none
76
+ }
77
+ include_examples "outputting links"
78
+ end
79
+ end # context
80
+
81
+ context "With no link to be reffed in it" do
82
+ let(:content) { %Q$The [UtterFAIL website](http://utterfail.info/ "UtterFAIL!") is good.$ }
83
+ let(:expected) { content }
84
+ subject { TextTube::LinkReffing.run content }
85
+ it { should_not be_nil }
86
+ it { should == expected }
87
+ end # context
88
+ end # context
89
+
90
+ context "Given no text" do
91
+ subject { TextTube::LinkReffing.run "" }
92
+ it { should_not be_nil }
93
+ it { should == "" }
94
+ end # context
95
+
96
+ end # describe LinkReffing
97
+ end # module
@@ -0,0 +1,280 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require_relative '../lib/texttube/base.rb'
5
+ require_relative '../lib/texttube/filterable.rb'
6
+
7
+ describe "TextTube" do
8
+ let(:content) { <<MARKDOWN
9
+ ## The Rainfall Problem ##
10
+
11
+ I read of a test given to students to see if they understand the concepts in the first part of a computer science course. It was in an interesting paper called *What Makes Code Hard to Understand?*[[http://arxiv.org/abs/1304.5257|What Makes Code Hard to Understand? Michael Hansen, Robert L. Goldstone, Andrew Lumsdaine]].
12
+
13
+ > To solve it, students must write a program that averages a list of numbers (rainfall amounts), where the list is terminated with a specific value – e.g., a negative number or 999999.
14
+
15
+ Of course, reading about the problem I immediately wanted to try it, but even though the idea of posing the problem was to test the understanding of loops, the problem lends itself naturally to a recursive solution, and that's much more interesting than a boring old loop! I realised it wouldn't run well in Ruby but decided to write it anyway:
16
+
17
+ ::::ruby
18
+ def rainfall(droplets,total=0,measures=1,limit=99_999)
19
+ return total.to_f.div measures if droplets == limit
20
+ unless droplets < 0
21
+ total += droplets
22
+ measures += 1
23
+ end
24
+ rainfall rand(limit + 1), total, measures
25
+ end
26
+
27
+ Normally I'd start this off with a random number, but just to make it clear that it works I started with the termination number. Then, I reran it until it worked. It gives you an idea of how poor Ruby is at recursion.
28
+
29
+ ::::shell
30
+ rainfall 99_999
31
+ # => 0
32
+ rainfall 99_998
33
+ SystemStackError: stack level too deep
34
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
35
+ Maybe IRB bug!
36
+ rainfall 99_998
37
+ SystemStackError: stack level too deep
38
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
39
+ Maybe IRB bug!
40
+ rainfall 99_998
41
+ SystemStackError: stack level too deep
42
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
43
+ Maybe IRB bug!
44
+ rainfall 99_998
45
+ SystemStackError: stack level too deep
46
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
47
+ Maybe IRB bug!
48
+ rainfall 99_998
49
+ # => 49693
50
+
51
+ Just to be clear, I ran this with Ruby 2.0.0-rc2 as well with the same results. It's a pity that Ruby fails at this kind of thing, because it is such an elegant and useful language that seems to have borrowed the best of many other niche languages. Recursion is often the most elegant *and* performant[[http://dictionary.cambridge.org/dictionary/british/pedant|If you're one of these then you won't like that I made a word up. Unfortunately for you, I'm British, which means that I understand that English is a living language, it is my tool not my master, and it has a long history of being changed to suit the speaker or writer. This is one such case.]] solution.
52
+ MARKDOWN
53
+ }
54
+ context "with simple examples" do
55
+ before :all do
56
+ module AFilter
57
+ extend TextTube::Filterable
58
+
59
+ filter_with :double do |text|
60
+ text * 2
61
+ end
62
+
63
+ filter_with :triple do |text|
64
+ text * 3
65
+ end
66
+ end
67
+
68
+ module BFil
69
+ extend TextTube::Filterable
70
+
71
+ filter_with :spacial do |current,options|
72
+ current.split(//).join " "
73
+ end
74
+ end
75
+
76
+ class NeuS < TextTube::Base
77
+ register BFil
78
+ register AFilter
79
+ register do
80
+ filter_with :dashes do |text|
81
+ "---#{text}---"
82
+ end
83
+ end
84
+ end
85
+ end
86
+ let(:n) { NeuS.new "abc" }
87
+ subject { n }
88
+ it { should == "abc" }
89
+ its(:filters) { should =~ [:spacial, :dashes, :double, :triple] }
90
+ its(:filter) { should == "---a b ca b ca b ca b ca b ca b c---" }
91
+ context "ordering" do
92
+ context "given one filter" do
93
+ subject { n.filter :spacial }
94
+ it { should == "a b c" }
95
+ end
96
+ context "given several filters but not all" do
97
+ subject { n.filter :spacial, :dashes }
98
+ it { should == "---a b c---" }
99
+ end
100
+ context "given several filters in a different order" do
101
+ subject { n.filter :dashes, :double, :spacial, :triple }
102
+ it { should == "- - - a b c - - - - - - a b c - - -- - - a b c - - - - - - a b c - - -- - - a b c - - - - - - a b c - - -" }
103
+ end
104
+ end
105
+ end
106
+ context "Real examples" do
107
+ require_relative "../lib/texttube.rb"
108
+ require 'rdiscount'
109
+
110
+ context "An article that needs all the filters" do
111
+ before :all do
112
+ TextTube.load_all_filters
113
+ class MyFilter < TextTube::Base
114
+ register TextTube::Coderay
115
+ register TextTube::LinkReffing
116
+ register TextTube::EmbeddingAudio
117
+ register TextTube::EmbeddingVideo
118
+ register TextTube::InsideBlock
119
+ register do
120
+ filter_with :rdiscount do |text|
121
+ RDiscount.new(text).to_html
122
+ end
123
+ end
124
+ end
125
+ end
126
+ let(:expected) { <<HTML
127
+ <h2>The Rainfall Problem</h2>
128
+
129
+ <p>I read of a test given to students to see if they understand the concepts in the first part of a computer science course. It was in an interesting paper called <em>What Makes Code Hard to Understand?</em><a href="#0" title="Jump to reference">⁰</a>.</p>
130
+
131
+ <blockquote><p>To solve it, students must write a program that averages a list of numbers (rainfall amounts), where the list is terminated with a specific value – e.g., a negative number or 999999.</p></blockquote>
132
+
133
+ <p>Of course, reading about the problem I immediately wanted to try it, but even though the idea of posing the problem was to test the understanding of loops, the problem lends itself naturally to a recursive solution, and that's much more interesting than a boring old loop! I realised it wouldn't run well in Ruby but decided to write it anyway:</p>
134
+
135
+ <pre><code class="CodeRay"><span class="keyword">def</span> <span class="function">rainfall</span>(droplets,total=<span class="integer">0</span>,measures=<span class="integer">1</span>,limit=<span class="integer">99_999</span>)
136
+ <span class="keyword">return</span> total.to_f.div measures <span class="keyword">if</span> droplets == limit
137
+ <span class="keyword">unless</span> droplets &lt; <span class="integer">0</span>
138
+ total += droplets
139
+ measures += <span class="integer">1</span>
140
+ <span class="keyword">end</span>
141
+ rainfall rand(limit + <span class="integer">1</span>), total, measures
142
+ <span class="keyword">end</span></code></pre>
143
+
144
+ <p>Normally I'd start this off with a random number, but just to make it clear that it works I started with the termination number. Then, I reran it until it worked. It gives you an idea of how poor Ruby is at recursion.</p>
145
+
146
+ <pre><code class="CodeRay">rainfall 99_999
147
+ # =&gt; 0
148
+ rainfall 99_998
149
+ SystemStackError: stack level too deep
150
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
151
+ Maybe IRB bug!
152
+ rainfall 99_998
153
+ SystemStackError: stack level too deep
154
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
155
+ Maybe IRB bug!
156
+ rainfall 99_998
157
+ SystemStackError: stack level too deep
158
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
159
+ Maybe IRB bug!
160
+ rainfall 99_998
161
+ SystemStackError: stack level too deep
162
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
163
+ Maybe IRB bug!
164
+ rainfall 99_998
165
+ # =&gt; 49693</code></pre>
166
+
167
+ <p>Just to be clear, I ran this with Ruby 2.0.0-rc2 as well with the same results. It's a pity that Ruby fails at this kind of thing, because it is such an elegant and useful language that seems to have borrowed the best of many other niche languages. Recursion is often the most elegant <em>and</em> performant<a href="#1" title="Jump to reference">¹</a> solution.</p>
168
+
169
+ <div id="reflinks">
170
+ <p><a name="0"></a>[0] <a href="http://arxiv.org/abs/1304.5257" title="http://arxiv.org/abs/1304.5257">http://arxiv.org/abs/1304.5257</a> What Makes Code Hard to Understand? Michael Hansen, Robert L. Goldstone, Andrew Lumsdaine</p>
171
+
172
+ <p><a name="1"></a>[1] <a href="http://dictionary.cambridge.org/dictionary/british/pedant" title="http://dictionary.cambridge.org/dictionary/british/pedant">http://dictionary.cambridge.org/dictionary/br...</a> If you're one of these then you won't like that I made a word up. Unfortunately for you, I'm British, which means that I understand that English is a living language, it is my tool not my master, and it has a long history of being changed to suit the speaker or writer. This is one such case.</p>
173
+ </div>
174
+
175
+ HTML
176
+ }
177
+ let(:my_f) { MyFilter.new content }
178
+ subject { my_f.filter :embeddingvideo, :embeddingaudio, :linkreffing, :rdiscount, :coderay, :insideblock }
179
+ it { should == expected }
180
+
181
+ describe "With options" do
182
+ context "Passed to the class" do
183
+ before :all do
184
+ MyFilter.options.merge! :linkreffing => {kind: :none}
185
+ end
186
+ subject { MyFilter.new(content).filter :embeddingvideo, :embeddingaudio, :linkreffing, :rdiscount, :coderay, :insideblock }
187
+ it { should_not == expected }
188
+
189
+ context "and passed to filter" do
190
+ subject { MyFilter.new(content).filter :embeddingvideo, :embeddingaudio, :linkreffing, :rdiscount, :coderay, :insideblock, :linkreffing => {kind: :reference} }
191
+ it { should == expected }
192
+ end
193
+ end
194
+ end
195
+ end
196
+
197
+ context "An atom feed that only needs some of the filters" do
198
+ let(:expected) { <<EXPECTED
199
+ <h2>The Rainfall Problem</h2>
200
+
201
+ <p>I read of a test given to students to see if they understand the concepts in the first part of a computer science course. It was in an interesting paper called <em>What Makes Code Hard to Understand?</em>.</p>
202
+
203
+ <blockquote><p>To solve it, students must write a program that averages a list of numbers (rainfall amounts), where the list is terminated with a specific value – e.g., a negative number or 999999.</p></blockquote>
204
+
205
+ <p>Of course, reading about the problem I immediately wanted to try it, but even though the idea of posing the problem was to test the understanding of loops, the problem lends itself naturally to a recursive solution, and that's much more interesting than a boring old loop! I realised it wouldn't run well in Ruby but decided to write it anyway:</p>
206
+
207
+ <pre><code>::::ruby
208
+ def rainfall(droplets,total=0,measures=1,limit=99_999)
209
+ return total.to_f.div measures if droplets == limit
210
+ unless droplets &lt; 0
211
+ total += droplets
212
+ measures += 1
213
+ end
214
+ rainfall rand(limit + 1), total, measures
215
+ end
216
+ </code></pre>
217
+
218
+ <p>Normally I'd start this off with a random number, but just to make it clear that it works I started with the termination number. Then, I reran it until it worked. It gives you an idea of how poor Ruby is at recursion.</p>
219
+
220
+ <pre><code>::::shell
221
+ rainfall 99_999
222
+ # =&gt; 0
223
+ rainfall 99_998
224
+ SystemStackError: stack level too deep
225
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
226
+ Maybe IRB bug!
227
+ rainfall 99_998
228
+ SystemStackError: stack level too deep
229
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
230
+ Maybe IRB bug!
231
+ rainfall 99_998
232
+ SystemStackError: stack level too deep
233
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
234
+ Maybe IRB bug!
235
+ rainfall 99_998
236
+ SystemStackError: stack level too deep
237
+ from /Users/iainuser/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
238
+ Maybe IRB bug!
239
+ rainfall 99_998
240
+ # =&gt; 49693
241
+ </code></pre>
242
+
243
+ <p>Just to be clear, I ran this with Ruby 2.0.0-rc2 as well with the same results. It's a pity that Ruby fails at this kind of thing, because it is such an elegant and useful language that seems to have borrowed the best of many other niche languages. Recursion is often the most elegant <em>and</em> performant solution.</p>
244
+ EXPECTED
245
+ }
246
+ before :all do
247
+ TextTube.load_all_filters
248
+ class MyFilter < TextTube::Base
249
+ register TextTube::LinkReffing
250
+ register TextTube::EmbeddingAudio
251
+ register TextTube::EmbeddingVideo
252
+ register do
253
+ filter_with :rdiscount do |text|
254
+ RDiscount.new(text).to_html
255
+ end
256
+ end
257
+ end
258
+ end
259
+ describe "With options" do
260
+ context "passed to filter" do
261
+ subject { MyFilter.new(content).filter :embeddingvideo, :embeddingaudio, :linkreffing, :rdiscount, :linkreffing => {kind: :none} }
262
+ it { should == expected }
263
+ end
264
+ context "set on the instance" do
265
+ subject { MyFilter.new(content, :linkreffing => {kind: :none}).filter :embeddingvideo, :embeddingaudio, :linkreffing, :rdiscount }
266
+ it { should == expected }
267
+ end
268
+ context "set on the class" do
269
+ before :all do
270
+ MyFilter.options.merge! :linkreffing => {kind: :none}
271
+ end
272
+
273
+ subject {
274
+ MyFilter.new(content).filter :embeddingvideo, :embeddingaudio, :linkreffing, :rdiscount }
275
+ it { should == expected }
276
+ end
277
+ end
278
+ end
279
+ end
280
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: UTF-8
2
+
3
+ unless Kernel.respond_to?(:require_relative)
4
+ module Kernel
5
+ def require_relative(path)
6
+ require File.join(File.dirname(caller[0]), path.to_str)
7
+ end
8
+ end
9
+ end
10
+
11
+ # code coverage
12
+ require 'simplecov'
13
+ SimpleCov.start do
14
+ add_filter "/vendor/"
15
+ add_filter "/bin/"
16
+ add_filter "/spec/"
17
+ end
18
+
19
+ require 'rspec'
20
+
21
+ Spec_dir = File.expand_path( File.dirname __FILE__ )
22
+
23
+
24
+ Dir[ File.join( Spec_dir, "/support/**/*.rb")].each do |f|
25
+ logger.info "requiring #{f}"
26
+ require f
27
+ end
28
+
29
+
30
+ RSpec.configure do |config|
31
+ config.treat_symbols_as_metadata_keys_with_true_values = true
32
+ end
33
+
data/texttube.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "texttube/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "texttube"
7
+ s.summary = "Some useful filters for markdown that I use in my blogs"
8
+ s.description = <<-EOF
9
+ Some markdown filters I find useful.
10
+ EOF
11
+ s.version = TextTube::VERSION
12
+ s.platform = Gem::Platform::RUBY
13
+ s.required_ruby_version = ">= 1.9.1"
14
+ s.author = "Iain Barnett"
15
+ s.files = `git ls-files`.split("\n")
16
+ s.add_dependency("nokogiri", '~>1.5.9' )
17
+ s.add_dependency("coderay", '~>1.0' )
18
+ s.email = "iainspeed @nospam@ gmail.com"
19
+ s.test_files = `git ls-files -- {test,spec,features}`.split("\n")
20
+ end