rogdl 0.1.3 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/string.rb +6 -4
  2. data/test/test_string.rb +15 -0
  3. metadata +2 -2
data/lib/string.rb CHANGED
@@ -7,17 +7,19 @@ class String
7
7
 
8
8
  def upper_camel_case
9
9
  str = self
10
- str.gsub!(/[^a-zA-Z_\- ]/," ")
11
- str = " " + str.split.join(" ")
12
- str.gsub!(/ (.)/) { $1.upcase }
13
10
 
14
- str.gsub!(/[^a-zA-Z_\- ]/,"_")
11
+ str.gsub!(/-/,"_")
12
+ str.gsub!(/ /,"_")
13
+ str.gsub!(/[^a-zA-Z0-9_\- ]/,"_")
15
14
  str = "_" + str.split.join("_")
16
15
  str.gsub!(/_(.)/) { $1.upcase }
17
16
 
18
17
  return str
18
+
19
19
  end
20
20
 
21
+
22
+
21
23
  def pluralize
22
24
  # TODO: replace with call to Inflector.pluralize
23
25
  return self + 's' if self[length-1, length] != 's'
data/test/test_string.rb CHANGED
@@ -6,14 +6,29 @@ class TestString < Test::Unit::TestCase
6
6
  include Rogdl
7
7
 
8
8
  def test_camel_case
9
+ assert_equal 'someText', 'Some Text'.camel_case
10
+ assert_equal 'someText', 'Some text'.camel_case
11
+
9
12
  assert_equal 'someText', 'some text'.camel_case
10
13
  assert_equal 'someText', 'some_text'.camel_case
14
+ assert_equal 'someText', 'some-text'.camel_case
15
+
16
+ assert_equal 'someText1', 'some text 1'.camel_case
17
+ assert_equal 'someText1', 'some_text_1'.camel_case
18
+ assert_equal 'someText1', 'some-text-1'.camel_case
11
19
  end
12
20
 
13
21
  def test_upper_camel_case
14
22
  assert_equal 'SomeText', 'some text'.upper_camel_case
15
23
  assert_equal 'SomeText', 'some_text'.upper_camel_case
24
+ assert_equal 'SomeText', 'some-text'.upper_camel_case
25
+
26
+ assert_equal 'SomeText1', 'some text 1'.upper_camel_case
27
+ assert_equal 'SomeText1', 'some_text_1'.upper_camel_case
28
+ assert_equal 'SomeText1', 'some-text-1'.upper_camel_case
16
29
  end
30
+
31
+
17
32
 
18
33
  def test_pluralize
19
34
  assert_equal 'dogs', 'dog'.pluralize
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.1.3
7
- date: 2007-08-21 00:00:00 -05:00
6
+ version: 0.1.6
7
+ date: 2007-08-22 00:00:00 -05:00
8
8
  summary: Rogdl is a package for parsing OGDL files.
9
9
  require_paths:
10
10
  - lib