Module: Octokit::Client::Contents
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/octokit/client/contents.rb |
Overview
Methods for the Repo Contents API
Instance Method Summary
-
#add_content(*args)
Alias for #create_contents.
-
#add_contents(*args)
Alias for #create_contents.
-
#archive_link(repo, options = {}) ⇒ String
This method will provide a URL to download a tarball or zipball archive for a repository.
-
#content(repo, options = {})
Alias for #contents.
-
#contents(repo, options = {}) ⇒ Sawyer::Resource
(also: #content)
Receive a listing of a repository folder or the contents of a file.
-
#create_content(*args)
Alias for #create_contents.
-
#create_contents(repo, path, message, content = nil, options = {}) ⇒ Sawyer::Resource
(also: #create_content, #add_content, #add_contents)
Add content to a repository.
-
#delete_content(repo, path, message, sha, options = {})
Alias for #delete_contents.
-
#delete_contents(repo, path, message, sha, options = {}) ⇒ Sawyer::Resource
(also: #delete_content, #remove_content, #remove_contents)
Delete content in a repository.
-
#readme(repo, options = {}) ⇒ Sawyer::Resource
Receive the default Readme for a repository.
-
#remove_content(repo, path, message, sha, options = {})
Alias for #delete_contents.
-
#remove_contents(repo, path, message, sha, options = {})
Alias for #delete_contents.
-
#update_content(*args)
Alias for #update_contents.
-
#update_contents(repo, path, message, sha, content = nil, options = {}) ⇒ Sawyer::Resource
(also: #update_content)
Update content in a repository.
Instance Method Details
#add_content(*args)
Alias for #create_contents.
# File 'lib/octokit/client/contents.rb', line 87
alias add_content create_contents
#add_contents(*args)
Alias for #create_contents.
# File 'lib/octokit/client/contents.rb', line 88
alias add_contents create_contents
#archive_link(repo, options = {}) ⇒ String
This method will provide a URL to download a tarball or zipball archive for a repository.
# File 'lib/octokit/client/contents.rb', line 155
def archive_link(repo, = {}) repo_ref = ERB::Util.url_encode( .delete(:ref)) format = ( .delete :format) || 'tarball' url = "#{Repository.path repo}/#{format}/#{repo_ref}" response = client_without_redirects.head(url, ) response.headers['Location'] end
#content(repo, options = {})
Alias for #contents.
# File 'lib/octokit/client/contents.rb', line 40
alias content contents
#contents(repo, options = {}) ⇒ Sawyer::Resource
Also known as: #content
Receive a listing of a repository folder or the contents of a file
# File 'lib/octokit/client/contents.rb', line 34
def contents(repo, = {}) = .dup repo_path = .delete :path url = "#{Repository.path repo}/contents/#{repo_path}" get url, end
#create_content(*args)
Alias for #create_contents.
# File 'lib/octokit/client/contents.rb', line 86
alias create_content create_contents
#create_contents(repo, path, message, content = nil, options = {}) ⇒ Sawyer::Resource
Also known as: #create_content, #add_content, #add_contents
Add content to a repository
# File 'lib/octokit/client/contents.rb', line 59
def create_contents(*args) args = args.map { |item| item&.dup } = args.last.is_a?(Hash) ? args.pop : {} repo = args.shift path = args.shift = args.shift content = args.shift if content.nil? && file = .delete(:file) case file when String if File.exist?(file) file = File.open(file, 'r') content = file.read file.close end when File, Tempfile content = file.read file.close end end raise ArgumentError, 'content or :file option required' if content.nil? [:content] = [content].pack('m0') # Base64.strict_encode64 [: ] = url = "#{Repository.path repo}/contents/#{path}" put url, end
#delete_content(repo, path, message, sha, options = {})
Alias for #delete_contents.
# File 'lib/octokit/client/contents.rb', line 142
alias delete_content delete_contents
#delete_contents(repo, path, message, sha, options = {}) ⇒ Sawyer::Resource
Also known as: #delete_content, #remove_content, #remove_contents
Delete content in a repository
# File 'lib/octokit/client/contents.rb', line 136
def delete_contents(repo, path, , sha, = {}) [: ] = [:sha] = sha url = "#{Repository.path repo}/contents/#{path}" delete url, end
#readme(repo, options = {}) ⇒ Sawyer::Resource
Receive the default Readme for a repository
# File 'lib/octokit/client/contents.rb', line 19
def readme(repo, = {}) get "#{Repository.path repo}/readme", end
#remove_content(repo, path, message, sha, options = {})
Alias for #delete_contents.
# File 'lib/octokit/client/contents.rb', line 143
alias remove_content delete_contents
#remove_contents(repo, path, message, sha, options = {})
Alias for #delete_contents.
# File 'lib/octokit/client/contents.rb', line 144
alias remove_contents delete_contents
#update_content(*args)
Alias for #update_contents.
# File 'lib/octokit/client/contents.rb', line 119
alias update_content update_contents
#update_contents(repo, path, message, sha, content = nil, options = {}) ⇒ Sawyer::Resource
Also known as: #update_content
Update content in a repository
# File 'lib/octokit/client/contents.rb', line 109
def update_contents(*args) = args.last.is_a?(Hash) ? args.pop : {} repo = args.shift path = args.shift = args.shift sha = args.shift content = args.shift .merge!(sha: sha) create_contents(repo, path, , content, ) end