string-urlize 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  require "string-urlize/version"
2
+ require "i18n"
2
3
 
3
4
  module StringUrlize
4
5
 
@@ -8,37 +9,9 @@ module StringUrlize
8
9
  end
9
10
  end
10
11
 
11
- # ISO-8859-1 encoding
12
- ACCENTS_MAPPING = {
13
- 'E' => [200,201,202,203],
14
- 'e' => [232,233,234,235],
15
- 'A' => [192,193,194,195,196,197],
16
- 'a' => [224,225,226,227,228,229,230],
17
- 'C' => [199],
18
- 'c' => [231],
19
- 'O' => [210,211,212,213,214,216],
20
- 'o' => [242,243,244,245,246,248],
21
- 'I' => [204,205,206,207],
22
- 'i' => [236,237,238,239],
23
- 'U' => [217,218,219,220],
24
- 'u' => [249,250,251,252],
25
- 'N' => [209],
26
- 'n' => [241],
27
- 'Y' => [221],
28
- 'y' => [253,255],
29
- 'AE' => [306],
30
- 'ae' => [346],
31
- 'OE' => [188],
32
- 'oe' => [189]
33
- }.freeze
34
-
35
- def self.transliterate_accents! string
36
- each_accents_map { |letter, map| string.gsub! /[#{map}]/, letter }
37
- end
38
-
39
12
  def self.urlize dirty_string, options = {}
40
13
  string = dirty_string.clone
41
- transliterate_accents!(string) if options[:replace_accents]
14
+ string = I18n.transliterate(string, options[:locale] || :en) unless options[:transliterate] == false
42
15
 
43
16
  string.gsub! /[^[:alnum:]\-\s\_]/, '' # Remove all characters except alphanumeric, spaces, dashes and underscores
44
17
  string.gsub! /(\s|_)+/, '-' # Replace spaces and underscores by dashes
@@ -50,13 +23,6 @@ module StringUrlize
50
23
  string.downcase!
51
24
  string
52
25
  end
53
-
54
- private
55
-
56
- def self.each_accents_map
57
- ACCENTS_MAPPING.each { |letter, map| yield letter, map.pack('U*') }
58
- end
59
-
60
26
  end
61
27
 
62
28
  String.send :include, StringUrlize::InstanceMethods
@@ -1,3 +1,3 @@
1
1
  module StringUrlize
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string-urlize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-19 00:00:00.000000000Z
12
+ date: 2012-03-20 00:00:00.000000000Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: i18n
16
+ requirement: &83302370 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.5.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *83302370
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: cucumber
16
- requirement: &74862740 !ruby/object:Gem::Requirement
27
+ requirement: &83302040 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ~>
@@ -21,10 +32,10 @@ dependencies:
21
32
  version: 1.1.9
22
33
  type: :development
23
34
  prerelease: false
24
- version_requirements: *74862740
35
+ version_requirements: *83302040
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: rspec
27
- requirement: &74862350 !ruby/object:Gem::Requirement
38
+ requirement: &83301750 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ~>
@@ -32,12 +43,14 @@ dependencies:
32
43
  version: '2.9'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *74862350
46
+ version_requirements: *83301750
36
47
  description: ! 'Extends ruby "String" class with "urlize" method which converts string
37
48
  to friendly url. It
38
49
 
39
50
  removes all characters that couldn''t be used in url and replaces spaces/underscores
40
- with dashes'
51
+ with dashes. In addition it
52
+
53
+ transliterate string using I18n library.'
41
54
  email:
42
55
  - cheef.che@gmail.ru
43
56
  executables: []
@@ -46,7 +59,7 @@ extra_rdoc_files: []
46
59
  files:
47
60
  - lib/string-urlize/version.rb
48
61
  - lib/string-urlize.rb
49
- homepage: http://github.com/cheef/urlize
62
+ homepage: https://github.com/cheef/string-urlize
50
63
  licenses: []
51
64
  post_install_message:
52
65
  rdoc_options: []