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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15de4945fe7e742d77f6bab3f6899c8311ea9b28
4
- data.tar.gz: da8c36060a8b50d0771f123668baa62b4f12b3c6
3
+ metadata.gz: '0225787642879143122ffa300d01e2f69c903d9a'
4
+ data.tar.gz: 64ef49fbdf4b0e413cdf0a44e16c4427b650c8de
5
5
  SHA512:
6
- metadata.gz: cf287039ae45d750ce6995d0b4ddd6cf6d04402d26dbabd2500e71c059ad6c59300ad21812d1c563fe88eeac9f2869a77f1f72280e1b5d54a86fcae012223392
7
- data.tar.gz: 4c9e35546556bfb94514115542bba1e800b60452452eb242751c0991df158d6ae96be6d2e9da054f209a3dadd934f2968e26d8735b120ae4cbd21ed4c0960e15
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
- text_nodes.each do |node|
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 doc.to_html.gsub(/\A<div>/, '').gsub(/<\/\s*div>\z/, '').chomp
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
- 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
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
@@ -1,3 +1,3 @@
1
1
  module ImproveTypography
2
- VERSION = '0.1.9'.freeze
2
+ VERSION = '0.1.10'.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.9
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-10-06 00:00:00.000000000 Z
11
+ date: 2017-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n