iciba 0.0.10 → 0.0.11
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.
- data/bin/fy +4 -1
- data/iciba.gemspec +1 -1
- data/lib/iciba.rb +2 -1
- data/lib/iciba/fanyi.rb +3 -0
- data/lib/iciba/version.rb +1 -1
- metadata +17 -1
data/bin/fy
CHANGED
@@ -4,6 +4,7 @@ require 'iciba'
|
|
4
4
|
require 'optparse'
|
5
5
|
require 'readability'
|
6
6
|
require 'fileutils'
|
7
|
+
|
7
8
|
$links = false
|
8
9
|
|
9
10
|
OptionParser.new do |opts|
|
@@ -26,7 +27,9 @@ OptionParser.new do |opts|
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
30
|
+
|
29
31
|
def wrap_text(txt, col = 80)
|
32
|
+
txt = txt.encode('UTF-8')
|
30
33
|
col = 40 if txt.contains_cjk?
|
31
34
|
txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/,
|
32
35
|
"\\1\\3\n")
|
@@ -54,5 +57,5 @@ end
|
|
54
57
|
pinyin = ($pinyin ? true : false)
|
55
58
|
extended = ($extended ? true : false)
|
56
59
|
|
57
|
-
Iciba::Fanyi.new(ARGV.first, 'auto', true, extended, pinyin)
|
60
|
+
Iciba::Fanyi.new(ARGV.first.dup.force_encoding("UTF-8"), 'auto', true, extended, pinyin)
|
58
61
|
loop_through_links(links) if ($links && links.size > 0)
|
data/iciba.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_dependency(%q<hashie>, [">= 0"])
|
19
19
|
gem.add_dependency(%q<yajl-ruby>, [">= 0"])
|
20
20
|
gem.add_dependency(%q<nokogiri>, [">= 0"])
|
21
|
-
# gem.add_dependency(%q<pinyin>, [">= 0"])
|
22
21
|
gem.add_dependency(%q<ruby-readability>, [">= 0"])
|
23
22
|
gem.add_dependency(%q<string_to_pinyin>, ['>= 0'])
|
23
|
+
gem.add_development_dependency(%q<pry>, ['>= 0'])
|
24
24
|
end
|
data/lib/iciba.rb
CHANGED
data/lib/iciba/fanyi.rb
CHANGED
@@ -9,6 +9,7 @@ module Iciba
|
|
9
9
|
def initialize(words, dir='auto', bin=false, extended=false, pinyin=false)
|
10
10
|
puts '------------------------------------------------------------------------------------' if bin
|
11
11
|
# puts if bingit
|
12
|
+
words = words.dup.force_encoding("UTF-8")
|
12
13
|
puts wrap_text(words, 40) if words.contains_cjk? && bin
|
13
14
|
puts wrap_text(words) unless words.contains_cjk? && bin
|
14
15
|
# puts '------------------------------------------------------------------------------------' if words.contains_cjk? && bin && pinyin
|
@@ -23,11 +24,13 @@ module Iciba
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def wrap_text(txt, col = 80)
|
27
|
+
txt = txt.dup.force_encoding("UTF-8")
|
26
28
|
txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/,
|
27
29
|
"\\1\\3\n")
|
28
30
|
end
|
29
31
|
|
30
32
|
def self.check_char(str)
|
33
|
+
str = str.dup.force_encoding("UTF-8")
|
31
34
|
str.contains_cjk?
|
32
35
|
end
|
33
36
|
|
data/lib/iciba/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iciba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -107,6 +107,22 @@ dependencies:
|
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: pry
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
110
126
|
description: iciba wrapper
|
111
127
|
email:
|
112
128
|
- ussballantyne@gmail.com
|