Sha256: 0e2ab54f2711be94647952d61ab9ce53dd275a2d35053104d108ac63997ee240

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 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' { |hook| ... }
    #
    def list(user_name, repo_name, params = {})
      _update_user_repo_params(user_name, repo_name)
      _validate_user_repo_params(user, repo) unless user? && repo?
      _normalize_params_keys(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)
      _validate_user_repo_params(user, repo) unless user? && repo?
      _normalize_params_keys(params)
      _filter_params_keys(%w[ org ], params)

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

  end # Repos::Forks
end # Github

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
github_api-0.6.0 lib/github_api/repos/forks.rb
github_api-0.5.4 lib/github_api/repos/forks.rb
github_api-0.5.3 lib/github_api/repos/forks.rb
github_api-0.5.2 lib/github_api/repos/forks.rb
github_api-0.5.1 lib/github_api/repos/forks.rb
github_api-0.5.0 lib/github_api/repos/forks.rb
github_api-0.5.0.rc1 lib/github_api/repos/forks.rb