piki_doc 0.0.2.2

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,19 @@
1
+ require File.expand_path("../spec_helper", File.dirname(__FILE__))
2
+ require 'piki_doc/document'
3
+
4
+ describe PikiDoc::Document do
5
+ describe "to_xhtml(image_link_with_param)" do
6
+ subject{ PikiDoc::Document.to_xhtml('http://image.exmaple.com/image.jpg?size=100x75') }
7
+
8
+ it{ should == "<p><img src=\"http://image.exmaple.com/image.jpg?size=100x75\" alt=\"image.jpg\" /></p>\n"}
9
+ end
10
+
11
+ describe "register(plugin)" do
12
+ before(:all) do
13
+ PikiDoc::Document.register(Object.new, Object.new)
14
+ end
15
+
16
+ it{ PikiDoc::Document.should have(2).plugins }
17
+ end
18
+ end
19
+
@@ -0,0 +1,45 @@
1
+ require File.expand_path("../spec_helper", File.dirname(__FILE__))
2
+ require 'piki_doc/output'
3
+
4
+ describe PikiDoc::HTMLOutput do
5
+ # {{vote_form('order','お名前', '[勉強会]','PP, Blog, Twitter or Github', 'ひとこと', '[ust設備あり]')}}
6
+ describe "call inline_plugin() when respond_to?(meth) and accept?()" do
7
+ RSpec::Matchers.define :ouptut_content do |expected|
8
+ match do |actual|
9
+ actual.finish.strip.should == expected
10
+ end
11
+ end
12
+
13
+ before do
14
+ @input = "plugin/source"
15
+
16
+ @plugin = mock("plugin")
17
+ @plugin.should_receive(:respond_to?).with(:inline_plugin).at_least(:once).and_return(true)
18
+ @plugin.should_receive(:respond_to?).with(:block_plugin).at_least(:once).and_return(true)
19
+ @plugin.should_receive(:accept?).with(@input).and_return(true)
20
+
21
+ @out = PikiDoc::HTMLOutput.new(suffix = " />", [@plugin]).tap(&:reset)
22
+ end
23
+
24
+ describe "inline_plugin" do
25
+ before do
26
+ @plugin.should_receive(:inline_plugin).with(@input).and_return("--out--")
27
+ end
28
+
29
+ it "should render plugin output" do
30
+ @out.inline_plugin(@input).should == "--out--"
31
+ end
32
+ end
33
+
34
+ describe "block_plugin" do
35
+ before do
36
+ @plugin.should_receive(:block_plugin).with(@input).and_return("--block--")
37
+ end
38
+
39
+ it "should render plugin output" do
40
+ @out.block_plugin(@input)
41
+ @out.should ouptut_content "--block--"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,82 @@
1
+ #coding:utf-8
2
+ require File.expand_path("spec_helper", File.dirname(__FILE__))
3
+ require 'piki_doc'
4
+
5
+ class HikiComatibilityMatcher
6
+ def initialize(format, hikidoc, options={})
7
+ @format = "to_#{format}"
8
+ @hikidoc = hikidoc
9
+ @options = options
10
+ end
11
+
12
+ def matches?(actual)
13
+ actual.send(@format, @hikidoc, @options) == HikiDoc.send(@format, @hikidoc, @options)
14
+ end
15
+
16
+ def description
17
+ "compat with " + shorten_content
18
+ end
19
+
20
+ def failure_message_for_should
21
+ "should compat but don't compat with " + shorten_content
22
+ end
23
+
24
+ def failure_message_for_should_not
25
+ "should not compat but compat with " + shorten_content
26
+ end
27
+
28
+ private
29
+ def shorten_content(num=50)
30
+ @hikidoc.gsub(/[\r\n]/, "\\n").split(//)[0, num].join("")
31
+ end
32
+ end
33
+
34
+ describe PikiDoc do
35
+ subject{ PikiDoc } # module itself
36
+ def compat_with_hiki(*arg)
37
+ HikiComatibilityMatcher.new(*arg)
38
+ end
39
+
40
+ shared_examples_for "プラグインなしの場合はオリジナルのHikiと同じように動くこと" do
41
+ it { should compat_with_hiki(format, <<-EOS) }
42
+ !おはよう
43
+ !!こんにちは
44
+
45
+ こんばんは
46
+ EOS
47
+
48
+ it { should compat_with_hiki(format, <<-EOS, :level => 3) }
49
+ !おはよう
50
+ !!こんにちは
51
+
52
+ こんばんは
53
+ EOS
54
+
55
+ it { should compat_with_hiki(format, <<-EOS) }
56
+ - foobar
57
+ - piyopiyo
58
+
59
+ EOS
60
+
61
+ end
62
+
63
+ shared_examples_for "プラグインありの場合はオリジナルと異なること" do
64
+ it { should_not compat_with_hiki(format, <<-EOS) }
65
+ !クエリつき画像リンク
66
+ http://image.with.query.example.com/photo.jpg?size=100x75
67
+ EOS
68
+ end
69
+
70
+ context :xhtml do
71
+ let(:format) { :xhtml }
72
+ it_should_behave_like "プラグインなしの場合はオリジナルのHikiと同じように動くこと"
73
+ it_should_behave_like "プラグインありの場合はオリジナルと異なること"
74
+ end
75
+
76
+ context :html do
77
+ let(:format) { :html }
78
+ it_should_behave_like "プラグインなしの場合はオリジナルのHikiと同じように動くこと"
79
+ it_should_behave_like "プラグインありの場合はオリジナルと異なること"
80
+ end
81
+ end
82
+
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: piki_doc
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ - 2
10
+ version: 0.0.2.2
11
+ platform: ruby
12
+ authors:
13
+ - MOROHASHI Kyosuke
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-18 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: extended HikiDoc to able to plug plugins.
23
+ email: moronatural@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.ja.hiki
30
+ - Changelog
31
+ files:
32
+ - README.ja.hiki
33
+ - Changelog
34
+ - Rakefile
35
+ - lib/piki_doc/bundles/asin.rb
36
+ - lib/piki_doc/bundles/gist.rb
37
+ - lib/piki_doc/bundles/plugin_adapter.rb
38
+ - lib/piki_doc/document.rb
39
+ - lib/piki_doc/image_uri_autolink_fix.rb
40
+ - lib/piki_doc/output.rb
41
+ - lib/piki_doc.rb
42
+ - lib/vendor/hikidoc.rb
43
+ - spec/piki_doc/document_spec.rb
44
+ - spec/piki_doc/output_spec.rb
45
+ - spec/piki_doc_spec.rb
46
+ - features/step_definitions/pluggable_hikidoc_steps.rb
47
+ - features/support/env.rb
48
+ - features/asin_plugin.feature
49
+ - features/gist_plugin.feature
50
+ has_rdoc: true
51
+ homepage: http://github.com/moro/piki_doc/
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options:
56
+ - --title
57
+ - piki_doc documentation
58
+ - --charset
59
+ - utf-8
60
+ - --opname
61
+ - index.html
62
+ - --line-numbers
63
+ - --main
64
+ - README.ja.hiki
65
+ - --inline-source
66
+ - --exclude
67
+ - ^(examples|extras)/
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ requirements: []
87
+
88
+ rubyforge_project:
89
+ rubygems_version: 1.3.7
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: extended HikiDoc to able to plug plugins.
93
+ test_files:
94
+ - spec/piki_doc/document_spec.rb
95
+ - spec/piki_doc/output_spec.rb
96
+ - spec/piki_doc_spec.rb
97
+ - features/step_definitions/pluggable_hikidoc_steps.rb
98
+ - features/support/env.rb
99
+ - features/asin_plugin.feature
100
+ - features/gist_plugin.feature