### Home Classes Methods

### In Files

- lib/github_api/repos/contents.rb

### Parent

Github::API

### Methods

- #archive
- #create
- #delete
- #find
- #get
- #readme
- #update

### Class/Module Index

Quicksearch

- Github
- Github::API
- Github::Activity
- Github::Activity::Events
- Github::Activity::Notifications
- Github::Activity::Starring
- Github::Activity::Watching
- Github::ApiFactory
- Github::Arguments
- Github::Authorization
- Github::Authorizations
- Github::AutoloadHelper
- Github::Client
- Github::Configuration
- Github::Connection
- Github::Constants
- Github::CoreExt
- Github::CoreExt::OrderedHash
- Github::Descendants
- Github::Emojis
- Github::Error
- Github::Error::BadRequest
- Github::Error::ClientError
- Github::Error::Forbidden
- Github::Error::GithubError
- Github::Error::InternalServerError
- Github::Error::InvalidOptions
- Github::Error::NotAcceptable
- Github::Error::NotFound
- Github::Error::RequiredParams
- Github::Error::ServiceError
- Github::Error::ServiceUnavailable
- Github::Error::Unauthorized
- Github::Error::UnknownValue
- Github::Error::UnprocessableEntity
- Github::Error::Validations
- Github::Gists
- Github::Gists::Comments
- Github::GitData
- Github::GitData::Blobs
- Github::GitData::Commits
- Github::GitData::References
- Github::GitData::Tags
- Github::GitData::Trees
- Github::Gitignore
- Github::Issues
- Github::Issues::Assignees
- Github::Issues::Comments
- Github::Issues::Events
- Github::Issues::Labels
- Github::Issues::Milestones
- Github::Jsonable
- Github::Markdown
- Github::Meta
- Github::MimeType
- Github::Normalizer
- Github::Orgs
- Github::Orgs::Members
- Github::Orgs::Teams
- Github::PageIterator
- Github::PageLinks
- Github::PagedRequest
- Github::Pagination
- Github::ParameterFilter
- Github::ParamsHash
- Github::PullRequests
- Github::PullRequests::Comments
- Github::RateLimit
- Github::Repos
- Github::Repos::Collaborators
- Github::Repos::Comments
- Github::Repos::Commits
- Github::Repos::Contents
- Github::Repos::Downloads
- Github::Repos::Forks
- Github::Repos::Hooks
- Github::Repos::Keys
- Github::Repos::Merging
- Github::Repos::PubSubHubbub
- Github::Repos::Statistics
- Github::Repos::Statuses
- Github::Request
- Github::Request::BasicAuth
- Github::Request::Jsonize
- Github::Request::OAuth2
- Github::Resource
- Github::Response
- Github::Response::Header
- Github::Response::Jsonize
- Github::Response::Mashify
- Github::Response::RaiseError
- Github::Response::Xmlize
- Github::ResponseWrapper
- Github::S3Uploader
- Github::Say
- Github::Scopes
- Github::Search
- Github::Users
- Github::Users::Emails
- Github::Users::Followers
- Github::Users::Keys
- Github::Utils
- Github::Utils::Url
- Github::VERSION
- Github::Validations
- Github::Validations::Format
- Github::Validations::Presence
- Github::Validations::Required
- Github::Validations::Token
- Hash

No matching classes.

# Github::Repos::Contents

These API methods let you retrieve the contents of files within a repository as Base64 encoded content.

### Constants

REQUIRED_CONTENT_OPTIONS

### Public Instance Methods

archive(*args) click to toggle source

Get archive link

This method will return a 302 to a URL to download a tarball or zipball archive for a repository. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request.

Note: For private repositories, these links are temporary and expire quickly.

# Parameters

- `:archive_format` - Required string - either tarball or zipball

- `:ref` - Optional string - valid Git reference, defaults to master

# Examples

    github = Github.new
    github.repos.contents.archive 'user-name', 'repo-name',
      "archive_format" =>  "tarball",
      "ref" => "master"

    # File lib/github_api/repos/contents.rb, line 177
    def archive(*args)
      arguments(args, :required => [:user, :repo])
      params         = arguments.params
      archive_format = params.delete('archive_format') || 'zipball'
      ref            = params.delete('ref') || 'master'

      get_request("/repos/#{user}/#{repo}/#{archive_format}/#{ref}", params)
    end

create(*args) click to toggle source

Create a file

This method creates a new file in a repository

# Parameters

- `:path` - Requried string - The content path

- `:message` - Requried string - The commit message

