rubypants 0.5.1 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b29b8d72353258ac6b847c78c77fedaa8a9cb33
4
- data.tar.gz: 965af58a1f2e7770e5a76a748e7ad564f6e24335
3
+ metadata.gz: 80fce7b0286c4b7268c4bbd6d73cc702acee77d5
4
+ data.tar.gz: b2206216e8645e82ad3705a54064e5465430eab3
5
5
  SHA512:
6
- metadata.gz: 7e8c42ca85e3a117f954311cbb016779329c9e390200a70244fd2f5828959a60d4226a924ae777904032ea756f4b774367c9ddd578b241621ce18b5ff1a33f4c
7
- data.tar.gz: 4456339e90147d4887917441d9400f17f1cb0f5df3a45e2528629eed88ed5da309eb99b6d0dff70819538ff1966d8351d6dd2d3e3bb3ad5ab630868db759f6f4
6
+ metadata.gz: 395f50ffc524bdf2e193dea148e1eec494453b4ac7a062220257d8c7514a65a7377c63ee7ecdb081fd0e625169263be6b32f1b9e0d592bb7a4537ee776fca7e0
7
+ data.tar.gz: 665a1f5b1d81ef0f95afaf6ad4db71ba684dfdd2b0fc2658f2628ba11d3aaec9fb41a9b50e5053ff96fc8f48ad685741f52f6d671bde8eedd10d4a5eb6c74bc2
data/.gitignore CHANGED
@@ -0,0 +1 @@
1
+ Gemfile.lock
@@ -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
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ gem "rake"
5
+ gem "codecov", :require => false, :group => :test
@@ -1,6 +1,8 @@
1
1
  = RubyPants: SmartyPants for Ruby
2
2
 
3
- {<img src="https://img.shields.io/gem/v/rubypants.png?style=plastic">}[https://rubygems.org/gems/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
 
@@ -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> :: 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>:convertquotes</tt> :: convert <tt>&quot;</tt> entities to
24
- # <tt>"</tt>
25
- # <tt>:stupefy</tt> :: translate RubyPants HTML entities
26
- # to their ASCII counterparts.
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>&quot;</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. The defaults for these entities
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>&#8216;</tt>
@@ -36,13 +40,31 @@ class RubyPants < String
36
40
  # <tt>:em_dash</tt> :: <tt>&#8212;</tt>
37
41
  # <tt>:en_dash</tt> :: <tt>&#8211;</tt>
38
42
  # <tt>:ellipsis</tt> :: <tt>&#8230;</tt>
39
- # <tt>:html_quote</tt> :: <tt>&quot; </tt>
43
+ # <tt>:html_quote</tt> :: <tt>&quot;</tt>
44
+ # <tt>:non_breaking_space</tt> :: <tt>&nbsp;</tt>
45
+ # <tt>:word_joiner</tt> :: <tt>&#8288;</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>&lsquo;</tt>
51
+ # <tt>:double_left_quote</tt> :: <tt>&ldquo;</tt>
52
+ # <tt>:single_right_quote</tt> :: <tt>&rsquo;</tt>
53
+ # <tt>:double_right_quote</tt> :: <tt>&rdquo;</tt>
54
+ # <tt>:em_dash</tt> :: <tt>&mdash;</tt>
55
+ # <tt>:en_dash</tt> :: <tt>&ndash;</tt>
56
+ # <tt>:ellipsis</tt> :: <tt>&hellip;</tt>
57
+ # <tt>:html_quote</tt> :: <tt>&quot;</tt>
58
+ # <tt>:non_breaking_space</tt> :: <tt>&nbsp;</tt>
59
+ # <tt>:word_joiner</tt> :: <tt>&#8288;</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.update(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 => "&#8230;",
401
423
  :html_quote => "&quot;",
402
424
  :non_breaking_space => "&nbsp;",
403
- :word_joiner => "&#65279;",
425
+ :word_joiner => "&#8288;",
426
+ }
427
+ end
428
+
429
+ def named_entities
430
+ {
431
+ :single_left_quote => '&lsquo;',
432
+ :double_left_quote => "&ldquo;",
433
+ :single_right_quote => "&rsquo;",
434
+ :double_right_quote => "&rdquo;",
435
+ :em_dash => "&mdash;",
436
+ :en_dash => "&ndash;",
437
+ :ellipsis => "&hellip;",
438
+ :html_quote => "&quot;",
439
+ :non_breaking_space => "&nbsp;",
440
+ # :word_joiner => N/A,
404
441
  }
405
442
  end
406
443
 
@@ -1,3 +1,3 @@
1
1
  class RubyPants
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -0,0 +1,5 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'codecov'
5
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
@@ -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
  '&#8212;foo&#8212;bar&#8212;quux&#8212;', 1
76
78
 
77
- assert_rp_equal "foo--bar", 'foo&#65279;&#8212;bar', [1, :prevent_breaks]
79
+ assert_rp_equal "foo--bar", 'foo&#8288;&#8212;bar', [1, :prevent_breaks]
78
80
  assert_rp_equal "foo --bar", 'foo &#8212;bar', 1
79
81
  assert_rp_equal "foo --bar", 'foo&nbsp;&#8212;bar', [1, :prevent_breaks]
80
82
  assert_rp_equal "foo -- bar", 'foo&nbsp;&#8212; bar', [1, :prevent_breaks]
@@ -86,13 +88,13 @@ EOF
86
88
  assert_rp_equal "--foo--bar--quux--",
87
89
  '&#8211;foo&#8211;bar&#8211;quux&#8211;', 2
88
90
 
89
- assert_rp_equal "foo--bar", 'foo&#65279;&#8211;bar', [2, :prevent_breaks]
91
+ assert_rp_equal "foo--bar", 'foo&#8288;&#8211;bar', [2, :prevent_breaks]
90
92
  assert_rp_equal "foo --bar", 'foo &#8211;bar', 2
91
93
  assert_rp_equal "foo --bar", 'foo&nbsp;&#8211;bar', [2, :prevent_breaks]
92
94
  assert_rp_equal "foo -- bar", 'foo&nbsp;&#8211; bar', [2, :prevent_breaks]
93
95
  assert_rp_equal "foo --bar", 'foo&nbsp;&#8211;bar', [2, :prevent_breaks]
94
96
 
95
- assert_rp_equal "foo---bar", 'foo&#65279;&#8212;bar', [2, :prevent_breaks]
97
+ assert_rp_equal "foo---bar", 'foo&#8288;&#8212;bar', [2, :prevent_breaks]
96
98
  assert_rp_equal "foo ---bar", 'foo &#8212;bar', 2
97
99
  assert_rp_equal "foo ---bar", 'foo&nbsp;&#8212;bar', [2, :prevent_breaks]
98
100
  assert_rp_equal "foo --- bar", 'foo&nbsp;&#8212; bar', [2, :prevent_breaks]
@@ -104,13 +106,13 @@ EOF
104
106
  assert_rp_equal "--foo--bar--quux--",
105
107
  '&#8212;foo&#8212;bar&#8212;quux&#8212;', 3
106
108
 
107
- assert_rp_equal "foo--bar", 'foo&#65279;&#8212;bar', [3, :prevent_breaks]
109
+ assert_rp_equal "foo--bar", 'foo&#8288;&#8212;bar', [3, :prevent_breaks]
108
110
  assert_rp_equal "foo --bar", 'foo &#8212;bar', 3
109
111
  assert_rp_equal "foo --bar", 'foo&nbsp;&#8212;bar', [3, :prevent_breaks]
110
112
  assert_rp_equal "foo -- bar", 'foo&nbsp;&#8212; bar', [3, :prevent_breaks]
111
113
  assert_rp_equal "foo --bar", 'foo&nbsp;&#8212;bar', [3, :prevent_breaks]
112
114
 
113
- assert_rp_equal "foo---bar", 'foo&#65279;&#8211;bar', [3, :prevent_breaks]
115
+ assert_rp_equal "foo---bar", 'foo&#8288;&#8211;bar', [3, :prevent_breaks]
114
116
  assert_rp_equal "foo ---bar", 'foo &#8211;bar', 3
115
117
  assert_rp_equal "foo ---bar", 'foo&nbsp;&#8211;bar', [3, :prevent_breaks]
116
118
  assert_rp_equal "foo --- bar", 'foo&nbsp;&#8211; 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&#65279;&#8230;bar', [:ellipses, :prevent_breaks]
141
+ assert_rp_equal "foo...bar", 'foo&#8288;&#8230;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&#65279;&#8230;bar', [:ellipses, :prevent_breaks]
150
+ assert_rp_equal "foo. . .bar", 'foo&#8288;&#8230;bar', [:ellipses, :prevent_breaks]
149
151
  assert_rp_equal "foo . . . bar", 'foo&nbsp;&#8230; 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 &lsquo;FOO!&rsquo;", [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.5.1
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-02 00:00:00.000000000 Z
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