Class: Hobix::Publish::Ping

Inherits:
BasePublish show all
Defined in:
lib/hobix/publish/ping.rb

Instance Method Summary collapse

Methods inherited from BasePlugin

inherited, start

Constructor Details

#initialize(weblog, urls) ⇒ Ping

Returns a new instance of Ping.



22
23
24
25
26
# File 'lib/hobix/publish/ping.rb', line 22

def initialize( weblog, urls )
    @title = weblog.title
    @link = weblog.link
    @urls = urls
end

Instance Method Details

#publish(pages) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/hobix/publish/ping.rb', line 30

def publish( pages )
    @urls.each do |u|
        link = @link.to_s
        u, link = u.keys.first, u.values.first if Hash === u
        puts "pinging #{ u }..."
        u = URI::parse( u )
        begin
            server = XMLRPC::Client.new( u.host, u.path, u.port )

            begin
                result = server.call( "weblogUpdates.ping", @title, link )
            rescue XMLRPC::FaultException => e
                puts "Error: "
                puts e.faultCode
                puts e.faultString
            end
        rescue Exception => e
            puts "Error: #{ e.message }"
        end
    end
end

#watchObject



27
28
29
# File 'lib/hobix/publish/ping.rb', line 27

def watch
    ['index']
end