couchup 0.0.6 → 0.0.7
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/couchup/extensions/string.rb +19 -0
- data/lib/couchup/extensions/symbol.rb +10 -16
- data/lib/couchup/version.rb +1 -1
- metadata +1 -1
@@ -2,4 +2,23 @@ class String
|
|
2
2
|
def blank?
|
3
3
|
nil || empty?
|
4
4
|
end
|
5
|
+
|
6
|
+
def constantize
|
7
|
+
Object.const_get(self)
|
8
|
+
end
|
9
|
+
|
10
|
+
def camelize
|
11
|
+
gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
12
|
+
end
|
13
|
+
# cargo culted from rails inflector.
|
14
|
+
def underscore
|
15
|
+
word = dup
|
16
|
+
word.gsub!(/::/, '/')
|
17
|
+
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
18
|
+
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
19
|
+
word.tr!("-", "_")
|
20
|
+
word.downcase!
|
21
|
+
word
|
22
|
+
end
|
23
|
+
|
5
24
|
end
|
@@ -1,19 +1,13 @@
|
|
1
1
|
class Symbol
|
2
2
|
def constantize
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
14
|
-
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
15
|
-
word.tr!("-", "_")
|
16
|
-
word.downcase!
|
17
|
-
word
|
18
|
-
end
|
3
|
+
to_s.constantize
|
4
|
+
end
|
5
|
+
|
6
|
+
def camelize
|
7
|
+
to_s.camelize
|
8
|
+
end
|
9
|
+
# cargo culted from rails inflector.
|
10
|
+
def underscore
|
11
|
+
to_s.underscore
|
12
|
+
end
|
19
13
|
end
|
data/lib/couchup/version.rb
CHANGED