Created
August 8, 2014 12:00
-
-
Save shunirr/a103d5c2bda00616661e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Name:: Automatic::Plugin::Publish::Fastladder | |
# Author:: shunirr <http://s5r.jp> | |
# Created:: Aug 8, 2014 | |
# Updated:: Aug 8, 2014 | |
# Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers. | |
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. | |
module Automatic::Plugin | |
class PublishFastladder | |
def initialize(config, pipeline=[]) | |
@config = config | |
@pipeline = pipeline | |
@base_url = @config['base_url'] | |
@api_key = @config['api_key'] | |
end | |
def run | |
@pipeline.each do |feeds| | |
next if feeds.nil? | |
feeds.items.each do |feed| | |
items = [] | |
items << { | |
"feedlink"=> feeds.channel.link, | |
"feedtitle"=> feeds.channel.title || 'NO TITLE', | |
"feeddescription"=> feeds.channel.description || '', | |
"link"=> feed.link, | |
"body"=> feed.description, | |
"category"=> feeds.channel.category || 'Subscriptions', | |
"title"=> feed.title, | |
} | |
Net::HTTP.post_form URI("#{@base_url}/rpc/update_feeds"), { | |
"api_key"=> @api_key, | |
"feeds"=> JSON.dump(items) | |
} | |
end | |
end | |
@pipeline | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment