rogdl 0.1.7 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/node.rb +1 -0
- data/lib/string.rb +5 -1
- data/test/test_node.rb +11 -0
- data/test/test_string.rb +12 -0
- metadata +1 -1
data/lib/node.rb
CHANGED
data/lib/string.rb
CHANGED
@@ -4,12 +4,15 @@ class String
|
|
4
4
|
str = upper_camel_case
|
5
5
|
return str[0,1].downcase + str[1, str.length]
|
6
6
|
end
|
7
|
+
alias cc camel_case
|
7
8
|
|
8
9
|
def upper_camel_case
|
9
10
|
str = self
|
10
|
-
|
11
|
+
|
12
|
+
str.downcase!
|
11
13
|
str.gsub!(/-/,"_")
|
12
14
|
str.gsub!(/ /,"_")
|
15
|
+
|
13
16
|
str.gsub!(/[^a-zA-Z0-9_\- ]/,"_")
|
14
17
|
str = "_" + str.split.join("_")
|
15
18
|
str.gsub!(/_(.)/) { $1.upcase }
|
@@ -17,6 +20,7 @@ class String
|
|
17
20
|
return str
|
18
21
|
|
19
22
|
end
|
23
|
+
alias ucc upper_camel_case
|
20
24
|
|
21
25
|
|
22
26
|
|
data/test/test_node.rb
CHANGED
@@ -138,6 +138,10 @@ class TestNode < Test::Unit::TestCase
|
|
138
138
|
|
139
139
|
parent.add Node.new("sibling")
|
140
140
|
assert_equal "child", parent.gvalue
|
141
|
+
|
142
|
+
parent.sibling.add('Hello World')
|
143
|
+
assert_equal 'Hello World', "#{parent.sibling.gvalue}"
|
144
|
+
|
141
145
|
end
|
142
146
|
|
143
147
|
def test_gval
|
@@ -257,6 +261,13 @@ class TestNode < Test::Unit::TestCase
|
|
257
261
|
|
258
262
|
end
|
259
263
|
|
264
|
+
def test_gpar
|
265
|
+
a = Node.new('a')
|
266
|
+
|
267
|
+
# gpar is alias for gparent
|
268
|
+
assert_equal nil, a.gpar
|
269
|
+
|
270
|
+
end
|
260
271
|
|
261
272
|
|
262
273
|
|
data/test/test_string.rb
CHANGED
@@ -16,7 +16,16 @@ class TestString < Test::Unit::TestCase
|
|
16
16
|
assert_equal 'someText1', 'some text 1'.camel_case
|
17
17
|
assert_equal 'someText1', 'some_text_1'.camel_case
|
18
18
|
assert_equal 'someText1', 'some-text-1'.camel_case
|
19
|
+
|
20
|
+
assert_equal 'ldap', 'LDAP'.camel_case
|
21
|
+
assert_equal 'ldapName', 'LDAP Name'.camel_case
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_alias
|
25
|
+
assert_equal 'someText', 'Some Text'.cc
|
26
|
+
assert_equal 'SomeText', 'Some Text'.ucc
|
19
27
|
end
|
28
|
+
|
20
29
|
|
21
30
|
def test_upper_camel_case
|
22
31
|
assert_equal 'SomeText', 'some text'.upper_camel_case
|
@@ -26,6 +35,9 @@ class TestString < Test::Unit::TestCase
|
|
26
35
|
assert_equal 'SomeText1', 'some text 1'.upper_camel_case
|
27
36
|
assert_equal 'SomeText1', 'some_text_1'.upper_camel_case
|
28
37
|
assert_equal 'SomeText1', 'some-text-1'.upper_camel_case
|
38
|
+
|
39
|
+
assert_equal 'Ldap', 'LDAP'.upper_camel_case
|
40
|
+
assert_equal 'LdapName', 'LDAP Name'.upper_camel_case
|
29
41
|
end
|
30
42
|
|
31
43
|
|