convert 0.1.3 → 0.1.4

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: a22241a31ca94ae8d3a66c4ade462391d65be420
4
- data.tar.gz: e0f125711a785f1a5b85247c8fe5dde78ff84487
3
+ metadata.gz: bd278fbb7c687e6160133fcb06e36b680d8dfeee
4
+ data.tar.gz: 6d3794a6dc74b8690b3b3c90a1eea720e230bdc9
5
5
  SHA512:
6
- metadata.gz: 074a8650dd8e2e300f471eca8cbeb29c35b0964ba4e5c0305b8d3b3a8d7be2fd07f7bb0687fd326eb467568b3a7f044e1bea662db8485f804569bb3a2042de9e
7
- data.tar.gz: 9e20b6614dc40bb7e7e851b828d6f60c3a6330f47308d6392a245c5ec27914cac0f42b007ae909979e32fd570a9ba15de54396661abcf44305debafd4a74a943
6
+ metadata.gz: 76eccb0b8269ddd5e9879f97d237d8e8d4f7644010c0f98982a5cd58eb6f473df5ce09a1620f5683284353f49a940d17e25790bdc2e24729acb359c7d869732d
7
+ data.tar.gz: e16ea9f2382e5469364b5a65483b0d569a04434a0b29b3f3c3542e840bffacae4d3fbf41dcc40c68ccbd00e41f0052ae3d659db4015004e12366ae03d522f2ff
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ **Version 0.1.3** - *2016-15-01*
2
+
3
+ - Added simpleidn support with to_ascii and to_unicode
4
+ - Fixed nil exception when converter list for scan is empty
5
+
6
+ **Version 0.1.3** - *2016-11-01*
7
+
8
+ - Made main class module instead of class
9
+
1
10
  **Version 0.1.2** - *2016-05-01*
2
11
 
3
12
  - Fixed gem files not being included
data/README.md CHANGED
@@ -18,7 +18,7 @@ require 'convert'
18
18
  Convert.run('string')
19
19
 
20
20
  # Convert with Nokogiri, used by 'run'
21
- Convert.nokogiri('HTML string')
21
+ Convert.scan('HTML string')
22
22
 
23
23
  # URL to HTML link
24
24
  Convert.auto_link('https://crowdfundhq.com')
@@ -124,6 +124,11 @@ Convert.youtube_image('string')
124
124
  # Embed Youtube JS API
125
125
  Convert.youtube_js_api('string')
126
126
 
127
+ # Convert Chinese and other non-standard characters to IDN
128
+ Convert.to_ascii('string')
129
+
130
+ # Reverse IDN conversion
131
+ Convert.to_unicode('string')
127
132
  ```
128
133
 
129
134
  Created and maintained by [Fugroup Ltd.](https://www.fugroup.net) We are the creators of [CrowdfundHQ.](https://crowdfundhq.com)
data/convert.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'convert'
3
- s.version = '0.1.3'
4
- s.date = '2017-01-12'
3
+ s.version = '0.1.4'
4
+ s.date = '2017-01-15'
5
5
  s.summary = "Convert strings and HTML to links and embedded content"
6
6
  s.description = "Easily convert any string and replace with links and embedded content from a long list of providers and libraries."
7
7
  s.authors = ["Fugroup Limited"]
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.add_runtime_dependency 'sanitize', '~> 4.4'
13
13
  s.add_runtime_dependency 'htmlentities', '~> 4.3'
14
14
  s.add_runtime_dependency 'nokogiri', '~> 1.6'
15
+ s.add_runtime_dependency 'simpleidn', '>= 0'
15
16
  s.add_development_dependency 'futest', '>= 0'
16
17
 
17
18
  s.email = 'mail@fugroup.net'
data/lib/convert.rb CHANGED
@@ -19,12 +19,13 @@ module Convert
19
19
  autoload :Rinku, 'rinku'
20
20
  autoload :Sanitize, 'sanitize'
21
21
  autoload :HTMLEntities, 'htmlentities'
22
+ autoload :Nokogiri, 'nokogiri'
23
+ autoload :SimpleIDN, 'simpleidn'
22
24
  end
23
- autoload :Nokogiri, 'nokogiri'
24
25
 
25
26
  # Some of the matchers are taken from https://github.com/dejan/auto_html
26
27
 
27
- CONVERTERS = [:iframe_embed, :dailymotion, :email_escape, :flickr, :gist, :google_maps, :hashtag, :escape_html, :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]
28
+ CONVERTERS = [:iframe_embed, :dailymotion, :email_escape, :flickr, :gist, :google_maps, :hashtag, :escape_html, :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, :scan, :to_ascii, :to_unicode]
28
29
 
29
30
  DEFAULT = [:dailymotion, :flickr, :gist, :google_maps, :instagram, :liveleak, :metacafe, :soundcloud, :ted, :twitter, :vimeo, :worldstar, :youtube, :auto_link]
30
31
 
@@ -5,7 +5,7 @@ module Convert
5
5
 
6
6
  # Scan a string with Nokogiri and convert if match string
7
7
  def scan(string, options = {})
8
- return string if options[:converters].empty?
8
+ return string if !options[:converters] or options[:converters].empty?
9
9
 
10
10
  doc = Nokogiri::HTML.fragment(string)
11
11
 
@@ -0,0 +1,15 @@
1
+ module Convert
2
+ module Converters
3
+
4
+ # Convert chinese characters to URL safe format
5
+ def to_ascii(string)
6
+ SimpleIDN.to_ascii(string)
7
+ end
8
+
9
+ # Reverse safe format back to unicode
10
+ def to_unicode(string)
11
+ SimpleIDN.to_unicode(string)
12
+ end
13
+
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fugroup Limited
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-12 00:00:00.000000000 Z
11
+ date: 2017-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simpleidn
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: futest
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +158,7 @@ files:
144
158
  - lib/converters/redcarpet.rb
145
159
  - lib/converters/sanitize.rb
146
160
  - lib/converters/simple_format.rb
161
+ - lib/converters/simpleidn.rb
147
162
  - lib/converters/soundcloud.rb
148
163
  - lib/converters/strip_params.rb
149
164
  - lib/converters/ted.rb