improve_typography 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a15353e5f98379ad53b4cba25f1bb06a9e871d87525400cbcaef028288a3b7cb
4
- data.tar.gz: 6449e0f1ef011b5178d8a9a9429b7854d22875e44048f191313d11bfe1bd9163
3
+ metadata.gz: 050ccf9750f3535176023f6156dd7397130fd1b30c03787f49b5a0a453959f72
4
+ data.tar.gz: e7a4c3661192eb7a19670e1b4f8c59896be5c16921976ab14dab7be4cc3bcd83
5
5
  SHA512:
6
- metadata.gz: 5263165ffa75b7aad4ae268c52cd2f7db550997c9880a645db074ef16756990abb77c45333db1cc43029fc462735894c517377bfecadf81d091b12027848e0f3
7
- data.tar.gz: 99035ac8f242688c1b3171672ec16e63045d60f5d702bc0be3b561c8a343bfee1792e1d97702dbddc8e62ed6c33a55d9dc0816c3be869345540f7bc988026f9a
6
+ metadata.gz: 60e078a0c5fc8c35956e407d3ac5fc81fdc9c8cfa0b239b934d6986137e22a1d2b2a81d27f6e445617d6fdf5fb2ab34f733f477d49149ecaf3f454ad5d5039c8
7
+ data.tar.gz: 9c400979338141b2660c679a0504ca8da41e0a2d7812e57b1d0d66d02a74b3ae61f0d3e1460c40fa41744976a0e0ea5fe5394446ee1042fa63f5b68c14e5e4b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.14
4
+
5
+ * first run simplest `match?` before `gsub` to make sure the replacement is actually needed
6
+
3
7
  ## 0.1.13
4
8
 
5
9
  * skip processing if no processor classes defined
@@ -4,6 +4,7 @@ module ImproveTypography
4
4
  REGEXP = /(\w+)'(\w*)/i
5
5
 
6
6
  def call
7
+ return str unless str.match?(/'/)
7
8
  replace_apostrophe
8
9
  end
9
10
 
@@ -2,6 +2,7 @@ module ImproveTypography
2
2
  module Processors
3
3
  class DoubleQuotes < Processor
4
4
  def call
5
+ return str unless str.match?(/[\"#{double_quotes[0]}#{double_quotes[1]}]/)
5
6
  replace_double_quotes
6
7
  end
7
8
 
@@ -5,6 +5,7 @@ module ImproveTypography
5
5
 
6
6
  def call
7
7
  return str unless ellipsis_sign
8
+ return str unless str.match?(REGEXP)
8
9
 
9
10
  str.gsub(REGEXP, ellipsis_sign)
10
11
  end
@@ -4,6 +4,7 @@ module ImproveTypography
4
4
  REGEXP = /(\w+?)\s+-{1,3}\s+(\w+?)/i
5
5
 
6
6
  def call
7
+ return str unless str.match?(/-{1,3}/)
7
8
  str.gsub(REGEXP, '\1'+em_dash_sign+'\2')
8
9
  end
9
10
 
@@ -4,6 +4,7 @@ module ImproveTypography
4
4
  REGEXP = /(\w+?)\s+-{1,2}\s+(\w+?)/i
5
5
 
6
6
  def call
7
+ return str unless str.match?(/-{1,3}/)
7
8
  str.gsub(REGEXP, '\1'+en_dash_sign+'\2')
8
9
  end
9
10
 
@@ -5,6 +5,7 @@ module ImproveTypography
5
5
 
6
6
  def call
7
7
  return str unless multiply_sign
8
+ return str unless str.match?(REGEXP)
8
9
 
9
10
  str.gsub(REGEXP, '\1'+multiply_sign+'\4')
10
11
  end
@@ -2,6 +2,8 @@ module ImproveTypography
2
2
  module Processors
3
3
  class Nbsp < Processor
4
4
  def call
5
+ return str unless str.match?(/(\A|\s+)(\S|\d+)([\.?!]?)(\s+|\z)/)
6
+
5
7
  str
6
8
  .gsub(/(\s+)(\S|\d+|\S\.)(\s+)(\S)/, '\1\2&nbsp;\4') # in the middle of string
7
9
  .gsub(/\A(\w|\d+|\w\.)(\s+)(\S)/, '\1&nbsp;\3') # at the beginning of string
@@ -2,6 +2,7 @@ module ImproveTypography
2
2
  module Processors
3
3
  class SingleQuotes < Processor
4
4
  def call
5
+ return str unless str.match?(/[\'#{single_quotes[0]}#{single_quotes[1]}]/)
5
6
  replace_single_quotes
6
7
  end
7
8
 
@@ -4,6 +4,7 @@ module ImproveTypography
4
4
  REGEXP = /(\d\s*)(m|mm|cm|km)(2|3)/
5
5
 
6
6
  def call
7
+ return str unless str.match?(REGEXP)
7
8
  str.gsub(REGEXP, '\1\2<sup>\3</sup>')
8
9
  end
9
10
  end
@@ -4,6 +4,7 @@ module ImproveTypography
4
4
  REGEXP = /\u2028/
5
5
 
6
6
  def call
7
+ return str unless str.match?(REGEXP)
7
8
  str.gsub(REGEXP, "\n")
8
9
  end
9
10
  end
@@ -1,3 +1,3 @@
1
1
  module ImproveTypography
2
- VERSION = '0.1.13'.freeze
2
+ VERSION = '0.1.14'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: improve_typography
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-12 00:00:00.000000000 Z
11
+ date: 2018-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n