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 +4 -4
- data/lib/sterile/smart_format.rb +3 -2
- data/lib/sterile/tags.rb +8 -4
- data/lib/sterile/version.rb +1 -1
- data/sterile.gemspec +2 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85e53308dc320efc61be6fbdc227a423c5e8832c
|
4
|
+
data.tar.gz: 40015a58adfdfcbe8499590e0562dceedb435a31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 871f81c39318b7ad549ffd0da0b2d4efc96719271743ef5687b25eb4226272a8c6903d18d233b1b922f90029f5205787b68e73207f202dc1e7368fc3c9a49811
|
7
|
+
data.tar.gz: a19a0ab41a05582ee6d8182d9cb0b5788439ed330de04b71e278c83ad8c9ddf7a097a2229770e0f3991042115a6d3ad050ed526653ab2c657703355b03920c85
|
data/lib/sterile/smart_format.rb
CHANGED
@@ -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
|
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
|
-
|
59
|
-
|
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
|
-
|
72
|
-
|
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
|
data/lib/sterile/version.rb
CHANGED
data/sterile.gemspec
CHANGED
@@ -15,10 +15,11 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.rubyforge_project = "sterile"
|
17
17
|
|
18
|
-
|
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
|
+
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:
|