Sha256: 6c0817bce79c88d6413702acd060bad32c684327076758a20a24f12d1bfed1b2

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 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

    # Creates new Gitignore API
    def initialize(options = {})
      super(options)
    end

    # 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)
      params = args.extract_options!
      normalize! params

      response = get_request("/gitignore/templates", 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", mime: 'applicatin/vnd.github.raw'
    #
    def get(name, params={})
      normalize! params
      assert_presence_of name

      if (mime_type = params.delete('mime'))
        options = { :raw => true, :headers => {'Accept' => mime_type} }
      end

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

  end # Gitignore
end # Github

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
github_api-0.8.11 lib/github_api/gitignore.rb
github_api-0.8.10 lib/github_api/gitignore.rb
github_api-0.8.9 lib/github_api/gitignore.rb
github_api-0.8.8 lib/github_api/gitignore.rb
github_api-0.8.7 lib/github_api/gitignore.rb
github_api-0.8.6 lib/github_api/gitignore.rb
github_api-0.8.5 lib/github_api/gitignore.rb
github_api-0.8.4 lib/github_api/gitignore.rb
github_api-0.8.3 lib/github_api/gitignore.rb
github_api-0.8.2 lib/github_api/gitignore.rb