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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1949fae18f18631f26a0305fdcf46d389ecb7d97
4
- data.tar.gz: 2b0b7a91421e64ebf878dfe767543d683fc1221f
3
+ metadata.gz: 8aa06c6f243a1ec99660c73fd8b1f5846ac84df7
4
+ data.tar.gz: c0e8c03aecf1ae600a2c51055b2f774c1ee71c4c
5
5
  SHA512:
6
- metadata.gz: 74c4b135b8e9251ab302e2384b5ee22cfbdb1f023fdfa927d5e789e6c8bcc4201156a5de4c52f181fd5b2e6be7255ccecd1e75e66822984146507730afb889c0
7
- data.tar.gz: 710228bbdd26a674a84f1809d662136670be0c1da83949abc733c5e702357f77497de987dcb44d588da9235a5cbb9b421b8f70505d4e649e46756279660250e7
6
+ metadata.gz: 097aec7a70335f8ac70c6a050e3bced8e338eae6409992fbe0c4ff97c305662d71ddcbf7d520694bdd7eec3cfe3eb3947f3d33ce867f1df491baf02fd26b3b8d
7
+ data.tar.gz: 85f6bee339a0cc64847e5564d1bbd99fd9eb99dfe5eabc04d09a60718a11ca20ed7b752241345f3bafb067396adcba68b1591902c7d2912124a7581a94ca8f17
@@ -1,7 +1,19 @@
1
1
  require "rails-i18n"
2
2
  require "the_string_to_slug/version"
3
3
 
4
- module TheStringToSlug; end
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
- .gsub('_', sep)
28
- .gsub('-', sep)
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 = {}
@@ -1,3 +1,3 @@
1
1
  module TheStringToSlug
2
- VERSION = "1.3"
2
+ VERSION = "1.4"
3
3
  end
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.3'
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-29 00:00:00.000000000 Z
11
+ date: 2016-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n