Sha256: b09d60c08269d9b272482d0398908c6f3d5636c913e311e0fcc5d8baaff17f6c

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8

module Github

  # When you create a new GitHub repository via the API, you can specify a
  # .gitignore template to apply to the repository upon creation.
  class Gitignore < API

    # List all templates available to pass as an option when creating a repository.
    #
    # = Examples
    #  github = Github.new
    #  github.gitignore.list
    #  github.gitignore.list { |template| ... }
    #
    def list(*args)
      arguments(args)

      response = get_request("/gitignore/templates", arguments.params)
      return response unless block_given?
      response.each { |el| yield el }
    end
    alias :all :list

    # Get a single template
    #
    # = Examples
    #  github = Github.new
    #  github.gitignore.get "template-name"
    #
    # Use the raw media type to get the raw contents.
    #
    # = Examples
    #  github = Github.new
    #  github.gitignore.get "template-name", accept: 'applicatin/vnd.github.raw'
    #
    def get(*args)
      params = arguments(args, :required => [:name]).params

      if (media = params.delete('accept'))
        params['accept'] = media
        params['raw'] = true
      end

      get_request("/gitignore/templates/#{name}", params)
    end
    alias :find :get

  end # Gitignore
end # Github

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
github_api-0.11.3 lib/github_api/gitignore.rb
github_api-0.11.2 lib/github_api/gitignore.rb
github_api-0.11.1 lib/github_api/gitignore.rb
github_api-0.11.0 lib/github_api/gitignore.rb
github_api-0.10.2 lib/github_api/gitignore.rb
github_api-0.10.1 lib/github_api/gitignore.rb
github_api-0.10.0 lib/github_api/gitignore.rb