lib/spigoter/webapi/devbukkit.rb in spigoter-0.2.0 vs lib/spigoter/webapi/devbukkit.rb in spigoter-0.2.2

- old
+ new

@@ -12,49 +12,40 @@ raise "Bad URL #{@url}" if @url.match(/http:\/\/dev.bukkit.org\/bukkit-plugins\/[a-z\-]+\/?/).nil? end def main_page return @main_page unless @main_page.nil? - Log.info "Downloading main page" begin @main_page = open(@url).read rescue raise "404 Error, that plugin URL doesn't exists" end return @main_page end def download_page return @download_page unless @download_page.nil? main_page - Log.info "Downloading download page" url_download_page = @main_page.match(/<a href="(?<download_page_url>.+)">Download/)[:download_page_url] - begin - @download_page = open("http://dev.bukkit.org/#{url_download_page}").read - rescue - raise "404 Error, that plugin URL doesn't exists" - end + @download_page = open("http://dev.bukkit.org/#{url_download_page}").read + # Don't need to begin-rescue, it's done by main_page return @download_page end def download_url return @download_url unless @download_url.nil? download_page - Log.info "Parsing download url" @download_url = /href="(?<download_url>.+)">Download/.match(@download_page)[:download_url] end def version return @version unless @version.nil? download_page - Log.info "Getting version" @version = /3">\s*<h1>\s+(?<version>.+)\s+<\/h1>/.match(@download_page)[:version] end def name return @name unless @name.nil? - Log.info "Getting name" @name = /ins\/(?<name>[a-z\-]+)\/?/.match(@url)[:name] end def download download_url - Log.info "Downloading" begin file = open(@download_url).read rescue raise "Can't download file for #{name}, #{@download_url}, check internet?" end \ No newline at end of file