typogrowth 0.9.5 → 0.9.7

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
  !binary "U0hBMQ==":
3
- metadata.gz: b2fec1cd3faf12f3d9572b3ce6212e656426276c
4
- data.tar.gz: ecc1a510f6fda9e9f40b71a93c61a2c03ecae9e7
3
+ metadata.gz: 53a02d4e8ed6d038744689a72340501f7320edbd
4
+ data.tar.gz: 13da2fe67adcd6bfb6794f97371badaf639bf16a
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: 421b2b311fe83738d9be9498334abf69005be6085ba30d47be3f41afece162d850f71340c88857c4a0b8ba998cb5c4261192d3013cd69c8b05b354fb570dd758
7
- data.tar.gz: c4dd0579e140938e3b63177998ad6bdb5b5e3ea2ac821207c023a4bc90aa5f4eecbf06c0f22d93ba05eda6b36c7ce9870b6068b06d8c77229a3035a39d065fbc
6
+ metadata.gz: 1843bc3d26f9a29e4c5ae603a1778ead2534007a0343723445c114440551198999db0420d7abfc084c7ea0e5d60d25bec38437a112a26cda8f1e26332e46926a
7
+ data.tar.gz: 897f8982e04275fc5529ba666c1317493d43f3e9a8a5159a50aad8d07b9aad4d1d209402c6261800584fbf44ac51448364fb78372cc572f2cfdc3b8536acc5ef
@@ -51,6 +51,7 @@ Feature: Text is to be typographed (spacing and pubctuation are to be sanitized)
51
51
  | "Here are ' english ' quotes . ." | "Here are ‘english’ quotes.." |
52
52
  | "Here are " english " quotes . ." | "Here are “english” quotes.." |
53
53
  | "Here we go : colon . ." | "Here we go: colon.." |
54
+ | "Here are ( brackets ) parenthesis." | "Here are (brackets) parenthesis." |
54
55
 
55
56
  Scenario: Inplace string modification
56
57
  Given the input string is "Foo 'Bar' Baz"
@@ -77,7 +78,7 @@ Feature: Text is to be typographed (spacing and pubctuation are to be sanitized)
77
78
  | input | output |
78
79
  | "<p><img src="http://mudasobwa.ru/i/self.jpg">Here: http://wikipedia.ru</p>" | "<p><img src="http://mudasobwa.ru/i/self.jpg">Here: http://wikipedia.ru</p>" |
79
80
 
80
- Scenario Outline: Language determining
81
+ Scenario Outline: Language recognition
81
82
  Given the input string is <input>
82
83
  When input string language is determined
83
84
  Then the language should equal to <output>
@@ -86,3 +87,14 @@ Feature: Text is to be typographed (spacing and pubctuation are to be sanitized)
86
87
  | input | output |
87
88
  | "<p><img src="http://mudasobwa.ru/i/self.jpg">Here: http://wikipedia.ru</p>" | "us" |
88
89
  | "<p><img src="http://mudasobwa.ru/i/self.jpg">Здесь: http://wikipedia.ru</p>" | "ru" |
90
+
91
+ Scenario Outline: Language punctuation
92
+ Given the input string is <input>
93
+ When input string is processed with Typogrowl’s typography parser
94
+ Then the call to string’s typo should equal to <output>
95
+
96
+ Examples:
97
+ | input | output |
98
+ | "Here 'you' go." | "Here “you” go." |
99
+ | "Тут 'русский' язык." | "Тут «русский» язык." |
100
+
@@ -152,3 +152,7 @@
152
152
  :re : '\s+(p{Punct})(?=\s|\Z)'
153
153
  :default :
154
154
  - ' \1'
155
+ :extra_spaces :
156
+ :re : '\s+'
157
+ :default :
158
+ - ' '
@@ -154,7 +154,7 @@ module Typogrowth
154
154
 
155
155
  # Out-of-place version of `String` typographing. See #parse!
156
156
  def self.is_ru? str, shadows: []
157
- Parser.new.is_ru? str, shadows: shadows
157
+ @@instance.is_ru? str, shadows: shadows
158
158
  end
159
159
 
160
160
  DEFAULT_SET = 'typogrowth'
@@ -167,6 +167,8 @@ module Typogrowth
167
167
  @shadows = [HTML_TAG_RE, URI.regexp(['ftp', 'http', 'https', 'mailto'])]
168
168
  end
169
169
 
170
+ # Ready-to-use single instance
171
+ @@instance = Parser.new
170
172
  end
171
173
 
172
174
  def self.parse str, lang: :default, shadows: []
@@ -7,12 +7,12 @@ class String
7
7
  # Typographyes the string and returns a result
8
8
  # See Typogrowth::Parser#parse
9
9
  def typo lang = nil
10
- Typogrowth.parse(self, lang: lang ? lang : I18n.locale)
10
+ Typogrowth.parse(self, lang: lang ? lang : is_ru? ? "ru" : I18n.locale)
11
11
  end
12
12
  # Typographyes the string inplace
13
13
  # See Typogrowth::Parser#parse!
14
14
  def typo! lang = nil
15
- Typogrowth.parse!(self, lang: lang ? lang : I18n.locale)
15
+ Typogrowth.parse!(self, lang: lang ? lang : is_ru? ? "ru" : I18n.locale)
16
16
  end
17
17
 
18
18
  def is_ru? shadows = []
@@ -1,3 +1,3 @@
1
1
  module Typogrowth
2
- VERSION = "0.9.5"
2
+ VERSION = "0.9.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typogrowth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexei Matyushkin