Sha256: c3b0e68598402f41c239a31a6cdc2035332c7bcae04587596434fa301dc8f695

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

require_relative "feed2gram/version"
require_relative "feed2gram/http"
require_relative "feed2gram/parses_options"
require_relative "feed2gram/loads_config"
require_relative "feed2gram/refreshes_token"
require_relative "feed2gram/loads_cache"
require_relative "feed2gram/parses_entries"
require_relative "feed2gram/filters_posts"
require_relative "feed2gram/publishes_posts"
require_relative "feed2gram/updates_cache"

module Feed2Gram
  class Error < StandardError; end

  def self.cli(argv)
    options = ParsesOptions.new.parse(argv)
    run(options)
  end

  def self.run(options)
    config = LoadsConfig.new.load(options)
    RefreshesToken.new.refresh!(config, options) unless options.skip_token_refresh

    cache = LoadsCache.new.load(options)
    puts "Loading entries from feed: #{config.feed_url}" if options.verbose
    entries = ParsesEntries.new.parse(config.feed_url)
    puts "Found #{entries.size} entries in feed" if options.verbose
    posts = FiltersPosts.new.filter(entries, cache)
    results = if options.populate_cache
      puts "Populating cache, marking #{posts.size} posts as skipped" if options.verbose
      posts.map { |post| Result.new(post: post, status: :skipped) }
    else
      PublishesPosts.new.publish(posts, config, options)
    end
    UpdatesCache.new.update!(cache, results, options)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
feed2gram-1.0.0 lib/feed2gram.rb
feed2gram-0.0.4 lib/feed2gram.rb
feed2gram-0.0.3 lib/feed2gram.rb