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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e630d67664e5e4a94c1240d1a662c822172552b
4
- data.tar.gz: 44da5d234bec3a2f42f0794e331bcaad81bf0a36
3
+ metadata.gz: c65393e3d4fe53d6b421a0eef8e976c49962af3c
4
+ data.tar.gz: 21e83b0123d5312c82b984fa605bafc1a444b116
5
5
  SHA512:
6
- metadata.gz: b518094b45b8e7bbeab5180177c755c3c8682416734549dc499db453430f6b4b8b067441415ffaa53e4544a7fe42a4552584ae870add4fbb694241198a0bde39
7
- data.tar.gz: 88d81e153dc6dce95554a2436ddb80fe84036eb1b2cd63c72b4960603d6964e54f603d5d0dc9ca454e735ae66ec446079b2742e180dfe0a790b5edd898c87161
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 `to_html`, to convert things like "Â" to "& Acirc;" (but without the space), but more will be added as required.
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 the file to HTML-safe characters
16
- # Uniconvert.to(:HTML, ARGV[0])
17
- Uniconvert.to(:ASCII, ARGV[0])
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 convert(file)
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
@@ -1,3 +1,3 @@
1
1
  module Uniconvert
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/uniconvert.rb CHANGED
@@ -1,16 +1,34 @@
1
1
  module Uniconvert
2
2
 
3
3
  #
4
- # Convert the text in the file using one of the supported conversion handlers
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.to(converter, file, create_file = false)
11
+ def self.file_to(converter, file, create_file = false)
12
12
  converter_obj = Uniconvert.const_get(converter).new(create_file)
13
- converter_obj.convert(file)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniconvert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe