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 +4 -4
- data/features/typogrowth.feature +13 -1
- data/lib/config/typogrowth.yaml +4 -0
- data/lib/typogrowth.rb +3 -1
- data/lib/typogrowth/string.rb +2 -2
- data/lib/typogrowth/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53a02d4e8ed6d038744689a72340501f7320edbd
|
4
|
+
data.tar.gz: 13da2fe67adcd6bfb6794f97371badaf639bf16a
|
5
5
|
!binary "U0hBNTEy":
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1843bc3d26f9a29e4c5ae603a1778ead2534007a0343723445c114440551198999db0420d7abfc084c7ea0e5d60d25bec38437a112a26cda8f1e26332e46926a
|
7
|
+
data.tar.gz: 897f8982e04275fc5529ba666c1317493d43f3e9a8a5159a50aad8d07b9aad4d1d209402c6261800584fbf44ac51448364fb78372cc572f2cfdc3b8536acc5ef
|
data/features/typogrowth.feature
CHANGED
@@ -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
|
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
|
+
|
data/lib/config/typogrowth.yaml
CHANGED
data/lib/typogrowth.rb
CHANGED
@@ -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
|
-
|
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: []
|
data/lib/typogrowth/string.rb
CHANGED
@@ -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 = []
|
data/lib/typogrowth/version.rb
CHANGED