Sha256: 3b2bc50e602543ce309ef1ca61318714098a1a810197fa8c47808849b3c04779
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module GistUpdater # Updates according to user configuration class Updater # @param options [Hash] options generated by Thor # @param config_class [Class] a Class which has configuration duty 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 # Update your Gist # # @return [Fixnum] Updated count def update count = 0 config.each do |gist_id:, file_paths:| file_paths.each do |file_path| count += 1 if update_by_gist(gist_id, file_path) end end count end private attr_reader :user, :access_token, :config # Update a Gist file # # @return (see GistUpdater::Content#update_if_need) def update_by_gist(id, file_path) Content.new( user: user, access_token: access_token, gist_id: 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.3.1 | lib/gist_updater/updater.rb |