Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add Curly#encoding, remove `get_document` and `post` class methods

  • Loading branch information...
commit bfe2ec482870868db6fb10af07c2f59367bdb83f 1 parent 4cbf837
Mislav Marohnić authored

Showing 1 changed file with 8 additions and 17 deletions. Show diff stats Hide diff stats

  1. +8 17 curly.rb
25 curly.rb
@@ -61,24 +61,19 @@ def doc
61 61
62 62 def body_unicode
63 63 body = body_str
64   - if body =~ /;\s*charset=([\w-]+)\s*['"]/ and $1.downcase != 'utf-8'
65   - body = Iconv.conv('UTF-8', $1, body)
  64 + if encoding and encoding != 'utf-8'
  65 + body = Iconv.conv('UTF-8', encoding, body)
66 66 end
67 67 body
68 68 end
69 69
70   - def self.get_document(url)
71   - curl = new(url)
72   - curl.get
73   - parse_curl curl
74   - end
75   -
76   - def self.parse_curl(object)
77   - body = object.body_str
78   - if body =~ /;\s*charset=([\w-]+)\s*['"]/ and $1.downcase != 'utf-8'
79   - body = Iconv.conv('UTF-8', $1, body)
  70 + def encoding
  71 + return @encoding unless @encoding == false
  72 + @encoding = if body_str =~ /;\s*charset=([\w-]+)\s*['"]/
  73 + $1.downcase
  74 + else
  75 + false
80 76 end
81   - Hpricot(body)
82 77 end
83 78
84 79 def post(params)
@@ -88,10 +83,6 @@ def post(params)
88 83 http_post *fields
89 84 end
90 85
91   - def self.post(url, params)
92   - new(url).post(params)
93   - end
94   -
95 86 class Form
96 87 def initialize(element)
97 88 @node = element

0 comments on commit bfe2ec4

Please sign in to comment.
Something went wrong with that request. Please try again.