iciba 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
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)
@@ -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
@@ -2,8 +2,9 @@
2
2
  require "iciba/version"
3
3
  require 'iciba/tools'
4
4
  require 'iciba/fanyi'
5
+
5
6
  class String
6
7
  def contains_cjk?
7
- !!(self =~ /\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}/)
8
+ !!(self =~ /\p{Han}/)
8
9
  end
9
10
  end
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Iciba
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
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.10
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