rubypants 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +18 -0
- data/Gemfile +5 -0
- data/README.rdoc +3 -1
- data/lib/rubypants/core.rb +52 -15
- data/lib/rubypants/version.rb +1 -1
- data/test/helper.rb +5 -0
- data/test/rubypants_test.rb +13 -7
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80fce7b0286c4b7268c4bbd6d73cc702acee77d5
|
4
|
+
data.tar.gz: b2206216e8645e82ad3705a54064e5465430eab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 395f50ffc524bdf2e193dea148e1eec494453b4ac7a062220257d8c7514a65a7377c63ee7ecdb081fd0e625169263be6b32f1b9e0d592bb7a4537ee776fca7e0
|
7
|
+
data.tar.gz: 665a1f5b1d81ef0f95afaf6ad4db71ba684dfdd2b0fc2658f2628ba11d3aaec9fb41a9b50e5053ff96fc8f48ad685741f52f6d671bde8eedd10d4a5eb6c74bc2
|
data/.gitignore
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
rvm:
|
2
|
+
- 2.0
|
3
|
+
- 2.1
|
4
|
+
- 2.2
|
5
|
+
- 2.3.0
|
6
|
+
- jruby
|
7
|
+
|
8
|
+
# Workaround for `NoMethodError: undefined method 'spec' for nil:NilClass`,
|
9
|
+
# see https://travis-ci.org/jmcnevin/rubypants/jobs/167182556
|
10
|
+
# and https://github.com/travis-ci/travis-ci/issues/5239
|
11
|
+
before_install:
|
12
|
+
- gem install bundler
|
13
|
+
|
14
|
+
# For now override the default `bundle exec rake` which fails because of an
|
15
|
+
# unresolved superclass mismatch in `core.rb` vs. `version.rb`. This should
|
16
|
+
# eventually be fixed in rubypants.
|
17
|
+
script:
|
18
|
+
- rake
|
data/Gemfile
ADDED
data/README.rdoc
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
= RubyPants: SmartyPants for Ruby
|
2
2
|
|
3
|
-
{<img src="https://img.shields.io/gem/v/rubypants.
|
3
|
+
{<img src="https://img.shields.io/gem/v/rubypants.svg?maxAge=2592000&style=plastic" alt="Gem">}[https://rubygems.org/gems/rubypants]
|
4
|
+
{<img src="https://img.shields.io/travis/jmcnevin/rubypants.svg?maxAge=2592000&style=plastic" alt="Travis">}[https://travis-ci.org/jmcnevin/rubypants]
|
5
|
+
{<img src="https://img.shields.io/codecov/c/github/jmcnevin/rubypants.svg?maxAge=2592000&style=plastic" alt="CodeCov">}[https://codecov.io/gh/jmcnevin/rubypants]
|
4
6
|
|
5
7
|
== Synopsis
|
6
8
|
|
data/lib/rubypants/core.rb
CHANGED
@@ -13,20 +13,24 @@ class RubyPants < String
|
|
13
13
|
# If you don't like any of these defaults, you can pass symbols to change
|
14
14
|
# RubyPants' behavior:
|
15
15
|
#
|
16
|
-
# <tt>:quotes</tt>
|
17
|
-
# <tt>:backticks</tt>
|
18
|
-
# <tt>:allbackticks</tt>
|
19
|
-
# <tt>:dashes</tt>
|
20
|
-
# <tt>:oldschool</tt>
|
21
|
-
# <tt>:inverted</tt>
|
22
|
-
# <tt>:ellipses</tt>
|
23
|
-
# <tt>:
|
24
|
-
#
|
25
|
-
# <tt>:
|
26
|
-
#
|
16
|
+
# <tt>:quotes</tt> :: quotes
|
17
|
+
# <tt>:backticks</tt> :: backtick quotes (``double'' only)
|
18
|
+
# <tt>:allbackticks</tt> :: backtick quotes (``double'' and `single')
|
19
|
+
# <tt>:dashes</tt> :: dashes
|
20
|
+
# <tt>:oldschool</tt> :: old school dashes
|
21
|
+
# <tt>:inverted</tt> :: inverted old school dashes
|
22
|
+
# <tt>:ellipses</tt> :: ellipses
|
23
|
+
# <tt>:prevent_breaks</tt> :: use nbsp and word-joiner to avoid breaking
|
24
|
+
# before dashes and ellipses
|
25
|
+
# <tt>:named_entities</tt> :: used named entities instead of the default
|
26
|
+
# decimal entities (see below)
|
27
|
+
# <tt>:convertquotes</tt> :: convert <tt>"</tt> entities to
|
28
|
+
# <tt>"</tt>
|
29
|
+
# <tt>:stupefy</tt> :: translate RubyPants HTML entities
|
30
|
+
# to their ASCII counterparts.
|
27
31
|
#
|
28
32
|
# In addition, you can customize the HTML entities that will be injected by
|
29
|
-
# passing in a hash for the final argument.
|
33
|
+
# passing in a hash for the final argument. The defaults for these entities
|
30
34
|
# are as follows:
|
31
35
|
#
|
32
36
|
# <tt>:single_left_quote</tt> :: <tt>‘</tt>
|
@@ -36,13 +40,31 @@ class RubyPants < String
|
|
36
40
|
# <tt>:em_dash</tt> :: <tt>—</tt>
|
37
41
|
# <tt>:en_dash</tt> :: <tt>–</tt>
|
38
42
|
# <tt>:ellipsis</tt> :: <tt>…</tt>
|
39
|
-
# <tt>:html_quote</tt> :: <tt>"
|
43
|
+
# <tt>:html_quote</tt> :: <tt>"</tt>
|
44
|
+
# <tt>:non_breaking_space</tt> :: <tt> </tt>
|
45
|
+
# <tt>:word_joiner</tt> :: <tt>⁠</tt>
|
46
|
+
#
|
47
|
+
# If the <tt>:named_entities</tt> option is used, the default entities are
|
48
|
+
# as follows:
|
49
|
+
#
|
50
|
+
# <tt>:single_left_quote</tt> :: <tt>‘</tt>
|
51
|
+
# <tt>:double_left_quote</tt> :: <tt>“</tt>
|
52
|
+
# <tt>:single_right_quote</tt> :: <tt>’</tt>
|
53
|
+
# <tt>:double_right_quote</tt> :: <tt>”</tt>
|
54
|
+
# <tt>:em_dash</tt> :: <tt>—</tt>
|
55
|
+
# <tt>:en_dash</tt> :: <tt>–</tt>
|
56
|
+
# <tt>:ellipsis</tt> :: <tt>…</tt>
|
57
|
+
# <tt>:html_quote</tt> :: <tt>"</tt>
|
58
|
+
# <tt>:non_breaking_space</tt> :: <tt> </tt>
|
59
|
+
# <tt>:word_joiner</tt> :: <tt>⁠</tt>
|
40
60
|
#
|
41
61
|
def initialize(string, options=[2], entities = {})
|
42
62
|
super string
|
43
63
|
|
44
64
|
@options = [*options]
|
45
|
-
@entities = default_entities
|
65
|
+
@entities = default_entities
|
66
|
+
@entities.merge!(named_entities) if @options.include?(:named_entities)
|
67
|
+
@entities.merge!(entities)
|
46
68
|
end
|
47
69
|
|
48
70
|
# Apply SmartyPants transformations.
|
@@ -400,7 +422,22 @@ class RubyPants < String
|
|
400
422
|
:ellipsis => "…",
|
401
423
|
:html_quote => """,
|
402
424
|
:non_breaking_space => " ",
|
403
|
-
:word_joiner => "&#
|
425
|
+
:word_joiner => "⁠",
|
426
|
+
}
|
427
|
+
end
|
428
|
+
|
429
|
+
def named_entities
|
430
|
+
{
|
431
|
+
:single_left_quote => '‘',
|
432
|
+
:double_left_quote => "“",
|
433
|
+
:single_right_quote => "’",
|
434
|
+
:double_right_quote => "”",
|
435
|
+
:em_dash => "—",
|
436
|
+
:en_dash => "–",
|
437
|
+
:ellipsis => "…",
|
438
|
+
:html_quote => """,
|
439
|
+
:non_breaking_space => " ",
|
440
|
+
# :word_joiner => N/A,
|
404
441
|
}
|
405
442
|
end
|
406
443
|
|
data/lib/rubypants/version.rb
CHANGED
data/test/helper.rb
ADDED
data/test/rubypants_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
1
3
|
require 'minitest/autorun'
|
2
4
|
require_relative '../lib/rubypants'
|
3
5
|
|
@@ -74,7 +76,7 @@ EOF
|
|
74
76
|
assert_rp_equal "--foo--bar--quux--",
|
75
77
|
'—foo—bar—quux—', 1
|
76
78
|
|
77
|
-
assert_rp_equal "foo--bar", 'foo&#
|
79
|
+
assert_rp_equal "foo--bar", 'foo⁠—bar', [1, :prevent_breaks]
|
78
80
|
assert_rp_equal "foo --bar", 'foo —bar', 1
|
79
81
|
assert_rp_equal "foo --bar", 'foo —bar', [1, :prevent_breaks]
|
80
82
|
assert_rp_equal "foo -- bar", 'foo — bar', [1, :prevent_breaks]
|
@@ -86,13 +88,13 @@ EOF
|
|
86
88
|
assert_rp_equal "--foo--bar--quux--",
|
87
89
|
'–foo–bar–quux–', 2
|
88
90
|
|
89
|
-
assert_rp_equal "foo--bar", 'foo&#
|
91
|
+
assert_rp_equal "foo--bar", 'foo⁠–bar', [2, :prevent_breaks]
|
90
92
|
assert_rp_equal "foo --bar", 'foo –bar', 2
|
91
93
|
assert_rp_equal "foo --bar", 'foo –bar', [2, :prevent_breaks]
|
92
94
|
assert_rp_equal "foo -- bar", 'foo – bar', [2, :prevent_breaks]
|
93
95
|
assert_rp_equal "foo --bar", 'foo –bar', [2, :prevent_breaks]
|
94
96
|
|
95
|
-
assert_rp_equal "foo---bar", 'foo&#
|
97
|
+
assert_rp_equal "foo---bar", 'foo⁠—bar', [2, :prevent_breaks]
|
96
98
|
assert_rp_equal "foo ---bar", 'foo —bar', 2
|
97
99
|
assert_rp_equal "foo ---bar", 'foo —bar', [2, :prevent_breaks]
|
98
100
|
assert_rp_equal "foo --- bar", 'foo — bar', [2, :prevent_breaks]
|
@@ -104,13 +106,13 @@ EOF
|
|
104
106
|
assert_rp_equal "--foo--bar--quux--",
|
105
107
|
'—foo—bar—quux—', 3
|
106
108
|
|
107
|
-
assert_rp_equal "foo--bar", 'foo&#
|
109
|
+
assert_rp_equal "foo--bar", 'foo⁠—bar', [3, :prevent_breaks]
|
108
110
|
assert_rp_equal "foo --bar", 'foo —bar', 3
|
109
111
|
assert_rp_equal "foo --bar", 'foo —bar', [3, :prevent_breaks]
|
110
112
|
assert_rp_equal "foo -- bar", 'foo — bar', [3, :prevent_breaks]
|
111
113
|
assert_rp_equal "foo --bar", 'foo —bar', [3, :prevent_breaks]
|
112
114
|
|
113
|
-
assert_rp_equal "foo---bar", 'foo&#
|
115
|
+
assert_rp_equal "foo---bar", 'foo⁠–bar', [3, :prevent_breaks]
|
114
116
|
assert_rp_equal "foo ---bar", 'foo –bar', 3
|
115
117
|
assert_rp_equal "foo ---bar", 'foo –bar', [3, :prevent_breaks]
|
116
118
|
assert_rp_equal "foo --- bar", 'foo – bar', [3, :prevent_breaks]
|
@@ -136,7 +138,7 @@ EOF
|
|
136
138
|
assert_rp_equal "foo....bar", 'foo....bar', [:ellipses]
|
137
139
|
# and with :prevent_breaks
|
138
140
|
assert_rp_equal "foo..bar", 'foo..bar', [:ellipses, :prevent_breaks]
|
139
|
-
assert_rp_equal "foo...bar", 'foo&#
|
141
|
+
assert_rp_equal "foo...bar", 'foo⁠…bar', [:ellipses, :prevent_breaks]
|
140
142
|
assert_rp_equal "foo....bar", 'foo....bar', [:ellipses, :prevent_breaks]
|
141
143
|
|
142
144
|
# dots and spaces
|
@@ -145,7 +147,7 @@ EOF
|
|
145
147
|
assert_rp_equal "foo. . . .bar", 'foo. . . .bar', [:ellipses]
|
146
148
|
assert_rp_equal "foo . . . . bar", 'foo . . . . bar', [:ellipses]
|
147
149
|
# and with :prevent_breaks
|
148
|
-
assert_rp_equal "foo. . .bar", 'foo&#
|
150
|
+
assert_rp_equal "foo. . .bar", 'foo⁠…bar', [:ellipses, :prevent_breaks]
|
149
151
|
assert_rp_equal "foo . . . bar", 'foo … bar', [:ellipses, :prevent_breaks]
|
150
152
|
assert_rp_equal "foo. . . .bar", 'foo. . . .bar', [:ellipses, :prevent_breaks]
|
151
153
|
assert_rp_equal "foo . . . . bar", 'foo . . . . bar', [:ellipses, :prevent_breaks]
|
@@ -229,4 +231,8 @@ EOF
|
|
229
231
|
}
|
230
232
|
assert_rp_equal "Testing 'FOO!'", "Testing SHAZAMFOO!POWZAP", [2], entities
|
231
233
|
end
|
234
|
+
|
235
|
+
def test_named_entities
|
236
|
+
assert_rp_equal "Testing 'FOO!'", "Testing ‘FOO!’", [2, :named_entities]
|
237
|
+
end
|
232
238
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubypants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Gruber
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2016-10-
|
15
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: minitest
|
@@ -39,6 +39,8 @@ extensions: []
|
|
39
39
|
extra_rdoc_files: []
|
40
40
|
files:
|
41
41
|
- ".gitignore"
|
42
|
+
- ".travis.yml"
|
43
|
+
- Gemfile
|
42
44
|
- LICENSE.rdoc
|
43
45
|
- README.rdoc
|
44
46
|
- Rakefile
|
@@ -46,6 +48,7 @@ files:
|
|
46
48
|
- lib/rubypants/core.rb
|
47
49
|
- lib/rubypants/version.rb
|
48
50
|
- rubypants.gemspec
|
51
|
+
- test/helper.rb
|
49
52
|
- test/rubypants_test.rb
|
50
53
|
homepage: https://github.com/jmcnevin/rubypants
|
51
54
|
licenses:
|
@@ -72,4 +75,5 @@ signing_key:
|
|
72
75
|
specification_version: 4
|
73
76
|
summary: RubyPants is a Ruby port of the smart-quotes library SmartyPants.
|
74
77
|
test_files:
|
78
|
+
- test/helper.rb
|
75
79
|
- test/rubypants_test.rb
|