convert 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/convert.rb +55 -47
- metadata +87 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f8038d316910757119756d12f77bfa2894ddd42
|
4
|
+
data.tar.gz: 4f3935f05c5cec5ac6e1af0cab3a31871570881b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b186341f0a93f93eb59f4a60753d80bb3104e91683c93f29fb0356ecbec8e12dc5ed6faeae76a922a7f936fd3584f93b6604cf05c3d29710fbb45b19f2e4c801
|
7
|
+
data.tar.gz: 24eae3560e9e575339c3289b476be9eda4b8e28f9ffa943f12169265bdb28a6a25518aaaed1dff8f2b2891793e8785b40a5912cd27640cf6c059d73082294e84
|
data/lib/convert.rb
CHANGED
@@ -1,56 +1,64 @@
|
|
1
|
-
|
1
|
+
# Require the converters
|
2
|
+
Dir['./lib/converters/*.rb'].each{|f| require f}
|
3
|
+
|
4
|
+
# Require the sanitizers
|
5
|
+
Dir['./lib/sanitizers/*.rb'].each{|f| require f}
|
6
|
+
|
7
|
+
# Autoload for faster loading
|
8
|
+
|
9
|
+
module Converters
|
10
|
+
autoload :Redcarpet, 'redcarpet'
|
11
|
+
autoload :Kramdown, 'kramdown'
|
12
|
+
autoload :Rinku, 'rinku'
|
13
|
+
autoload :Sanitize, 'sanitize'
|
14
|
+
autoload :HTMLEntities, 'htmlentities'
|
15
|
+
end
|
16
|
+
autoload :Nokogiri, 'nokogiri'
|
17
|
+
|
18
|
+
# # # # # #
|
19
|
+
# The Convert module is responsible for converting strings
|
20
|
+
#
|
21
|
+
class Convert
|
2
22
|
|
3
23
|
# # # # # #
|
4
|
-
# Convert strings and HTML from a long list of
|
24
|
+
# Convert strings and HTML from a long list of converters
|
5
25
|
# @homepage: https://github.com/fugroup/convert
|
6
26
|
# @author: Vidar <vidar@fugroup.net>, Fugroup Ltd.
|
7
27
|
# @license: MIT, contributions are welcome.
|
8
28
|
# # # # # #
|
9
29
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
:
|
25
|
-
|
26
|
-
|
27
|
-
:
|
28
|
-
|
29
|
-
|
30
|
-
:
|
31
|
-
|
32
|
-
|
33
|
-
:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:
|
40
|
-
|
41
|
-
|
42
|
-
:youtube_embed,
|
43
|
-
:youtube_image,
|
44
|
-
:youtube_js_api
|
45
|
-
]
|
46
|
-
|
47
|
-
# Only run the ones set in Convert.converters, see above.
|
48
|
-
Convert.converters.each do |c|
|
49
|
-
|
50
|
-
# Require
|
51
|
-
require_relative "converters/#{c}"
|
52
|
-
|
53
|
-
# Extend
|
54
|
-
extend Object.const_get("Convert::#{c.to_s.split('_').map(&:capitalize).join}")
|
30
|
+
# Some of the matchers are taken from https://github.com/dejan/auto_html
|
31
|
+
|
32
|
+
CONVERTERS = [:iframe_embed, :dailymotion, :email_escape, :flickr, :gist, :google_maps, :hashtag, :html_escape, :image_tag, :instagram, :liveleak, :markdown, :metacafe, :redcarpet, :soundcloud, :ted, :twitter, :video_embed, :vimeo, :vimeo_embed, :worldstar, :youtube, :youtube_embed, :youtube_js_api, :auto_link, :encode, :decode, :strip_params, :sanitize, :nokogiri]
|
33
|
+
|
34
|
+
DEFAULT = [:dailymotion, :flickr, :gist, :google_maps, :instagram, :liveleak, :metacafe, :soundcloud, :ted, :twitter, :vimeo, :worldstar, :youtube, :auto_link]
|
35
|
+
|
36
|
+
# Include converters
|
37
|
+
extend Converters
|
38
|
+
|
39
|
+
# Run all the converters or the ones you sent to the initializers
|
40
|
+
def self.run(string, options = {})
|
41
|
+
return '' if !string
|
42
|
+
|
43
|
+
# Setup
|
44
|
+
options = {:markdown => true, :config => :custom, :converters => DEFAULT}.merge(options)
|
45
|
+
|
46
|
+
# Include
|
47
|
+
options[:converters] += options[:include] if options[:include]
|
48
|
+
|
49
|
+
# Exclude
|
50
|
+
options[:converters] -= options[:exclude] if options[:exclude]
|
51
|
+
|
52
|
+
# Markdown
|
53
|
+
string = markdown(string, :autolink => false) if options[:markdown]
|
54
|
+
|
55
|
+
# Scan
|
56
|
+
string = scan(string, options)
|
57
|
+
|
58
|
+
# Sanitize
|
59
|
+
string = sanitize(string, :config => options[:config])
|
60
|
+
|
61
|
+
string
|
55
62
|
end
|
63
|
+
|
56
64
|
end
|
metadata
CHANGED
@@ -1,15 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
12
|
-
dependencies:
|
11
|
+
date: 2016-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: redcarpet
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kramdown
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rinku
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sanitize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.4'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: htmlentities
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.3'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nokogiri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.6'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.6'
|
13
97
|
description: Easily convert any string and replace with links and embedded content
|
14
98
|
from a long list of providers and libraries.
|
15
99
|
email: mail@fugroup.net
|