raf 0.0.0 → 0.0.1

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.
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), "../lib")
3
+ require 'test_helper'
4
+ require 'rafinlineparser.tab'
5
+
6
+ class TestRafReference < Test::Unit::TestCase
7
+ def setup
8
+ @raf = Raf::InlineParser.new
9
+ end
10
+
11
+ def test_reference_is_reference
12
+ res = @raf.parse('((<aaa>))')
13
+ assert_kind_of Raf::Reference, res[0]
14
+ end
15
+
16
+ def test_reference_label_only
17
+ str = '((<aaa>))'
18
+ res = @raf.parse(str)
19
+ assert_kind_of Raf::Reference, res[0]
20
+ assert_equal "aaa", res[0].contents[0] # title
21
+ assert_equal "#" + "aaa".to_code, res[0].contents[1] # label
22
+ end
23
+
24
+ def test_reference_title_and_label
25
+ str = '((<aaa|hoge>))'
26
+ res = @raf.parse(str)
27
+ assert_kind_of Raf::Reference, res[0]
28
+ assert_equal "aaa", res[0].contents[0] # title
29
+ assert_equal "#" + "hoge".to_code, res[0].contents[1] # label
30
+ end
31
+
32
+ def test_reference_uri_only
33
+ str = '((<http://example.com>))'
34
+ res = @raf.parse(str)
35
+ assert_kind_of Raf::Reference, res[0]
36
+ assert_equal "http://example.com", res[0].contents[0] # title
37
+ assert_equal "http://example.com", res[0].contents[1] # label
38
+ end
39
+
40
+ def test_reference_title_and_uri
41
+ str = '((<aaa|http://example.com>))'
42
+ res = @raf.parse(str)
43
+ assert_kind_of Raf::Reference, res[0]
44
+ assert_equal "aaa", res[0].contents[0] # title
45
+ assert_equal "http://example.com", res[0].contents[1] # label
46
+ end
47
+ end
data/test/test_ruby.rb ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), "../lib")
3
+ require 'test_helper'
4
+ require 'rafinlineparser.tab'
5
+
6
+ class TestRafRuby < Test::Unit::TestCase
7
+ def setup
8
+ @raf = Raf::InlineParser.new
9
+ end
10
+
11
+ def test_ruby_is_ruby
12
+ str = '((^AAA|aaa^))'
13
+ res = @raf.parse(str)
14
+ assert_kind_of Raf::Ruby, res[0]
15
+ assert_equal ["AAA","aaa"], res[0].contents
16
+ assert_equal '<Ruby>Base:AAA,Text:aaa</Ruby>', res[0].apply
17
+ end
18
+
19
+ def test_ruby_base_only
20
+ str = '((^AAA|^))'
21
+ res = @raf.parse(str)
22
+ assert_kind_of Raf::Ruby, res[0]
23
+ assert_equal '<Ruby>Base:AAA,Text:</Ruby>', res[0].apply
24
+
25
+ str2 = '((^AAA^))'
26
+ res = @raf.parse(str2)
27
+ assert_kind_of Raf::Ruby, res[0]
28
+ assert_equal '<Ruby>Base:AAA,Text:AAA</Ruby>', res[0].apply
29
+ end
30
+
31
+ def test_ruby_text_only
32
+ str = '((^|aaa^))'
33
+ res = @raf.parse(str)
34
+ assert_kind_of Raf::Ruby, res[0]
35
+ assert_equal '<Ruby>Base:,Text:aaa</Ruby>', res[0].apply
36
+ end
37
+
38
+ def test_ruby_in_element
39
+ str1 = '((^((*AAA*))|aaa^))'
40
+ res = @raf.parse(str1)
41
+ assert_equal '<Ruby>Base:((*AAA*)),Text:aaa</Ruby>', res[0].apply
42
+
43
+ str2 = '((*aaa|((^AAA|bbb^))*))'
44
+ res = @raf.parse(str2)
45
+ assert_equal '<Emphasis>aaa|<Ruby>Base:AAA,Text:bbb</Ruby></Emphasis>', res[0].apply
46
+ end
47
+
48
+ def test_emphasis_raise_non_terminate
49
+ str = '((^aaa))'
50
+ assert_raise Racc::ParseError do
51
+ @raf.parse(str)
52
+ end
53
+
54
+ str = '((^aaa'
55
+ assert_raise Racc::ParseError do
56
+ @raf.parse(str)
57
+ end
58
+ end
59
+
60
+ def test_emphasis_raise_different_terminate
61
+ str = '((^aaa-))'
62
+ assert_raise Racc::ParseError do
63
+ @raf.parse(str)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), "../lib")
3
+ require 'test_helper'
4
+ require 'rafinlineparser.tab'
5
+
6
+ class TestRafStrike < Test::Unit::TestCase
7
+ def setup
8
+ @raf = Raf::InlineParser.new
9
+ end
10
+
11
+ def test_strike_is_strike
12
+ str = '((-aaa-))'
13
+ res = @raf.parse(str)
14
+ assert_kind_of Raf::Strike, res[0]
15
+ end
16
+
17
+ def test_strike_apply
18
+ str = '((-aaa-))'
19
+ res = @raf.parse(str)
20
+ assert_respond_to res[0], 'apply'
21
+ assert_equal '<Strike>aaa</Strike>', res[0].apply
22
+ end
23
+
24
+ def test_strike_in_element
25
+ str1 = '((-((-aaa-))-))'
26
+ res = @raf.parse(str1)
27
+ assert_equal [Raf::Strike], res[0].contents.map {|c| c.class }
28
+ assert_equal '<Strike><Strike>aaa</Strike></Strike>', res[0].apply
29
+
30
+ str2 = '((-a((-a-))a-))'
31
+ res = @raf.parse(str2)
32
+ assert_equal [Raf::Plain, Raf::Strike, Raf::Plain], res[0].contents.map {|c| c.class }
33
+ assert_equal '<Strike>a<Strike>a</Strike>a</Strike>', res[0].apply
34
+
35
+ str3 = '((-a((*a*))a-))'
36
+ res = @raf.parse(str3)
37
+ assert_equal [Raf::Plain, Raf::Emphasis, Raf::Plain], res[0].contents.map {|c| c.class }
38
+ assert_equal '<Strike>a<Emphasis>a</Emphasis>a</Strike>', res[0].apply
39
+ end
40
+
41
+ def test_strike_raise_non_terminate
42
+ str = '((-aaa))'
43
+ assert_raise Racc::ParseError do
44
+ @raf.parse(str)
45
+ end
46
+
47
+ str = '((-aaa'
48
+ assert_raise Racc::ParseError do
49
+ @raf.parse(str)
50
+ end
51
+ end
52
+
53
+ def test_strike_raise_different_terminate
54
+ str = '((-aaa*))'
55
+ assert_raise Racc::ParseError do
56
+ @raf.parse(str)
57
+ end
58
+ end
59
+
60
+ def test_strike_linefeed
61
+ str1 = <<EOL
62
+ ((-a
63
+ aa-))
64
+ EOL
65
+ res = @raf.parse(str1)
66
+ assert_kind_of Raf::Strike, res[0]
67
+ assert_equal "<Strike>a\naa</Strike>", res[0].apply
68
+
69
+ str2 = '((-a
70
+
71
+ aa-))'
72
+ res = @raf.parse(str2)
73
+ assert_kind_of Raf::Strike, res[0]
74
+ assert_equal "<Strike>a\n\naa</Strike>", res[0].apply
75
+ end
76
+ end
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), "../lib")
3
+ require 'test_helper'
4
+ require 'rafblockparser.tab'
5
+
6
+ class TestRafTableBlock < Test::Unit::TestCase
7
+ def setup
8
+ @raf = Raf::BlockParser.new
9
+ @table = TableString.new
10
+ end
11
+
12
+ def test_table_is_table
13
+ res = @raf.parse(@table.single)
14
+ assert_kind_of Raf::Table, res[0]
15
+ assert_equal "|aaa|bbb\n|ccc|ddd\n", res[0].apply
16
+ end
17
+
18
+ def test_table_with_terminate
19
+ res = @raf.parse(@table.single_with_terminate)
20
+ assert_kind_of Raf::Table, res[0]
21
+ assert_equal "|aaa|bbb\n|ccc|ddd\n", res[0].apply
22
+ end
23
+
24
+ def test_table_with_head
25
+ res = @raf.parse(@table.head)
26
+ assert_kind_of Raf::Table, res[0]
27
+ assert_equal "|*aaa|*bbb\n|ccc|ddd\n", res[0].apply
28
+ end
29
+
30
+ def test_table_with_head_and_terminate
31
+ res = @raf.parse(@table.head_with_terminate)
32
+ assert_kind_of Raf::Table, res[0]
33
+ assert_equal "|*aaa|*bbb\n|ccc|ddd\n", res[0].apply
34
+ end
35
+ end
36
+
37
+ class TableString
38
+ def single
39
+ <<EOL
40
+ |aaa|bbb
41
+ |ccc|ddd
42
+ EOL
43
+ end
44
+ def single_with_terminate
45
+ <<EOL
46
+ |aaa|bbb|
47
+ |ccc|ddd|
48
+ EOL
49
+ end
50
+
51
+ def head
52
+ <<EOL
53
+ |*aaa|*bbb|
54
+ |ccc|ddd|
55
+ EOL
56
+ end
57
+ def head_with_terminate
58
+ <<EOL
59
+ |*aaa*|*bbb*|
60
+ |ccc|ddd|
61
+ EOL
62
+ end
63
+ end
data/test/test_verb.rb ADDED
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), "../lib")
3
+ require 'test_helper'
4
+ require 'rafinlineparser.tab'
5
+
6
+ class TestRafVerb < Test::Unit::TestCase
7
+ def setup
8
+ @raf = Raf::InlineParser.new
9
+ end
10
+
11
+ def test_verb_is_verb
12
+ str = "(('aaa'))"
13
+ res = @raf.parse(str)
14
+ assert_kind_of Raf::Verb, res[0]
15
+ assert_equal ["aaa"], res[0].contents
16
+ assert_equal '<Verb>aaa</Verb>', res[0].apply
17
+ end
18
+
19
+ def test_verb_in_emphasis
20
+ str = "(('((*aaa*))'))"
21
+ res = @raf.parse(str)
22
+ assert_kind_of Raf::Verb, res[0]
23
+ assert_equal '<Verb>((*aaa*))</Verb>', res[0].apply
24
+
25
+ str = "(('((*aaa))'))"
26
+ res = @raf.parse(str)
27
+ assert_kind_of Raf::Verb, res[0]
28
+ assert_equal '<Verb>((*aaa))</Verb>', res[0].apply
29
+ end
30
+
31
+ def test_verb_in_italic
32
+ str = "(('((_aaa_))'))"
33
+ res = @raf.parse(str)
34
+ assert_kind_of Raf::Verb, res[0]
35
+ assert_equal '<Verb>((_aaa_))</Verb>', res[0].apply
36
+ end
37
+
38
+ def test_verb_in_strike
39
+ str = "(('((-aaa-))'))"
40
+ res = @raf.parse(str)
41
+ assert_kind_of Raf::Verb, res[0]
42
+ assert_equal '<Verb>((-aaa-))</Verb>', res[0].apply
43
+ end
44
+
45
+ def test_verb_in_ruby
46
+ str = "(('((^aaa^))'))"
47
+ res = @raf.parse(str)
48
+ assert_kind_of Raf::Verb, res[0]
49
+ assert_equal '<Verb>((^aaa^))</Verb>', res[0].apply
50
+ end
51
+
52
+ def test_verb_in_footnote
53
+ str = "(('(([aaa]))'))"
54
+ res = @raf.parse(str)
55
+ assert_kind_of Raf::Verb, res[0]
56
+ assert_equal '<Verb>(([aaa]))</Verb>', res[0].apply
57
+ end
58
+
59
+ def test_verb_in_image
60
+ str = "(('(($aaa$))'))"
61
+ res = @raf.parse(str)
62
+ assert_kind_of Raf::Verb, res[0]
63
+ assert_equal '<Verb>(($aaa$))</Verb>', res[0].apply
64
+ end
65
+
66
+ def test_verb_in_reference
67
+ str = "(('((<aaa>))'))"
68
+ res = @raf.parse(str)
69
+ assert_kind_of Raf::Verb, res[0]
70
+ assert_equal '<Verb>((<aaa>))</Verb>', res[0].apply
71
+ end
72
+
73
+ def test_verb_in_manuedo
74
+ str = "(('((/aaa/))'))"
75
+ res = @raf.parse(str)
76
+ assert_kind_of Raf::Verb, res[0]
77
+ assert_equal '<Verb>((/aaa/))</Verb>', res[0].apply
78
+ end
79
+
80
+ def test_verb_in_erb
81
+ str = "(('<%= aaa %>'))"
82
+ res = @raf.parse(str)
83
+ assert_kind_of Raf::Verb, res[0]
84
+ assert_equal '<Verb><%= aaa %></Verb>', res[0].apply
85
+ end
86
+ end
data/test/ts_block.rb ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # = ts_block
3
+ require "test_headline"
4
+ require "test_paragraph"
5
+ require "test_quoteblock"
6
+ require "test_reference"
7
+ require "test_itemlistblock"
8
+ require "test_numlistblock"
9
+ require "test_tableblock"
data/test/ts_inline.rb ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # = ts_inline
3
+ require "test_emphasis"
4
+ require "test_italic"
5
+ require "test_strike"
6
+ require "test_ruby"
7
+ require "test_verb"
8
+
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # = ts_rafparser.rb
3
+ require "ts_inline"
4
+ require "ts_block"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raf
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 0
10
- version: 0.0.0
9
+ - 1
10
+ version: 0.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - garin
@@ -16,7 +16,7 @@ bindir: bin
16
16
  cert_chain: []
