fast_parameterize 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f2ea6fd1830774b3e605fc7d7edcc5d3fb946c125992b61367c900b979cf4ac
4
- data.tar.gz: 98d7e79bd0c62d33332a24d45eafb724fea935a99761b56697155bb345e6f83d
3
+ metadata.gz: e0354d6761a3991f65512cbdb7864417a0f13d2be2052ce442bdd422ab139f8f
4
+ data.tar.gz: 807e7a340d4f014b2ee8077a868091787ae95a0e05b5a41841e6560e76507820
5
5
  SHA512:
6
- metadata.gz: ee18b8d230eae73b416ce9fab9d5090e12891bdc28fb11e0e64a90eccf79d6d621d68bdafa0046a22ff301c9e811f8acfaf65c7d3c6cc70a66f783e1dd74df99
7
- data.tar.gz: c2555d0f44e75257a91b87303d31765ec103fee7c55c780a5c98f3dc9bc63945d15c29001d272a78aa96ae6d3489a289da721450e41a8efe0b587ce524813bc2
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.0)
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.15.0.2)
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.0.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.4)
42
- rubocop (1.12.0)
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.42.0)
58
+ steep (0.43.1)
61
59
  activesupport (>= 5.1)
62
- ast_utils (>= 0.4.0)
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 (2.0.0)
71
+ unicode-display_width (1.7.0)
72
72
  zeitwerk (2.4.2)
73
73
 
74
74
  PLATFORMS
data/Steepfile CHANGED
@@ -1,5 +1,6 @@
1
- target :lib do
2
- signature "sig"
1
+ # frozen_string_literal: true
3
2
 
4
- check "lib"
3
+ target :lib do
4
+ signature 'sig'
5
+ check 'lib'
5
6
  end
@@ -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 equivalent to the characters that are allowed to be part of
38
- // the output string as opposed to the ones that get replaced by the separator.
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(*caser)(int) = options[1] == Qtrue ? tosame : tolower;
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++] = caser(character);
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++] = caser(character);
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++] = caser(character);
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
- // FastUnderscore::parameterize
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;
@@ -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.extend(ActiveSupportInflectorPatch)
49
- String.include(ActiveSupportStringPatch)
48
+ ActiveSupport::Inflector.prepend(ActiveSupportInflectorPatch)
49
+ String.prepend(ActiveSupportStringPatch)
50
50
  end
51
51
  end
52
52
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastParameterize
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_parameterize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Deisz