class Pluto::SiteRefresher
note: refresh
refresh will fetch site subscriptions, parse and than update the site subscriptions (e.g. update is just one operation of refresh)
Public Class Methods
new()
click to toggle source
# File lib/pluto/update/site_refresher.rb, line 17 def initialize @worker = SiteFetcher.new end
Public Instance Methods
debug?()
click to toggle source
# File lib/pluto/update/site_refresher.rb, line 21 def debug?() Pluto.config.debug?; end
refresh_sites( opts={} )
click to toggle source
# File lib/pluto/update/site_refresher.rb, line 24 def refresh_sites( opts={} ) # refresh (fetch+parse+update) all site configs start_time = Time.now Activity.create!( text: "start update sites (#{Site.count})" ) #### - hack - use order(:id) instead of .all - avoids rails/activerecord 4 warnings Site.order(:id).each do |site| refresh_site_worker( site ) if site.url.present? # note: only update if (source) url present end total_secs = Time.now - start_time Activity.create!( text: "done update sites (#{Site.count}) in #{total_secs}s" ) end
Private Instance Methods
refresh_site_worker( site_rec )
click to toggle source
# File lib/pluto/update/site_refresher.rb, line 40 def refresh_site_worker( site_rec ) site_text = @worker.fetch( site_rec ) # on error or if http-not modified etc. skip update/processing return if site_text.nil? site_config = INI.load( site_text ) site_rec.deep_update_from_hash!( site_config ) end