iciba 0.0.17 → 0.0.18

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.
@@ -14,7 +14,8 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "iciba"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Iciba::VERSION
17
- gem.add_dependency(%q<curb>, [">= 0"])
17
+ # gem.add_dependency(%q<curb>, [">= 0"])
18
+ gem.add_dependency('rest-client')
18
19
  gem.add_dependency(%q<hashie>, [">= 0"])
19
20
  gem.add_dependency(%q<yajl-ruby>, [">= 0"])
20
21
  gem.add_dependency(%q<nokogiri>, [">= 0"])
@@ -43,7 +43,7 @@ module Iciba
43
43
 
44
44
 
45
45
  def download_and_parse(words, dir, extended)
46
- self.response = Iciba::Tools.parse(Iciba::Tools.post('http://fy.iciba.com/api.php', {:q => words, :type => dir}).body_str)
46
+ self.response = Iciba::Tools.parse(Iciba::Tools.post('http://fy.iciba.com/api.php', {:q => words, :type => dir}))
47
47
  self.html = self.response.ret.encode("UTF-8")
48
48
  self.result = (Iciba::Tools.doc(self.html)/'div.translate_result').text.strip if self.html.include?('translate_result')
49
49
  self.result = (Iciba::Tools.doc(self.html)/'span.dd').text.strip if !self.html.include?('translate_result')
@@ -1,36 +1,15 @@
1
1
  # coding: utf-8
2
2
  require 'yajl'
3
3
  require 'hashie'
4
- require 'curb'
4
+ require 'rest_client'
5
5
  require 'nokogiri'
6
6
  require 'hpricot'
7
7
  module Iciba
8
8
  module Tools
9
9
 
10
- def self.download(url)
11
- c = self.curb(url)
12
- c.body_str
13
- end
14
-
15
10
  def self.post(url, options)
16
- Curl.post(url, options)
17
- end
18
-
19
- def self.last_effective_url(url)
20
- c = self.curb(url)
21
- c.last_effective_url
22
- end
23
-
24
- def self.curb(url)
25
- c = Curl::Easy.new(url) do |curl|
26
- curl.headers["User-Agent"] = user_agent
27
- # curl.verbose = true
28
- curl.timeout = 120
29
- curl.follow_location = true
30
- curl.max_redirects = 20
31
- end
32
- c.perform
33
- c
11
+ options = options.merge(:user_agent => user_agent)
12
+ RestClient.post url, options
34
13
  end
35
14
 
36
15
  def self.parse(data)
@@ -1,3 +1,3 @@
1
1
  module Iciba
2
- VERSION = "0.0.17"
2
+ VERSION = "0.0.18"
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.17
4
+ version: 0.0.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-25 00:00:00.000000000 Z
12
+ date: 2012-11-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: curb
15
+ name: rest-client
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  version: '0'
179
179
  requirements: []
180
180
  rubyforge_project:
181
- rubygems_version: 1.8.21
181
+ rubygems_version: 1.8.24
182
182
  signing_key:
183
183
  specification_version: 3
184
184
  summary: iciba wrapper