Sha256: 23340d205b7c49d41f73aebd96923374306ac0966c62fca86d6b2d078fe7ebc7

Contents?: true

Size: 838 Bytes

Versions: 9

Compression:

Stored size: 838 Bytes

Contents

require 'concurrent'

require 'zooniverse_social/posts'
require 'zooniverse_social/statuses'
require 'zooniverse_social/tweets'
require 'zooniverse_social/task_observer'

module ZooniverseSocial
  class Data
    def self.posts
      @posts ||= Posts.new
    end

    def self.tweets
      @tweets ||= Tweets.new
    end

    def self.statuses
      @statuses ||= Statuses.new
    end

    def self.sources
      [posts, tweets, statuses]
    end

    def self.current
      {
        posts: posts.data,
        tweets: tweets.data,
        statuses: statuses.data
      }
    end

    def self.update
      sources.each &:update
    end

    def self.start
      task = Concurrent::TimerTask.new(execution_interval: 600, timeout_interval: 20, run_now: true){ update }.execute
      TaskObserver.new task, method(:start)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
zooniverse_social-1.2.0 lib/zooniverse_social/data.rb
zooniverse_social-1.1.0 lib/zooniverse_social/data.rb
zooniverse_social-1.0.6 lib/zooniverse_social/data.rb
zooniverse_social-1.0.5 lib/zooniverse_social/data.rb
zooniverse_social-1.0.4 lib/zooniverse_social/data.rb
zooniverse_social-1.0.3 lib/zooniverse_social/data.rb
zooniverse_social-1.0.2 lib/zooniverse_social/data.rb
zooniverse_social-1.0.1 lib/zooniverse_social/data.rb
zooniverse_social-1.0.0 lib/zooniverse_social/data.rb