better_struct 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/better_struct.rb +4 -4
- data/lib/better_struct/version.rb +1 -1
- data/test/better_struct_test.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 006098f63de80140f1925efccb3c7ee6fe3c6b8b
|
4
|
+
data.tar.gz: edcd040ce1895c46e517a7cbcc15054c2097fa32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e23162469cfd0a28d775c3ca523792e5752d121b77f7661b38c9f4d0763e27daf83f3bbbddc46a81c23c862862deb0791f6f3f560748adc31449d015bea3ee60
|
7
|
+
data.tar.gz: c989dfbee079dc0ebc22ca59691cb9c4f86eb6afdb24bb3c71136afd88e2314f0cc9463b423928f2924338e778e50adfaa65d9ad621e7670edbaff51671a7542
|
data/lib/better_struct.rb
CHANGED
@@ -39,13 +39,13 @@ private
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def underscore(
|
43
|
-
return
|
42
|
+
def underscore(word)
|
43
|
+
return word.to_s if word.to_s =~ /\A[a-z0-9_]+\z/
|
44
44
|
|
45
|
-
word =
|
45
|
+
word = word.to_s.gsub(/\W+/, '_')
|
46
|
+
word.gsub!(/\A[_]+|[_]+\z/, '')
|
46
47
|
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
|
47
48
|
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
48
|
-
word.tr!("- ", "_")
|
49
49
|
word.downcase!
|
50
50
|
word
|
51
51
|
end
|
data/test/better_struct_test.rb
CHANGED