17
17
 
18
18
  date: 2011-04-07 00:00:00 +09:00
19
- default_executable:
19
+ default_executable: raf2html
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: shoulda
@@ -78,10 +78,10 @@ dependencies:
78
78
  requirement: *id004
79
79
  type: :development
80
80
  prerelease: false
81
- description: longer description of your gem
81
+ description: raf is simple document format
82
82
  email: garin54@gmail.com
83
- executables: []
84
-
83
+ executables:
84
+ - raf2html
85
85
  extensions: []
86
86
 
87
87
  extra_rdoc_files:
@@ -89,18 +89,53 @@ extra_rdoc_files:
89
89
  - README.rdoc
90
90
  files:
91
91
  - .document
92
+ - COPYING
92
93
  - Gemfile
94
+ - Gemfile.lock
95
+ - History.rdoc
93
96
  - LICENSE.txt
94
97
  - README.rdoc
95
98
  - Rakefile
96
99
  - VERSION
97
- - lib/raf.rb
100
+ - bin/raf2html
101
+ - lib/default.css
102
+ - lib/parserutility.rb
103
+ - lib/raf2html.rb
104
+ - lib/raf2html_element.rb
105
+ - lib/rafblockparser.output
106
+ - lib/rafblockparser.ry
107
+ - lib/rafblockparser.tab.rb
108
+ - lib/rafelement.rb
109
+ - lib/rafinlineparser.output
110
+ - lib/rafinlineparser.ry
111
+ - lib/rafinlineparser.tab.rb
112
+ - raf.gemspec
98
113
  - test/helper.rb
