Sha256: 942ddfdc0ed5c55c31763c9a78a1b8be4577b86bc472ebfcf80900bbf1b3d2cd

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 Bytes

Contents

# frozen_string_literal: true

module GistUpdater
  class Updater
    def initialize(options, config_class = Config)
      @user             = options[:user] || ENV['GISTUPDATER_USER']
      @access_token     = options[:token] || ENV['GISTUPDATER_ACCESS_TOKEN']
      @config           = config_class.new(options[:yaml])
      GistUpdater.debug = options[:debug]
    end

    def update
      count = 0

      config.each do |gist_id, file_path|
        count += 1 if update_1(gist_id, file_path)
      end

      count
    end

    private

    attr_reader :user, :access_token, :config

    def update_1(gist_id, file_path)
      Content.new(
        user: user,
        access_token: access_token,
        gist_id: gist_id,
        file_path: file_path
      ).update_if_need
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gist_updater-0.2.0 lib/gist_updater/updater.rb