raw 0.49.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/doc/CONTRIBUTORS +106 -0
  2. data/doc/LICENSE +32 -0
  3. data/doc/coding_conventions.txt +11 -0
  4. data/lib/raw.rb +42 -0
  5. data/lib/raw/adapter.rb +113 -0
  6. data/lib/raw/adapter/cgi.rb +41 -0
  7. data/lib/raw/adapter/fastcgi.rb +48 -0
  8. data/lib/raw/adapter/mongrel.rb +146 -0
  9. data/lib/raw/adapter/script.rb +94 -0
  10. data/lib/raw/adapter/webrick.rb +144 -0
  11. data/lib/raw/adapter/webrick/vcr.rb +91 -0
  12. data/lib/raw/cgi.rb +323 -0
  13. data/lib/raw/cgi/cookie.rb +47 -0
  14. data/lib/raw/cgi/http.rb +62 -0
  15. data/lib/raw/compiler.rb +138 -0
  16. data/lib/raw/compiler/filter/cleanup.rb +21 -0
  17. data/lib/raw/compiler/filter/elements.rb +166 -0
  18. data/lib/raw/compiler/filter/elements/element.rb +210 -0
  19. data/lib/raw/compiler/filter/localization.rb +23 -0
  20. data/lib/raw/compiler/filter/markup.rb +32 -0
  21. data/lib/raw/compiler/filter/morph.rb +123 -0
  22. data/lib/raw/compiler/filter/morph/each.rb +34 -0
  23. data/lib/raw/compiler/filter/morph/for.rb +11 -0
  24. data/lib/raw/compiler/filter/morph/if.rb +26 -0
  25. data/lib/raw/compiler/filter/morph/selected_if.rb +43 -0
  26. data/lib/raw/compiler/filter/morph/standard.rb +55 -0
  27. data/lib/raw/compiler/filter/morph/times.rb +27 -0
  28. data/lib/raw/compiler/filter/script.rb +116 -0
  29. data/lib/raw/compiler/filter/squeeze.rb +16 -0
  30. data/lib/raw/compiler/filter/static_include.rb +74 -0
  31. data/lib/raw/compiler/filter/template.rb +121 -0
  32. data/lib/raw/compiler/reloader.rb +96 -0
  33. data/lib/raw/context.rb +154 -0
  34. data/lib/raw/context/flash.rb +157 -0
  35. data/lib/raw/context/global.rb +88 -0
  36. data/lib/raw/context/request.rb +338 -0
  37. data/lib/raw/context/response.rb +57 -0
  38. data/lib/raw/context/session.rb +198 -0
  39. data/lib/raw/context/session/drb.rb +11 -0
  40. data/lib/raw/context/session/file.rb +15 -0
  41. data/lib/raw/context/session/memcached.rb +13 -0
  42. data/lib/raw/context/session/memory.rb +12 -0
  43. data/lib/raw/context/session/og.rb +15 -0
  44. data/lib/raw/context/session/pstore.rb +13 -0
  45. data/lib/raw/control.rb +18 -0
  46. data/lib/raw/control/attribute.rb +91 -0
  47. data/lib/raw/control/attribute/checkbox.rb +25 -0
  48. data/lib/raw/control/attribute/datetime.rb +21 -0
  49. data/lib/raw/control/attribute/file.rb +20 -0
  50. data/lib/raw/control/attribute/fixnum.rb +26 -0
  51. data/lib/raw/control/attribute/float.rb +26 -0
  52. data/lib/raw/control/attribute/options.rb +38 -0
  53. data/lib/raw/control/attribute/password.rb +16 -0
  54. data/lib/raw/control/attribute/text.rb +16 -0
  55. data/lib/raw/control/attribute/textarea.rb +16 -0
  56. data/lib/raw/control/none.rb +16 -0
  57. data/lib/raw/control/relation.rb +59 -0
  58. data/lib/raw/control/relation/belongs_to.rb +0 -0
  59. data/lib/raw/control/relation/has_many.rb +97 -0
  60. data/lib/raw/control/relation/joins_many.rb +0 -0
  61. data/lib/raw/control/relation/many_to_many.rb +0 -0
  62. data/lib/raw/control/relation/refers_to.rb +29 -0
  63. data/lib/raw/controller.rb +37 -0
  64. data/lib/raw/controller/publishable.rb +160 -0
  65. data/lib/raw/dispatcher.rb +209 -0
  66. data/lib/raw/dispatcher/format.rb +108 -0
  67. data/lib/raw/dispatcher/format/atom.rb +31 -0
  68. data/lib/raw/dispatcher/format/css.rb +0 -0
  69. data/lib/raw/dispatcher/format/html.rb +42 -0
  70. data/lib/raw/dispatcher/format/json.rb +31 -0
  71. data/lib/raw/dispatcher/format/rss.rb +33 -0
  72. data/lib/raw/dispatcher/format/xoxo.rb +31 -0
  73. data/lib/raw/dispatcher/mounter.rb +60 -0
  74. data/lib/raw/dispatcher/router.rb +111 -0
  75. data/lib/raw/errors.rb +19 -0
  76. data/lib/raw/helper.rb +86 -0
  77. data/lib/raw/helper/benchmark.rb +23 -0
  78. data/lib/raw/helper/buffer.rb +60 -0
  79. data/lib/raw/helper/cookie.rb +32 -0
  80. data/lib/raw/helper/debug.rb +28 -0
  81. data/lib/raw/helper/default.rb +16 -0
  82. data/lib/raw/helper/feed.rb +451 -0
  83. data/lib/raw/helper/form.rb +284 -0
  84. data/lib/raw/helper/javascript.rb +59 -0
  85. data/lib/raw/helper/layout.rb +40 -0
  86. data/lib/raw/helper/navigation.rb +87 -0
  87. data/lib/raw/helper/pager.rb +305 -0
  88. data/lib/raw/helper/table.rb +247 -0
  89. data/lib/raw/helper/xhtml.rb +218 -0
  90. data/lib/raw/helper/xml.rb +125 -0
  91. data/lib/raw/mixin/magick.rb +35 -0
  92. data/lib/raw/mixin/sweeper.rb +71 -0
  93. data/lib/raw/mixin/thumbnails.rb +1 -0
  94. data/lib/raw/mixin/webfile.rb +165 -0
  95. data/lib/raw/render.rb +271 -0
  96. data/lib/raw/render/builder.rb +26 -0
  97. data/lib/raw/render/caching.rb +81 -0
  98. data/lib/raw/render/call.rb +43 -0
  99. data/lib/raw/render/send_file.rb +46 -0
  100. data/lib/raw/render/stream.rb +39 -0
  101. data/lib/raw/scaffold.rb +13 -0
  102. data/lib/raw/scaffold/controller.rb +25 -0
  103. data/lib/raw/scaffold/model.rb +157 -0
  104. data/lib/raw/test.rb +5 -0
  105. data/lib/raw/test/assertions.rb +169 -0
  106. data/lib/raw/test/context.rb +55 -0
  107. data/lib/raw/test/testcase.rb +79 -0
  108. data/lib/raw/util/attr.rb +128 -0
  109. data/lib/raw/util/encode_uri.rb +149 -0
  110. data/lib/raw/util/html_filter.rb +538 -0
  111. data/lib/raw/util/markup.rb +130 -0
  112. data/test/glue/tc_webfile.rb +1 -0
  113. data/test/nitro/CONFIG.rb +3 -0
  114. data/test/nitro/adapter/raw_post1.bin +9 -0
  115. data/test/nitro/adapter/tc_webrick.rb +16 -0
  116. data/test/nitro/cgi/tc_cookie.rb +14 -0
  117. data/test/nitro/cgi/tc_request.rb +61 -0
  118. data/test/nitro/compiler/tc_client_morpher.rb +47 -0
  119. data/test/nitro/compiler/tc_compiler.rb +25 -0
  120. data/test/nitro/dispatcher/tc_mounter.rb +47 -0
  121. data/test/nitro/helper/tc_feed.rb +135 -0
  122. data/test/nitro/helper/tc_navbar.rb +74 -0
  123. data/test/nitro/helper/tc_pager.rb +35 -0
  124. data/test/nitro/helper/tc_table.rb +68 -0
  125. data/test/nitro/helper/tc_xhtml.rb +19 -0
  126. data/test/nitro/tc_caching.rb +19 -0
  127. data/test/nitro/tc_cgi.rb +222 -0
  128. data/test/nitro/tc_context.rb +17 -0
  129. data/test/nitro/tc_controller.rb +103 -0
  130. data/test/nitro/tc_controller_aspect.rb +32 -0
  131. data/test/nitro/tc_controller_params.rb +885 -0
  132. data/test/nitro/tc_dispatcher.rb +109 -0
  133. data/test/nitro/tc_element.rb +85 -0
  134. data/test/nitro/tc_flash.rb +59 -0
  135. data/test/nitro/tc_helper.rb +47 -0
  136. data/test/nitro/tc_render.rb +119 -0
  137. data/test/nitro/tc_router.rb +61 -0
  138. data/test/nitro/tc_server.rb +35 -0
  139. data/test/nitro/tc_session.rb +66 -0
  140. data/test/nitro/tc_template.rb +71 -0
  141. data/test/nitro/util/tc_encode_url.rb +87 -0
  142. data/test/nitro/util/tc_markup.rb +31 -0
  143. data/test/public/blog/another/very_litle/index.xhtml +1 -0
  144. data/test/public/blog/inc1.xhtml +2 -0
  145. data/test/public/blog/inc2.xhtml +1 -0
  146. data/test/public/blog/list.xhtml +9 -0
  147. data/test/public/dummy_mailer/registration.xhtml +5 -0
  148. metadata +244 -0
