iciba 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,13 +22,14 @@ Command-line usage:
22
22
 
23
23
  $ fy 'words to be translated'
24
24
  $ fy 'english' # for single word answers
25
- $ fy 'english' -e for complete definition if available
26
- $ fy 'words to be translated' -l
25
+ $ fy 'english' -e #for complete definition if available
26
+ $ fy http://www.chinadaily.com.cn/business/2012-09/07/content_15742188.htm -l #to download links
27
+ $ fy http://www.chinadaily.com.cn/business/2012-09/07/content_15742188.htm -l -r #to translate the links
27
28
 
28
29
  Ruby usage:
29
30
 
30
31
  require 'iciba'
31
- Iciba::Fanyi.new('words to be translated')
32
+ Iciba::Fanyi.new('words to be translated').result
32
33
 
33
34
  ## Contributing
34
35
 
data/bin/fy CHANGED
@@ -26,6 +26,7 @@ OptionParser.new do |opts|
26
26
  end
27
27
 
28
28
  def wrap_text(txt, col = 80)
29
+ col = 40 if txt.contains_cjk?
29
30
  txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/,
30
31
  "\\1\\3\n")
31
32
  end
data/lib/iciba/fanyi.rb CHANGED
@@ -8,8 +8,8 @@ module Iciba
8
8
  def initialize(words, dir='auto', bin=false, extended=false)
9
9
  puts '------------------------------------------------------------------------------------' if bin
10
10
  # puts if bingit
11
- puts wrap_text(words, 40) if check_char(words) if bin
12
- puts wrap_text(words) unless check_char(words) if bin
11
+ puts wrap_text(words, 40) if words.contains_cjk? && bin
12
+ puts wrap_text(words) unless words.contains_cjk? && bin
13
13
  puts '------------------------------------------------------------------------------------' if bin
14
14
  download_and_parse(words, dir, extended)
15
15
  puts wrap_text(self.result) if bin
@@ -22,7 +22,7 @@ module Iciba
22
22
  "\\1\\3\n")
23
23
  end
24
24
 
25
- def check_char(str)
25
+ def self.check_char(str)
26
26
  str.contains_cjk?
27
27
  end
28
28
 
data/lib/iciba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iciba
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-08 00:00:00.000000000 Z
12
+ date: 2012-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: curb