Sha256: bc16b2849425911d20604120c447908aa481bc23a45430520597cc13e1a84e47

Contents?: true

Size: 1.45 KB

Versions: 16

Compression:

Stored size: 1.45 KB

Contents

# encoding: utf-8

module Github

  # Since blobs can be any arbitrary binary data, the input and responses for
  # the blob api takes an encoding parameter that can be either utf-8 or base64.
  # If your data cannot be losslessly sent as a UTF-8 string, you can base64 encode it.
  class Client::GitData::Blobs < API

    VALID_BLOB_PARAM_NAMES = %w[ content encoding ].freeze

    # Get a blob
    #
    # @example
    #  github = Github.new
    #  github.git_data.blobs.get 'user-name', 'repo-name', 'sha'
    #
    # @api public
    def get(*args)
      arguments(args, required: [:user, :repo, :sha])

      get_request("/repos/#{arguments.user}/#{arguments.repo}/git/blobs/#{arguments.sha}", arguments.params)
    end
    alias :find :get

    # Create a blob
    #
    # @param [Hash] params
    # @input params [String] :content
    #   String of content.
    # @input params [String] :encoding
    #   String containing encoding<tt>utf-8</tt> or <tt>base64</tt>
    #
    # @examples
    #  github = Github.new
    #  github.git_data.blobs.create 'user-name', 'repo-name',
    #    content: "Content of the blob",
    #    encoding: "utf-8"
    #
    # @api public
    def create(*args)
      arguments(args, required: [:user, :repo]) do
        permit VALID_BLOB_PARAM_NAMES
        assert_required VALID_BLOB_PARAM_NAMES
      end

      post_request("/repos/#{arguments.user}/#{arguments.repo}/git/blobs", arguments.params)
    end
  end # GitData::Blobs
end # Github

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
github_api-0.17.0 lib/github_api/client/git_data/blobs.rb
github_api-0.16.0 lib/github_api/client/git_data/blobs.rb
github_api-0.15.0 lib/github_api/client/git_data/blobs.rb
github_api-0.14.5 lib/github_api/client/git_data/blobs.rb
github_api-0.14.4 lib/github_api/client/git_data/blobs.rb
github_api-0.14.3 lib/github_api/client/git_data/blobs.rb
github_api-0.14.2 lib/github_api/client/git_data/blobs.rb
github_api-0.14.1 lib/github_api/client/git_data/blobs.rb
github_api-0.14.0 lib/github_api/client/git_data/blobs.rb
github_api-0.13.1 lib/github_api/client/git_data/blobs.rb
github_api-0.13.0 lib/github_api/client/git_data/blobs.rb
github_api-0.12.4 lib/github_api/client/git_data/blobs.rb
github_api-0.12.3 lib/github_api/client/git_data/blobs.rb
github_api-0.12.2 lib/github_api/client/git_data/blobs.rb
github_api-0.12.1 lib/github_api/client/git_data/blobs.rb
github_api-0.12.0 lib/github_api/client/git_data/blobs.rb