fast_underscore 0.2.0 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/main.yml +44 -0
- data/.rubocop.yml +21 -5
- data/CHANGELOG.md +51 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +57 -30
- data/{LICENSE.txt → LICENSE} +1 -1
- data/README.md +16 -37
- data/Steepfile +6 -0
- data/bin/{benchmark → bench} +1 -0
- data/bin/console +1 -0
- data/ext/fast_underscore/fast_underscore.c +132 -191
- data/fast_underscore.gemspec +21 -11
- data/gemfiles/5.1.gemfile +1 -1
- data/gemfiles/5.2.gemfile +1 -1
- data/gemfiles/6.0.gemfile +7 -0
- data/gemfiles/6.1.gemfile +7 -0
- data/lib/fast_underscore/version.rb +1 -1
- data/lib/fast_underscore.rb +73 -16
- data/sig/fast_underscore.rbs +10 -0
- metadata +44 -25
- data/.travis.yml +0 -9
- data/bin/rake +0 -29
- data/bin/rubocop +0 -29
- data/lib/fast_underscore/ext/acronym_regex.rb +0 -28
- data/lib/fast_underscore/ext/acronym_underscore_regex.rb +0 -23
- data/lib/fast_underscore/ext/plain_string.rb +0 -13
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_underscore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Kevin
|
8
|
-
autorequire:
|
7
|
+
- Kevin Newton
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake-compiler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,34 +86,50 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1.12'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '1.12'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: steep
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Provides a C-optimized method for underscoring a string
|
98
112
|
email:
|
99
|
-
-
|
113
|
+
- kddnewton@gmail.com
|
100
114
|
executables: []
|
101
115
|
extensions:
|
102
116
|
- ext/fast_underscore/extconf.rb
|
103
117
|
extra_rdoc_files: []
|
104
118
|
files:
|
119
|
+
- ".github/dependabot.yml"
|
120
|
+
- ".github/workflows/main.yml"
|
105
121
|
- ".gitignore"
|
106
122
|
- ".rubocop.yml"
|
107
|
-
-
|
123
|
+
- CHANGELOG.md
|
124
|
+
- CODE_OF_CONDUCT.md
|
108
125
|
- Gemfile
|
109
126
|
- Gemfile.lock
|
110
|
-
- LICENSE
|
127
|
+
- LICENSE
|
111
128
|
- README.md
|
112
129
|
- Rakefile
|
113
|
-
-
|
130
|
+
- Steepfile
|
131
|
+
- bin/bench
|
114
132
|
- bin/console
|
115
|
-
- bin/rake
|
116
|
-
- bin/rubocop
|
117
133
|
- bin/setup
|
118
134
|
- ext/fast_underscore/extconf.rb
|
119
135
|
- ext/fast_underscore/fast_underscore.c
|
@@ -121,16 +137,20 @@ files:
|
|
121
137
|
- fast_underscore.gemspec
|
122
138
|
- gemfiles/5.1.gemfile
|
123
139
|
- gemfiles/5.2.gemfile
|
140
|
+
- gemfiles/6.0.gemfile
|
141
|
+
- gemfiles/6.1.gemfile
|
124
142
|
- lib/fast_underscore.rb
|
125
|
-
- lib/fast_underscore/ext/acronym_regex.rb
|
126
|
-
- lib/fast_underscore/ext/acronym_underscore_regex.rb
|
127
|
-
- lib/fast_underscore/ext/plain_string.rb
|
128
143
|
- lib/fast_underscore/version.rb
|
129
|
-
|
144
|
+
- sig/fast_underscore.rbs
|
145
|
+
homepage: https://github.com/kddnewton/fast_underscore
|
130
146
|
licenses:
|
131
147
|
- MIT
|
132
|
-
metadata:
|
133
|
-
|
148
|
+
metadata:
|
149
|
+
bug_tracker_uri: https://github.com/kddnewton/fast_underscore/issues
|
150
|
+
changelog_uri: https://github.com/kddnewton/fast_underscore/blob/v0.3.3/CHANGELOG.md
|
151
|
+
source_code_uri: https://github.com/kddnewton/fast_underscore
|
152
|
+
rubygems_mfa_required: 'true'
|
153
|
+
post_install_message:
|
134
154
|
rdoc_options: []
|
135
155
|
require_paths:
|
136
156
|
- lib
|
@@ -145,9 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
165
|
- !ruby/object:Gem::Version
|
146
166
|
version: '0'
|
147
167
|
requirements: []
|
148
|
-
|
149
|
-
|
150
|
-
signing_key:
|
168
|
+
rubygems_version: 3.2.3
|
169
|
+
signing_key:
|
151
170
|
specification_version: 4
|
152
171
|
summary: Fast String#underscore implementation
|
153
172
|
test_files: []
|
data/.travis.yml
DELETED
data/bin/rake
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rake' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("rake", "rake")
|
data/bin/rubocop
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
#
|
5
|
-
# This file was generated by Bundler.
|
6
|
-
#
|
7
|
-
# The application 'rubocop' is installed as part of a gem, and
|
8
|
-
# this file is here to facilitate running it.
|
9
|
-
#
|
10
|
-
|
11
|
-
require "pathname"
|
12
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
-
Pathname.new(__FILE__).realpath)
|
14
|
-
|
15
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
-
|
17
|
-
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
-
load(bundle_binstub)
|
20
|
-
else
|
21
|
-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require "rubygems"
|
27
|
-
require "bundler/setup"
|
28
|
-
|
29
|
-
load Gem.bin_path("rubocop", "rubocop")
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FastUnderscore
|
4
|
-
# Uses ActiveSupport's `acronym_regex` method to construct a memoized pattern
|
5
|
-
# for replacing acronyms within strings that need to be underscored.
|
6
|
-
module AcronymRegex
|
7
|
-
def self.pattern
|
8
|
-
return @pattern if defined?(@pattern)
|
9
|
-
|
10
|
-
acronym_regex = ActiveSupport::Inflector.inflections.acronym_regex
|
11
|
-
@pattern ||= /(?:(?<=([A-Za-z\d]))|\b)(#{acronym_regex})(?=\b|[^a-z])/
|
12
|
-
end
|
13
|
-
|
14
|
-
def underscore(string)
|
15
|
-
return string unless /[A-Z-]|::/.match?(string)
|
16
|
-
|
17
|
-
response = string.dup
|
18
|
-
response.gsub!(AcronymRegex.pattern) { "#{$1 && '_'}#{$2.downcase}" }
|
19
|
-
|
20
|
-
FastUnderscore.underscore(response)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class << ActiveSupport::Inflector
|
25
|
-
alias as_underscore underscore
|
26
|
-
prepend AcronymRegex
|
27
|
-
end
|
28
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FastUnderscore
|
4
|
-
# Uses ActiveSupport's `acronym_underscore_regex` method for replacing
|
5
|
-
# acronyms within strings that need to be underscored.
|
6
|
-
module AcronymUnderscoreRegex
|
7
|
-
def underscore(string)
|
8
|
-
return string unless /[A-Z-]|::/.match?(string)
|
9
|
-
|
10
|
-
response = string.dup
|
11
|
-
acronyms = ActiveSupport::Inflector.inflections.acronyms_underscore_regex
|
12
|
-
|
13
|
-
response.gsub!(acronyms) { "#{$1 && '_'}#{$2.downcase}" }
|
14
|
-
|
15
|
-
FastUnderscore.underscore(response)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class << ActiveSupport::Inflector
|
20
|
-
alias as_underscore underscore
|
21
|
-
prepend AcronymUnderscoreRegex
|
22
|
-
end
|
23
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FastUnderscore
|
4
|
-
# Extends String to include an underscore method that delegates over to
|
5
|
-
# FastUnderscore's `#underscore` method.
|
6
|
-
module StringExtension
|
7
|
-
def underscore
|
8
|
-
FastUnderscore.underscore(self)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
String.prepend(FastUnderscore::StringExtension)
|