Sha256: d8aa7bacf6bf748886dd3969f9012809d64780093fa3c8439590bcf2de0de1af

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

# encoding: utf-8

module Github
  class Repos
    module Forks

      # List repository forks
      #
      # = Examples
      #  @github = Github.new
      #  @github.repos.forks 'user-name', 'repo-name'
      #  @github.repos.forks 'user-name', 'repo-name' { |hook| ... }
      #
      def forks(user_name=nil, repo_name=nil, params = {})
        _update_user_repo_params(user_name, repo_name)
        _validate_user_repo_params(user, repo) unless user? && repo?
        _normalize_params_keys(params)

        response = get("/repos/#{user}/#{repo}/forks")
        return response unless block_given?
        response.each { |el| yield el }
      end
      alias :repo_forks :forks
      alias :repository_forks :forks

      # 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.create_fork 'user-name', 'repo-name',
      #    "org" =>  "github"
      #
      def create_fork(user_name=nil, repo_name=nil, 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("/repos/#{user}/#{repo}/forks", params)
      end

    end # Forks
  end # Repos
end # Github

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
github_api-0.3.4 lib/github_api/repos/forks.rb
github_api-0.3.3 lib/github_api/repos/forks.rb
github_api-0.3.2 lib/github_api/repos/forks.rb
github_api-0.3.1 lib/github_api/repos/forks.rb
github_api-0.3.0 lib/github_api/repos/forks.rb
github_api-0.2.2 lib/github_api/repos/forks.rb
github_api-0.2.1 lib/github_api/repos/forks.rb