From 91a03e183f7c81374a904a7fd29e2bbae30e6e07 Mon Sep 17 00:00:00 2001 From: id774 Date: Wed, 19 Feb 2014 14:47:39 +0900 Subject: [PATCH 1/2] #66 Refactoring --- plugins/subscription/text.rb | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/plugins/subscription/text.rb b/plugins/subscription/text.rb index 6510bd9..d13af2e 100644 --- a/plugins/subscription/text.rb +++ b/plugins/subscription/text.rb @@ -8,26 +8,11 @@ module Automatic::Plugin class TextFeed + attr_accessor :title, :link def initialize @link = 'http://dummy' @title = 'dummy' end - - def link - @link - end - - def title - @title - end - - def set_link(link) - @link = link - end - - def set_title(title) - @title = title - end end class SubscriptionText @@ -41,7 +26,7 @@ def initialize(config, pipeline=[]) unless @config['titles'].nil? @config['titles'].each {|title| textFeed = TextFeed.new - textFeed.set_title(title) + textFeed.title = title @dummyfeeds << textFeed } end @@ -49,7 +34,7 @@ def initialize(config, pipeline=[]) unless @config['urls'].nil? @config['urls'].each {|url| textFeed = TextFeed.new - textFeed.set_link(url) + textFeed.link = url @dummyfeeds << textFeed } end @@ -57,8 +42,8 @@ def initialize(config, pipeline=[]) unless @config['feeds'].nil? @config['feeds'].each {|feed| textFeed = TextFeed.new - textFeed.set_title(feed['title']) unless feed['title'].nil? - textFeed.set_link(feed['url']) unless feed['url'].nil? + textFeed.title = feed['title'] unless feed['title'].nil? + textFeed.link = feed['url'] unless feed['url'].nil? @dummyfeeds << textFeed } end From e9dd237e87f4f8699ab1354ffa3313b74a4252d3 Mon Sep 17 00:00:00 2001 From: id774 Date: Wed, 19 Feb 2014 15:01:37 +0900 Subject: [PATCH 2/2] #66 Add fields description, author, comments --- plugins/subscription/text.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/plugins/subscription/text.rb b/plugins/subscription/text.rb index d13af2e..939590f 100644 --- a/plugins/subscription/text.rb +++ b/plugins/subscription/text.rb @@ -1,17 +1,22 @@ # -*- coding: utf-8 -*- # Name:: Automatic::Plugin::Subscription::Text # Author:: soramugi -# Created:: May 6, 2013 -# Updated:: May 6, 2013 -# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers. +# 774 +# Created:: May 6, 2013 +# Updated:: Feb 19, 2014 +# Copyright:: Copyright (c) 2012-2014 Automatic Ruby Developers. # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. module Automatic::Plugin class TextFeed - attr_accessor :title, :link + attr_accessor :title, :link, :description, :author, :comments + def initialize - @link = 'http://dummy' - @title = 'dummy' + @link = 'http://dummy' + @title = 'dummy' + @description = '' + @author = '' + @comments = '' end end @@ -44,11 +49,14 @@ def initialize(config, pipeline=[]) textFeed = TextFeed.new textFeed.title = feed['title'] unless feed['title'].nil? textFeed.link = feed['url'] unless feed['url'].nil? + textFeed.description = feed['description'] unless feed['description'].nil? + textFeed.author = feed['author'] unless feed['author'].nil? + textFeed.comments = feed['comments'] unless feed['comments'].nil? @dummyfeeds << textFeed } end - end + end end def run