flannel 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/flannel.gemspec +7 -4
- data/lib/flannel/block.treetop +5 -3
- data/test/block_cutter_test.rb +28 -0
- data/test/block_parser_styles_test.rb +75 -0
- data/test/block_parser_test.rb +6 -0
- data/test/file_cache_test.rb +9 -9
- data/test/flannel_test.rb +15 -0
- data/test/html_formatter_test.rb +22 -22
- data/test/test_helper.rb +6 -4
- metadata +39 -23
data/VERSION.yml
CHANGED
data/flannel.gemspec
CHANGED
@@ -5,13 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{flannel}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jamal Hansen"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-24}
|
13
|
+
s.default_executable = %q{quilt-it}
|
13
14
|
s.email = %q{jamal.hansen@gmail.com}
|
14
|
-
s.executables = ["quilt-it
|
15
|
+
s.executables = ["quilt-it"]
|
15
16
|
s.extra_rdoc_files = [
|
16
17
|
"LICENSE",
|
17
18
|
"README.rdoc"
|
@@ -62,6 +63,7 @@ Gem::Specification.new do |s|
|
|
62
63
|
"test/base_block_html_generation_test.rb",
|
63
64
|
"test/base_block_test.rb",
|
64
65
|
"test/block_cutter_test.rb",
|
66
|
+
"test/block_parser_styles_test.rb",
|
65
67
|
"test/block_parser_test.rb",
|
66
68
|
"test/feed_parser_test.rb",
|
67
69
|
"test/file_cache_test.rb",
|
@@ -73,7 +75,7 @@ Gem::Specification.new do |s|
|
|
73
75
|
s.rdoc_options = ["--charset=UTF-8"]
|
74
76
|
s.require_paths = ["lib"]
|
75
77
|
s.rubyforge_project = %q{flannel}
|
76
|
-
s.rubygems_version = %q{1.3.
|
78
|
+
s.rubygems_version = %q{1.3.6}
|
77
79
|
s.summary = %q{A soft comfortable worn in markup language for Ruby}
|
78
80
|
s.test_files = [
|
79
81
|
"test/html_formatter_test.rb",
|
@@ -81,6 +83,7 @@ Gem::Specification.new do |s|
|
|
81
83
|
"test/test_helper.rb",
|
82
84
|
"test/file_cache_test.rb",
|
83
85
|
"test/base_block_test.rb",
|
86
|
+
"test/block_parser_styles_test.rb",
|
84
87
|
"test/block_parser_test.rb",
|
85
88
|
"test/feed_parser_test.rb",
|
86
89
|
"test/flannel_test.rb",
|
data/lib/flannel/block.treetop
CHANGED
@@ -16,7 +16,7 @@ grammar Block
|
|
16
16
|
end
|
17
17
|
|
18
18
|
rule block_header
|
19
|
-
block_start block_type block_id parent_id? attribute_list? [\n]* {
|
19
|
+
block_start block_type block_id? parent_id? attribute_list? [\n]* {
|
20
20
|
def content
|
21
21
|
elements.map{ |element| element.respond_to?(:content) ? element.content : nil}.compact
|
22
22
|
end
|
@@ -40,7 +40,7 @@ grammar Block
|
|
40
40
|
end
|
41
41
|
|
42
42
|
rule block_type
|
43
|
-
( paragraph / feed / preformatted / list / header ) {
|
43
|
+
( paragraph / feed / preformatted / list / header / blockquote ) {
|
44
44
|
def content
|
45
45
|
[:block_type, text_value.to_sym ]
|
46
46
|
end
|
@@ -79,7 +79,9 @@ grammar Block
|
|
79
79
|
"header_six" { def content; text_value; end }
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
rule blockquote
|
83
|
+
"blockquote" { def content; text_value; end }
|
84
|
+
end
|
83
85
|
|
84
86
|
rule feed
|
85
87
|
"feed" { def content; text_value; end }
|
data/test/block_cutter_test.rb
CHANGED
@@ -18,6 +18,16 @@ class BlockCutterTest < Test::Unit::TestCase
|
|
18
18
|
assert_equal "baz", blocks[1].id
|
19
19
|
|
20
20
|
end
|
21
|
+
|
22
|
+
should "accept a block without an id" do
|
23
|
+
markup = ":paragraph\n some text"
|
24
|
+
|
25
|
+
blocks = @block_cutter.cut markup
|
26
|
+
assert_equal 1, blocks.length
|
27
|
+
|
28
|
+
assert_equal :paragraph, blocks[0].type
|
29
|
+
assert_nil blocks[0].id
|
30
|
+
end
|
21
31
|
|
22
32
|
should "not split preformatted text based on blank lines" do
|
23
33
|
markup = ":preformatted my_preformatted\n foo\n\nbar\n"
|
@@ -52,5 +62,23 @@ class BlockCutterTest < Test::Unit::TestCase
|
|
52
62
|
blocks = @block_cutter.cut markup
|
53
63
|
assert_equal :feed, blocks[0].type
|
54
64
|
end
|
65
|
+
|
66
|
+
should "parse a paragraph with a simple wiki link" do
|
67
|
+
markup = ":paragraph\n-ravioli>"
|
68
|
+
|
69
|
+
blocks = @block_cutter.cut markup
|
70
|
+
assert_equal :paragraph, blocks[0].type
|
71
|
+
assert_nil blocks[0].id
|
72
|
+
assert_equal '-ravioli>', blocks[0].text
|
73
|
+
end
|
74
|
+
|
75
|
+
should "parse a simple paragraph" do
|
76
|
+
markup = ":paragraph\nbar bar\n"
|
77
|
+
|
78
|
+
blocks = @block_cutter.cut markup
|
79
|
+
assert_equal :paragraph, blocks[0].type
|
80
|
+
assert_nil blocks[0].id
|
81
|
+
assert_equal "bar bar", blocks[0].text
|
82
|
+
end
|
55
83
|
end
|
56
84
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class BlockParserStylesTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@parser = BlockParser.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_paragraph
|
9
|
+
doc = @parser.parse(":paragraph\ntext")
|
10
|
+
|
11
|
+
assert_doc doc, :paragraph, nil, "text"
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_list
|
15
|
+
doc = @parser.parse(":list\ntext")
|
16
|
+
|
17
|
+
assert_doc doc, :list, nil, "text"
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_feed
|
21
|
+
doc = @parser.parse(":feed\ntext")
|
22
|
+
|
23
|
+
assert_doc doc, :feed, nil, "text"
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_blockquote
|
27
|
+
doc = @parser.parse(":blockquote\ntext")
|
28
|
+
|
29
|
+
assert_doc doc, :blockquote, nil, "text"
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_preformatted
|
33
|
+
doc = @parser.parse(":preformatted\ntext")
|
34
|
+
|
35
|
+
assert_doc doc, :preformatted, nil, "text"
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_header_one
|
39
|
+
doc = @parser.parse(":header_one\ntext")
|
40
|
+
|
41
|
+
assert_doc doc, :header_one, nil, "text"
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_header_two
|
45
|
+
doc = @parser.parse(":header_two\ntext")
|
46
|
+
|
47
|
+
assert_doc doc, :header_two, nil, "text"
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_header_three
|
51
|
+
doc = @parser.parse(":header_three\ntext")
|
52
|
+
|
53
|
+
assert_doc doc, :header_three, nil, "text"
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_header_four
|
57
|
+
doc = @parser.parse(":header_four\ntext")
|
58
|
+
|
59
|
+
assert_doc doc, :header_four, nil, "text"
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_header_five
|
63
|
+
doc = @parser.parse(":header_five\ntext")
|
64
|
+
|
65
|
+
assert_doc doc, :header_five, nil, "text"
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_header_six
|
69
|
+
doc = @parser.parse(":header_six\ntext")
|
70
|
+
|
71
|
+
assert_doc doc, :header_six, nil, "text"
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
data/test/block_parser_test.rb
CHANGED
@@ -16,6 +16,12 @@ class BlockParserTest < Test::Unit::TestCase
|
|
16
16
|
assert_doc doc, :paragraph, "wonki", "text"
|
17
17
|
end
|
18
18
|
|
19
|
+
def test_parser_returns_simple_block_without_id
|
20
|
+
doc = @parser.parse(":paragraph\ntext")
|
21
|
+
|
22
|
+
assert_doc doc, :paragraph, nil, "text"
|
23
|
+
end
|
24
|
+
|
19
25
|
def test_parser_returns_block_with_dashed_block_id
|
20
26
|
doc = @parser.parse(":paragraph wonki-donki\ntext")
|
21
27
|
|
data/test/file_cache_test.rb
CHANGED
@@ -5,19 +5,19 @@ class FileCacheTest < Test::Unit::TestCase
|
|
5
5
|
context "Creating File cache" do
|
6
6
|
should "require a location" do
|
7
7
|
begin
|
8
|
-
|
9
|
-
|
8
|
+
cache = Flannel::FileCache.new
|
9
|
+
assert_fail "should have raised ArgumentError"
|
10
10
|
rescue ArgumentError => e
|
11
|
-
|
11
|
+
assert true
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
should "require a valid location" do
|
16
16
|
begin
|
17
|
-
|
18
|
-
|
17
|
+
cache = Flannel::FileCache.new "foo/bar"
|
18
|
+
assert_fail "should have raised Flannel::CacheLocationDoesNotExistError"
|
19
19
|
rescue Flannel::CacheLocationDoesNotExistError => e
|
20
|
-
|
20
|
+
assert true
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -29,10 +29,10 @@ class FileCacheTest < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
should "be private" do
|
31
31
|
begin
|
32
|
-
|
33
|
-
|
32
|
+
key = @cache.generate_key "http://example.com"
|
33
|
+
assert_fail "generate_key should be private"
|
34
34
|
rescue NoMethodError => e
|
35
|
-
|
35
|
+
assert true
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
data/test/flannel_test.rb
CHANGED
@@ -17,6 +17,12 @@ class FlannelTest < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
context "basic behavior" do
|
20
|
+
|
21
|
+
should "parse a block without an id" do
|
22
|
+
markup = ":paragraph\n this is my paragraph"
|
23
|
+
assert_equal "<p>this is my paragraph</p>", Flannel.quilt(markup)
|
24
|
+
end
|
25
|
+
|
20
26
|
should "strip and convert underscores to pre tags" do
|
21
27
|
markup = ":preformatted foo\nfoo\n\n bar\n"
|
22
28
|
assert_equal "<pre id='foo'>foo\n\n bar\n</pre>", Flannel.quilt(markup)
|
@@ -53,4 +59,13 @@ class FlannelTest < Test::Unit::TestCase
|
|
53
59
|
assert_equal result, Flannel.quilt(markup)
|
54
60
|
end
|
55
61
|
end
|
62
|
+
|
63
|
+
context "bug fixes" do
|
64
|
+
should "parse a simple paragraph" do
|
65
|
+
markup = ":paragraph\nbar bar\n"
|
66
|
+
result = "<p>bar bar</p>"
|
67
|
+
|
68
|
+
assert_equal result, Flannel.quilt(markup)
|
69
|
+
end
|
70
|
+
end
|
56
71
|
end
|
data/test/html_formatter_test.rb
CHANGED
@@ -12,72 +12,72 @@ class HtmlFormatterTest < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
context "subdirectories" do
|
14
14
|
should "handle subdirectories and not display directory info" do
|
15
|
-
|
16
|
-
|
15
|
+
result = @formatter.do("I think it -cheese/tastes good>.", :paragraph)
|
16
|
+
assert_equal '<p>I think it <a href="cheese/tastes-good">tastes good</a>.</p>', result
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
context "blockquotes" do
|
21
21
|
should "wrap a blockquoted block in blockquotes" do
|
22
|
-
|
23
|
-
|
22
|
+
result = @formatter.do("Ruby is #1", :blockquote)
|
23
|
+
assert_equal '<blockquote>Ruby is #1</blockquote>', result
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
context "links" do
|
28
28
|
should "output the link" do
|
29
|
-
|
29
|
+
assert_equal '<p><a href="cheese">cheese</a></p>', @formatter.do("-cheese>", :paragraph)
|
30
30
|
end
|
31
31
|
|
32
32
|
should "hyphenate words" do
|
33
|
-
|
34
|
-
|
33
|
+
result = @formatter.do("-cheese is good>", :paragraph)
|
34
|
+
assert_equal '<p><a href="cheese-is-good">cheese is good</a></p>', result
|
35
35
|
end
|
36
36
|
|
37
37
|
should "replace text surrounded by - and > with a wiki link" do
|
38
|
-
|
39
|
-
|
38
|
+
result = @formatter.do("red, -green>, refactor", :paragraph)
|
39
|
+
assert_equal '<p>red, <a href="green">green</a>, refactor</p>',result
|
40
40
|
end
|
41
41
|
|
42
42
|
should "not replace text surrounded by - and > with a wiki link if spaced" do
|
43
|
-
|
44
|
-
|
43
|
+
result = @formatter.do("red, - green >, refactor", :paragraph)
|
44
|
+
assert_equal '<p>red, - green >, refactor</p>', result
|
45
45
|
end
|
46
46
|
|
47
47
|
should "not replace text surrounded by - and > with a wiki link if spaced on right" do
|
48
|
-
|
49
|
-
|
48
|
+
result = @formatter.do("red, -green >, refactor", :paragraph)
|
49
|
+
assert_equal '<p>red, -green >, refactor</p>', result
|
50
50
|
end
|
51
51
|
|
52
52
|
should "not replace surrounded by - and > with a wiki link if spaced on left" do
|
53
|
-
|
54
|
-
|
53
|
+
result = @formatter.do("red, - green>, refactor", :paragraph)
|
54
|
+
assert_equal '<p>red, - green>, refactor</p>', result
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
context "preformatted text" do
|
59
59
|
should "html escape preformatted text" do
|
60
|
-
|
61
|
-
|
60
|
+
result = @formatter.do("<p>& foo</p>", :preformatted)
|
61
|
+
assert_equal "<pre><p>& foo</p></pre>", result
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
context "making permalinks" do
|
66
66
|
should "replace spaces with dashes" do
|
67
|
-
|
67
|
+
assert_equal "get-the-box", @formatter.permalink("get the box")
|
68
68
|
end
|
69
69
|
|
70
70
|
should "replace multiple spaces with single dashes" do
|
71
|
-
|
71
|
+
assert_equal "get-the-box", @formatter.permalink("get the box")
|
72
72
|
end
|
73
73
|
|
74
74
|
should "replace odd characters with dashes" do
|
75
|
-
|
75
|
+
assert_equal "get-the-box", @formatter.permalink("get the @#)(* box")
|
76
76
|
end
|
77
77
|
|
78
78
|
should "not be greedy in matching" do
|
79
|
-
|
80
|
-
|
79
|
+
result = @formatter.do "a -foo> and a -bar>.", :paragraph
|
80
|
+
assert_equal '<p>a <a href="foo">foo</a> and a <a href="bar">bar</a>.</p>', result
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
data/test/test_helper.rb
CHANGED
@@ -40,10 +40,12 @@ class Test::Unit::TestCase
|
|
40
40
|
assert_equal :block_type, type[0]
|
41
41
|
assert_equal expected_type, type[1]
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
if expected_id
|
44
|
+
id = header.shift
|
45
|
+
assert_equal 2, id.length
|
46
|
+
assert_equal :block_id, id[0]
|
47
|
+
assert_equal expected_id, id[1]
|
48
|
+
end
|
47
49
|
|
48
50
|
if expected_parent_id
|
49
51
|
parent_id = header.shift
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flannel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 11
|
9
|
+
version: 0.2.11
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Jamal Hansen
|
@@ -9,53 +14,60 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-02-
|
13
|
-
default_executable:
|
17
|
+
date: 2010-02-24 00:00:00 -06:00
|
18
|
+
default_executable: quilt-it
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: treetop
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
- !ruby/object:Gem::Dependency
|
26
33
|
name: polyglot
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
33
41
|
version: "0"
|
34
|
-
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
35
44
|
- !ruby/object:Gem::Dependency
|
36
45
|
name: shoulda
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
48
|
requirements:
|
41
49
|
- - ">="
|
42
50
|
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
43
53
|
version: "0"
|
44
|
-
|
54
|
+
type: :development
|
55
|
+
version_requirements: *id003
|
45
56
|
- !ruby/object:Gem::Dependency
|
46
57
|
name: mocha
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
prerelease: false
|
59
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
60
|
requirements:
|
51
61
|
- - ">="
|
52
62
|
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
53
65
|
version: "0"
|
54
|
-
|
66
|
+
type: :development
|
67
|
+
version_requirements: *id004
|
55
68
|
description:
|
56
69
|
email: jamal.hansen@gmail.com
|
57
70
|
executables:
|
58
|
-
- quilt-it~
|
59
71
|
- quilt-it
|
60
72
|
extensions: []
|
61
73
|
|
@@ -108,6 +120,7 @@ files:
|
|
108
120
|
- test/base_block_html_generation_test.rb
|
109
121
|
- test/base_block_test.rb
|
110
122
|
- test/block_cutter_test.rb
|
123
|
+
- test/block_parser_styles_test.rb
|
111
124
|
- test/block_parser_test.rb
|
112
125
|
- test/feed_parser_test.rb
|
113
126
|
- test/file_cache_test.rb
|
@@ -127,18 +140,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
140
|
requirements:
|
128
141
|
- - ">="
|
129
142
|
- !ruby/object:Gem::Version
|
143
|
+
segments:
|
144
|
+
- 0
|
130
145
|
version: "0"
|
131
|
-
version:
|
132
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
147
|
requirements:
|
134
148
|
- - ">="
|
135
149
|
- !ruby/object:Gem::Version
|
150
|
+
segments:
|
151
|
+
- 0
|
136
152
|
version: "0"
|
137
|
-
version:
|
138
153
|
requirements: []
|
139
154
|
|
140
155
|
rubyforge_project: flannel
|
141
|
-
rubygems_version: 1.3.
|
156
|
+
rubygems_version: 1.3.6
|
142
157
|
signing_key:
|
143
158
|
specification_version: 3
|
144
159
|
summary: A soft comfortable worn in markup language for Ruby
|
@@ -148,6 +163,7 @@ test_files:
|
|
148
163
|
- test/test_helper.rb
|
149
164
|
- test/file_cache_test.rb
|
150
165
|
- test/base_block_test.rb
|
166
|
+
- test/block_parser_styles_test.rb
|
151
167
|
- test/block_parser_test.rb
|
152
168
|
- test/feed_parser_test.rb
|
153
169
|
- test/flannel_test.rb
|