fast_parameterize 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -11
- data/Steepfile +4 -3
- data/ext/fast_parameterize/fast_parameterize.c +8 -9
- data/lib/fast_parameterize.rb +2 -2
- data/lib/fast_parameterize/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: e0354d6761a3991f65512cbdb7864417a0f13d2be2052ce442bdd422ab139f8f
|
4
|
+
data.tar.gz: 807e7a340d4f014b2ee8077a868091787ae95a0e05b5a41841e6560e76507820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af3132d1ab42898b4780658a48e2eea26736aa1f97177d1e725717c1850b9529c6dc5eb84f80da199dae0f31b2b4496bfaecc675f5d7c288a68017ba7d2d39bd
|
7
|
+
data.tar.gz: 68b38f23f0a907121176a211656e9aa062a15c35855b6a4ae4fa9c9d3c2d779e4ffb3d06075dbf43875d2d1ef2abf9414530fa3635a1e622d815f684a5184753
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fast_parameterize (0.1.
|
4
|
+
fast_parameterize (0.1.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -13,21 +13,19 @@ GEM
|
|
13
13
|
tzinfo (~> 2.0)
|
14
14
|
zeitwerk (~> 2.3)
|
15
15
|
ast (2.4.2)
|
16
|
-
ast_utils (0.4.0)
|
17
|
-
parser (>= 2.7.0)
|
18
16
|
benchmark-ips (2.8.4)
|
19
17
|
concurrent-ruby (1.1.8)
|
20
18
|
docile (1.3.5)
|
21
19
|
ffi (1.15.0)
|
22
20
|
i18n (1.8.10)
|
23
21
|
concurrent-ruby (~> 1.0)
|
24
|
-
language_server-protocol (3.
|
22
|
+
language_server-protocol (3.16.0.0)
|
25
23
|
listen (3.5.1)
|
26
24
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
27
25
|
rb-inotify (~> 0.9, >= 0.9.10)
|
28
26
|
minitest (5.14.4)
|
29
27
|
parallel (1.20.1)
|
30
|
-
parser (3.0.
|
28
|
+
parser (3.0.1.0)
|
31
29
|
ast (~> 2.4.1)
|
32
30
|
rainbow (3.0.0)
|
33
31
|
rake (13.0.3)
|
@@ -38,8 +36,8 @@ GEM
|
|
38
36
|
ffi (~> 1.0)
|
39
37
|
rbs (1.1.1)
|
40
38
|
regexp_parser (2.1.1)
|
41
|
-
rexml (3.2.
|
42
|
-
rubocop (1.12.
|
39
|
+
rexml (3.2.5)
|
40
|
+
rubocop (1.12.1)
|
43
41
|
parallel (~> 1.10)
|
44
42
|
parser (>= 3.0.0.0)
|
45
43
|
rainbow (>= 2.2.2, < 4.0)
|
@@ -57,18 +55,20 @@ GEM
|
|
57
55
|
simplecov_json_formatter (~> 0.1)
|
58
56
|
simplecov-html (0.12.3)
|
59
57
|
simplecov_json_formatter (0.1.2)
|
60
|
-
steep (0.
|
58
|
+
steep (0.43.1)
|
61
59
|
activesupport (>= 5.1)
|
62
|
-
|
63
|
-
language_server-protocol (~> 3.15.0.1)
|
60
|
+
language_server-protocol (>= 3.15, < 4.0)
|
64
61
|
listen (~> 3.0)
|
65
62
|
parallel (>= 1.0.0)
|
66
63
|
parser (>= 2.7)
|
67
64
|
rainbow (>= 2.2.2, < 4.0)
|
68
65
|
rbs (~> 1.1.0)
|
66
|
+
terminal-table (>= 2, < 4)
|
67
|
+
terminal-table (3.0.0)
|
68
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
69
69
|
tzinfo (2.0.4)
|
70
70
|
concurrent-ruby (~> 1.0)
|
71
|
-
unicode-display_width (
|
71
|
+
unicode-display_width (1.7.0)
|
72
72
|
zeitwerk (2.4.2)
|
73
73
|
|
74
74
|
PLATFORMS
|
data/Steepfile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#include <ctype.h>
|
1
2
|
#include <ruby.h>
|
2
3
|
#include <ruby/encoding.h>
|
3
4
|
|
@@ -34,8 +35,8 @@ enum state {
|
|
34
35
|
STATE_SEP
|
35
36
|
};
|
36
37
|
|
37
|
-
// This is used to
|
38
|
-
//
|
38
|
+
// This is used to tell if the given character is allowed to be part of the
|
39
|
+
// output string as opposed to being replaced by the separator.
|
39
40
|
static inline int ischar(int character) {
|
40
41
|
return (
|
41
42
|
(character >= 'a' && character <= 'z') ||
|
@@ -63,7 +64,7 @@ static VALUE parameterize(VALUE string, VALUE kwargs) {
|
|
63
64
|
// Configure the options based on the inputted keyword arguments
|
64
65
|
const char *separator = options[0] == Qundef ? "-" : StringValueCStr(options[0]);
|
65
66
|
size_t separator_size = strlen(separator);
|
66
|
-
int(*
|
67
|
+
int(*tocase)(int) = options[1] == Qtrue ? tosame : tolower;
|
67
68
|
|
68
69
|
// Set the initial state and build a buffer for the resulting string
|
69
70
|
enum state state = STATE_START;
|
@@ -86,13 +87,13 @@ static VALUE parameterize(VALUE string, VALUE kwargs) {
|
|
86
87
|
switch (state) {
|
87
88
|
case STATE_START:
|
88
89
|
if (ischar(character)) {
|
89
|
-
result[size++] =
|
90
|
+
result[size++] = tocase(character);
|
90
91
|
state = STATE_CHAR;
|
91
92
|
}
|
92
93
|
break;
|
93
94
|
case STATE_CHAR:
|
94
95
|
if (ischar(character)) {
|
95
|
-
result[size++] =
|
96
|
+
result[size++] = tocase(character);
|
96
97
|
} else {
|
97
98
|
state = STATE_SEP;
|
98
99
|
}
|
@@ -102,10 +103,8 @@ static VALUE parameterize(VALUE string, VALUE kwargs) {
|
|
102
103
|
strncpy(result + size, separator, separator_size);
|
103
104
|
size += separator_size;
|
104
105
|
|
105
|
-
result[size++] =
|
106
|
+
result[size++] = tocase(character);
|
106
107
|
state = STATE_CHAR;
|
107
|
-
} else {
|
108
|
-
state = STATE_SEP;
|
109
108
|
}
|
110
109
|
break;
|
111
110
|
}
|
@@ -114,7 +113,7 @@ static VALUE parameterize(VALUE string, VALUE kwargs) {
|
|
114
113
|
return rb_enc_str_new(result, size, encoding);
|
115
114
|
}
|
116
115
|
|
117
|
-
//
|
116
|
+
// FastParameterize::parameterize
|
118
117
|
static VALUE fast_parameterize(int argc, VALUE* argv, VALUE self) {
|
119
118
|
VALUE string = Qnil;
|
120
119
|
VALUE kwargs = Qnil;
|
data/lib/fast_parameterize.rb
CHANGED
@@ -45,8 +45,8 @@ module FastParameterize
|
|
45
45
|
# FastParameterize.
|
46
46
|
def self.active_support
|
47
47
|
ActiveSupport::Inflector.alias_method(:as_parameterize, :parameterize)
|
48
|
-
ActiveSupport::Inflector.
|
49
|
-
String.
|
48
|
+
ActiveSupport::Inflector.prepend(ActiveSupportInflectorPatch)
|
49
|
+
String.prepend(ActiveSupportStringPatch)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|