99
- - test/test_raf.rb
114
+ - test/test_descblock.rb
115
+ - test/test_emphasis.rb
116
+ - test/test_erb.rb
117
+ - test/test_footnote.rb
118
+ - test/test_headline.rb
119
+ - test/test_headline_and_itemlist.rb
120
+ - test/test_helper.rb
121
+ - test/test_image.rb
122
+ - test/test_italic.rb
123
+ - test/test_itemlistblock.rb
124
+ - test/test_numlistblock.rb
125
+ - test/test_paragraph.rb
126
+ - test/test_quoteblock.rb
127
+ - test/test_reference.rb
128
+ - test/test_ruby.rb
129
+ - test/test_strike.rb
130
+ - test/test_tableblock.rb
131
+ - test/test_verb.rb
132
+ - test/ts_block.rb
133
+ - test/ts_inline.rb
134
+ - test/ts_rafparser.rb
100
135
  has_rdoc: true
101
136
  homepage: http://github.com/garin/raf
102
137
  licenses:
103
- - MIT
138
+ - GPL
104
139
  post_install_message:
105
140
  rdoc_options: []
106
141
 
@@ -130,7 +165,27 @@ rubyforge_project:
130
165
  rubygems_version: 1.6.2
131
166
  signing_key:
132
167
  specification_version: 3
133
- summary: one-line summary of your gem
168
+ summary: raf is simple document format
134
169
  test_files:
135
170
  - test/helper.rb
136
- - test/test_raf.rb
171
+ - test/test_descblock.rb
172
+ - test/test_emphasis.rb
173
+ - test/test_erb.rb
174
+ - test/test_footnote.rb
175
+ - test/test_headline.rb
176
+ - test/test_headline_and_itemlist.rb
177
+ - test/test_helper.rb
178
+ - test/test_image.rb
179
+ - test/test_italic.rb
180
+ - test/test_itemlistblock.rb
181
+ - test/test_numlistblock.rb
182
+ - test/test_paragraph.rb
183
+ - test/test_quoteblock.rb
184
+ - test/test_reference.rb
185
+ - test/test_ruby.rb
186
+ - test/test_strike.rb
187
+ - test/test_tableblock.rb
188
+ - test/test_verb.rb
189
+ - test/ts_block.rb
190
+ - test/ts_inline.rb
191
+ - test/ts_rafparser.rb
data/lib/raf.rb DELETED
File without changes
data/test/test_raf.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestRaf < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end