wparser 0.1.2 → 0.1.3

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.
@@ -1,3 +1,18 @@
1
+ === 0.1.3 2011-01-02
2
+ Ruby1.9.2 対応
3
+
4
+ block.rb - text.collect => text.each_line.collect
5
+ 1.9でString#collectが無くなった為。
6
+
7
+ inline.rb - Http.parse parse_lines.to_s
8
+ => Http.parse parse_lines.join
9
+ 1.9と1.8でto_sの挙動が違った為。
10
+
11
+ httpの適用と修正
12
+
13
+ 全てのDomainに対応。
14
+ パスを表記すると<a>タグがおかしくなるBugFix.
15
+
1
16
  === 0.1.2 2010-08-24
2
17
  version0.1.2のリリース 1行のコードの整形
3
18
  @と@に囲まれている部分が、以下のようになります。
@@ -4,7 +4,7 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  #require File.join(directory, 'wparser', 'Parser')
5
5
  require 'wparser/parser'
6
6
  module WParser
7
- VERSION = '0.1.2'
7
+ VERSION = '0.1.3'
8
8
 
9
9
  def WParser.new
10
10
  Parser.new
@@ -8,7 +8,7 @@ module Block
8
8
 
9
9
  def parse text
10
10
  @protected_preTag = nil
11
- parse_text = text.collect{|line| parse_line line}
11
+ parse_text = text.each_line.collect{|line| parse_line line}
12
12
  end
13
13
 
14
14
  private
@@ -7,10 +7,22 @@ module Inlines
7
7
  url_rex = %r!
8
8
  \b
9
9
  (
10
- http:// [-a-z0-9]+(\.[-a-z0-9]+)*\.(com|edu|info|net) \b
11
- (
10
+ https?:// [-a-z0-9]+(\.[-a-z0-9]+)*\.(?:com
11
+ |edu
12
+ |biz
13
+ |org
14
+ |gov
15
+ |in(?:t|fo)
16
+ |mil
17
+ |net
18
+ |name
19
+ |museum
20
+ |coop
21
+ |aero
22
+ |[a-z][a-z]) \b
23
+ (?:
12
24
  / [-a-z0-9_:\@&?=+,.\!/~*'%\$]*[^.,?\!]
13
- )?
25
+ )? \b
14
26
  )
15
27
  !x
16
28
 
@@ -12,9 +12,12 @@ module Inline
12
12
 
13
13
  def parse text
14
14
  @protected_preTag = nil
15
- parse_lines = text.collect {|line| parse_line line}
15
+
16
+ parse_lines = text.inject([]) do |r, line|
17
+ r << parse_line(Http.parse line)
18
+ end
16
19
 
17
- Http.parse parse_lines.to_s
20
+ parse_lines.join
18
21
  end
19
22
 
20
23
  private
@@ -30,11 +33,11 @@ module Inline
30
33
  if @protected_preTag == nil
31
34
  parse_line = Heading.parse parse_line
32
35
  parse_line = Strong.parse parse_line
33
- parse_line = Code.parse parse_line
36
+ parse_line = Code.parse parse_line
34
37
  parse_line = Italic.parse parse_line
35
38
  parse_line = UnderLine.parse parse_line
36
39
  parse_line = Deleted.parse parse_line
37
- parse_line = Paragraph.parse parse_line
40
+ parse_line = Paragraph.parse parse_line
38
41
  else
39
42
  parse_line
40
43
  end
@@ -2,7 +2,7 @@ begin
2
2
  require 'spec'
3
3
  rescue LoadError
4
4
  require 'rubygems' unless ENV['NO_RUBYGEMS']
5
- gem 'rspec'
5
+ gem 'spec'
6
6
  require 'spec'
7
7
  end
8
8
 
@@ -1,11 +1,126 @@
1
+ # -*- coding: utf-8 -*-
2
+ #!/usr/bin/ruby -Ku
1
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
4
 
3
5
  # Time to add your specs!
4
6
  # http://rspec.info/
5
- describe "Place your specs here" do
6
-
7
- it "find this spec in spec directory" do
8
- # violated "Be sure to write your specs"
7
+ describe WParser, "Test Method" do
8
+ before(:all) do
9
+ @parser = WParser.new
10
+ end
11
+
12
+ it "Heading" do
13
+ (1..6).each do |n|
14
+ @parser.parse("h#{n}. Rubyist\n").should == "<h#{n}>Rubyist</h#{n}>\n"
15
+ end
16
+ end
17
+
18
+ it "Inline" do
19
+ before_kouyaTakao = <<-EOS
20
+ ぬしの*女房*はんに、\\*わちき\\*、なりたいんざます。
21
+ _来年三月十五日_、年季(ねん)が\\_明ける\\_んざます。
22
+ +そのとき+は眉毛-落として-歯に鉄漿(かね)染めて、 ぬしの傍に参りんすよって、お内儀(かみ)さんにしてくんなますか?
23
+
24
+ EOS
25
+
26
+ after_kouyaTakao = <<-EOS
27
+ <p>
28
+ ぬしの<strong>女房</strong>はんに、*わちき*、なりたいんざます。<br />
29
+ <I>来年三月十五日</I>、年季(ねん)が_明ける_んざます。<br />
30
+ <U>そのとき</U>は眉毛<S>落として</S>歯に鉄漿(かね)染めて、 ぬしの傍に参りんすよって、お内儀(かみ)さんにしてくんなますか?<br />
31
+ </p>
32
+
33
+ EOS
34
+
35
+ @parser.parse(before_kouyaTakao).should == after_kouyaTakao
36
+ end
37
+
38
+ it "Code" do
39
+ @parser.parse("@printf \"Hello World!\"@").should ==
40
+ "<pre><code>printf \"Hello World!\"</code></pre>"
41
+ end
42
+
43
+ it "Pre" do
44
+ text = <<-EOS
45
+ This *is* _wiki_ +style+ *parser*. _Italic_ +UnderLine+.
46
+
47
+ # list1
48
+ # list2
49
+
50
+ * list1
51
+ * list2
52
+ EOS
53
+
54
+ @parser.parse(">||#{text}||<").should == "<pre>#{text}</pre>"
55
+ end
56
+
57
+ it "Pre class=\"prettyprint\"" do
58
+ text = <<-EOS
59
+ This *is* _wiki_ +style+ *parser*. _Italic_ +UnderLine+.
60
+
61
+ # list1
62
+ # list2
63
+
64
+ * list1
65
+ * list2
66
+ EOS
67
+
68
+ @parser.parse(">|code|#{text}|code|<").should ==
69
+ "<pre class=\"prettyprint\">#{text}</pre>"
70
+ end
71
+
72
+ it "Blockquote" do
73
+ text = <<-EOS
74
+ >>
75
+ Blockquote
76
+ <<
77
+ EOS
78
+ @parser.parse(text).should == <<-EOS
79
+ <blockquote>
80
+ <p>
81
+ Blockquote<br />
82
+ </p>
83
+ </blockquote>
84
+ EOS
85
+ end
86
+
87
+ it "List\'s" do
88
+ text = <<-EOS
89
+ # list1
90
+ # list2
91
+
92
+ * list1
93
+ * list2
94
+
95
+ EOS
96
+
97
+ @parser.parse(text).should == <<-EOS
98
+ <ol>
99
+ <li>list1</li>
100
+ <li>list2</li>
101
+ </ol>
102
+
103
+ <ul>
104
+ <li>list1</li>
105
+ <li>list2</li>
106
+ </ul>
107
+
108
+ EOS
109
+ end
110
+
111
+ it "http" do
112
+ domains = %w[com edu biz org gov int info mil net name museum coop aero]
113
+ domains.each do |domain|
114
+ @parser.parse("http://www.arnote.#{domain}\n\n").should == <<-EOS
115
+ <p>
116
+ <a href=\"http://www.arnote.#{domain}\">http://www.arnote.#{domain}</a><br />
117
+ </p>\n
118
+ EOS
119
+ @parser.parse("https://www.arnote.#{domain}/rspec\n\n").should == <<-EOS
120
+ <p>
121
+ <a href=\"https://www.arnote.#{domain}/rspec\">https://www.arnote.#{domain}/rspec</a><br />
122
+ </p>\n
123
+ EOS
124
+ end
9
125
  end
10
-
11
126
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wparser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 2
10
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - iori
@@ -15,41 +14,24 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-08-24 00:00:00 +09:00
17
+ date: 2011-01-02 00:00:00 +09:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: rubyforge
21
+ name: hoe
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 7
30
28
  segments:
31
29
  - 2
30
+ - 8
32
31
  - 0
33
- - 4
34
- version: 2.0.4
32
+ version: 2.8.0
35
33
  type: :development
36
34
  version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: hoe
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 21
46
- segments:
47
- - 2
48
- - 6
49
- - 1
50
- version: 2.6.1
51
- type: :development
52
- version_requirements: *id002
53
35
  description: |-
54
36
  http://wiki.github.com/iori/wparser/
55
37
 
@@ -115,7 +97,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
97
  requirements:
116
98
  - - ">="
117
99
  - !ruby/object:Gem::Version
118
- hash: 3
119
100
  segments:
120
101
  - 0
121
102
  version: "0"
@@ -124,7 +105,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
105
  requirements:
125
106
  - - ">="
126
107
  - !ruby/object:Gem::Version
127
- hash: 3
128
108
  segments:
129
109
  - 0
130
110
  version: "0"