the_string_to_slug 1.3 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/the_string_to_slug.rb +16 -6
- data/lib/the_string_to_slug/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aa06c6f243a1ec99660c73fd8b1f5846ac84df7
|
4
|
+
data.tar.gz: c0e8c03aecf1ae600a2c51055b2f774c1ee71c4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 097aec7a70335f8ac70c6a050e3bced8e338eae6409992fbe0c4ff97c305662d71ddcbf7d520694bdd7eec3cfe3eb3947f3d33ce867f1df491baf02fd26b3b8d
|
7
|
+
data.tar.gz: 85f6bee339a0cc64847e5564d1bbd99fd9eb99dfe5eabc04d09a60718a11ca20ed7b752241345f3bafb067396adcba68b1591902c7d2912124a7581a94ca8f17
|
data/lib/the_string_to_slug.rb
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
require "rails-i18n"
|
2
2
|
require "the_string_to_slug/version"
|
3
3
|
|
4
|
-
module TheStringToSlug
|
4
|
+
module TheStringToSlug
|
5
|
+
class << self
|
6
|
+
def basic_parametrize(str, sep)
|
7
|
+
str.gsub('_', sep).gsub('-', sep)
|
8
|
+
end
|
9
|
+
|
10
|
+
def parameterize(str, sep)
|
11
|
+
Rails::VERSION::MAJOR > 4 ? \
|
12
|
+
str.parameterize(separator: sep) : \
|
13
|
+
str.parameterize(sep)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
5
17
|
|
6
18
|
class String
|
7
19
|
def to_slug_param opts = {}
|
@@ -21,13 +33,11 @@ class String
|
|
21
33
|
# -----------------------------------
|
22
34
|
class << self
|
23
35
|
def to_slug_param str, opts = {}
|
24
|
-
sep = opts.delete(:sep) || '-'
|
25
36
|
str = str.gsub(/\-{2,}/, '-').mb_chars
|
37
|
+
sep = opts.delete(:sep) || '-'
|
26
38
|
str = I18n::transliterate(str, opts)
|
27
|
-
|
28
|
-
|
29
|
-
.parameterize(separator: sep)
|
30
|
-
.to_s
|
39
|
+
str = TheStringToSlug::basic_parametrize(str, sep)
|
40
|
+
TheStringToSlug::parameterize(str, sep).to_s
|
31
41
|
end
|
32
42
|
|
33
43
|
def file_ext file_name, opts = {}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_string_to_slug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya N. Zykin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|