@@ -0,0 +1,130 @@
1
+ require "redcloth"
2
+ require "cgi"
3
+
4
+ require "facets/core/module/class_extension"
5
+
6
+ require "raw/util/html_filter"
7
+
8
+ module Raw
9
+
10
+ # Generalised Markup transformations.
11
+ #
12
+ # The expand methods evaluate (expand) the markup
13
+ # code to produce the final content. The compact
14
+ # methods reverse this process to create the original
15
+ # markup code. Not all markup transformations are
16
+ # reversible.
17
+ #
18
+ # When this library is included, the default PropertyUtils
19
+ # implementation is overriden to add markup support.
20
+ #
21
+ # === Examples
22
+ #
23
+ # Define your custom markup methods like this:
24
+ #
25
+ # module Markup
26
+ # def markup_simple
27
+ # ...
28
+ # end
29
+ # def markup_special
30
+ # ...
31
+ # end
32
+ #
33
+ # # maps the {{..}} macro
34
+ # alias_method :sanitize, :markup_simple
35
+ # # maps the {|..|} macro
36
+ # alias_method :markup, :markup_special
37
+ # end
38
+ #
39
+ # here comes the #{obj.body} # => prints the expanded version.
40
+ #
41
+ # obj.body = markup(@params['body'])
42
+
43
+ module Markup
44
+
45
+ private
46
+ # The default markup method. You should override this method
47
+ # in your application to call your custom markup
48
+ # methods.
49
+
50
+ def expand(str)
51
+ if str
52
+ xstr = str.dup
53
+ xstr.gsub!(/</, '&lt;')
54
+ xstr.gsub!(/>/, '&gt;')
55
+ xstr.gsub!(/\r/, '<br />')
56
+ return xstr.html_filter
57
+ end
58
+ return nil
59
+ end
60
+ alias_method :sanitize, :expand
61
+
62
+ # ...
63
+ begin
64
+ require 'redcloth'
65
+ # Translates a String with Textile/Markdown formatting
66
+ # into XHTML. Depends on the RedCloth gem to work properly
67
+
68
+ def expand_redcloth(str)
69
+ if str
70
+ return RedCloth.new(expand(str)).to_html
71
+ end
72
+ return nil
73
+ end
74
+ rescue LoadError
75
+ def expand_redcloth(str) # :nodoc:
76
+ "You called expand_redcloth(), but it needs RedCloth installed to work"
77
+ end
78
+ end
79
+ alias_method :markup, :expand_redcloth
80
+
81
+ # Compact (reverse) the content to the origial markup
82
+ # code. Not all markup transformations are reversible.
83
+ # You should override this method in your application
84
+ # to call your custom markup methods.
85
+ #
86
+ # NOT IMPLEMENTED.
87
+
88
+ def compact(str, meth = nil)
89
+ end
90
+
91
+ # Remove markup code from the input string.
92
+ #
93
+ # NOT IMPLEMENTED.
94
+
95
+ def clear(str)
96
+ end
97
+
98
+ def escape(str)
99
+ CGI.escape(str.gsub(/ /, '_'))
100
+ end
101
+
102
+ def unescape(str)
103
+ CGI.unescape(str.gsub(/_/, ' '))
104
+ end
105
+
106
+ class_extension do
107
+ # Helper method for manipulating the sanitize transformation.
108
+
109
+ def setup_sanitize_transform(&block)
110
+ self.send :define_method, :sanitize, block
111
+ end
112
+ alias_method :setup_sanitize_transformation, :setup_sanitize_transform
113
+
114
+ # Helper method for manipulating the markup transformation.
115
+
116
+ def setup_markup_transform(&block)
117
+ self.send :define_method, :markup, block
118
+ end
119
+ alias_method :setup_markup_transformation, :setup_markup_transform
120
+ end
121
+ end
122
+
123
+ # An abstract Markup class.
124
+
125
+ class MarkupKit
126
+ extend Markup
127
+ include Markup
128
+ end
129
+
130
+ end
@@ -0,0 +1 @@
1
+ # Please add me!
@@ -0,0 +1,3 @@
1
+ $NITRO_NO_ENVIRONMENT = true
2
+
3
+ require 'nitro'
@@ -0,0 +1,9 @@
1
+ -----------------------------277124474474241471962886717
2
+ Content-Disposition: form-data; name="title"
3
+
4
+ dsadsad
5
+ -----------------------------277124474474241471962886717
6
+ Content-Disposition: form-data; name="file"; filename="nitro.png"
7
+ Content-Type: image/png
8
+
9
+ �PNG
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')
2
+
3
+ require 'test/unit'
4
+ require 'ostruct'
5
+
6
+ require 'glue'
7
+ require 'nitro'
8
+ require 'nitro/adapter/webrick'
9
+
10
+ class TC_AdaptersWebrick < Test::Unit::TestCase # :nodoc: all
11
+ include Nitro
12
+
13
+ def test_adaptor
14
+ end
15
+
16
+ end
@@ -0,0 +1,14 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')
2
+
3
+ require 'test/unit'
4
+
5
+ require 'nitro/cgi/cookie'
6
+
7
+ class TC_Cookie < Test::Unit::TestCase # :nodoc: all
8
+ include Nitro
9
+
10
+ def test_init
11
+ c = Cookie.new('hello', 'world')
12
+ assert_equal '/', c.path
13
+ end
14
+ end
@@ -0,0 +1,61 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')
2
+
3
+ require 'test/unit'
4
+
5
+ require 'nitro/cgi/request'
6
+
7
+ class TC_Request < Test::Unit::TestCase # :nodoc: all
8
+ class DummyRequest
9
+ include Nitro::Request
10
+
11
+ def initialize
12
+ @headers = {}
13
+ @params = {}
14
+ end
15
+ end
16
+
17
+ def test_all
18
+ req = DummyRequest.new
19
+
20
+ req.headers['HTTP_HOST'] = 'www.nitroproject.org'
21
+ assert_equal 'nitroproject.org', req.domain
22
+ assert_equal 'www', req.subdomains.first
23
+
24
+ req.headers['HTTP_HOST'] = 'www.nitroproject.co.uk'
25
+ assert_equal 'nitroproject.co.uk', req.domain(2)
26
+
27
+ req.headers['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
28
+ assert req.xhr?
29
+
30
+ req.headers['REQUEST_METHOD'] = 'POST'
31
+
32
+ req.headers['CONTENT_TYPE'] = 'application/x-yaml'
33
+ assert req.yaml_post?
34
+
35
+ req.instance_variable_set '@post_format', nil
36
+ req.headers['CONTENT_TYPE'] = 'text/xml'
37
+ assert req.xml_post?
38
+
39
+ req['test'] = 'hello'
40
+ assert req['test']
41
+ assert_equal 'hello', req['test']
42
+ assert req.has?('test')
43
+
44
+ assert !req.has?('phantom')
45
+
46
+ req['bug'] = nil
47
+ assert !req.has?('bug')
48
+ end
49
+
50
+ def test_local_net?
51
+ req = DummyRequest.new
52
+
53
+ local_ips = ["192.168.1.1", "192.168.20.1", "192.168.99.1", "192.168.200.1", "192.168.21.245", "192.168.90.34", "192.168.254.254", "172.16.1.1", "172.18.1.1", "172.31.254.1", "172.21.1.254", "10.16.1.1", "10.0.1.1", "10.254.1.254", "10.192.1.192", "10.254.254.254", "10.10.10.10"]
54
+
55
+ not_local_ips = ["191.168.1.1", "192.169.20.1", "193.168.254.254", "172.15.1.1", "171.18.1.1", "172.32.0.0", "173.21.1.254", "11.16.1.1", "66.249.93.104", "72.14.221.104", "66.102.9.104", "17.254.3.183", "207.46.250.119", "207.46.130.108", "207.68.160.190", "65.54.240.126", "213.199.144.151", "65.55.238.126"]
56
+
57
+ assert_equal true, local_ips.map { |ip| req.local_net?(ip) }.all?
58
+ assert_equal true, not_local_ips.map { |ip| req.local_net?(ip) }.all?{|v|!v}
59
+ end
60
+
61
+ end
@@ -0,0 +1,47 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')
2
+
3
+ require 'test/unit'
4
+
5
+ require 'nitro/test/testcase'
6
+ require 'nitro/compiler'
7
+
8
+ class TC_ClientMorpher < Test::Unit::TestCase
9
+ class MyController < Nitro::Controller
10
+ class Client
11
+ def check_album
12
+ ajax_update 'tools_block', {
13
+ :action => 'checked_albums',
14
+ :params => 'some parameters'
15
+ }
16
+ end
17
+ end
18
+ end
19
+
20
+ Action_Name = :an_object_responding_to_the_method_to_sym_is_now_required_when_compiling_a_template
21
+
22
+ def setup
23
+ @compiler = Nitro::Compiler.new(MyController)
24
+ end
25
+
26
+ def teardown
27
+ @compiler = nil
28
+ end
29
+
30
+ def test_javascript_no_params
31
+ template = '<a href="#" client="check_album">Test</a>'
32
+ result = @compiler.transform_template(Action_Name, template)
33
+ assert_match(/__nc_check_album\(\)/, result)
34
+ end
35
+
36
+ def test_javascript_one_param
37
+ template = '<a href="#" client="check_album" params="this.id">Test</a>'
38
+ result = @compiler.transform_template(Action_Name, template)
39
+ assert_match(/__nc_check_album\(this\.id\)/, result)
40
+ end
41
+
42
+ def test_javascript_multi_params
43
+ template = '<a href="#" client="check_album" params="this.id, this.class">Test</a>'
44
+ result = @compiler.transform_template(Action_Name, template)
45
+ assert_match(/__nc_check_album\(this\.id, this\.class\)/, result)
46
+ end
47
+ end
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')
2
+
3
+ require 'test/unit'
4
+
5
+ require 'nitro/test/testcase'
6
+
7
+ require 'nitro'
8
+ require 'nitro/test/context'
9
+
10
+ class TC_Compiler < Test::Unit::TestCase
11
+ class TestController < Nitro::Controller
12
+ def test(arg1, arg2); end
13
+ end
14
+
15
+ def setup
16
+ Server.map['/'] = TestController
17
+ reset_context()
18
+ end
19
+
20
+ def test_no_param_specified
21
+ assert_nothing_raised do
22
+ process(:uri => '/test/two')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,47 @@
1
+ require File.join(File.dirname(__FILE__), "..", "CONFIG.rb")
2
+
3
+ require "test/unit"
4
+
5
+ require "nitro/dispatcher"
6
+
7
+ class TC_DispatcherMounter < Test::Unit::TestCase # :nodoc: all
8
+
9
+ include Nitro
10
+
11
+ class RootController
12
+ end
13
+
14
+ class LinkController
15
+ end
16
+
17
+ class LinkCommentController
18
+ end
19
+
20
+ class UserController
21
+ end
22
+
23
+ def setup
24
+ @d = Dispatcher.new
25
+ end
26
+
27
+ def teardown
28
+ @d = nil
29
+ end
30
+
31
+ def test_mount
32
+ @d.root = RootController
33
+ assert_equal RootController, @d["/"]
34
+
35
+ @d.root.links = LinkController
36
+ assert_equal LinkController, @d["/links"]
37
+ assert_equal RootController, LinkController.ann(:self, :parent)
38
+
39
+ @d.root.links.comments = LinkCommentController
40
+ assert_equal LinkCommentController, @d["/links/comments"]
41
+ assert_equal LinkController, LinkCommentController.ann(:self, :parent)
42
+
43
+ @d.root.users = UserController
44
+ assert_equal UserController, @d["/users"]
45
+ end
46
+
47
+ end
@@ -0,0 +1,135 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'CONFIG.rb')
2
+
3
+ require 'test/unit'
4
+ require 'nitro/helper/feed'
5
+
6
+ class TC_FeedHelper < Test::Unit::TestCase # :nodoc: all
7
+ include Nitro
8
+ include FeedHelper
9
+
10
+ Blog = Struct.new(:title, :body, :to_href)
11
+ Blog2 = Struct.new(:title, :body, :to_href, :update_time)
12
+ # TODO: add more (all)
13
+ FullBlown = Struct.new(:title, :body, :full_content, :to_href, :update_time, :create_time, :author)
14
+
15
+ # RSS Testing
16
+ def test_rss
17
+ blogs = []
18
+ blogs << Blog.new('Hello1', 'World1', 'uri1');
19
+ blogs << Blog.new('Hello2', 'World2', 'uri2');
20
+ blogs << Blog.new('Hello3', 'World3', 'uri3');
21
+ blogs2 = []
22
+ updated = Time.now
23
+ blogs2 << Blog2.new('Hello1', 'World1', 'uri1', updated);
24
+ blogs2 << Blog2.new('Hello2', 'World2', 'uri2', updated);
25
+ blogs2 << Blog2.new('Hello3', 'World3', 'uri3', updated);
26
+
27
+ # rss without version (0.9)
28
+ rss = build_rss(blogs, :base => 'http://oxyliquit.de')
29
+
30
+ assert_match %r{<link>http://oxyliquit.de/uri1</link>}, rss
31
+ assert_match %r{<link>http://oxyliquit.de/uri2</link>}, rss
32
+
33
+ # rss 0.9
34
+ rss09 = build_rss(blogs, :version => "0.91", :link => 'http://oxyliquit.de')
35
+ assert_match %r{<link>http://oxyliquit.de/uri1</link>}, rss09
36
+ assert_match %r{<link>http://oxyliquit.de/uri2</link>}, rss09
37
+
38
+ # rss 1.0
39
+ rss10 = build_rss(blogs, :version => "1.0", :link => 'http://oxyliquit.de')
40
+ assert_match %r{<link>http://oxyliquit.de/uri1</link>}, rss10
41
+ assert_match %r{<link>http://oxyliquit.de/uri2</link>}, rss10
42
+
43
+ # rss 2.0
44
+ rss20 = build_rss(blogs2, :version => "2.0", :link => 'http://oxyliquit.de')
45
+ assert_match %r{<link>http://oxyliquit.de/uri1</link>}, rss20
46
+ assert_match %r{<link>http://oxyliquit.de/uri2</link>}, rss20
47
+
48
+ # rss full blown
49
+ rssfull = build_rss(blogs, :version => "0.9", :base => 'http://oxyliquit.de', :link => 'http://oxyliquit.de/feed', :title => "Oxyliquit feed", :language => 'en', :about => 'http://ox.li/about.rdf', :description => "Example feed of Oxyliquit", :search_title => "Oxyliquit search", :search_description => "Search through Oxyliqit", :search_input_name => "q", :search_form_action => "http://oxyliquit.de/search")
50
+ assert_match %r{<link>http://oxyliquit.de/uri1</link>}, rssfull
51
+ assert_match %r{<link>http://oxyliquit.de/uri2</link>}, rssfull
52
+ # TODO: there should be some more
53
+
54
+ # rss with full blown object
55
+ update_time = Time.now
56
+ create_time = Time.now - 360
57
+ author = Hash.new
58
+ author[:name] = "Bill"
59
+ author[:link] = "http://bills.url"
60
+ author[:email] = "bill@email.com"
61
+ fullblownobject = []
62
+ fullblownobject << FullBlown.new('Hello1', 'World1', 'Fullsize text with lots of words..', 'uri1', update_time, create_time, author)
63
+ fullblownobject << FullBlown.new('Hello2', 'World2', ' text with lots of words..', 'uri2', update_time, create_time, author)
64
+ rss_f_o = build_rss(fullblownobject, :version => "0.9", :base => 'http://oxyliquit.de', :link => 'http://oxyliquit.de/feed', :title => "Oxyliquit feed", :language => 'en', :about => 'http://ox.li/about.rdf', :description => "Example feed of Oxyliquit", :search_title => "Oxyliquit search", :search_description => "Search through Oxyliqit", :search_input_name => "q", :search_form_action => "http://oxyliquit.de/search")
65
+ assert_match %r{<link>http://oxyliquit.de/uri1</link>}, rss_f_o
66
+ assert_match %r{<link>http://oxyliquit.de/uri2</link>}, rss_f_o
67
+
68
+ # rss with wrong version
69
+ assert_raise(RuntimeError) do
70
+ build_rss(blogs, :version => "0.5", :link => 'http://oxyliquit.de')
71
+ end
72
+
73
+ end # test_rss
74
+
75
+ # Atom Testing
76
+ def test_atom
77
+ blogs = []
78
+ updated = Time.now
79
+ blogs << Blog2.new('Hello1', 'World1', 'uri1', updated);
80
+ blogs << Blog2.new('Hello2', 'World2', 'uri2', updated);
81
+ blogs << Blog2.new('Hello3', 'World3', 'uri3', updated);
82
+
83
+ # atom small
84
+ atom = build_atom(blogs, :base => 'http://oxyliquit.de')
85
+
86
+ assert_match %r{<id>http://oxyliquit.de/uri1</id>}, atom
87
+ assert_match %r{<id>http://oxyliquit.de/uri2</id>}, atom
88
+
89
+ # atom big
90
+ atom = build_atom(blogs, :title => "Oxyliquit Feed", :base => "http://oxyliquit.de", :link => "http://oxyliquit.de/atomfeed", :author_name => "Fabian Buch", :author_email => "fabian@fabian-buch.de", :author_link => "http://fabian-buch.de")
91
+
92
+ assert_match %r{<id>http://oxyliquit.de/uri1</id>}, atom
93
+ assert_match %r{<id>http://oxyliquit.de/uri2</id>}, atom
94
+ assert_match %r{<title>Oxyliquit Feed</title>}, atom
95
+ assert_match %r{<updated>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2})</updated>}, atom
96
+
97
+ # atom with full blown object
98
+ update_time = Time.now
99
+ create_time = Time.now - 360
100
+ author = Hash.new
101
+ author[:name] = "Bill"
102
+ author[:link] = "http://bills.url"
103
+ author[:email] = "bill@email.com"
104
+ fullblownobject = []
105
+ fullblownobject << FullBlown.new('Hello1', 'World1', 'Fullsize text with lots of words..', 'uri1', update_time, create_time, author)
106
+ fullblownobject << FullBlown.new('Hello2', 'World2', ' text with lots of words..', 'uri2', update_time, create_time, author)
107
+ atom_f_o = build_atom(fullblownobject, :title => "Oxyliquit Feed", :base => "http://oxyliquit.de", :link => "http://oxyliquit.de/atomfeed", :author_name => "Fabian Buch", :author_email => "fabian@fabian-buch.de", :author_link => "http://fabian-buch.de")
108
+ assert_match %r{<id>http://oxyliquit.de/uri1</id>}, atom_f_o
109
+ assert_match %r{<id>http://oxyliquit.de/uri2</id>}, atom_f_o
110
+ assert_match %r{<title>Oxyliquit Feed</title>}, atom_f_o
111
+ assert_match %r{<summary>\w+</summary>}, atom_f_o
112
+ assert_match %r{<updated>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2})</updated>}, atom_f_o
113
+ assert_match %r{<published>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2})</published>}, atom_f_o
114
+ assert_match %r{<author><name>Bill</name><email>bill@email.com</email><uri>http://bills.url</uri></author>}, atom_f_o
115
+
116
+ end # test_atom
117
+
118
+ # OPML Testing
119
+ def test_opml
120
+
121
+ opml = build_opml(
122
+ {
123
+ "http://oxyliquit.de/feed" => "rss",
124
+ "http://oxyliquit.de/feed/questions" => "rss",
125
+ "http://oxyliquit.de/feed/tips" => "rss",
126
+ "http://oxyliquit.de/feed/tutorials" => "rss"
127
+ },
128
+ :title => "My feeds"
129
+ )
130
+
131
+ assert_match %r{<outline xmlUrl='http://oxyliquit.de/feed/tips' type='rss'/>}, opml
132
+
133
+ end # test_opml
134
+
135
+ end