- `:content` - Requried string - The new file content,

      which will be Base64 encoded

- `:branch` - Optional string - The branch name. If not provided,

      uses the repository’s default branch (usually master)

# Optional Parameters

The `author` section is optional and is filled in with the `committer` information if omitted. If the `committer` information is omitted, the authenticated user’s information is used.

You must provide values for both `name` and `email`, whether you choose to use `author` or `committer`. Otherwise, you’ll receive a `500` status code.

- `author.name` - string - The name of the author of the commit

- `author.email` - string - The email of the author of the commit

- `committer.name` - string - The name of the committer of the commit

- `committer.email` - string - The email of the committer of the commit

# Examples

    github = Github.new
    github.repos.contents.create 'user-name', 'repo-name', 'path',
      path: 'hello.rb',
      content: "puts 'hello ruby'",
      message: "my commit message"

    # File lib/github_api/repos/contents.rb, line 83
    def create(*args)
      arguments(args, :required => [:user, :repo, :path]) do
        assert_required REQUIRED_CONTENT_OPTIONS
      end
      params = arguments.params
      params.strict_encode64('content')

      put_request("/repos/#{user}/#{repo}/contents/#{path}", params)
    end

delete(*args) click to toggle source

Delete a file

This method deletes a file in a repository

# Parameters

- `:path` - Requried string - The content path

- `:message` - Requried string - The commit message

- `:sha` - Requried string - The blob SHA of the file being removed.

- `:branch` - Optional string - The branch name. If not provided,

      uses the repository’s default branch (usually master)

# Optional Parameters

The `author` section is optional and is filled in with the `committer` information if omitted. If the `committer` information is omitted, the authenticated user’s information is used.

You must provide values for both `name` and `email`, whether you choose to use `author` or `committer`. Otherwise, you’ll receive a `500` status code.

- `author.name` - string - The name of the author of the commit

- `author.email` - string - The email of the author of the commit

- `committer.name` - string - The name of the committer of the commit

- `committer.email` - string - The email of the committer of the commit

# Examples

    github = Github.new
    github.repos.contents.delete 'user-name', 'repo-name', 'path',
      path: 'hello.rb',
      message: "delete hello.rb file",
      sha: "329688480d39049927147c162b9d2deaf885005f"

    # File lib/github_api/repos/contents.rb, line 150
    def delete(*args)
      arguments(args, :required => [:user, :repo, :path]) do
        assert_required ] path message sha ]
      end

      delete_request("/repos/#{user}/#{repo}/contents/#{path}", arguments.params)
    end

find(*args) click to toggle source
Alias for: get
get(*args) click to toggle source

Get contents

This method returns the contents of any file or directory in a repository.

# Parameters

- `:ref` - Optional string - valid Git reference, defaults to master

# Examples

    github = Github.new
    github.repos.contents.get 'user-name', 'repo-name', 'path'

    github = Github.new user: 'user-name', repo: 'repo-name'
    github.repos.contents.get path: 'README.md'

    # File lib/github_api/repos/contents.rb, line 42
    def get(*args)
      arguments(args, :required => [:user, :repo, :path])
      params = arguments.params

      get_request("/repos/#{user}/#{repo}/contents/#{path}", params)
    end

Also aliased as: find
readme(*args) click to toggle source

Get the README

This method returns the preferred README for a repository.

# Examples

    github = Github.new
    github.repos.contents.readme 'user-name', 'repo-name'

    content = Github::Repos;:Contents.new user: 'user-name', 'repo-name'
    content.readme

    # File lib/github_api/repos/contents.rb, line 21
    def readme(*args)
      arguments(args, :required => [:user, :repo])
      params = arguments.params

      get_request("/repos/#{user}/#{repo}/readme", params)
    end

update(*args) click to toggle source

Update a file

This method updates a file in a repository

# Parameters

- `:path` - Requried string - The content path

- `:message` - Requried string - The commit message

- `:content` - Requried string - The new file content,

      which will be Base64 encoded

- `:sha` - Requried string - The blob SHA of the file being replaced.

- `:branch` - Optional string - The branch name. If not provided,

      uses the repository’s default branch (usually master)

# Examples

    github = Github.new
    github.repos.contents.update 'user-name', 'repo-name', 'path',
      path: 'hello.rb',
      content: "puts 'hello ruby again'",
      message: "my commit message",
      sha: "25b0bef9e404bd2e3233de26b7ef8cbd86d0e913"

    # File lib/github_api/repos/contents.rb, line 114
    def update(*args)
      create(*args)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.