Sha256: 1345c4a21043ed6bf27e84629aa1a80194381f8c80aeedef597d5015e8fbcd75

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

require 'yaml'

module GistUpdater
  # User configuration
  class Config
    # @param file [String] a YAML file path
    def initialize(file)
      @file = file
    end

    # Calls block once for each element in config
    #
    # @yield [gist_id:, file_paths:] Gist file paths
    # @yieldparam gist_id [String] a Gist id
    # @yieldparam file_paths [Array<String>] file paths
    # @yieldreturn [Array]
    # @return [Enumerator]
    def each
      return enum_for(:each) unless block_given?

      config.each do |c|
        yield(gist_id: c.first, file_paths: c.drop(1))
      end
    end

    private

    attr_reader :file

    def config
      @config ||= YAML.load(IO.read(file))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gist_updater-0.4.3 lib/gist_updater/config.rb
gist_updater-0.4.2 lib/gist_updater/config.rb
gist_updater-0.3.1 lib/gist_updater/config.rb