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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85e53308dc320efc61be6fbdc227a423c5e8832c
4
- data.tar.gz: 40015a58adfdfcbe8499590e0562dceedb435a31
3
+ metadata.gz: 242ff144553ae8fcc742866d19685e5682f6f8ae
4
+ data.tar.gz: 303bcb379f93d8bbd62aac30e5a33a84bfb12294
5
5
  SHA512:
6
- metadata.gz: 871f81c39318b7ad549ffd0da0b2d4efc96719271743ef5687b25eb4226272a8c6903d18d233b1b922f90029f5205787b68e73207f202dc1e7368fc3c9a49811
7
- data.tar.gz: a19a0ab41a05582ee6d8182d9cb0b5788439ed330de04b71e278c83ad8c9ddf7a097a2229770e0f3991042115a6d3ad050ed526653ab2c657703355b03920c85
6
+ metadata.gz: 1d281666a0ded129a24beede55231f313408d00db70d0f955af9ed776a8b97aa8d5d1b93e24856141d10eca7c6e3ae5ce599d47943f3c3ce80e7d89db3e8599a
7
+ data.tar.gz: 1f3e3c4b0ef9583691bc3df2aaa31292972f6473c2ab472be2851166285bbbdb683abf8032ef1bd70d3ac1ef35d6c9f362fd4fed95257b4a7bd9117249729fc3
data/Gemfile.lock CHANGED
@@ -1,11 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sterile (1.0.4)
4
+ sterile (1.0.6)
5
+ nokogiri
5
6
 
6
7
  GEM
7
8
  remote: http://rubygems.org/
8
9
  specs:
10
+ mini_portile2 (2.1.0)
11
+ nokogiri (1.7.0.1)
12
+ mini_portile2 (~> 2.1.0)
9
13
 
10
14
  PLATFORMS
11
15
  ruby
@@ -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
@@ -38,7 +38,7 @@ module Sterile
38
38
  [/"(\s|\S|\Z)/, "”\\1"],
39
39
  [/\'([\s.]|\Z)/, "’\\1"],
40
40
  [/(\d+)x(\d+)/, "\\1×\\2"],
41
- [/([a-z])'(t|d|s|ll|re|ve)(\b)/i, "\\1’\\2\\3"]
41
+ [/([a-z])'(t|d|s|ll|re|ve)(\b)/i, "\\1’\\2\\3"],
42
42
  ]
43
43
  end
44
44
  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
+
@@ -10,7 +10,7 @@ module Sterile
10
10
  #
11
11
  def smart_format(string)
12
12
  smart_format_rules.each do |rule|
13
- string.gsub!(rule[0], rule[1])
13
+ string.gsub! rule[0], rule[1]
14
14
  end
15
15
  string
16
16
  end
data/lib/sterile/tags.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  # encoding: UTF-8
2
+ require "nokogiri"
3
+
2
4
 
3
5
  module Sterile
4
6
 
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Sterile
4
- VERSION = "1.0.5"
4
+ VERSION = "1.0.6"
5
5
  end
6
6
 
data/lib/sterile.rb CHANGED
@@ -24,6 +24,7 @@
24
24
 
25
25
  require "sterile/transliterate"
26
26
  require "sterile/smart_format"
27
+ require "sterile/plain_format"
27
28
  require "sterile/titlecase"
28
29
  require "sterile/utilities"
29
30
  require "sterile/entities"
data/sterile ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec irb -r sterile
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.5
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: 2016-09-15 00:00:00.000000000 Z
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: []