fast_underscore 0.2.0 → 0.3.0
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 +1 -1
- data/lib/fast_underscore.rb +30 -17
- data/lib/fast_underscore/{ext/acronym_regex.rb → acronym_regex.rb} +1 -1
- data/lib/fast_underscore/{ext/acronym_underscore_regex.rb → acronym_underscore_regex.rb} +1 -1
- data/lib/fast_underscore/version.rb +1 -1
- metadata +4 -5
- data/lib/fast_underscore/ext/plain_string.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d28091570b3b614967f128f03463f53a4756ead6eac601f5079f243360a792d
|
4
|
+
data.tar.gz: ed2f503634f9409882bce0c0c678f5e40d20deeb5df32f90b0bad1f957feaee6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c1c36bb21b58386e63507972fa55914e3942e2fc19b7448b9d2bf1b93887b732e480f4da554cc8fcbf331f1ec7cab1e0a5aa10f4fccf7341fb56317c273c295
|
7
|
+
data.tar.gz: 11eabdb8ddc721164856fe7a76856045decf07b1b561e142e6915503e3648194cb59c3f4d021a3c1809435b31d75dcf7da6d06681b88693512aeeb759e10b777
|
data/Gemfile.lock
CHANGED
data/lib/fast_underscore.rb
CHANGED
@@ -4,28 +4,41 @@ require 'fast_underscore/version'
|
|
4
4
|
require 'fast_underscore/fast_underscore'
|
5
5
|
|
6
6
|
module FastUnderscore
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
# Depending on `ActiveSupport::VERSION`, `::install` determines the manner in
|
8
|
+
# which acronyms are handled, then it redefines the
|
9
|
+
# `ActiveSupport::Inflector::underscore` method to use the `FastUnderscore`
|
10
|
+
# native extension. It leaves the existing `ActiveSupport` monkeypatch on
|
11
|
+
# `String` that allows it to call into the newly redefined `Inflector` method.
|
12
|
+
def self.install
|
13
|
+
require 'active_support/version'
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
require 'fast_underscore/ext/acronym_regex'
|
20
|
-
end
|
15
|
+
if ActiveSupport::VERSION::MAJOR == 5 && ActiveSupport::VERSION::MINOR >= 2
|
16
|
+
require 'fast_underscore/acronym_underscore_regex'
|
17
|
+
else
|
18
|
+
require 'fast_underscore/acronym_regex'
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
if defined?(ActiveSupport)
|
24
|
+
FastUnderscore.install
|
25
|
+
else
|
26
|
+
module ActiveSupport
|
27
|
+
module Inflector
|
28
|
+
class << self
|
29
|
+
prepend(
|
30
|
+
Module.new do
|
31
|
+
# Hooks into ActiveSupport::Inflector and waits for the #underscore
|
32
|
+
# method to be defined. When it is, it automatically redefines it.
|
33
|
+
# Using this `prepend` trick to attempt to be a good citizen in the
|
34
|
+
# case that someone else has already hooked into `method_added` on
|
35
|
+
# `Inflector`.
|
36
|
+
def method_added(method)
|
37
|
+
method == :underscore ? FastUnderscore.install : super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
)
|
41
|
+
end
|
29
42
|
end
|
30
43
|
end
|
31
44
|
end
|
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.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Deisz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -122,9 +122,8 @@ files:
|
|
122
122
|
- gemfiles/5.1.gemfile
|
123
123
|
- gemfiles/5.2.gemfile
|
124
124
|
- lib/fast_underscore.rb
|
125
|
-
- lib/fast_underscore/
|
126
|
-
- lib/fast_underscore/
|
127
|
-
- lib/fast_underscore/ext/plain_string.rb
|
125
|
+
- lib/fast_underscore/acronym_regex.rb
|
126
|
+
- lib/fast_underscore/acronym_underscore_regex.rb
|
128
127
|
- lib/fast_underscore/version.rb
|
129
128
|
homepage: https://github.com/kddeisz/fast_underscore
|
130
129
|
licenses:
|
@@ -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)
|