uniconvert 0.2.1 → 0.2.2

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: c65393e3d4fe53d6b421a0eef8e976c49962af3c
4
- data.tar.gz: 21e83b0123d5312c82b984fa605bafc1a444b116
3
+ metadata.gz: 995a875537b674c9e58241ec3c43e45470ee2611
4
+ data.tar.gz: 6ccb5e523a8a2a6e7bc6337e22991780c241062e
5
5
  SHA512:
6
- metadata.gz: defa7f9ef43d330aaad8777caeb78ae555aeecf773143a39f3fec45c77776fab055262a29676ef4945ab58ee6d56106b4a7db195015cf4c418630f395e99121c
7
- data.tar.gz: 9bf41a6f33a019c9129dd8118dd2ceeb67c046d4c289a72a1bbc4b06d9916faacebbcb51cd0acc3f1a50a11bb87d65496d5b82fe1d9ea99783293d5570c2ca79
6
+ metadata.gz: 30a34f5b3f78147697de801f11f5c83dc6358ece2109f7c326d6c477253dd98580bc52c9abc3ea16a3f9e0a684a076d03030aecf1b3ec4f3c0bc22bd52952c56
7
+ data.tar.gz: f8b4bb8be251a93493d108d87a3e83bd652fcb341e43c38172d00bda8311bed35ead4c22700dfa73a9660df767adbd43df3924be6bde433efc10e5ed05ee30ed
@@ -1,27 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
4
3
  require 'htmlentities'
5
- require 'unicode'
6
4
  require 'notifaction'
7
- require 'iconv'
8
5
  require 'pathname'
9
6
 
10
- Dir['lib/uniconvert/converters/*'].each do |f|
11
- require_relative "../#{f}"
12
- end
13
-
7
+ require_relative "../lib/uniconvert/setup.rb"
14
8
  require_relative "../lib/uniconvert.rb"
15
9
 
16
- # convert input to HTML-safe characters
17
- str = Pathname.new(ARGV[0])
10
+ setup = Uniconvert::Setup.new
18
11
 
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
12
+ # include all converters
13
+ setup.load_converters
14
+
15
+ # convert input to HTML-safe characters
16
+ setup.execute_conversion
@@ -27,7 +27,7 @@ module Uniconvert
27
27
 
28
28
  # copy to clipboard?
29
29
  # if system('type pbcopy')
30
- # `echo "#{converted_str}" | pbcopy`
30
+ # `echo "#{converted_str}" > /dev/null 2>&1 | pbcopy`
31
31
  # end
32
32
  end
33
33
 
@@ -8,20 +8,24 @@ module Uniconvert
8
8
  end
9
9
 
10
10
  def convert_file(file)
11
- file_contents = File.read(file)
12
- converted = @encoder.encode(file_contents, :named)
11
+ begin
12
+ file_contents = File.read(file)
13
+ converted = @encoder.encode(file_contents, :named)
13
14
 
14
- if @create_file
15
- translated_file_name = file + '.converted'
15
+ if @create_file
16
+ translated_file_name = file + '.converted'
16
17
 
17
- File.open(translated_file_name, 'w+') do |f|
18
- f.write converted
18
+ File.open(translated_file_name, 'w+') do |f|
19
+ f.write converted
20
+ end
21
+
22
+ `$EDITOR #{translated_file_name}`
19
23
  end
20
24
 
21
- `$EDITOR #{translated_file_name}`
25
+ converted.nil?
26
+ rescue Errno::EISDIR
27
+ false
22
28
  end
23
-
24
- converted.nil?
25
29
  end
26
30
 
27
31
  def convert_str(str)
@@ -0,0 +1,25 @@
1
+ module Uniconvert
2
+ class Setup
3
+
4
+ def load_converters
5
+ Dir['lib/uniconvert/converters/*'].each do |f|
6
+ require_relative "../../#{f}"
7
+ end
8
+ end
9
+
10
+ def execute_conversion
11
+ str = Pathname.new(ARGV[0])
12
+
13
+ if str.readable?
14
+ Uniconvert.file_to(:HTML, str)
15
+ else
16
+ Notify.spacer
17
+ Notify.success("Converted text below")
18
+ Notify.spacer
19
+ Notify.spit(Uniconvert.str_to(:HTML, str))
20
+ Notify.spacer
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Uniconvert
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniconvert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-23 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -127,6 +127,7 @@ files:
127
127
  - exe/uniconvert
128
128
  - lib/uniconvert.rb
129
129
  - lib/uniconvert/converters/HTML.rb
130
+ - lib/uniconvert/setup.rb
130
131
  - lib/uniconvert/version.rb
131
132
  - uniconvert.gemspec
132
133
  homepage: https://rubygems.org/aapis/unicode-lang-converter