nitro 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +284 -0
- data/{LICENCE → LICENSE} +1 -1
- data/README +13 -17
- data/RELEASES +13 -1
- data/Rakefile +1 -9
- data/bin/cluster.rb +5 -5
- data/examples/blog/README +45 -0
- data/examples/blog/apache.conf +0 -0
- data/examples/blog/app.rb +21 -0
- data/examples/blog/config.rb +88 -0
- data/examples/blog/lib/blog.rb +104 -0
- data/examples/blog/log/app.log +117 -0
- data/examples/blog/root/comments.xhtml +38 -0
- data/examples/blog/root/entry_form.xhtml +18 -0
- data/examples/blog/root/index.xhtml +43 -0
- data/examples/blog/root/login.xhtml +24 -0
- data/examples/blog/root/m/bubbles.gif +0 -0
- data/examples/blog/root/m/comments_curve.gif +0 -0
- data/examples/blog/root/m/down.gif +0 -0
- data/examples/blog/root/m/footer_bg.gif +0 -0
- data/examples/blog/root/m/garrow.gif +0 -0
- data/examples/blog/root/m/gbull.gif +0 -0
- data/examples/blog/root/m/grbull.gif +0 -0
- data/examples/blog/root/m/h1_bg.gif +0 -0
- data/examples/blog/root/m/header_bg.gif +0 -0
- data/examples/blog/root/m/obull.gif +0 -0
- data/examples/blog/root/m/page_bg.gif +0 -0
- data/examples/blog/root/m/side_title_bg.gif +0 -0
- data/examples/blog/root/m/sidebar_bg.gif +0 -0
- data/examples/blog/root/recent_posts.xhtml +14 -0
- data/examples/blog/root/style.css +201 -0
- data/examples/blog/root/style.xsl +118 -0
- data/examples/blog/root/view_entry.xhtml +29 -0
- data/examples/og/run.rb +27 -29
- data/examples/tiny/README +3 -4
- data/examples/tiny/app.rb +6 -16
- data/examples/tiny/config.rb +30 -0
- data/examples/tiny/log/app.log +23 -0
- data/examples/tiny/root/{index.sx → index.xhtml} +3 -6
- data/lib/{n/std.rb → nitro.rb} +9 -4
- data/lib/{n → nitro}/application.rb +13 -7
- data/lib/{n → nitro}/config.rb +38 -8
- data/lib/{n → nitro}/events.rb +1 -1
- data/lib/{n → nitro}/l10n.rb +1 -1
- data/lib/{n → nitro}/logger.rb +8 -8
- data/lib/{n → nitro}/macros.rb +3 -3
- data/lib/{n → nitro}/mixins.rb +1 -1
- data/lib/nitro/properties.rb +301 -0
- data/lib/{n → nitro}/server.rb +2 -2
- data/lib/{n → nitro}/server/appserver.rb +14 -5
- data/lib/{n → nitro}/server/cluster.rb +5 -5
- data/lib/{n → nitro}/server/cookie.rb +1 -1
- data/lib/nitro/server/dispatcher.rb +66 -0
- data/lib/{n → nitro}/server/filters.rb +7 -7
- data/lib/{n → nitro}/server/filters/autologin.rb +3 -3
- data/lib/{n → nitro}/server/fragment.rb +3 -3
- data/lib/{n → nitro}/server/handlers.rb +3 -3
- data/lib/nitro/server/render.rb +200 -0
- data/lib/{n → nitro}/server/request.rb +6 -6
- data/lib/{n → nitro}/server/requestpart.rb +5 -5
- data/lib/{n → nitro}/server/script.rb +3 -3
- data/lib/{n → nitro}/server/server.rb +4 -4
- data/lib/{n → nitro}/server/session.rb +3 -3
- data/lib/nitro/server/shaders.rb +165 -0
- data/lib/{n → nitro}/server/user.rb +1 -1
- data/lib/nitro/server/webrick.rb +175 -0
- data/lib/nitro/service.rb +25 -0
- data/lib/{n → nitro}/sitemap.rb +2 -2
- data/lib/{n → nitro}/ui/date-select.rb +0 -0
- data/lib/{n → nitro}/ui/pager.rb +1 -1
- data/lib/{n → nitro}/ui/popup.rb +1 -1
- data/lib/{n → nitro}/ui/select.rb +1 -1
- data/lib/{n → nitro}/ui/tabs.rb +1 -1
- data/lib/{n → nitro}/utils/array.rb +1 -1
- data/lib/{n → nitro}/utils/cache.rb +1 -1
- data/lib/{n → nitro}/utils/gfx.rb +1 -1
- data/lib/{n → nitro}/utils/hash.rb +1 -1
- data/lib/{n → nitro}/utils/html.rb +1 -1
- data/lib/{n → nitro}/utils/http.rb +1 -1
- data/lib/{n → nitro}/utils/mail.rb +1 -1
- data/lib/{n → nitro}/utils/number.rb +1 -1
- data/lib/{n → nitro}/utils/pool.rb +1 -1
- data/lib/{n → nitro}/utils/string.rb +19 -95
- data/lib/{n → nitro}/utils/template.rb +0 -0
- data/lib/{n → nitro}/utils/time.rb +1 -1
- data/lib/{n → nitro}/utils/uri.rb +3 -3
- data/lib/nitro/version.rb +11 -0
- data/lib/{n/og.rb → og.rb} +61 -31
- data/lib/{n/og → og}/backend.rb +13 -7
- data/lib/{n/og → og}/backends/mysql.rb +43 -39
- data/lib/{n/og → og}/backends/psql.rb +42 -38
- data/lib/{n/og → og}/connection.rb +21 -9
- data/lib/{n/og → og}/meta.rb +18 -12
- data/lib/xsl/base.xsl +11 -88
- data/test/n/server/tc_cookie.rb +1 -1
- data/test/n/server/tc_filters.rb +1 -1
- data/test/n/server/tc_request.rb +3 -3
- data/test/n/server/tc_requestpart.rb +2 -2
- data/test/n/server/tc_session.rb +1 -1
- data/test/n/tc_events.rb +1 -1
- data/test/n/tc_og.rb +16 -18
- data/test/n/tc_properties.rb +22 -18
- data/test/n/tc_sitemap.rb +2 -2
- data/test/n/ui/tc_pager.rb +4 -4
- data/test/n/utils/tc_cache.rb +1 -1
- data/test/n/utils/tc_hash.rb +1 -1
- data/test/n/utils/tc_html.rb +1 -1
- data/test/n/utils/tc_http.rb +1 -1
- data/test/n/utils/tc_number.rb +1 -1
- data/test/n/utils/tc_strings.rb +1 -46
- data/test/n/utils/tc_uri.rb +1 -1
- metadata +101 -108
- data/examples/simple/README +0 -42
- data/examples/simple/app.rb +0 -31
- data/examples/simple/conf/apache.conf +0 -100
- data/examples/simple/conf/config.rb +0 -72
- data/examples/simple/conf/debug-config.rb +0 -26
- data/examples/simple/conf/live-config.rb +0 -26
- data/examples/simple/conf/requires.rb +0 -43
- data/examples/simple/ctl +0 -32
- data/examples/simple/env.rb +0 -32
- data/examples/simple/install.rb +0 -12
- data/examples/simple/lib/articles/entities.rb +0 -37
- data/examples/simple/lib/articles/lc-en.rb +0 -36
- data/examples/simple/lib/articles/methods.rb +0 -55
- data/examples/simple/lib/articles/part.rb +0 -57
- data/examples/simple/root/add-article.sx +0 -15
- data/examples/simple/root/article-form.ss +0 -20
- data/examples/simple/root/comments-form.ss +0 -16
- data/examples/simple/root/comments.si +0 -30
- data/examples/simple/root/index.sx +0 -44
- data/examples/simple/root/shader/shader.xsl +0 -100
- data/examples/simple/root/shader/style.css +0 -9
- data/examples/simple/root/view-article.sx +0 -29
- data/examples/tiny/conf/config.rb +0 -62
- data/examples/tiny/conf/requires.rb +0 -33
- data/examples/tiny/ctl +0 -16
- data/lib/n/parts.rb +0 -157
- data/lib/n/properties.rb +0 -199
- data/lib/n/server/dispatcher.rb +0 -55
- data/lib/n/server/handlers/code-handler.rb +0 -182
- data/lib/n/server/handlers/page-handler.rb +0 -612
- data/lib/n/server/webrick.rb +0 -283
- data/lib/n/shaders.rb +0 -166
- data/lib/n/sync/clc.rb +0 -110
- data/lib/n/sync/handler.rb +0 -229
- data/lib/n/sync/server.rb +0 -176
- data/lib/p/README +0 -1
data/lib/xsl/base.xsl
CHANGED
@@ -54,20 +54,20 @@ author: gmosx
|
|
54
54
|
<xsl:apply-templates/>
|
55
55
|
</xsl:template>
|
56
56
|
|
57
|
-
<!-- create a new, nested output buffer -->
|
57
|
+
<!-- create a new, nested output buffer NOT WORKING -->
|
58
58
|
<xsl:template name="x:ob-start" match="x:ob-start">
|
59
|
-
<
|
59
|
+
<ruby>
|
60
60
|
<![CDATA[__out_buffers = [] unless __out_buffers
|
61
61
|
__out_buffers.push(__out)
|
62
62
|
__out = ""]]>
|
63
|
-
</
|
63
|
+
</ruby>
|
64
64
|
</xsl:template>
|
65
65
|
|
66
|
-
<!-- close a nested output buffer -->
|
66
|
+
<!-- close a nested output buffer NOT WORKING -->
|
67
67
|
<xsl:template name="x:ob-end" match="x:ob-end">
|
68
|
-
<
|
68
|
+
<ruby>
|
69
69
|
<![CDATA[__out == __out_buffers.pop()]]>
|
70
|
-
</
|
70
|
+
</ruby>
|
71
71
|
</xsl:template>
|
72
72
|
|
73
73
|
<!-- NOT WORKING YET -->
|
@@ -79,103 +79,26 @@ author: gmosx
|
|
79
79
|
|
80
80
|
<!-- form errors temlate -->
|
81
81
|
<xsl:template name='x:form-errors' match='x:form-errors'>
|
82
|
-
<
|
83
|
-
|
84
|
-
|
85
|
-
end]]>
|
86
|
-
</xsl:processing-instruction>
|
82
|
+
<ruby>if errors = request.errors_to_a()</ruby>
|
83
|
+
<div class="errors"><b>ERRORS:</b><br />#{errors.join("<br />")}</div>
|
84
|
+
<ruby>end</ruby>
|
87
85
|
</xsl:template>
|
88
86
|
|
89
87
|
<xsl:template match='x:cell'>
|
90
88
|
<xsl:apply-templates/>
|
91
89
|
</xsl:template>
|
92
90
|
|
93
|
-
<!-- better use css :) -->
|
94
|
-
<xsl:template name="x:vblank" match="x:vblank">
|
95
|
-
<xsl:param name="height"><xsl:value-of select="@height"/></xsl:param>
|
96
|
-
<img src="d.gif" width="0" height="{$height}"/>
|
97
|
-
</xsl:template>
|
98
|
-
|
99
|
-
<xsl:template name="x:hblank" match="x:hblank">
|
100
|
-
<xsl:param name="width"><xsl:value-of select="@width"/></xsl:param>
|
101
|
-
<img src="d.gif" height="0" width="{$width}"/>
|
102
|
-
</xsl:template>
|
103
|
-
|
104
|
-
<!-- button links -->
|
105
|
-
|
106
|
-
<!--
|
107
|
-
ex:
|
108
|
-
<x:link class="m/delete.gif" title="Delete" href="r/glue/c/cmd.rb?oid=2" />
|
109
|
-
TODO: handle onclick too!
|
110
|
-
-->
|
111
|
-
<xsl:template match="x:link">
|
112
|
-
<xsl:param name="class"><xsl:value-of select="@class" /></xsl:param>
|
113
|
-
<xsl:param name="href"><xsl:value-of select="@href" /></xsl:param>
|
114
|
-
<xsl:param name="onclick"><xsl:value-of select="@onclick" /></xsl:param>
|
115
|
-
<a href="{$href}" class="{$class}">
|
116
|
-
<span><xsl:value-of select="@title" /></span>
|
117
|
-
<xsl:apply-templates />
|
118
|
-
</a>
|
119
|
-
</xsl:template>
|
120
|
-
|
121
|
-
<!--
|
122
|
-
ex:
|
123
|
-
<x:link class="m/delete.gif" title="Delete" onclick="javascript: alert('3')" />
|
124
|
-
-->
|
125
|
-
<xsl:template match="x:jslink">
|
126
|
-
<xsl:param name="class"><xsl:value-of select="@class"/></xsl:param>
|
127
|
-
<xsl:param name="onclick"><xsl:value-of select="@onclick"/></xsl:param>
|
128
|
-
<a href="#" onclick="{$onclick}" class="{$class}">
|
129
|
-
<span><xsl:value-of select="@title" /></span>
|
130
|
-
<xsl:apply-templates />
|
131
|
-
</a>
|
132
|
-
</xsl:template>
|
133
|
-
|
134
|
-
<!--
|
135
|
-
emit some extra divs to allow greater flexibility in css styling.
|
136
|
-
use those divs to add extra pictures and fancy stuff!
|
137
|
-
|
138
|
-
TODO:
|
139
|
-
find a better name.
|
140
|
-
-->
|
141
|
-
<xsl:template name="x:extra-divs" match="x:extra-divs">
|
142
|
-
<div id="extra0"><span></span></div>
|
143
|
-
<div id="extra1"><span></span></div>
|
144
|
-
<div id="extra2"><span></span></div>
|
145
|
-
<div id="extra3"><span></span></div>
|
146
|
-
<div id="extra4"><span></span></div>
|
147
|
-
<div id="extra5"><span></span></div>
|
148
|
-
<div id="extra6"><span></span></div>
|
149
|
-
<div id="extra7"><span></span></div>
|
150
|
-
</xsl:template>
|
151
|
-
|
152
91
|
<xsl:template match="x:clear" name="x:clear">
|
153
92
|
<div class="clear">.</div>
|
154
93
|
</xsl:template>
|
155
94
|
|
156
|
-
<!-- check for admin rights, gmosx: not really usefull I think -->
|
157
|
-
<xsl:template name='x:if-admin' match='x:if-admin'>
|
158
|
-
<xsl:processing-instruction name='ruby'>
|
159
|
-
<![CDATA[if admin]]>
|
160
|
-
</xsl:processing-instruction>
|
161
|
-
<xsl:apply-templates />
|
162
|
-
<xsl:processing-instruction name='ruby'>
|
163
|
-
<![CDATA[end]]>
|
164
|
-
</xsl:processing-instruction>
|
165
|
-
</xsl:template>
|
166
|
-
|
167
|
-
|
168
95
|
<!-- admin ui -->
|
169
96
|
<xsl:template name='x:admin-ui' match='x:admin-ui'>
|
170
|
-
<
|
171
|
-
<![CDATA[if admin]]>
|
172
|
-
</xsl:processing-instruction>
|
97
|
+
<ruby>if admin</ruby>
|
173
98
|
<span class="admin">
|
174
99
|
<xsl:apply-templates />
|
175
100
|
</span>
|
176
|
-
<
|
177
|
-
<![CDATA[end]]>
|
178
|
-
</xsl:processing-instruction>
|
101
|
+
<ruby>end</ruby>
|
179
102
|
</xsl:template>
|
180
103
|
|
181
104
|
<!-- transaction form -->
|
data/test/n/server/tc_cookie.rb
CHANGED
data/test/n/server/tc_filters.rb
CHANGED
data/test/n/server/tc_request.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
require "test/unit"
|
4
4
|
|
5
|
-
require "
|
5
|
+
require "nitro/logger"; $log = Logger.new(STDERR) unless $log
|
6
6
|
|
7
|
-
require "
|
8
|
-
require "
|
7
|
+
require "nitro/server/cookie"
|
8
|
+
require "nitro/server/request"
|
9
9
|
|
10
10
|
include N
|
11
11
|
|
data/test/n/server/tc_session.rb
CHANGED
data/test/n/tc_events.rb
CHANGED
data/test/n/tc_og.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require "test/unit"
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
3
|
+
require "nitro/logger"; $log = Logger.new(STDERR) unless $log
|
4
|
+
require "og"
|
5
5
|
|
6
6
|
module Test # :nodoc: all
|
7
7
|
|
8
8
|
# bug: creates a table that fucksup postgres if not
|
9
9
|
# correctly escaped.
|
10
10
|
class User
|
11
|
-
prop_accessor
|
11
|
+
prop_accessor :name, String
|
12
12
|
|
13
13
|
def initialize(name = nil)
|
14
14
|
@name = name
|
@@ -18,10 +18,10 @@ end
|
|
18
18
|
class Comment; end
|
19
19
|
|
20
20
|
class Article
|
21
|
-
|
22
|
-
prop_accessor
|
23
|
-
prop_accessor
|
24
|
-
|
21
|
+
prop_accessor :title, String
|
22
|
+
prop_accessor :body, String
|
23
|
+
prop_accessor :options, Hash
|
24
|
+
has_many :comments, Test::Comment
|
25
25
|
|
26
26
|
def initialize(title = nil, body = nil)
|
27
27
|
@title = title
|
@@ -43,10 +43,10 @@ class Article
|
|
43
43
|
end
|
44
44
|
|
45
45
|
class Comment
|
46
|
-
belongs_to Test::Article
|
47
|
-
belongs_to Test::User
|
48
|
-
prop_accessor
|
49
|
-
prop_accessor
|
46
|
+
belongs_to :article, Test::Article
|
47
|
+
belongs_to :author, Test::User
|
48
|
+
prop_accessor :body, String
|
49
|
+
prop_accessor :create_time, Time
|
50
50
|
|
51
51
|
def initialize(body = nil)
|
52
52
|
@create_time = Time.now
|
@@ -87,8 +87,8 @@ class TC_N_OG < Test::Unit::TestCase
|
|
87
87
|
}
|
88
88
|
end
|
89
89
|
|
90
|
-
|
91
|
-
$og =
|
90
|
+
Og::Database.drop_db!(config)
|
91
|
+
$og = Og::Database.new(config)
|
92
92
|
end
|
93
93
|
|
94
94
|
def teardown
|
@@ -102,8 +102,6 @@ class TC_N_OG < Test::Unit::TestCase
|
|
102
102
|
|
103
103
|
$og.get_connection()
|
104
104
|
|
105
|
-
$og.manage_classes(Article, Comment, User)
|
106
|
-
|
107
105
|
article = Article.new("Title", "Here comes the body")
|
108
106
|
$og << article
|
109
107
|
|
@@ -112,7 +110,7 @@ class TC_N_OG < Test::Unit::TestCase
|
|
112
110
|
|
113
111
|
$og.pupdate("body='Hello'", article)
|
114
112
|
|
115
|
-
article.
|
113
|
+
article.update_properties "body='Hello'"
|
116
114
|
|
117
115
|
another = Article[1]
|
118
116
|
assert_equal(1, another.oid)
|
@@ -133,9 +131,9 @@ class TC_N_OG < Test::Unit::TestCase
|
|
133
131
|
user = User.new("gmosx")
|
134
132
|
user.save!
|
135
133
|
|
136
|
-
|
134
|
+
user = User["gmosx"]
|
137
135
|
|
138
|
-
assert_equal("gmosx",
|
136
|
+
assert_equal("gmosx", user.name)
|
139
137
|
|
140
138
|
users1 = $og.select("name='gmosx' ORDER BY oid", User)
|
141
139
|
|
data/test/n/tc_properties.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
require "test/unit"
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "nitro/logger"; $log = Logger.new(STDERR) unless $log
|
4
4
|
|
5
|
-
require "
|
5
|
+
require "nitro/properties"
|
6
6
|
|
7
7
|
module Test # :nodoc: all
|
8
8
|
|
9
|
-
class
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
prop_accessor
|
14
|
-
prop_accessor
|
15
|
-
prop_accessor
|
9
|
+
class Msg
|
10
|
+
include Og::Unmanageable
|
11
|
+
|
12
|
+
prop Fixnum, :owner_oid
|
13
|
+
prop_accessor :val1, :val2, :val3, Fixnum, :sql => "smallint"
|
14
|
+
prop_accessor :title, :body, String
|
15
|
+
prop_accessor :test, String, :sql => "char(10) NOT NULL"
|
16
|
+
prop_accessor :count, Fixnum
|
17
|
+
prop_accessor :create_time, Time
|
16
18
|
|
17
19
|
# a marshaled property
|
18
20
|
prop_accessor Array, :options
|
@@ -24,16 +26,19 @@ class Message
|
|
24
26
|
|
25
27
|
end
|
26
28
|
|
27
|
-
class
|
29
|
+
class SubMsg < Msg
|
30
|
+
# to avoid conflicts with tc_og.rb
|
31
|
+
include Og::Unmanageable
|
32
|
+
|
28
33
|
inherit_meta(superclass)
|
29
|
-
# duplicate definition
|
30
|
-
prop_accessor
|
34
|
+
# duplicate definition with different type!
|
35
|
+
prop_accessor :count, Float
|
31
36
|
end
|
32
37
|
|
33
38
|
class TC_N_Properties < Test::Unit::TestCase
|
34
39
|
|
35
40
|
def setup
|
36
|
-
@msg1 =
|
41
|
+
@msg1 = Msg.new
|
37
42
|
end
|
38
43
|
|
39
44
|
def teardown
|
@@ -42,15 +47,14 @@ class TC_N_Properties < Test::Unit::TestCase
|
|
42
47
|
|
43
48
|
def test_props
|
44
49
|
|
45
|
-
|
46
50
|
# bug: props for subclasses.
|
47
51
|
|
48
|
-
assert(
|
49
|
-
assert_equal(
|
52
|
+
assert(SubMsg.__props)
|
53
|
+
assert_equal(Msg.__props.size(), SubMsg.__props.size())
|
50
54
|
|
51
55
|
# bug: duplicate definition
|
52
|
-
|
53
|
-
assert_equal(Float,
|
56
|
+
|
57
|
+
assert_equal(Float, SubMsg.__props.find { |p| :count == p.symbol }.klass)
|
54
58
|
|
55
59
|
# dont force conversion
|
56
60
|
|
data/test/n/tc_sitemap.rb
CHANGED
data/test/n/ui/tc_pager.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
require "test/unit"
|
4
4
|
|
5
|
-
require "
|
5
|
+
require "nitro/logger"; $log = Logger.new(STDERR) unless $log
|
6
6
|
|
7
|
-
require "
|
8
|
-
require "
|
7
|
+
require "og"
|
8
|
+
require "nitro/ui/pager"
|
9
9
|
|
10
10
|
class RequestMock < Hash
|
11
11
|
def get(k, default)
|
@@ -17,7 +17,7 @@ class TC_N_UI_Pager < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
def setup
|
19
19
|
=begin
|
20
|
-
$og =
|
20
|
+
$og = Og::Database.new(
|
21
21
|
:addres => "localhost",
|
22
22
|
:database => "testdb",
|
23
23
|
:user => "root",
|
data/test/n/utils/tc_cache.rb
CHANGED
data/test/n/utils/tc_hash.rb
CHANGED
data/test/n/utils/tc_html.rb
CHANGED
data/test/n/utils/tc_http.rb
CHANGED
data/test/n/utils/tc_number.rb
CHANGED
data/test/n/utils/tc_strings.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# :nodoc: all
|
2
2
|
|
3
3
|
require "test/unit"
|
4
|
-
require "
|
4
|
+
require "nitro/utils/string"
|
5
5
|
|
6
6
|
class TC_StringUtilsUtils < Test::Unit::TestCase
|
7
7
|
# :nodoc: all
|
@@ -77,45 +77,6 @@ class TC_StringUtilsUtils < Test::Unit::TestCase
|
|
77
77
|
assert_equal("", StringUtils::wrap("", 4, " "))
|
78
78
|
assert_equal(nil, StringUtils::wrap(nil, 4, " "))
|
79
79
|
end
|
80
|
-
|
81
|
-
def test_extension_from_path
|
82
|
-
assert_equal(nil, StringUtils.extension_from_path(nil))
|
83
|
-
assert_equal(nil, StringUtils.extension_from_path("this is a dymy text!"))
|
84
|
-
assert_equal("gif", StringUtils.extension_from_path("gmosx.gif"))
|
85
|
-
assert_equal("gif", StringUtils.extension_from_path("/n/images/gmosx.gif"))
|
86
|
-
assert_equal(nil, StringUtils.extension_from_path("/n/images/gmosx."))
|
87
|
-
assert_equal("rx", StringUtils.extension_from_path("/n/images/gmosx.gif.rx"))
|
88
|
-
assert_equal("rx", StringUtils.extension_from_path("*parts/polls/poll-box.rx"))
|
89
|
-
assert_equal("rx", StringUtils.extension_from_path("../n1/web/parts/polls/poll-box.rx"))
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_filename_from_path
|
93
|
-
assert_equal("gmosx", StringUtils.filename_from_path("gmosx.gif"))
|
94
|
-
filename = StringUtils.filename_from_path("/n/images/gmosx.gif")
|
95
|
-
assert_equal("/n/images/gmosx", filename)
|
96
|
-
filename = StringUtils.filename_from_path(nil)
|
97
|
-
assert_equal("", filename)
|
98
|
-
filename = StringUtils.filename_from_path("/n/images/gmosx")
|
99
|
-
assert_equal("/n/images/gmosx", filename)
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_file_from_path
|
103
|
-
file = StringUtils.file_from_path("/n/images/gmosx.gif")
|
104
|
-
assert_equal("gmosx.gif", file)
|
105
|
-
file = StringUtils.file_from_path(nil)
|
106
|
-
assert_equal("", file)
|
107
|
-
file = StringUtils.file_from_path("/n/images/gmosx")
|
108
|
-
assert_equal("gmosx", file)
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_directory_from_path
|
112
|
-
directory = StringUtils.directory_from_path("/n/images/gmosx.gif")
|
113
|
-
assert_equal("/n/images", directory)
|
114
|
-
directory = StringUtils.directory_from_path(nil)
|
115
|
-
assert_equal("", directory)
|
116
|
-
directory = StringUtils.directory_from_path("/n/images/gmosx")
|
117
|
-
assert_equal("/n/images", directory)
|
118
|
-
end
|
119
80
|
|
120
81
|
def test_rationalize_filename
|
121
82
|
filename = StringUtils.rationalize_filename("hello my friend!.gif")
|
@@ -137,12 +98,6 @@ class TC_StringUtilsUtils < Test::Unit::TestCase
|
|
137
98
|
assert(s1.size == s2.size)
|
138
99
|
end
|
139
100
|
|
140
|
-
def test_unicode_to_iso88597
|
141
|
-
# check that dup works.
|
142
|
-
s = "Original"
|
143
|
-
assert_equal("Original", StringUtils.unicode_to_iso88597(s))
|
144
|
-
end
|
145
|
-
|
146
101
|
def teardown
|
147
102
|
@s = nil
|
148
103
|
end
|