Sha256: 23ca463fa55ebf7ddd6c77c5ea57dd7f93575069c1baeed48a8ceae8dfd73e14

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

# encoding: utf-8

module Github
  class Repos::Forks < API

    # List repository forks
    #
    # = Parameters
    # * <tt>:sort</tt> - newest, oldest, watchers, default: newest
    #
    # = Examples
    #  github = Github.new
    #  github.repos.forks.list 'user-name', 'repo-name'
    #  github.repos.forks.list 'user-name', 'repo-name' { |fork| ... }
    #
    def list(user_name, repo_name, params = {})
      _update_user_repo_params(user_name, repo_name)
      assert_presence_of user, repo
      normalize! params

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

    # Create a fork for the authenticated user
    #
    # = Inputs
    # * <tt>:org</tt> - Optional string - the name of the service that is being called.
    #
    # = Examples
    #  github = Github.new
    #  github.repos.forks.create 'user-name', 'repo-name',
    #    "org" =>  "github"
    #
    def create(user_name, repo_name, params={})
      _update_user_repo_params(user_name, repo_name)
      assert_presence_of user, repo
      normalize! params
      filter! %w[ org ], params

      post_request("/repos/#{user}/#{repo}/forks", params)
    end

  end # Repos::Forks
end # Github

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github_api-0.7.1 lib/github_api/repos/forks.rb