Sha256: a21e5785c046a21f106eb0eedfeb47708ba37cf6f5c380c9adf3a09e36816232

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

# encoding: utf-8

require_relative '../../api'

module Github
  class Client::Repos::Branches < API
    require_all 'github_api/client/repos/branches', 'protections'

    # Access to Repos::Branches::Protections API
    namespace :protections

    # List branches
    #
    # @example
    #   github = Github.new
    #   github.repos.branches.list 'user-name', 'repo-name'
    #   github.repos(user: 'user-name', repo: 'repo-name').branches.list
    #
    # @example
    #   repos = Github::Repos.new
    #   repos.branches.list 'user-name', 'repo-name'
    #
    # @api public
    def list(*args)
      arguments(args, required: [:user, :repo])

      response = get_request("/repos/#{arguments.user}/#{arguments.repo}/branches", arguments.params)
      return response unless block_given?
      response.each { |el| yield el }
    end
    alias :all :list

    # Get branch
    #
    # @example
    #   github = Github.new
    #   github.repos.branches.get 'user-name', 'repo-name', 'branch-name'
    #   github.repos.branches.get user: 'user-name', repo: 'repo-name', branch: 'branch-name'
    #   github.repos(user: 'user-name', repo: 'repo-name', branch: 'branch-name').branches.get
    # @api public
    def get(*args)
      arguments(args, required: [:user, :repo, :branch])

      get_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}", arguments.params)
    end
    alias :find :get
  end # Client::Repos::Branches
end # Github

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
github_api-0.19.0 lib/github_api/client/repos/branches.rb
lingfennan-github_api-0.18.2 lib/github_api/client/repos/branches.rb
github_api-0.18.2 lib/github_api/client/repos/branches.rb
github_api-0.18.1 lib/github_api/client/repos/branches.rb