evil-front 0.3.6 → 0.3.7
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 +4 -4
- data/ChangeLog.md +4 -0
- data/lib/evil-front/russian.rb +4 -1
- data/lib/evil-front/typograph.rb +0 -1
- data/lib/evil-front/version.rb +1 -1
- data/spec/english_spec.rb +4 -4
- data/spec/helpers_spec.rb +26 -25
- data/spec/russian_spec.rb +30 -25
- data/spec/sass_spec.rb +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d96eb4951a8bdbffddf9a0ef42f019779815c47
|
4
|
+
data.tar.gz: be71847e890181a430ffb82dd809aef78a653dcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac095442776a4cc72d4ad17fe0a0c568cfe2218cefca03b2782074ebf27c89d68d481f640459638b2de202211e723326e5270f9471b203b2e228144fdc58d46f
|
7
|
+
data.tar.gz: 9f7b2aab0ca2560f2c2a6502ccd6f1553d3ff3df60e6a3be3c83afe518c6487c47731dcbd7ccdc1d2aceeb4d7595c33f725c98d141ef7cb990e3a128c35e4181
|
data/ChangeLog.md
CHANGED
data/lib/evil-front/russian.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'unicode_utils'
|
4
|
+
# encoding: utf-8
|
5
|
+
|
4
6
|
require 'standalone_typograf'
|
5
7
|
|
6
8
|
module EvilFront
|
@@ -46,7 +48,8 @@ module EvilFront
|
|
46
48
|
# Replace symbols to right ones, like m-dash, quotes, etc.
|
47
49
|
def self.use_right_symbols(text)
|
48
50
|
StandaloneTypograf::Typograf.new(text).prepare
|
49
|
-
.gsub(' —', ' —')
|
51
|
+
.gsub(' —', ' —') # nbsp before m-dash
|
52
|
+
.gsub(/([а-яА-Я])-([а-яА-Я])/, '\1‑\2') # non-break dash
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
data/lib/evil-front/typograph.rb
CHANGED
data/lib/evil-front/version.rb
CHANGED
data/spec/english_spec.rb
CHANGED
@@ -10,19 +10,19 @@ describe EvilFront::English do
|
|
10
10
|
describe 'typograph' do
|
11
11
|
|
12
12
|
it 'changes quotes' do
|
13
|
-
nbsp_mark_typograph('"a".').
|
13
|
+
expect(nbsp_mark_typograph('"a".')).to eq '“a”.'
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'changes dashes' do
|
17
|
-
nbsp_mark_typograph('a - b').
|
17
|
+
expect(nbsp_mark_typograph('a - b')).to eq 'a - b'
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'changes ellipsis' do
|
21
|
-
nbsp_mark_typograph('a...').
|
21
|
+
expect(nbsp_mark_typograph('a...')).to eq 'a…'
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'inserts non-break spaces' do
|
25
|
-
nbsp_mark_typograph('he is a hero').
|
25
|
+
expect(nbsp_mark_typograph('he is a hero')).to eq 'he is_a_hero'
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
data/spec/helpers_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe EvilFront::Helpers do
|
|
9
9
|
describe 'capitalize_first' do
|
10
10
|
|
11
11
|
it 'capitalizes Russian' do
|
12
|
-
capitalize_first('тест').
|
12
|
+
expect(capitalize_first('тест')).to eq 'Тест'
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -17,7 +17,7 @@ describe EvilFront::Helpers do
|
|
17
17
|
describe 'disable_mobile_zoom' do
|
18
18
|
|
19
19
|
it 'returns viewport meta tag' do
|
20
|
-
disable_mobile_zoom.
|
20
|
+
expect(disable_mobile_zoom).to match(/^<meta name="viewport" /)
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -25,14 +25,15 @@ describe EvilFront::Helpers do
|
|
25
25
|
describe 'flying_quotes' do
|
26
26
|
|
27
27
|
it 'set quotes to text' do
|
28
|
-
flying_quotes('a').
|
29
|
-
|
28
|
+
expect(flying_quotes('a')).to eq(
|
29
|
+
'<span class="space-before-quote"> </span>' +
|
30
|
+
'<span class="quotes">«a»</span>')
|
30
31
|
end
|
31
32
|
|
32
33
|
it 'escapes HTML' do
|
33
|
-
flying_quotes('<br>').
|
34
|
+
expect(flying_quotes('<br>')).to eq(
|
34
35
|
'<span class="space-before-quote"> </span>' +
|
35
|
-
'<span class="quotes">«<br>»</span>'
|
36
|
+
'<span class="quotes">«<br>»</span>')
|
36
37
|
end
|
37
38
|
|
38
39
|
end
|
@@ -40,15 +41,15 @@ describe EvilFront::Helpers do
|
|
40
41
|
describe 'auto_flying_quotes' do
|
41
42
|
|
42
43
|
it 'set quotes to text' do
|
43
|
-
auto_flying_quotes('от «a»').
|
44
|
+
expect(auto_flying_quotes('от «a»')).to eq(
|
44
45
|
'от<span class="space-before-quote"> </span>' +
|
45
|
-
'<span class="quotes">«a»</span>'
|
46
|
+
'<span class="quotes">«a»</span>')
|
46
47
|
end
|
47
48
|
|
48
49
|
it 'escapes HTML' do
|
49
|
-
auto_flying_quotes('от «<br>»').
|
50
|
+
expect(auto_flying_quotes('от «<br>»')).to eq(
|
50
51
|
'от<span class="space-before-quote"> </span>' +
|
51
|
-
'<span class="quotes">«<br>»</span>'
|
52
|
+
'<span class="quotes">«<br>»</span>')
|
52
53
|
end
|
53
54
|
|
54
55
|
end
|
@@ -56,7 +57,7 @@ describe EvilFront::Helpers do
|
|
56
57
|
describe 'ruble' do
|
57
58
|
|
58
59
|
it 'returns span' do
|
59
|
-
ruble.
|
60
|
+
expect(ruble).to be_a(String)
|
60
61
|
end
|
61
62
|
|
62
63
|
end
|
@@ -65,11 +66,11 @@ describe EvilFront::Helpers do
|
|
65
66
|
|
66
67
|
it 'typographs text inside tags' do
|
67
68
|
tag = '<a title="а...">а...</a>'.html_safe
|
68
|
-
russian_typograph(tag).
|
69
|
+
expect(russian_typograph(tag)).to eq'<a title="а...">а…</a>'
|
69
70
|
end
|
70
71
|
|
71
72
|
it 'escapes HTML' do
|
72
|
-
russian_typograph('<a>').
|
73
|
+
expect(russian_typograph('<a>')).to eq '<a>'
|
73
74
|
end
|
74
75
|
|
75
76
|
end
|
@@ -78,11 +79,11 @@ describe EvilFront::Helpers do
|
|
78
79
|
|
79
80
|
it 'typographs text inside tags' do
|
80
81
|
tag = '<a title="a...">a...</a>'.html_safe
|
81
|
-
english_typograph(tag).
|
82
|
+
expect(english_typograph(tag)).to eq '<a title="a...">a…</a>'
|
82
83
|
end
|
83
84
|
|
84
85
|
it 'escapes HTML' do
|
85
|
-
english_typograph('<a>').
|
86
|
+
expect(english_typograph('<a>')).to eq '<a>'
|
86
87
|
end
|
87
88
|
|
88
89
|
end
|
@@ -94,15 +95,15 @@ describe EvilFront::Helpers do
|
|
94
95
|
|
95
96
|
it 'typographs by current locale' do
|
96
97
|
I18n.locale = :en
|
97
|
-
typograph_by_locale('"a"').
|
98
|
+
expect(typograph_by_locale('"a"')).to eq '“a”'
|
98
99
|
|
99
100
|
I18n.locale = :ru
|
100
|
-
typograph_by_locale('"a"').
|
101
|
+
expect(typograph_by_locale('"a"')).to eq '«a»'
|
101
102
|
end
|
102
103
|
|
103
104
|
it 'returns origin text on unknown locale' do
|
104
105
|
I18n.locale = :fr
|
105
|
-
typograph_by_locale('"a"').
|
106
|
+
expect(typograph_by_locale('"a"')).to eq '"a"'
|
106
107
|
end
|
107
108
|
|
108
109
|
end
|
@@ -114,37 +115,37 @@ describe EvilFront::Helpers do
|
|
114
115
|
end
|
115
116
|
|
116
117
|
it 'shows site name' do
|
117
|
-
title_tag('Site').
|
118
|
+
expect(title_tag('Site')).to eq '<title>Site</title>'
|
118
119
|
end
|
119
120
|
|
120
121
|
it 'shows site names' do
|
121
|
-
title_tag('One', 'Two').
|
122
|
+
expect(title_tag('One', 'Two')).to eq '<title>One - Two</title>'
|
122
123
|
end
|
123
124
|
|
124
125
|
it 'shows page name' do
|
125
126
|
title 'Page', 'Section'
|
126
|
-
title_tag('Site').
|
127
|
+
expect(title_tag('Site')).to eq '<title>Page - Section - Site</title>'
|
127
128
|
end
|
128
129
|
|
129
130
|
it 'shows Russian separator' do
|
130
131
|
I18n.locale = :ru
|
131
132
|
title 'Страница', 'Раздел'
|
132
|
-
title_tag('Сайт').
|
133
|
+
expect(title_tag('Сайт')).to eq '<title>Страница — Раздел — Сайт</title>'
|
133
134
|
end
|
134
135
|
|
135
136
|
it 'shows custom separator' do
|
136
137
|
title 'One', 'Two'
|
137
|
-
title_tag(separator: ' | ').
|
138
|
+
expect(title_tag(separator: ' | ')).to eq '<title>One | Two</title>'
|
138
139
|
end
|
139
140
|
|
140
141
|
it 'escapes HTML' do
|
141
142
|
title '<B>'
|
142
|
-
title_tag.
|
143
|
+
expect(title_tag).to eq '<title><B></title>'
|
143
144
|
end
|
144
145
|
|
145
146
|
it 'hides site name on request' do
|
146
147
|
title 'Page', no_site: true
|
147
|
-
title_tag('Site').
|
148
|
+
expect(title_tag('Site')).to eq '<title>Page</title>'
|
148
149
|
end
|
149
150
|
|
150
151
|
end
|
data/spec/russian_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe EvilFront::Russian do
|
|
7
7
|
describe 'capitalize_first' do
|
8
8
|
|
9
9
|
it 'capitalizes first letter in russian text' do
|
10
|
-
EvilFront::Russian.capitalize_first('тест тест').
|
10
|
+
expect(EvilFront::Russian.capitalize_first('тест тест')).to eq 'Тест тест'
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
@@ -15,20 +15,20 @@ describe EvilFront::Russian do
|
|
15
15
|
describe 'flying_quotes' do
|
16
16
|
|
17
17
|
it 'inserts tags and quotes with space by default' do
|
18
|
-
EvilFront::Russian.flying_quotes('тест').
|
18
|
+
expect(EvilFront::Russian.flying_quotes('тест')).to eq(
|
19
19
|
'<span class="space-before-quote"> </span>' +
|
20
|
-
'<span class="quotes">«тест»</span>'
|
20
|
+
'<span class="quotes">«тест»</span>')
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'inserts specified space' do
|
24
|
-
EvilFront::Russian.flying_quotes('тест', space: '-').
|
24
|
+
expect(EvilFront::Russian.flying_quotes('тест', space: '-')).to eq(
|
25
25
|
'<span class="space-before-quote">-</span>' +
|
26
|
-
'<span class="quotes">«тест»</span>'
|
26
|
+
'<span class="quotes">«тест»</span>')
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'ignores space on request' do
|
30
|
-
EvilFront::Russian.flying_quotes('тест', space: '').
|
31
|
-
'<span class="quotes">«тест»</span>'
|
30
|
+
expect(EvilFront::Russian.flying_quotes('тест', space: '')).to eq(
|
31
|
+
'<span class="quotes">«тест»</span>')
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
@@ -36,19 +36,19 @@ describe EvilFront::Russian do
|
|
36
36
|
describe 'auto_flying_quotes' do
|
37
37
|
|
38
38
|
it 'replaces quotes on start' do
|
39
|
-
EvilFront::Russian.auto_flying_quotes('«тест»').
|
40
|
-
'<span class="quotes">«тест»</span>'
|
39
|
+
expect(EvilFront::Russian.auto_flying_quotes('«тест»')).to eq(
|
40
|
+
'<span class="quotes">«тест»</span>')
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'replaces quotes in middle' do
|
44
|
-
EvilFront::Russian.auto_flying_quotes('на «тесте».').
|
44
|
+
expect(EvilFront::Russian.auto_flying_quotes('на «тесте».')).to eq(
|
45
45
|
'на<span class="space-before-quote"> </span>' +
|
46
|
-
'<span class="quotes">«тесте»</span>.'
|
46
|
+
'<span class="quotes">«тесте»</span>.')
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'works with HTML' do
|
50
|
-
EvilFront::Russian.auto_flying_quotes('<a>«ссылка»</a>').
|
51
|
-
'<a><span class="quotes">«ссылка»</span></a>'
|
50
|
+
expect(EvilFront::Russian.auto_flying_quotes('<a>«ссылка»</a>')).to eq(
|
51
|
+
'<a><span class="quotes">«ссылка»</span></a>')
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
@@ -59,20 +59,25 @@ describe EvilFront::Russian do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'changes quotes' do
|
62
|
-
nbsp_mark_typograph('сказал "смотри "зорко"".').
|
63
|
-
'сказал «смотри „зорко“».'
|
62
|
+
expect(nbsp_mark_typograph('сказал "смотри "зорко"".')).to eq(
|
63
|
+
'сказал «смотри „зорко“».')
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'changes dashes' do
|
67
|
-
nbsp_mark_typograph('а - это б').
|
67
|
+
expect(nbsp_mark_typograph('а - это б')).to eq 'а_— это_б'
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'changes ellipsis' do
|
71
|
-
nbsp_mark_typograph('а...').
|
71
|
+
expect(nbsp_mark_typograph('а...')).to eq 'а…'
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'inserts non-break spaces' do
|
75
|
-
nbsp_mark_typograph('оно не надо').
|
75
|
+
expect(nbsp_mark_typograph('оно не надо')).to eq 'оно не_надо'
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'uses non-break dash on for Russian' do
|
79
|
+
expect(nbsp_mark_typograph('web-standards.ru')).to eq 'web-standards.ru'
|
80
|
+
expect(nbsp_mark_typograph('а-то')).to eq 'а‑то'
|
76
81
|
end
|
77
82
|
|
78
83
|
end
|
@@ -80,22 +85,22 @@ describe EvilFront::Russian do
|
|
80
85
|
describe 'typograph_html' do
|
81
86
|
|
82
87
|
it 'typographs plain text' do
|
83
|
-
EvilFront::Russian.typograph_html('а...').
|
88
|
+
expect(EvilFront::Russian.typograph_html('а...')).to eq 'а…'
|
84
89
|
end
|
85
90
|
|
86
91
|
it 'typographs only in text nodes' do
|
87
|
-
EvilFront::Russian.typograph_html('<a title="а...">а...</a>').
|
88
|
-
'<a title="а...">а…</a>'
|
92
|
+
expect(EvilFront::Russian.typograph_html('<a title="а...">а...</a>')).
|
93
|
+
to eq '<a title="а...">а…</a>'
|
89
94
|
end
|
90
95
|
|
91
96
|
it 'ignores code tags' do
|
92
|
-
EvilFront::Russian.typograph_html('<code>а...</code>').
|
93
|
-
'<code>а...</code>'
|
97
|
+
expect(EvilFront::Russian.typograph_html('<code>а...</code>')).
|
98
|
+
to eq '<code>а...</code>'
|
94
99
|
end
|
95
100
|
|
96
101
|
it 'keeps escaping' do
|
97
|
-
EvilFront::Russian.typograph_html('<b><a></b>').
|
98
|
-
'<b><a></b>'
|
102
|
+
expect(EvilFront::Russian.typograph_html('<b><a></b>')).
|
103
|
+
to eq '<b><a></b>'
|
99
104
|
end
|
100
105
|
|
101
106
|
end
|
data/spec/sass_spec.rb
CHANGED
@@ -14,27 +14,27 @@ describe 'Sass Helpers' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'loads Rails Sass Images' do
|
17
|
-
@assets['load'].to_s.
|
17
|
+
expect(@assets['load'].to_s).to match(/data:text\/plain/)
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'loads variables, functions and mixins' do
|
21
21
|
load = @assets['load'].to_s
|
22
|
-
load.
|
23
|
-
load.
|
24
|
-
load.
|
22
|
+
expect(load).to match(/rgba\(0, 0, 0, 0.5\)/)
|
23
|
+
expect(load).to match(/cubic-bezier\(0.47, 0, 0.745, 0.715\)/)
|
24
|
+
expect(load).to match(/a:after/)
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '+import-ruble' do
|
28
28
|
|
29
29
|
it 'adds font-faces and .ruble' do
|
30
30
|
ruble = @assets['ruble'].to_s
|
31
|
-
ruble.
|
32
|
-
ruble.
|
31
|
+
expect(ruble).to match(/font-family: ALSRubl-Arial, PT Sans, sans-serif/)
|
32
|
+
expect(ruble).not_to match(/font-woff;base64/)
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'inlines specified fonts' do
|
36
36
|
ruble = @assets['inline-ruble'].to_s
|
37
|
-
ruble.
|
37
|
+
expect(ruble).to match(/font-style: italic;\s*src: url\('data/n)
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -45,11 +45,11 @@ describe 'Sass Helpers' do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'receives size without units' do
|
48
|
-
@media.
|
48
|
+
expect(@media).to match(/max-width: 100px/)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'receives size with units' do
|
52
|
-
@media.
|
52
|
+
expect(@media).to match(/min-width: 200px/)
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
@@ -60,15 +60,15 @@ describe 'Sass Helpers' do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'receives 2 sizes' do
|
63
|
-
@size.
|
63
|
+
expect(@size).to match(/.all {\s*width: 10px;\s*height: 20px; }/)
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'receives 1 sizes' do
|
67
|
-
@size.
|
67
|
+
expect(@size).to match(/.one {\s*width: 30px;\s*height: 30px; }/)
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'receives size without unit' do
|
71
|
-
@size.
|
71
|
+
expect(@size).to match(/.no-unit {\s*width: 15px;\s*height: 15px; }/)
|
72
72
|
end
|
73
73
|
|
74
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evil-front
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Sitnik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|