accent_to_ascii 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2529618c6ab55b1cfd51b7c12a8db5b6882c71e0
4
- data.tar.gz: d2fcbffe171d0d38fcdd3d3ba6e6a40e538c2cfb
3
+ metadata.gz: 6e1b3456efd1dbc527f07aa580e425665fac2a8f
4
+ data.tar.gz: 85a928759cfc7db9fe38a9924d81768c5761c26d
5
5
  SHA512:
6
- metadata.gz: 736add2ba8db3016128eb37c134be1cc3c1530e8c90b20a99c1c1c5f6d25e64b4b1b8b3af2b6847e4e248e5aff696164c3d3bdec40731ad7e2cf4fe8cee762f8
7
- data.tar.gz: 8f493c6655ab933d900720fd294ec362cc62f0b2bcdca61f075f571a4e6f2baafaa54bd0d53b4ca2306aaa81cc026160529c9849ff604e2e9dc4df7dc7bcc971
6
+ metadata.gz: 6f14c1846d46302bc2e56de59323dd757deb988c9766ab574ee3da61f0179426c5430a4ffc9879f3d7eca85909f3317e4bece264b108b8bd8c997f92d1954dc5
7
+ data.tar.gz: 80d203f099f8edf8526356c966237dad9757c546fd31f40f6ba5453b2ad9736e74e36e311a9e12f04685f01274a860dc77a11b1335d052f297c813fda773d26d
data/README.md CHANGED
@@ -42,7 +42,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
42
42
 
43
43
  ## Contributing
44
44
 
45
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/accent_to_ascii. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/unieagle/accent_to_ascii. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
46
46
 
47
47
 
48
48
  ## License
@@ -24,24 +24,31 @@ module AccentToAscii
24
24
  'OE' => [188],
25
25
  'oe' => [189]
26
26
  }
27
+
28
+ class AccentToAscii
29
+ def self.accent_to_ascii(string)
30
+ string.tap do |s|
31
+ ACCENTS_MAPPING.each { |letter, accents| replace(s, letter, accents) }
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def self.replace(string, letter, accents)
38
+ packed = accents.pack('U*')
39
+ regex = Regexp.new("[#{packed}]", nil)
40
+ string.gsub!(regex, letter)
41
+ end
42
+ end
43
+
27
44
  end
28
45
 
29
46
  class String
30
47
  def accent_to_ascii(string = String.new(self))
31
- string.tap do |s|
32
- AccentToAscii::ACCENTS_MAPPING.each { |letter, accents| replace(s, letter, accents) }
33
- end
48
+ AccentToAscii::AccentToAscii.accent_to_ascii(string)
34
49
  end
35
50
 
36
51
  def accent_to_ascii!
37
52
  accent_to_ascii(self)
38
53
  end
39
-
40
- private
41
-
42
- def replace(string, letter, accents)
43
- packed = accents.pack('U*')
44
- regex = Regexp.new("[#{packed}]", nil)
45
- string.gsub!(regex, letter)
46
- end
47
54
  end
@@ -1,3 +1,3 @@
1
1
  module AccentToAscii
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: accent_to_ascii
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - uniEagle