Sha256: fc2418f33a2d984904bf4090d18ba3792487831b1af3abe1578ed31c9b3b2e8a

Contents?: true

Size: 622 Bytes

Versions: 2

Compression:

Stored size: 622 Bytes

Contents

require 'open-uri'

module Prpr
  module Config
    class Github
      attr_reader :repository, :branch

      def initialize(repository, branch: 'master')
        @repository = repository
        @branch = branch
      end

      def read(path)
        decode_content(path).tap { |s| s.force_encoding('utf-8') }
      end

      private

      def decode_content(path)
        Base64.decode64 resource(path).content
      end

      def resource(path)
        github.content(repository, path: path, ref: branch)
      end

      def github
        @github ||= Prpr::Repository::Github.default
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prpr-0.2.0 lib/prpr/config/github.rb
prpr-0.1.0 lib/prpr/config/github.rb