lib/ruskino33_parser.rb in ruskino33_parser-0.1.1 vs lib/ruskino33_parser.rb in ruskino33_parser-0.1.2
- old
+ new
@@ -1,20 +1,18 @@
require 'nokogiri'
require 'httpclient'
require 'ruskino33_parser/announce'
require 'ruskino33_parser/movie'
require "ruskino33_parser/version"
+require "ruskino33_parser/premiers"
module Ruskino33Parser
-
- # Headers are needed to mimic proper request to ruskino33
def self.fetch(url)
- HTTPClient.new.get url, nil, { 'User-Agent'=>'a', 'Accept-Encoding'=>'a' }
+ HTTPClient.new.get url, nil, 'User-Agent' => 'a', 'Accept-Encoding' => 'a'
end
- # Returns a nokogiri document or an error if fetch response status is not 200
def self.parse(url)
p = fetch url
- raise(Empty) if p.http_body.content.size.zero?
- p.status == 200 ? Nokogiri::HTML(p.body.encode('utf-8')) : raise(NotFound)
+ fail(Empty) if p.http_body.content.size.zero?
+ p.status == 200 ? Nokogiri::HTML(p.body.encode('utf-8')) : fail(NotFound)
end
end