Permalink
Browse files

Version bump to 0.0.0

  • Loading branch information...
1 parent 55c9ed9 commit 83edcefa577a7907f86335a981b5a709b13775f2 @teejayvanslyke committed Jul 7, 2009
Showing with 43 additions and 0 deletions.
  1. +1 −0 VERSION
  2. +42 −0 lib/google-blog-pinging-service.rb
View
@@ -0,0 +1 @@
+0.0.0
@@ -0,0 +1,42 @@
+require 'rubygems'
+
+require 'cgi'
+require 'curb'
+
+module GoogleBlogPingingService
+
+ class Request
+ SERVICE_URI = "http://blogsearch.google.com/ping"
+
+ def initialize(name, uri, changes_url=nil)
+ @params = {
+ 'name' => name,
+ 'url' => uri
+ }
+ @params['changesUrl'] = changes_url if changes_url
+ end
+
+ def query_string
+ elements = []
+ @params.keys.size.times do |i|
+ elements << "#{@params.keys[i]}=#{CGI::escape(@params.values[i])}"
+ end
+ elements.join('&')
+ end
+
+ def perform
+ c = Curl::Easy.new("#{SERVICE_URI}?#{query_string}") do |curl|
+ curl.verbose = true
+ end
+ c.perform
+
+ return c.body_str == 'Thanks for the ping.'
+ end
+ end
+
+ def self.ping(name, uri, changes_url=nil)
+ Request.new(name, uri, changes_url).perform
+ end
+
+end
+

0 comments on commit 83edcef

Please sign in to comment.