sterile 1.0.4 → 1.0.5

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: b0b5683d7e6b1288d13ae6d324cae8b88899ac0e
4
- data.tar.gz: 971ee96c2c6cec81e82c044cba65bb12569880d8
3
+ metadata.gz: 85e53308dc320efc61be6fbdc227a423c5e8832c
4
+ data.tar.gz: 40015a58adfdfcbe8499590e0562dceedb435a31
5
5
  SHA512:
6
- metadata.gz: 04607f2fd7a9ed4f433c8aef4f5437fb691c62acfbb67ca42d758d4699b6042c36284efecacf6f8e3f7f648a9d51152107ec2608dbdd265dc3db6928365e3833
7
- data.tar.gz: ca3ac6882004ad4c9646aab748298a3ec8f77ca5a05770452213242c0b590e7786f84d8eb8ec3624987ccca03f3e72b3758466cdff8a7c1d6a1ab389308c95c3
6
+ metadata.gz: 871f81c39318b7ad549ffd0da0b2d4efc96719271743ef5687b25eb4226272a8c6903d18d233b1b922f90029f5205787b68e73207f202dc1e7368fc3c9a49811
7
+ data.tar.gz: a19a0ab41a05582ee6d8182d9cb0b5788439ed330de04b71e278c83ad8c9ddf7a097a2229770e0f3991042115a6d3ad050ed526653ab2c657703355b03920c85
@@ -20,8 +20,8 @@ module Sterile
20
20
  #
21
21
  def smart_format_tags(string)
22
22
  string.gsub_tags do |text|
23
- text.smart_format.encode_entities
24
- end
23
+ text.smart_format
24
+ end.encode_entities
25
25
  end
26
26
 
27
27
 
@@ -39,3 +39,4 @@ module Sterile
39
39
  end # class << self
40
40
 
41
41
  end # module Sterile
42
+
data/lib/sterile/tags.rb CHANGED
@@ -55,9 +55,11 @@ module Sterile
55
55
  def gsub_tags(string, &block)
56
56
  raise "No block given" unless block_given?
57
57
 
58
- string.gsub(/(<[^>]*>)|([^<]+)/) do |match|
59
- $2 ? yield($2) : $1
58
+ fragment = Nokogiri::HTML::DocumentFragment.parse string
59
+ fragment.traverse do |node|
60
+ node.content = yield(node.content) if node.text?
60
61
  end
62
+ fragment.to_html
61
63
  end
62
64
 
63
65
 
@@ -68,9 +70,11 @@ module Sterile
68
70
  def scan_tags(string, &block)
69
71
  raise "No block given" unless block_given?
70
72
 
71
- string.scan(/(<[^>]*>)|([^<]+)/) do |match|
72
- yield($2) unless $2.nil?
73
+ fragment = Nokogiri::HTML::DocumentFragment.parse string
74
+ fragment.traverse do |node|
75
+ yield(node.content) if node.text?
73
76
  end
77
+ nil
74
78
  end
75
79
 
76
80
  end # class << self
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Sterile
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.5"
5
5
  end
6
6
 
data/sterile.gemspec CHANGED
@@ -15,10 +15,11 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.rubyforge_project = "sterile"
17
17
 
18
- # s.add_dependency("nokogiri")
18
+ s.add_dependency("nokogiri")
19
19
 
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
22
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
23
  s.require_paths = ["lib"]
24
24
  end
25
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sterile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Hogan
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-09-15 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Sterilize your strings! Transliterate, generate slugs, smart format,
14
28
  strip tags, encode/decode entities and more.
15
29
  email: