Sha256: a9a9d17a44b5322318eddd8df4d8dded6154b0c028caf4b141cee25f70a17724

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

# encoding: utf-8

require_relative '../../api'

module Github
  class Client::Repos::Branches < API
    require_all 'github_api2/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

2 entries across 2 versions & 1 rubygems

Version Path
github_api2-1.0.1 lib/github_api2/client/repos/branches.rb
github_api2-1.0.0 lib/github_api2/client/repos/branches.rb