uniconvert 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/exe/uniconvert +13 -3
- data/lib/uniconvert/converters/HTML.rb +5 -1
- data/lib/uniconvert/version.rb +1 -1
- data/lib/uniconvert.rb +21 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c65393e3d4fe53d6b421a0eef8e976c49962af3c
|
4
|
+
data.tar.gz: 21e83b0123d5312c82b984fa605bafc1a444b116
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: defa7f9ef43d330aaad8777caeb78ae555aeecf773143a39f3fec45c77776fab055262a29676ef4945ab58ee6d56106b4a7db195015cf4c418630f395e99121c
|
7
|
+
data.tar.gz: 9bf41a6f33a019c9129dd8118dd2ceeb67c046d4c289a72a1bbc4b06d9916faacebbcb51cd0acc3f1a50a11bb87d65496d5b82fe1d9ea99783293d5570c2ca79
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Uniconvert
|
2
2
|
|
3
|
-
Various conversions for non-Latin characters. So far the only method is `
|
3
|
+
Various conversions for non-Latin characters. So far the only method is `to`, to convert things like "Â" to "& Acirc;" (but without the space), but more will be added as required.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
data/exe/uniconvert
CHANGED
@@ -5,6 +5,7 @@ require 'htmlentities'
|
|
5
5
|
require 'unicode'
|
6
6
|
require 'notifaction'
|
7
7
|
require 'iconv'
|
8
|
+
require 'pathname'
|
8
9
|
|
9
10
|
Dir['lib/uniconvert/converters/*'].each do |f|
|
10
11
|
require_relative "../#{f}"
|
@@ -12,6 +13,15 @@ end
|
|
12
13
|
|
13
14
|
require_relative "../lib/uniconvert.rb"
|
14
15
|
|
15
|
-
# convert
|
16
|
-
|
17
|
-
|
16
|
+
# convert input to HTML-safe characters
|
17
|
+
str = Pathname.new(ARGV[0])
|
18
|
+
|
19
|
+
if str.readable?
|
20
|
+
Uniconvert.file_to(:HTML, str)
|
21
|
+
else
|
22
|
+
Notify.spacer
|
23
|
+
Notify.success("Translated text below")
|
24
|
+
Notify.spacer
|
25
|
+
Notify.spit(Uniconvert.str_to(:HTML, str))
|
26
|
+
Notify.spacer
|
27
|
+
end
|
@@ -7,7 +7,7 @@ module Uniconvert
|
|
7
7
|
@encoder = HTMLEntities.new
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def convert_file(file)
|
11
11
|
file_contents = File.read(file)
|
12
12
|
converted = @encoder.encode(file_contents, :named)
|
13
13
|
|
@@ -24,5 +24,9 @@ module Uniconvert
|
|
24
24
|
converted.nil?
|
25
25
|
end
|
26
26
|
|
27
|
+
def convert_str(str)
|
28
|
+
@encoder.encode(str, :named)
|
29
|
+
end
|
30
|
+
|
27
31
|
end
|
28
32
|
end
|
data/lib/uniconvert/version.rb
CHANGED
data/lib/uniconvert.rb
CHANGED
@@ -1,16 +1,34 @@
|
|
1
1
|
module Uniconvert
|
2
2
|
|
3
3
|
#
|
4
|
-
# Convert
|
4
|
+
# Convert contents of a file using one of the supported conversion handlers
|
5
5
|
#
|
6
6
|
# @converter Symbol The converter you'd like to use
|
7
7
|
# @file String Path to the input file which contains the text you'd
|
8
8
|
# like to convert
|
9
9
|
# @create_file Bool Flag to create a new file with the converted data
|
10
10
|
#
|
11
|
-
def self.
|
11
|
+
def self.file_to(converter, file, create_file = false)
|
12
12
|
converter_obj = Uniconvert.const_get(converter).new(create_file)
|
13
|
-
converter_obj.
|
13
|
+
converter_obj.convert_file(file)
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Convert a string using one of the supported conversion handlers
|
18
|
+
#
|
19
|
+
# @converter Symbol The converter you'd like to use
|
20
|
+
# @file String Path to the input file which contains the text you'd
|
21
|
+
# like to convert
|
22
|
+
# @create_file Bool Flag to create a new file with the converted data
|
23
|
+
#
|
24
|
+
def self.str_to(converter, file, create_file = false)
|
25
|
+
converter_obj = Uniconvert.const_get(converter).new(create_file)
|
26
|
+
converted_str = converter_obj.convert_str(file)
|
27
|
+
|
28
|
+
# copy to clipboard?
|
29
|
+
# if system('type pbcopy')
|
30
|
+
# `echo "#{converted_str}" | pbcopy`
|
31
|
+
# end
|
14
32
|
end
|
15
33
|
|
16
34
|
end
|