sterile 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -1
- data/lib/sterile/data/plain_format_rules.rb +45 -0
- data/lib/sterile/data/smart_format_rules.rb +1 -1
- data/lib/sterile/plain_format.rb +39 -0
- data/lib/sterile/smart_format.rb +1 -1
- data/lib/sterile/tags.rb +2 -0
- data/lib/sterile/version.rb +1 -1
- data/lib/sterile.rb +1 -0
- data/sterile +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 242ff144553ae8fcc742866d19685e5682f6f8ae
|
4
|
+
data.tar.gz: 303bcb379f93d8bbd62aac30e5a33a84bfb12294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d281666a0ded129a24beede55231f313408d00db70d0f955af9ed776a8b97aa8d5d1b93e24856141d10eca7c6e3ae5ce599d47943f3c3ce80e7d89db3e8599a
|
7
|
+
data.tar.gz: 1f3e3c4b0ef9583691bc3df2aaa31292972f6473c2ab472be2851166285bbbdb683abf8032ef1bd70d3ac1ef35d6c9f362fd4fed95257b4a7bd9117249729fc3
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Sterile
|
4
|
+
# @private
|
5
|
+
class Data
|
6
|
+
def self.plain_format_rules
|
7
|
+
[
|
8
|
+
['“', '"'],
|
9
|
+
['”', '"'],
|
10
|
+
['“', '"'],
|
11
|
+
['”', '"'],
|
12
|
+
['‘', "'"],
|
13
|
+
['’', "'"],
|
14
|
+
['‘', "'"],
|
15
|
+
['’', "'"],
|
16
|
+
['—', '--'],
|
17
|
+
['—', '--'],
|
18
|
+
['…', '...'],
|
19
|
+
['…', '...'],
|
20
|
+
['©', '(c)'],
|
21
|
+
['©', '(c)'],
|
22
|
+
['™', '(tm)'],
|
23
|
+
['™', '(tm)'],
|
24
|
+
['×', 'x'],
|
25
|
+
['×', 'x'],
|
26
|
+
['′', "'"],
|
27
|
+
['′', "'"],
|
28
|
+
['″', '"'],
|
29
|
+
['″', '"'],
|
30
|
+
['"', '"'],
|
31
|
+
['­', ''],
|
32
|
+
['
', ''],
|
33
|
+
['’', "'"],
|
34
|
+
['‘', "'"],
|
35
|
+
['”', '"'],
|
36
|
+
['“', '"'],
|
37
|
+
# [145.chr, "'"],
|
38
|
+
# [146.chr, "'"],
|
39
|
+
# [147.chr, '"'],
|
40
|
+
# [148.chr, '"'],
|
41
|
+
# [151.chr, "--"],
|
42
|
+
]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Sterile
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def plain_format(string)
|
8
|
+
string = string.encode_entities
|
9
|
+
plain_format_rules.each do |rule|
|
10
|
+
string.gsub! rule[0], rule[1]
|
11
|
+
end
|
12
|
+
string
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
# Like +plain_format+, but works with HTML/XML (somewhat).
|
17
|
+
#
|
18
|
+
def plain_format_tags(string)
|
19
|
+
string.gsub_tags do |text|
|
20
|
+
text.plain_format
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Lazy load plain formatting rules
|
28
|
+
#
|
29
|
+
def plain_format_rules
|
30
|
+
@plain_format_rules ||= begin
|
31
|
+
require "sterile/data/plain_format_rules"
|
32
|
+
Data.plain_format_rules
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end # class << self
|
37
|
+
|
38
|
+
end # module Sterile
|
39
|
+
|
data/lib/sterile/smart_format.rb
CHANGED
data/lib/sterile/tags.rb
CHANGED
data/lib/sterile/version.rb
CHANGED
data/lib/sterile.rb
CHANGED
data/sterile
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Hogan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -43,8 +43,10 @@ files:
|
|
43
43
|
- lib/sterile.rb
|
44
44
|
- lib/sterile/data/codepoints_data.rb
|
45
45
|
- lib/sterile/data/html_entities_data.rb
|
46
|
+
- lib/sterile/data/plain_format_rules.rb
|
46
47
|
- lib/sterile/data/smart_format_rules.rb
|
47
48
|
- lib/sterile/entities.rb
|
49
|
+
- lib/sterile/plain_format.rb
|
48
50
|
- lib/sterile/smart_format.rb
|
49
51
|
- lib/sterile/string_extensions.rb
|
50
52
|
- lib/sterile/tags.rb
|
@@ -52,6 +54,7 @@ files:
|
|
52
54
|
- lib/sterile/transliterate.rb
|
53
55
|
- lib/sterile/utilities.rb
|
54
56
|
- lib/sterile/version.rb
|
57
|
+
- sterile
|
55
58
|
- sterile.gemspec
|
56
59
|
homepage: https://github.com/pbhogan/sterile
|
57
60
|
licenses: []
|