breakout_parser 0.0.11-x86-mingw32 → 0.0.12-x86-mingw32
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.
- data/ChangeLog +12 -0
- data/lib/breakout_parser/win32-ruby1.8/breakout_parser.so +0 -0
- data/spec/parser_spec.rb +92 -8
- metadata +4 -2
data/ChangeLog
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
[ 0.0.12 ]
|
2
|
+
|
3
|
+
* new internal calling convention
|
4
|
+
* parse() and parse_links_only() methods now accept site url as third (optional)
|
5
|
+
argument: parse( "some markup", "space_name", "http://breakout.localhost:3000" )
|
6
|
+
* Handle [[r:num:rev]] in addition to [[r:num]]; also handle [[revision:num:rev]]
|
7
|
+
see http://www.assembla.com/spaces/breakout/tickets/5637
|
8
|
+
* parse() and parse_links_only() methods now accept git url as fourth (optional)
|
9
|
+
argument, f.ex. if "http://github.com/" provided as git url, it will be
|
10
|
+
concatenated with git commit id and converted to a html anchor
|
11
|
+
|
12
|
+
# vim:ts=2:sw=2:expandtab:syntax=ruby:textwidth=0
|
Binary file
|
data/spec/parser_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'breakout_parser'
|
2
|
+
require File.dirname(__FILE__) + '/obj_proxy'
|
2
3
|
|
3
4
|
describe 'BreakoutParser' do
|
4
5
|
def self.hex_string s
|
@@ -10,6 +11,19 @@ describe 'BreakoutParser' do
|
|
10
11
|
end
|
11
12
|
def hex_string s; self.class.hex_string(s); end
|
12
13
|
|
14
|
+
it 'accepts from 2 to 4 arguments' do
|
15
|
+
[0,1,5,6,7,8,9,10].each do |argc|
|
16
|
+
lambda{
|
17
|
+
BreakoutParser.parse(*(['a']*argc))
|
18
|
+
}.should raise_error(ArgumentError, "wrong number of arguments (#{argc} for 2..4)")
|
19
|
+
end
|
20
|
+
(2..4).each do |argc|
|
21
|
+
lambda{
|
22
|
+
BreakoutParser.parse(*(['a']*argc))
|
23
|
+
}.should_not raise_error
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
13
27
|
it 'converts \n to <br />' do
|
14
28
|
parse("aaa\nbbb").should match(%r"aaa ?<br /> ?bbb")
|
15
29
|
end
|
@@ -31,22 +45,22 @@ describe 'BreakoutParser' do
|
|
31
45
|
|
32
46
|
it "handles nil & false text well" do
|
33
47
|
parse(false).should == ""
|
34
|
-
parse(false,false).should == ""
|
35
|
-
parse("",false).should == ""
|
48
|
+
parse(false, :space_name => false).should == ""
|
49
|
+
parse("", :space_name => false).should == ""
|
36
50
|
parse(nil).should == ""
|
37
|
-
parse(nil,nil).should == ""
|
38
|
-
parse("",nil).should == ""
|
51
|
+
parse(nil, :space_name => nil).should == ""
|
52
|
+
parse("", :space_name => nil).should == ""
|
39
53
|
end
|
40
54
|
|
41
55
|
it "handles nil space_name well" do
|
42
56
|
lambda{
|
43
|
-
parse("#123",nil)
|
57
|
+
parse("#123", :space_name => nil)
|
44
58
|
}.should raise_error(TypeError)
|
45
59
|
end
|
46
60
|
|
47
61
|
it "handles false space_name well" do
|
48
62
|
lambda{
|
49
|
-
parse("#123",false)
|
63
|
+
parse("#123", :space_name => false)
|
50
64
|
}.should raise_error(TypeError)
|
51
65
|
end
|
52
66
|
|
@@ -740,8 +754,14 @@ describe 'BreakoutParser' do
|
|
740
754
|
'<a href="/code/test_space/git/changesets/1f4bdab77be696efd">revision:1f4bdab77be696efd</a>'
|
741
755
|
a["revision:12345"] =
|
742
756
|
'<a href="/code/test_space/subversion/changesets/12345">revision:12345</a>'
|
757
|
+
a["revision:567:1f4bdab77be696efd"] =
|
758
|
+
'<a href="/code/test_space/git-567/changesets/1f4bdab77be696efd">revision:1f4bdab77be696efd</a>'
|
759
|
+
a["revision:3:12345"] =
|
760
|
+
'<a href="/code/test_space/subversion-3/changesets/12345">revision:12345</a>'
|
743
761
|
a["r:2345"] = '<a href="/code/test_space/subversion/changesets/2345">revision:2345</a>'
|
744
762
|
a["r:2345ef"] = '<a href="/code/test_space/git/changesets/2345ef">revision:2345ef</a>'
|
763
|
+
a["r:10:2345"] = '<a href="/code/test_space/subversion-10/changesets/2345">revision:2345</a>'
|
764
|
+
a["r:1:2345ef"] = '<a href="/code/test_space/git-1/changesets/2345ef">revision:2345ef</a>'
|
745
765
|
|
746
766
|
a["url:http://www.ru"] = '<a rel="nofollow" href="http://www.ru">http://www.ru</a>'
|
747
767
|
a["url:https://www.ru"] = '<a rel="nofollow" href="https://www.ru">https://www.ru</a>'
|
@@ -765,6 +785,69 @@ describe 'BreakoutParser' do
|
|
765
785
|
it "parses [[#{k}|test & here]]" do
|
766
786
|
parse("[[#{k}|test & here]]").should == v.sub(/>.*</,">test & here<")
|
767
787
|
end
|
788
|
+
if v['href="/'] && !k['url:']
|
789
|
+
it "parses [[#{k}]] with a site url" do
|
790
|
+
site_url = "http://www.ru"
|
791
|
+
parse("[[#{k}]]", :site_url => site_url).should ==
|
792
|
+
v.gsub('href="/',"href=\"#{site_url}/")
|
793
|
+
|
794
|
+
# with extraordinary slash
|
795
|
+
parse("[[#{k}]]", :site_url => "#{site_url}/").should ==
|
796
|
+
v.gsub('href="/',"href=\"#{site_url}/")
|
797
|
+
|
798
|
+
site_url = "http://127.0.0.1:3000"
|
799
|
+
parse("[[#{k}]]", :site_url => site_url).should ==
|
800
|
+
v.gsub('href="/',"href=\"#{site_url}/")
|
801
|
+
|
802
|
+
# with extraordinary slash
|
803
|
+
parse("[[#{k}]]", :site_url => "#{site_url}/").should ==
|
804
|
+
v.gsub('href="/',"href=\"#{site_url}/")
|
805
|
+
end
|
806
|
+
end
|
807
|
+
if v['/git/']
|
808
|
+
it "parses [[#{k}]] with custom git_url (String)" do
|
809
|
+
git_url = "http://www.ru/"
|
810
|
+
rev = k.split(':').last.tr(']','')
|
811
|
+
parse("[[#{k}]]", :git_url => git_url).should ==
|
812
|
+
v.sub('/code/test_space/git/changesets/',git_url)
|
813
|
+
end
|
814
|
+
|
815
|
+
it "parses [[#{k}]] with custom git_url (ObjProxy)" do
|
816
|
+
rev = k.split(':').last.tr(']','')
|
817
|
+
@asdfg = 'http://mmm.us'
|
818
|
+
git_url = Breakout::ObjProxy.new do
|
819
|
+
@asdfg + '/'
|
820
|
+
end
|
821
|
+
parse("[[#{k}]]", :git_url => git_url).should ==
|
822
|
+
v.sub('/code/test_space/git/changesets/',git_url)
|
823
|
+
end
|
824
|
+
|
825
|
+
it "parses [[#{k}]] with NULL git_url (ObjProxy)" do
|
826
|
+
rev = k.split(':').last.tr(']','')
|
827
|
+
git_url = Breakout::ObjProxy.new do
|
828
|
+
nil
|
829
|
+
end
|
830
|
+
parse("[[#{k}]]", :git_url => git_url).should == v
|
831
|
+
end
|
832
|
+
|
833
|
+
it "parses [[#{k}]] with FALSE git_url (ObjProxy)" do
|
834
|
+
rev = k.split(':').last.tr(']','')
|
835
|
+
git_url = Breakout::ObjProxy.new do
|
836
|
+
false
|
837
|
+
end
|
838
|
+
parse("[[#{k}]]", :git_url => git_url).should == v
|
839
|
+
end
|
840
|
+
end
|
841
|
+
end
|
842
|
+
|
843
|
+
it "should not instantiate ObjProxy's internal object if there's no git links in text" do
|
844
|
+
git_url = Breakout::ObjProxy.new do
|
845
|
+
raise 'should not be raised'
|
846
|
+
end
|
847
|
+
lambda {
|
848
|
+
parse("[[r:2345]]", :git_url => git_url).should ==
|
849
|
+
'<a href="/code/test_space/subversion/changesets/2345">revision:2345</a>'
|
850
|
+
}.should_not raise_error
|
768
851
|
end
|
769
852
|
|
770
853
|
a = {}
|
@@ -823,7 +906,8 @@ describe 'BreakoutParser' do
|
|
823
906
|
s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
|
824
907
|
end
|
825
908
|
|
826
|
-
def parse s,
|
827
|
-
|
909
|
+
def parse s, h = {}
|
910
|
+
h[:space_name] = "test_space" unless h.key?(:space_name)
|
911
|
+
BreakoutParser.parse(s, h[:space_name], h[:site_url], h[:git_url]).strip
|
828
912
|
end
|
829
913
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breakout_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Andrey "Zed" Zaikin
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-04-01 00:00:00 +06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -29,8 +29,10 @@ executables: []
|
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
32
|
+
- ChangeLog
|
32
33
|
- LICENSE
|
33
34
|
files:
|
35
|
+
- ChangeLog
|
34
36
|
- LICENSE
|
35
37
|
- lib/breakout_parser.rb
|
36
38
|
- lib/breakout_parser/win32-ruby1.8/breakout_parser.so
|