improve_typography 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/improve_typography/base.rb +11 -10
- data/lib/improve_typography/version.rb +1 -1
- 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: '0225787642879143122ffa300d01e2f69c903d9a'
|
4
|
+
data.tar.gz: 64ef49fbdf4b0e413cdf0a44e16c4427b650c8de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a056252bc24e78bdd0f41118e3cde2105ed1f9b38d097106ea871c4c18dcad27dc3f9ee577da7be5ebc6bfa0447a064c5af24ea71121b30485db0a011d74b65
|
7
|
+
data.tar.gz: e04674c1ebb7417e2621ea988683f9bbe1e8afd9343d88329fda7c9e7a5b1b5c7a04293764c5b68acccab1a553eff687d64c81b90be6296347a127ca8006493c
|
@@ -11,25 +11,23 @@ module ImproveTypography
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def call
|
14
|
-
|
14
|
+
doc.xpath('.//text()').each do |node|
|
15
15
|
processor_classes.each do |processor|
|
16
16
|
node.content = processor.call(node.content, options)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
CGI.unescapeHTML
|
20
|
+
CGI.unescapeHTML(
|
21
|
+
doc.to_html.strip[5..-7]
|
22
|
+
)
|
21
23
|
end
|
22
24
|
|
23
|
-
private
|
25
|
+
private
|
24
26
|
|
25
27
|
def doc
|
26
28
|
@doc ||= Nokogiri::HTML::DocumentFragment.parse("<div>#{str}</div>")
|
27
29
|
end
|
28
30
|
|
29
|
-
def text_nodes
|
30
|
-
doc.xpath('.//text()')
|
31
|
-
end
|
32
|
-
|
33
31
|
def configuration
|
34
32
|
@configuration ||= Configuration.new
|
35
33
|
end
|
@@ -49,9 +47,12 @@ module ImproveTypography
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def processor_for_locale(klass)
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
@processor_for_locale ||= {}
|
51
|
+
@processor_for_locale[klass] ||= begin
|
52
|
+
name = klass.to_s.split('::').last
|
53
|
+
locale_specific_klass = "ImproveTypography::Processors::#{locale.to_s.upcase}::#{name}"
|
54
|
+
all_processor_classes.detect { |cls| cls.to_s == locale_specific_klass } || klass
|
55
|
+
end
|
55
56
|
end
|
56
57
|
|
57
58
|
def locale
|
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.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|