quotinator 0.0.3 → 0.1.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.
- data/CHANGELOG.md +1 -0
- data/README.md +10 -11
- data/Rakefile +9 -0
- data/lib/quotinator.rb +6 -7
- data/test/test_quotinator.rb +41 -0
- metadata +4 -2
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,37 +3,36 @@
|
|
3
3
|
|
4
4
|
## Background
|
5
5
|
|
6
|
-
|
6
|
+
I got tired of writing a bunch substitutions to handle the Microsoft fancy quotes and other such special characters. So what better way to never have to do it again than by putting it all into a gem?
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
|
10
10
|
Just include The Quotinator to your gemfile:
|
11
|
-
|
11
|
+
`gem "quotinator"`
|
12
12
|
|
13
13
|
Then call any of the functions while passing in the string you wish to clean up.
|
14
|
-
|
14
|
+
`Quotinator.replace("It's your text, why not clean it up?")`
|
15
15
|
|
16
16
|
## Available functions
|
17
17
|
|
18
|
-
|
18
|
+
`about`
|
19
19
|
Outputs a brief description of what the gem does. Pretty much a useless function.
|
20
20
|
|
21
|
-
|
21
|
+
`replace(txt)`
|
22
22
|
Shorthand function for `replace_all()`
|
23
23
|
|
24
|
-
|
24
|
+
`replace_all(txt)`
|
25
25
|
Function which handles replacing all known "special" characters.
|
26
26
|
|
27
|
-
|
27
|
+
`doublequotes(txt)`
|
28
28
|
Replaces only the special double quotation marks
|
29
29
|
|
30
|
-
|
30
|
+
`singlequotes(txt)`
|
31
31
|
Replaces only the special single quotation marks
|
32
32
|
|
33
|
-
|
33
|
+
`ellipsis(txt)`
|
34
34
|
Replaces only the special ellipsis (...)
|
35
35
|
|
36
|
-
|
36
|
+
`longdash(txt)`
|
37
37
|
Replaces only the special long dash
|
38
38
|
|
39
|
-
|
data/Rakefile
ADDED
data/lib/quotinator.rb
CHANGED
@@ -24,17 +24,15 @@ class Quotinator
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.doublequotes(txt)
|
27
|
-
txt.gsub
|
28
|
-
txt.gsub!(/“/,'"')
|
27
|
+
txt = txt.gsub(/”/,'"').gsub(/“/,'"')
|
29
28
|
# There seems to be two different sets of special quotes.
|
30
|
-
txt.gsub
|
31
|
-
txt.gsub!(
|
29
|
+
txt = txt.gsub(/”/,'"').gsub(/“/,'"')
|
30
|
+
txt.gsub!(/[\u201c\u201d]/, '"')
|
32
31
|
return txt
|
33
32
|
end
|
34
33
|
|
35
34
|
def self.singlequotes(txt)
|
36
|
-
txt.gsub
|
37
|
-
txt.gsub!(/‘/,"'")
|
35
|
+
txt = txt.gsub(/’/,"'").gsub(/‘/,"'")
|
38
36
|
return txt
|
39
37
|
end
|
40
38
|
|
@@ -48,4 +46,5 @@ class Quotinator
|
|
48
46
|
return txt
|
49
47
|
end
|
50
48
|
|
51
|
-
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'quotinator'
|
5
|
+
|
6
|
+
class QuotinatorTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
# Running tests on the following phrase:
|
9
|
+
# Let’s see if this passes the “test” – I hope it does…
|
10
|
+
# Of course, the long dash is breaking the tests, so we'll skip it for the moment.
|
11
|
+
|
12
|
+
def test_all
|
13
|
+
input = "Let’s see if this passes the “test” I hope it does…"
|
14
|
+
output = Quotinator.replace_all(input)
|
15
|
+
expected = "Let's see if this passes the \"test\" I hope it does..."
|
16
|
+
assert_equal expected, output
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_doublequotes
|
20
|
+
input = "Let’s see if this passes the “test” I hope it does…"
|
21
|
+
output = Quotinator.doublequotes(input)
|
22
|
+
expected = "Let’s see if this passes the \"test\" I hope it does…"
|
23
|
+
assert_equal expected, output
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_singlequotes
|
27
|
+
input = "Let’s see if this passes the “test” I hope it does…"
|
28
|
+
output = Quotinator.singlequotes(input)
|
29
|
+
expected = "Let's see if this passes the “test” I hope it does…"
|
30
|
+
assert_equal expected, output
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_ellipsis
|
34
|
+
input = "Let’s see if this passes the “test” I hope it does…"
|
35
|
+
output = Quotinator.ellipsis(input)
|
36
|
+
expected = "Let’s see if this passes the “test” I hope it does..."
|
37
|
+
assert_equal expected, output
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quotinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple gem to replace the special characters from Microsoft products
|
15
15
|
to their basic equivalents.
|
@@ -21,6 +21,8 @@ files:
|
|
21
21
|
- lib/quotinator.rb
|
22
22
|
- CHANGELOG.md
|
23
23
|
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- test/test_quotinator.rb
|
24
26
|
homepage: http://rubygems.org/gems/quotinator
|
25
27
|
licenses:
|
26
28
|
- MIT
|