Skip to content

Instantly share code, notes, and snippets.

@shunirr
Created August 8, 2014 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shunirr/a103d5c2bda00616661e to your computer and use it in GitHub Desktop.
Save shunirr/a103d5c2bda00616661e to your computer and use it in GitHub Desktop.
# -*- 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