rogdl 0.2.2 → 0.2.3
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/lib/string.rb +12 -5
- data/test/test_string.rb +27 -3
- metadata +2 -2
data/lib/string.rb
CHANGED
@@ -10,11 +10,19 @@ class String
|
|
10
10
|
str = String.new(self)
|
11
11
|
|
12
12
|
str.downcase!
|
13
|
-
|
14
|
-
str.gsub!(
|
13
|
+
|
14
|
+
str.gsub!(/-/,'_')
|
15
|
+
str.gsub!(/ /,'_')
|
16
|
+
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
empties = %w{! @ # $ % ^ & * ( ) , < . > ; : ' " / ? [ { ] } = + \\ |}
|
19
|
+
empties.each do |empty|
|
20
|
+
r = Regexp.new('\\'+empty)
|
21
|
+
str.gsub!(r, '')
|
22
|
+
end
|
23
|
+
|
24
|
+
str.gsub!(/[^a-zA-Z0-9_\- ]/,'_')
|
25
|
+
str = '_' + str.split.join('_')
|
18
26
|
str.gsub!(/_(.)/) { $1.upcase }
|
19
27
|
|
20
28
|
return str
|
@@ -25,7 +33,6 @@ class String
|
|
25
33
|
|
26
34
|
|
27
35
|
def pluralize
|
28
|
-
# TODO: replace with call to Inflector.pluralize
|
29
36
|
return self + 's' if self[length-1, length] != 's'
|
30
37
|
return self + 'es' if self[length-1, length] == 's'
|
31
38
|
end
|
data/test/test_string.rb
CHANGED
@@ -17,14 +17,38 @@ class TestString < Test::Unit::TestCase
|
|
17
17
|
assert_equal 'someText1', 'some_text_1'.camel_case
|
18
18
|
assert_equal 'someText1', 'some-text-1'.camel_case
|
19
19
|
|
20
|
-
assert_equal 'ldap', 'LDAP'.camel_case
|
21
|
-
assert_equal 'ldapName', 'LDAP Name'.camel_case
|
22
|
-
|
23
20
|
s = 'some text'
|
24
21
|
s.camel_case
|
25
22
|
assert_equal 'some text', s
|
26
23
|
end
|
24
|
+
|
25
|
+
def test_camel_case_ldap
|
26
|
+
assert_equal 'ldap', 'LDAP'.camel_case
|
27
|
+
assert_equal 'ldapName', 'LDAP Name'.camel_case
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_camel_case_parens
|
31
|
+
assert_equal 'termToMaturityInYears', 'Term to Maturity (in years)'.camel_case
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_camel_case_special
|
35
|
+
specials = %w{! @ # $ % ^ & * ( ) , < . > ; : ' " / ? [ { ] } = + \\ |}
|
36
|
+
specials.each do |special|
|
37
|
+
s = special + 'hi' + special + 'bye' + special
|
38
|
+
assert_equal 'hibye', s.camel_case
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
27
42
|
|
43
|
+
def test camel_case_empty
|
44
|
+
assert_equal '', ''
|
45
|
+
end
|
46
|
+
|
47
|
+
def test camel_case_space
|
48
|
+
assert_equal '', ' '
|
49
|
+
assert_equal '', ' '
|
50
|
+
end
|
51
|
+
|
28
52
|
def test_alias
|
29
53
|
assert_equal 'someText', 'Some Text'.cc
|
30
54
|
assert_equal 'SomeText', 'Some Text'.ucc
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rogdl
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2007-08-
|
6
|
+
version: 0.2.3
|
7
|
+
date: 2007-08-30 00:00:00 -05:00
|
8
8
|
summary: Rogdl is a package for parsing OGDL files.
|
9
9
|
require_paths:
|
10
10
|
- lib
|