iciba 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -21,6 +21,9 @@ Or install it yourself as:
21
21
  Command-line usage:
22
22
 
23
23
  $ fy 'words to be translated'
24
+ $ fy 'english' # for single word answers
25
+ $ fy 'english' -e for complete definition if available
26
+ $ fy 'words to be translated' -l
24
27
 
25
28
  Ruby usage:
26
29
 
data/bin/fy CHANGED
@@ -39,8 +39,9 @@ regex = /https?:\/\/[\S]+/
39
39
  links = ARGV.first.scan(regex)
40
40
 
41
41
  def loop_through_links(links)
42
+ puts links.inspect
42
43
  links.each do |l|
43
- text = Readability::Document.new(Iciba::Tools.download(l)).content.gsub('<p>', '').gsub('</p>', "\r\n").gsub('</div></div>', '').gsub('<div><div>', '')
44
+ text = Readability::Document.new(Iciba::Tools.download(l).force_encoding("UTF-8")).content.gsub('<p>', '').gsub('</p>', "\r\n").gsub('</div></div>', '').gsub('<div><div>', '')
44
45
  puts wrap_text(text) unless text == ''
45
46
  puts '------------------------------------------------------------------------------------' unless text == ''
46
47
  end
@@ -24,7 +24,7 @@ module Iciba
24
24
 
25
25
  def download_and_parse(words, dir, extended)
26
26
  self.response = Iciba::Tools.parse(Iciba::Tools.post('http://fy.iciba.com/api.php', {:q => words, :type => dir}).body_str)
27
- self.html = self.response.ret
27
+ self.html = self.response.ret.force_encoding("UTF-8")
28
28
  self.result = (Iciba::Tools.doc(self.html)/'span.dd').text.strip
29
29
  self.result = self.html if self.result == ""
30
30
  self.result = self.result.split(',')[0] if self.result.include?(',') unless extended
@@ -1,3 +1,3 @@
1
1
  module Iciba
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: