fast_camelize 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/ext/fast_camelize/fast_camelize.c +1 -1
- data/lib/fast_camelize.rb +21 -0
- data/lib/fast_camelize/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2c8b7e5c206059c52331f7a44759865759ff1f28fe4ad53de359af473e44133
|
4
|
+
data.tar.gz: b124786ba169d38ac73f2fdb8a4dc91119ff000b91de1fd1defdb63fc6a44444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fb8679402babf736efed793213bbbdcbe89771788848e6b6a52285783d05c4b54c3f9b82dab9c0e7a5fdf001f5a87c84c51f7fc428619fbbe4cbb77fb66f058
|
7
|
+
data.tar.gz: b28d9ad3d8b4beeebdea450345594b6e8ae9979b56fbb5123bb938f41fe752b48f01e7fa80c815143c95277e55dcfb8d0994f418cd34e9616b3f5e7f511ff09f
|
data/Gemfile.lock
CHANGED
@@ -159,7 +159,7 @@ static VALUE camelize(VALUE string, VALUE kwargs) {
|
|
159
159
|
// If we're in the DEFAULT or SEGBODY state, then we need to flush out the
|
160
160
|
// remaining segment.
|
161
161
|
if ((state == STATE_SEGBODY || state == STATE_DEFAULT) && segment_size > 0) {
|
162
|
-
copy_segment(result, &result_size, segment, &segment_size, acronyms,
|
162
|
+
copy_segment(result, &result_size, segment, &segment_size, acronyms, state == STATE_SEGBODY);
|
163
163
|
}
|
164
164
|
|
165
165
|
return rb_enc_str_new(result, result_size, encoding);
|
data/lib/fast_camelize.rb
CHANGED
@@ -32,6 +32,26 @@ module FastCamelize
|
|
32
32
|
# rubocop:disable all
|
33
33
|
end
|
34
34
|
|
35
|
+
# Override String#camelize if we need to get back to the original behavior
|
36
|
+
# that fast_camelize overroad.
|
37
|
+
module ActiveSupportStringPatch
|
38
|
+
def camelize(first_letter = :upper)
|
39
|
+
case first_letter
|
40
|
+
when :upper
|
41
|
+
ActiveSupport::Inflector.camelize(self, true)
|
42
|
+
when :lower
|
43
|
+
ActiveSupport::Inflector.camelize(self, false)
|
44
|
+
else
|
45
|
+
# Skipping here because Steep doesn't understand that this is going to
|
46
|
+
# be included into a class that has Kernel included.
|
47
|
+
__skip__ =
|
48
|
+
begin
|
49
|
+
raise ArgumentError, 'Invalid option, use either :upper or :lower.'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
35
55
|
# Override ActiveSupport::Inflector::method_added so that if and when the
|
36
56
|
# camelize method gets defined, we can immediately redefine it.
|
37
57
|
module ActiveSupportDelayedPatch
|
@@ -45,6 +65,7 @@ module FastCamelize
|
|
45
65
|
def self.active_support
|
46
66
|
ActiveSupport::Inflector.alias_method(:as_camelize, :camelize)
|
47
67
|
ActiveSupport::Inflector.include(ActiveSupportInflectorPatch)
|
68
|
+
String.include(ActiveSupportStringPatch)
|
48
69
|
end
|
49
70
|
end
|
50
71
|
|