id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
12,500
markdownlint/markdownlint
lib/mdl/doc.rb
MarkdownLint.Doc.extract_text
def extract_text(element, prefix="", restore_whitespace = true) quotes = { :rdquo => '"', :ldquo => '"', :lsquo => "'", :rsquo => "'" } # If anything goes amiss here, e.g. unknown type, then nil will be # returned and we'll just not catch that part of the text, which seems # like a sensible failure mode. lines = element.children.map { |e| if e.type == :text e.value elsif [:strong, :em, :p, :codespan].include?(e.type) extract_text(e, prefix, restore_whitespace).join("\n") elsif e.type == :smart_quote quotes[e.value] end }.join.split("\n") # Text blocks have whitespace stripped, so we need to add it back in at # the beginning. Because this might be in something like a blockquote, # we optionally strip off a prefix given to the function. if restore_whitespace lines[0] = element_line(element).sub(prefix, "") end lines end
ruby
def extract_text(element, prefix="", restore_whitespace = true) quotes = { :rdquo => '"', :ldquo => '"', :lsquo => "'", :rsquo => "'" } # If anything goes amiss here, e.g. unknown type, then nil will be # returned and we'll just not catch that part of the text, which seems # like a sensible failure mode. lines = element.children.map { |e| if e.type == :text e.value elsif [:strong, :em, :p, :codespan].include?(e.type) extract_text(e, prefix, restore_whitespace).join("\n") elsif e.type == :smart_quote quotes[e.value] end }.join.split("\n") # Text blocks have whitespace stripped, so we need to add it back in at # the beginning. Because this might be in something like a blockquote, # we optionally strip off a prefix given to the function. if restore_whitespace lines[0] = element_line(element).sub(prefix, "") end lines end
[ "def", "extract_text", "(", "element", ",", "prefix", "=", "\"\"", ",", "restore_whitespace", "=", "true", ")", "quotes", "=", "{", ":rdquo", "=>", "'\"'", ",", ":ldquo", "=>", "'\"'", ",", ":lsquo", "=>", "\"'\"", ",", ":rsquo", "=>", "\"'\"", "}", "# If anything goes amiss here, e.g. unknown type, then nil will be", "# returned and we'll just not catch that part of the text, which seems", "# like a sensible failure mode.", "lines", "=", "element", ".", "children", ".", "map", "{", "|", "e", "|", "if", "e", ".", "type", "==", ":text", "e", ".", "value", "elsif", "[", ":strong", ",", ":em", ",", ":p", ",", ":codespan", "]", ".", "include?", "(", "e", ".", "type", ")", "extract_text", "(", "e", ",", "prefix", ",", "restore_whitespace", ")", ".", "join", "(", "\"\\n\"", ")", "elsif", "e", ".", "type", "==", ":smart_quote", "quotes", "[", "e", ".", "value", "]", "end", "}", ".", "join", ".", "split", "(", "\"\\n\"", ")", "# Text blocks have whitespace stripped, so we need to add it back in at", "# the beginning. Because this might be in something like a blockquote,", "# we optionally strip off a prefix given to the function.", "if", "restore_whitespace", "lines", "[", "0", "]", "=", "element_line", "(", "element", ")", ".", "sub", "(", "prefix", ",", "\"\"", ")", "end", "lines", "end" ]
Extracts the text from an element whose children consist of text elements and other things
[ "Extracts", "the", "text", "from", "an", "element", "whose", "children", "consist", "of", "text", "elements", "and", "other", "things" ]
a9e80fcf3989d73b654b00bb2225a00be53983e8
https://github.com/markdownlint/markdownlint/blob/a9e80fcf3989d73b654b00bb2225a00be53983e8/lib/mdl/doc.rb#L249-L275
12,501
markdownlint/markdownlint
lib/mdl/doc.rb
MarkdownLint.Doc.add_levels
def add_levels(elements, level=1) elements.each do |e| e.options[:element_level] = level add_levels(e.children, level+1) end end
ruby
def add_levels(elements, level=1) elements.each do |e| e.options[:element_level] = level add_levels(e.children, level+1) end end
[ "def", "add_levels", "(", "elements", ",", "level", "=", "1", ")", "elements", ".", "each", "do", "|", "e", "|", "e", ".", "options", "[", ":element_level", "]", "=", "level", "add_levels", "(", "e", ".", "children", ",", "level", "+", "1", ")", "end", "end" ]
Adds a 'level' option to all elements to show how nested they are
[ "Adds", "a", "level", "option", "to", "all", "elements", "to", "show", "how", "nested", "they", "are" ]
a9e80fcf3989d73b654b00bb2225a00be53983e8
https://github.com/markdownlint/markdownlint/blob/a9e80fcf3989d73b654b00bb2225a00be53983e8/lib/mdl/doc.rb#L282-L287
12,502
mojombo/chronic
lib/chronic/parser.rb
Chronic.Parser.guess
def guess(span, mode = :middle) return span if not mode return span.begin + span.width / 2 if span.width > 1 and (mode == true or mode == :middle) return span.end if mode == :end span.begin end
ruby
def guess(span, mode = :middle) return span if not mode return span.begin + span.width / 2 if span.width > 1 and (mode == true or mode == :middle) return span.end if mode == :end span.begin end
[ "def", "guess", "(", "span", ",", "mode", "=", ":middle", ")", "return", "span", "if", "not", "mode", "return", "span", ".", "begin", "+", "span", ".", "width", "/", "2", "if", "span", ".", "width", ">", "1", "and", "(", "mode", "==", "true", "or", "mode", "==", ":middle", ")", "return", "span", ".", "end", "if", "mode", "==", ":end", "span", ".", "begin", "end" ]
Guess a specific time within the given span. span - The Chronic::Span object to calcuate a guess from. Returns a new Time object.
[ "Guess", "a", "specific", "time", "within", "the", "given", "span", "." ]
2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c
https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/parser.rb#L152-L157
12,503
mojombo/chronic
lib/chronic/dictionary.rb
Chronic.Dictionary.definitions
def definitions defined_items.each_with_object({}) do |word, defs| word_type = "#{word.capitalize.to_s + 'Definitions'}" defs[word] = Chronic.const_get(word_type).new(options).definitions end end
ruby
def definitions defined_items.each_with_object({}) do |word, defs| word_type = "#{word.capitalize.to_s + 'Definitions'}" defs[word] = Chronic.const_get(word_type).new(options).definitions end end
[ "def", "definitions", "defined_items", ".", "each_with_object", "(", "{", "}", ")", "do", "|", "word", ",", "defs", "|", "word_type", "=", "\"#{word.capitalize.to_s + 'Definitions'}\"", "defs", "[", "word", "]", "=", "Chronic", ".", "const_get", "(", "word_type", ")", ".", "new", "(", "options", ")", ".", "definitions", "end", "end" ]
returns a hash of each word's Definitions
[ "returns", "a", "hash", "of", "each", "word", "s", "Definitions" ]
2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c
https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/dictionary.rb#L14-L19
12,504
mojombo/chronic
lib/chronic/handlers.rb
Chronic.Handlers.handle_od_rm
def handle_od_rm(tokens, options) day = tokens[0].get_tag(OrdinalDay).type month = tokens[2].get_tag(RepeaterMonth) handle_m_d(month, day, tokens[3..tokens.size], options) end
ruby
def handle_od_rm(tokens, options) day = tokens[0].get_tag(OrdinalDay).type month = tokens[2].get_tag(RepeaterMonth) handle_m_d(month, day, tokens[3..tokens.size], options) end
[ "def", "handle_od_rm", "(", "tokens", ",", "options", ")", "day", "=", "tokens", "[", "0", "]", ".", "get_tag", "(", "OrdinalDay", ")", ".", "type", "month", "=", "tokens", "[", "2", "]", ".", "get_tag", "(", "RepeaterMonth", ")", "handle_m_d", "(", "month", ",", "day", ",", "tokens", "[", "3", "..", "tokens", ".", "size", "]", ",", "options", ")", "end" ]
Handle ordinal this month
[ "Handle", "ordinal", "this", "month" ]
2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c
https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/handlers.rb#L54-L58
12,505
mojombo/chronic
lib/chronic/handlers.rb
Chronic.Handlers.handle_r
def handle_r(tokens, options) dd_tokens = dealias_and_disambiguate_times(tokens, options) get_anchor(dd_tokens, options) end
ruby
def handle_r(tokens, options) dd_tokens = dealias_and_disambiguate_times(tokens, options) get_anchor(dd_tokens, options) end
[ "def", "handle_r", "(", "tokens", ",", "options", ")", "dd_tokens", "=", "dealias_and_disambiguate_times", "(", "tokens", ",", "options", ")", "get_anchor", "(", "dd_tokens", ",", "options", ")", "end" ]
anchors Handle repeaters
[ "anchors", "Handle", "repeaters" ]
2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c
https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/handlers.rb#L432-L435
12,506
mojombo/chronic
lib/chronic/handlers.rb
Chronic.Handlers.handle_orr
def handle_orr(tokens, outer_span, options) repeater = tokens[1].get_tag(Repeater) repeater.start = outer_span.begin - 1 ordinal = tokens[0].get_tag(Ordinal).type span = nil ordinal.times do span = repeater.next(:future) if span.begin >= outer_span.end span = nil break end end span end
ruby
def handle_orr(tokens, outer_span, options) repeater = tokens[1].get_tag(Repeater) repeater.start = outer_span.begin - 1 ordinal = tokens[0].get_tag(Ordinal).type span = nil ordinal.times do span = repeater.next(:future) if span.begin >= outer_span.end span = nil break end end span end
[ "def", "handle_orr", "(", "tokens", ",", "outer_span", ",", "options", ")", "repeater", "=", "tokens", "[", "1", "]", ".", "get_tag", "(", "Repeater", ")", "repeater", ".", "start", "=", "outer_span", ".", "begin", "-", "1", "ordinal", "=", "tokens", "[", "0", "]", ".", "get_tag", "(", "Ordinal", ")", ".", "type", "span", "=", "nil", "ordinal", ".", "times", "do", "span", "=", "repeater", ".", "next", "(", ":future", ")", "if", "span", ".", "begin", ">=", "outer_span", ".", "end", "span", "=", "nil", "break", "end", "end", "span", "end" ]
narrows Handle oridinal repeaters
[ "narrows", "Handle", "oridinal", "repeaters" ]
2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c
https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/handlers.rb#L488-L504
12,507
mojombo/chronic
lib/chronic/handlers.rb
Chronic.Handlers.find_within
def find_within(tags, span, pointer) puts "--#{span}" if Chronic.debug return span if tags.empty? head = tags.shift head.start = (pointer == :future ? span.begin : span.end) h = head.this(:none) if span.cover?(h.begin) || span.cover?(h.end) find_within(tags, h, pointer) end end
ruby
def find_within(tags, span, pointer) puts "--#{span}" if Chronic.debug return span if tags.empty? head = tags.shift head.start = (pointer == :future ? span.begin : span.end) h = head.this(:none) if span.cover?(h.begin) || span.cover?(h.end) find_within(tags, h, pointer) end end
[ "def", "find_within", "(", "tags", ",", "span", ",", "pointer", ")", "puts", "\"--#{span}\"", "if", "Chronic", ".", "debug", "return", "span", "if", "tags", ".", "empty?", "head", "=", "tags", ".", "shift", "head", ".", "start", "=", "(", "pointer", "==", ":future", "?", "span", ".", "begin", ":", "span", ".", "end", ")", "h", "=", "head", ".", "this", "(", ":none", ")", "if", "span", ".", "cover?", "(", "h", ".", "begin", ")", "||", "span", ".", "cover?", "(", "h", ".", "end", ")", "find_within", "(", "tags", ",", "h", ",", "pointer", ")", "end", "end" ]
Recursively finds repeaters within other repeaters. Returns a Span representing the innermost time span or nil if no repeater union could be found
[ "Recursively", "finds", "repeaters", "within", "other", "repeaters", ".", "Returns", "a", "Span", "representing", "the", "innermost", "time", "span", "or", "nil", "if", "no", "repeater", "union", "could", "be", "found" ]
2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c
https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/handlers.rb#L584-L595
12,508
mojombo/chronic
lib/chronic/handler.rb
Chronic.Handler.match
def match(tokens, definitions) token_index = 0 @pattern.each do |elements| was_optional = false elements = [elements] unless elements.is_a?(Array) elements.each_index do |i| name = elements[i].to_s optional = name[-1, 1] == '?' name = name.chop if optional case elements[i] when Symbol if tags_match?(name, tokens, token_index) token_index += 1 break else if optional was_optional = true next elsif i + 1 < elements.count next else return false unless was_optional end end when String return true if optional && token_index == tokens.size if definitions.key?(name.to_sym) sub_handlers = definitions[name.to_sym] else raise "Invalid subset #{name} specified" end sub_handlers.each do |sub_handler| return true if sub_handler.match(tokens[token_index..tokens.size], definitions) end else raise "Invalid match type: #{elements[i].class}" end end end return false if token_index != tokens.size return true end
ruby
def match(tokens, definitions) token_index = 0 @pattern.each do |elements| was_optional = false elements = [elements] unless elements.is_a?(Array) elements.each_index do |i| name = elements[i].to_s optional = name[-1, 1] == '?' name = name.chop if optional case elements[i] when Symbol if tags_match?(name, tokens, token_index) token_index += 1 break else if optional was_optional = true next elsif i + 1 < elements.count next else return false unless was_optional end end when String return true if optional && token_index == tokens.size if definitions.key?(name.to_sym) sub_handlers = definitions[name.to_sym] else raise "Invalid subset #{name} specified" end sub_handlers.each do |sub_handler| return true if sub_handler.match(tokens[token_index..tokens.size], definitions) end else raise "Invalid match type: #{elements[i].class}" end end end return false if token_index != tokens.size return true end
[ "def", "match", "(", "tokens", ",", "definitions", ")", "token_index", "=", "0", "@pattern", ".", "each", "do", "|", "elements", "|", "was_optional", "=", "false", "elements", "=", "[", "elements", "]", "unless", "elements", ".", "is_a?", "(", "Array", ")", "elements", ".", "each_index", "do", "|", "i", "|", "name", "=", "elements", "[", "i", "]", ".", "to_s", "optional", "=", "name", "[", "-", "1", ",", "1", "]", "==", "'?'", "name", "=", "name", ".", "chop", "if", "optional", "case", "elements", "[", "i", "]", "when", "Symbol", "if", "tags_match?", "(", "name", ",", "tokens", ",", "token_index", ")", "token_index", "+=", "1", "break", "else", "if", "optional", "was_optional", "=", "true", "next", "elsif", "i", "+", "1", "<", "elements", ".", "count", "next", "else", "return", "false", "unless", "was_optional", "end", "end", "when", "String", "return", "true", "if", "optional", "&&", "token_index", "==", "tokens", ".", "size", "if", "definitions", ".", "key?", "(", "name", ".", "to_sym", ")", "sub_handlers", "=", "definitions", "[", "name", ".", "to_sym", "]", "else", "raise", "\"Invalid subset #{name} specified\"", "end", "sub_handlers", ".", "each", "do", "|", "sub_handler", "|", "return", "true", "if", "sub_handler", ".", "match", "(", "tokens", "[", "token_index", "..", "tokens", ".", "size", "]", ",", "definitions", ")", "end", "else", "raise", "\"Invalid match type: #{elements[i].class}\"", "end", "end", "end", "return", "false", "if", "token_index", "!=", "tokens", ".", "size", "return", "true", "end" ]
pattern - An Array of patterns to match tokens against. handler_method - A Symbol representing the method to be invoked when a pattern matches. tokens - An Array of tokens to process. definitions - A Hash of definitions to check against. Returns true if a match is found.
[ "pattern", "-", "An", "Array", "of", "patterns", "to", "match", "tokens", "against", ".", "handler_method", "-", "A", "Symbol", "representing", "the", "method", "to", "be", "invoked", "when", "a", "pattern", "matches", ".", "tokens", "-", "An", "Array", "of", "tokens", "to", "process", ".", "definitions", "-", "A", "Hash", "of", "definitions", "to", "check", "against", "." ]
2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c
https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/handler.rb#L20-L68
12,509
piotrmurach/github
lib/github_api/client/repos.rb
Github.Client::Repos.create
def create(*args) arguments(args) do assert_required %w[ name ] end params = arguments.params # Requires authenticated user if (org = params.delete('org') || org) post_request("/orgs/#{org}/repos", params) else post_request("/user/repos", params) end end
ruby
def create(*args) arguments(args) do assert_required %w[ name ] end params = arguments.params # Requires authenticated user if (org = params.delete('org') || org) post_request("/orgs/#{org}/repos", params) else post_request("/user/repos", params) end end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ")", "do", "assert_required", "%w[", "name", "]", "end", "params", "=", "arguments", ".", "params", "# Requires authenticated user", "if", "(", "org", "=", "params", ".", "delete", "(", "'org'", ")", "||", "org", ")", "post_request", "(", "\"/orgs/#{org}/repos\"", ",", "params", ")", "else", "post_request", "(", "\"/user/repos\"", ",", "params", ")", "end", "end" ]
Create a new repository for the authenticated user. @param [Hash] params @option params [String] :name Required string @option params [String] :description Optional string @option params [String] :homepage Optional string @option params [Boolean] :private Optional boolean - true to create a private repository, false to create a public one. @option params [Boolean] :has_issues Optional boolean - true to enable issues for this repository, false to disable them @option params [Boolean] :has_wiki Optional boolean - true to enable the wiki for this repository, false to disable it. Default is true @option params [Boolean] :has_downloads Optional boolean - true to enable downloads for this repository @option params [String] :org Optional string - The organisation in which this repository will be created @option params [Numeric] :team_id Optional number - The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization @option params [Boolean] :auto_init Optional boolean - true to create an initial commit with empty README. Default is false. @option params [String] :gitignore_template Optional string - Desired language or platform .gitignore template to apply. Use the name of the template without the extension. For example, “Haskell” Ignored if auto_init parameter is not provided. @example github = Github.new github.repos.create "name": 'repo-name' "description": "This is your first repo", "homepage": "https://github.com", "private": false, "has_issues": true, "has_wiki": true, "has_downloads": true Create a new repository in this organisation. The authenticated user must be a member of this organisation @example github = Github.new oauth_token: '...' github.repos.create name: 'repo-name', org: 'organisation-name' @example
[ "Create", "a", "new", "repository", "for", "the", "authenticated", "user", "." ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos.rb#L240-L252
12,510
piotrmurach/github
lib/github_api/client/users.rb
Github.Client::Users.get
def get(*args) params = arguments(args).params if user_name = params.delete('user') get_request("/users/#{user_name}", params) else get_request("/user", params) end end
ruby
def get(*args) params = arguments(args).params if user_name = params.delete('user') get_request("/users/#{user_name}", params) else get_request("/user", params) end end
[ "def", "get", "(", "*", "args", ")", "params", "=", "arguments", "(", "args", ")", ".", "params", "if", "user_name", "=", "params", ".", "delete", "(", "'user'", ")", "get_request", "(", "\"/users/#{user_name}\"", ",", "params", ")", "else", "get_request", "(", "\"/user\"", ",", "params", ")", "end", "end" ]
Get a single unauthenticated user @example github = Github.new github.users.get user: 'user-name' Get the authenticated user @example github = Github.new oauth_token: '...' github.users.get @api public
[ "Get", "a", "single", "unauthenticated", "user" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/users.rb#L68-L76
12,511
piotrmurach/github
lib/github_api/client/pull_requests/reviews.rb
Github.Client::PullRequests::Reviews.create
def create(*args) arguments(args, required: [:user, :repo, :number]) params = arguments.params params["accept"] ||= PREVIEW_MEDIA post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews", params) end
ruby
def create(*args) arguments(args, required: [:user, :repo, :number]) params = arguments.params params["accept"] ||= PREVIEW_MEDIA post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews", params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":number", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "PREVIEW_MEDIA", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews\"", ",", "params", ")", "end" ]
Create a pull request review @param [Hash] params @option params [String] :event Required string - The review action (event) to perform; can be one of APPROVE, REQUEST_CHANGES, or COMMENT. If left blank, the API returns HTTP 422 (Unrecognizable entity) and the review is left PENDING @option params [String] :body Optional string. The text of the review. @option params [Array] :comments Optional array of draft review comment objects. An array of comments part of the review. @example github = Github.new github.pull_requests.reviews.create 'user-name', 'repo-name', 'number', body: "Nice change", event: "APPROVE", comments: [ { path: 'path/to/file/commented/on', position: 10, body: 'This looks good.' } ] @api public
[ "Create", "a", "pull", "request", "review" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/pull_requests/reviews.rb#L86-L93
12,512
piotrmurach/github
lib/github_api/client/pull_requests/reviews.rb
Github.Client::PullRequests::Reviews.update
def update(*args) arguments(args, required: [:user, :repo, :number, :id]) params = arguments.params params["accept"] ||= PREVIEW_MEDIA post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}/events", params) end
ruby
def update(*args) arguments(args, required: [:user, :repo, :number, :id]) params = arguments.params params["accept"] ||= PREVIEW_MEDIA post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}/events", params) end
[ "def", "update", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":number", ",", ":id", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "PREVIEW_MEDIA", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/reviews/#{arguments.id}/events\"", ",", "params", ")", "end" ]
Update a pull request review @param [Hash] params @option params [String] :state Required string - The review action (event) to perform; can be one of APPROVE, REQUEST_CHANGES, or COMMENT. If left blank, the API returns HTTP 422 (Unrecognizable entity) and the review is left PENDING @optoin params [String] :body Optional string @example github = Github.new oauth_token: '...' github.pull_requests.reviews.update 'user-name', 'repo-name', 'number', 'review-id' body: "Update body", event: "APPROVE" @api public
[ "Update", "a", "pull", "request", "review" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/pull_requests/reviews.rb#L112-L119
12,513
piotrmurach/github
lib/github_api/client/activity/feeds.rb
Github.Client::Activity::Feeds.get
def get(*args) arguments(args, required: [:name]) name = arguments.name response = list.body._links[name] if response params = arguments.params params['accept'] = response.type get_request(response.href, params) end end
ruby
def get(*args) arguments(args, required: [:name]) name = arguments.name response = list.body._links[name] if response params = arguments.params params['accept'] = response.type get_request(response.href, params) end end
[ "def", "get", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":name", "]", ")", "name", "=", "arguments", ".", "name", "response", "=", "list", ".", "body", ".", "_links", "[", "name", "]", "if", "response", "params", "=", "arguments", ".", "params", "params", "[", "'accept'", "]", "=", "response", ".", "type", "get_request", "(", "response", ".", "href", ",", "params", ")", "end", "end" ]
Get all the items for a named timeline @see https://developer.github.com/v3/activity/feeds/#list-feeds @example github = Github.new github.activity.feeds.get "timeline" @param [String] name the name of the timeline resource @api public
[ "Get", "all", "the", "items", "for", "a", "named", "timeline" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/activity/feeds.rb#L37-L47
12,514
piotrmurach/github
lib/github_api/client/projects/cards.rb
Github.Client::Projects::Cards.list
def list(*args) arguments(args, required: [:column_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA response = get_request("/projects/columns/#{arguments.column_id}/cards", params) return response unless block_given? response.each { |el| yield el } end
ruby
def list(*args) arguments(args, required: [:column_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA response = get_request("/projects/columns/#{arguments.column_id}/cards", params) return response unless block_given? response.each { |el| yield el } end
[ "def", "list", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":column_id", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "::", "Github", "::", "Client", "::", "Projects", "::", "PREVIEW_MEDIA", "response", "=", "get_request", "(", "\"/projects/columns/#{arguments.column_id}/cards\"", ",", "params", ")", "return", "response", "unless", "block_given?", "response", ".", "each", "{", "|", "el", "|", "yield", "el", "}", "end" ]
List project cards for a column @example github = Github.new github.projects.cards.list :column_id @see https://developer.github.com/v3/projects/cards/#list-project-cards @api public
[ "List", "project", "cards", "for", "a", "column" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects/cards.rb#L19-L29
12,515
piotrmurach/github
lib/github_api/client/projects/cards.rb
Github.Client::Projects::Cards.create
def create(*args) arguments(args, required: [:column_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA post_request("/projects/columns/#{arguments.column_id}/cards", params) end
ruby
def create(*args) arguments(args, required: [:column_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA post_request("/projects/columns/#{arguments.column_id}/cards", params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":column_id", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "::", "Github", "::", "Client", "::", "Projects", "::", "PREVIEW_MEDIA", "post_request", "(", "\"/projects/columns/#{arguments.column_id}/cards\"", ",", "params", ")", "end" ]
Create a project card for a column @param [Hash] params @option params [String] :note The card's note content. Only valid for cards without another type of content, so this must be omitted if content_id and content_type are specified. @option params [Integer] :content_id The id of the Issue to associate with this card. @option params [String] :content_type The type of content to associate with this card. Can only be "Issue" at this time. @example github = Github.new github.projects.cards.create :column_id, note: 'Card Note' @example github = Github.new github.projects.cards.create :column_id, content_id: <content-id>, content_type: 'content-type' @see https://developer.github.com/v3/projects/cards/#create-a-project-card @api public
[ "Create", "a", "project", "card", "for", "a", "column" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects/cards.rb#L75-L82
12,516
piotrmurach/github
lib/github_api/client/projects/cards.rb
Github.Client::Projects::Cards.update
def update(*args) arguments(args, required: [:card_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA patch_request("/projects/columns/cards/#{arguments.card_id}", params) end
ruby
def update(*args) arguments(args, required: [:card_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA patch_request("/projects/columns/cards/#{arguments.card_id}", params) end
[ "def", "update", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":card_id", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "::", "Github", "::", "Client", "::", "Projects", "::", "PREVIEW_MEDIA", "patch_request", "(", "\"/projects/columns/cards/#{arguments.card_id}\"", ",", "params", ")", "end" ]
Update a project card @param [Hash] params @option params [String] :note The card's note content. Only valid for cards without another type of content, so this cannot be specified if the card already has a content_id and content_type. @example github = Github.new github.projects.cards.update :card_id, note: 'New card note' @see https://developer.github.com/v3/projects/cards/#update-a-project-card @api public
[ "Update", "a", "project", "card" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects/cards.rb#L99-L106
12,517
piotrmurach/github
lib/github_api/client/projects/cards.rb
Github.Client::Projects::Cards.delete
def delete(*args) arguments(args, required: [:card_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA delete_request("/projects/columns/cards/#{arguments.card_id}", params) end
ruby
def delete(*args) arguments(args, required: [:card_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA delete_request("/projects/columns/cards/#{arguments.card_id}", params) end
[ "def", "delete", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":card_id", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "::", "Github", "::", "Client", "::", "Projects", "::", "PREVIEW_MEDIA", "delete_request", "(", "\"/projects/columns/cards/#{arguments.card_id}\"", ",", "params", ")", "end" ]
Delete a project card @example github = Github.new github.projects.cards.delete :card_id @see https://developer.github.com/v3/projects/cards/#delete-a-project-card @api public
[ "Delete", "a", "project", "card" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects/cards.rb#L118-L125
12,518
piotrmurach/github
lib/github_api/client/projects/cards.rb
Github.Client::Projects::Cards.move
def move(*args) arguments(args, required: [:card_id]) do assert_required REQUIRED_MOVE_CARD_PARAMS end params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA post_request("/projects/columns/cards/#{arguments.card_id}/moves", params) end
ruby
def move(*args) arguments(args, required: [:card_id]) do assert_required REQUIRED_MOVE_CARD_PARAMS end params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA post_request("/projects/columns/cards/#{arguments.card_id}/moves", params) end
[ "def", "move", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":card_id", "]", ")", "do", "assert_required", "REQUIRED_MOVE_CARD_PARAMS", "end", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "::", "Github", "::", "Client", "::", "Projects", "::", "PREVIEW_MEDIA", "post_request", "(", "\"/projects/columns/cards/#{arguments.card_id}/moves\"", ",", "params", ")", "end" ]
Move a project card @param [Hash] params @option params [String] :position Required. Required. Can be one of 'first', 'last', or 'after:<column-id>', where <column-id> is the id value of a column in the same project. @example github = Github.new github.projects.cards.move :card_id, position: 'bottom' @example github = Github.new github.projects.cards.move :card_id, position: 'after:<card-id>', column_id: <column-id> @see https://developer.github.com/v3/projects/cards/#move-a-project-card @api public
[ "Move", "a", "project", "card" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects/cards.rb#L147-L156
12,519
piotrmurach/github
lib/github_api/client/issues.rb
Github.Client::Issues.list
def list(*args) params = arguments(args) do assert_values VALID_ISSUE_PARAM_VALUES end.params response = if (org = params.delete('org')) get_request("/orgs/#{org}/issues", params) elsif (user_name = params.delete('user')) && (repo_name = params.delete('repo')) list_repo user_name, repo_name elsif args.include? :user get_request("/user/issues", params) else get_request("/issues", params) end return response unless block_given? response.each { |el| yield el } end
ruby
def list(*args) params = arguments(args) do assert_values VALID_ISSUE_PARAM_VALUES end.params response = if (org = params.delete('org')) get_request("/orgs/#{org}/issues", params) elsif (user_name = params.delete('user')) && (repo_name = params.delete('repo')) list_repo user_name, repo_name elsif args.include? :user get_request("/user/issues", params) else get_request("/issues", params) end return response unless block_given? response.each { |el| yield el } end
[ "def", "list", "(", "*", "args", ")", "params", "=", "arguments", "(", "args", ")", "do", "assert_values", "VALID_ISSUE_PARAM_VALUES", "end", ".", "params", "response", "=", "if", "(", "org", "=", "params", ".", "delete", "(", "'org'", ")", ")", "get_request", "(", "\"/orgs/#{org}/issues\"", ",", "params", ")", "elsif", "(", "user_name", "=", "params", ".", "delete", "(", "'user'", ")", ")", "&&", "(", "repo_name", "=", "params", ".", "delete", "(", "'repo'", ")", ")", "list_repo", "user_name", ",", "repo_name", "elsif", "args", ".", "include?", ":user", "get_request", "(", "\"/user/issues\"", ",", "params", ")", "else", "get_request", "(", "\"/issues\"", ",", "params", ")", "end", "return", "response", "unless", "block_given?", "response", ".", "each", "{", "|", "el", "|", "yield", "el", "}", "end" ]
List your issues List all issues across all the authenticated user’s visible repositories including owned repositories, member repositories, and organization repositories. @example github = Github.new oauth_token: '...' github.issues.list List all issues across owned and member repositories for the authenticated user. @example github = Github.new oauth_token: '...' github.issues.list :user List all issues for a given organization for the authenticated user. @example github = Github.new oauth_token: '...' github.issues.list org: 'org-name' List issues for a repository @example github = Github.new github.issues.list user: 'user-name', repo: 'repo-name' @param [Hash] params @option params [String] :filter * assigned Issues assigned to you (default) * created Issues created by you * mentioned Issues mentioning you * subscribed Issues you've subscribed to updates for * all All issues the user can see @option params [String] :milestone * Integer Milestone number * none for Issues with no Milestone. * * for Issues with any Milestone @option params [String] :state open, closed, default: open @option params [String] :labels String list of comma separated Label names. Example: bug,ui,@high @option params [String] :assignee * String User login * <tt>none</tt> for Issues with no assigned User. * <tt>*</tt> for Issues with any assigned User. @option params [String] :creator String User login @option params [String] :mentioned String User login @option params [String] :sort created, updated, comments, default: <tt>created</tt> @option params [String] :direction asc, desc, default: desc @option params [String] :since Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ @example github = Github.new oauth_token: '...' github.issues.list since: '2011-04-12T12:12:12Z', filter: 'created', state: 'open', labels: "bug,ui,bla", sort: 'comments', direction: 'asc' @api public
[ "List", "your", "issues" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues.rb#L125-L144
12,520
piotrmurach/github
lib/github_api/client/repos/releases/assets.rb
Github.Client::Repos::Releases::Assets.upload
def upload(*args) arguments(args, required: [:owner, :repo, :id, :filepath]) do permit VALID_ASSET_PARAM_NAMES end params = arguments.params unless type = params['content_type'] type = infer_media(arguments.filepath) end file = Faraday::UploadIO.new(arguments.filepath, type) options = { headers: { content_type: type }, endpoint: upload_endpoint, query: {'name' => params['name']} } params['data'] = file.read params['options'] = options post_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}/assets", params) ensure file.close if file end
ruby
def upload(*args) arguments(args, required: [:owner, :repo, :id, :filepath]) do permit VALID_ASSET_PARAM_NAMES end params = arguments.params unless type = params['content_type'] type = infer_media(arguments.filepath) end file = Faraday::UploadIO.new(arguments.filepath, type) options = { headers: { content_type: type }, endpoint: upload_endpoint, query: {'name' => params['name']} } params['data'] = file.read params['options'] = options post_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}/assets", params) ensure file.close if file end
[ "def", "upload", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":owner", ",", ":repo", ",", ":id", ",", ":filepath", "]", ")", "do", "permit", "VALID_ASSET_PARAM_NAMES", "end", "params", "=", "arguments", ".", "params", "unless", "type", "=", "params", "[", "'content_type'", "]", "type", "=", "infer_media", "(", "arguments", ".", "filepath", ")", "end", "file", "=", "Faraday", "::", "UploadIO", ".", "new", "(", "arguments", ".", "filepath", ",", "type", ")", "options", "=", "{", "headers", ":", "{", "content_type", ":", "type", "}", ",", "endpoint", ":", "upload_endpoint", ",", "query", ":", "{", "'name'", "=>", "params", "[", "'name'", "]", "}", "}", "params", "[", "'data'", "]", "=", "file", ".", "read", "params", "[", "'options'", "]", "=", "options", "post_request", "(", "\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}/assets\"", ",", "params", ")", "ensure", "file", ".", "close", "if", "file", "end" ]
Upload a release asset @param [Hash] params @input params [String] :name Required string. The file name of the asset @input params [String] :content_type Required string. The content type of the asset. Example: “application/zip”. @example github = Github.new github.repos.releases.assets.upload 'owner', 'repo', 'id', 'file-path' name: "batman.jpg", content_type: "application/octet-stream" @api public
[ "Upload", "a", "release", "asset" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/releases/assets.rb#L62-L84
12,521
piotrmurach/github
lib/github_api/client/repos/releases/assets.rb
Github.Client::Repos::Releases::Assets.infer_media
def infer_media(filepath) require 'mime/types' types = MIME::Types.type_for(filepath) types.empty? ? 'application/octet-stream' : types.first rescue LoadError raise Github::Error::UnknownMedia.new(filepath) end
ruby
def infer_media(filepath) require 'mime/types' types = MIME::Types.type_for(filepath) types.empty? ? 'application/octet-stream' : types.first rescue LoadError raise Github::Error::UnknownMedia.new(filepath) end
[ "def", "infer_media", "(", "filepath", ")", "require", "'mime/types'", "types", "=", "MIME", "::", "Types", ".", "type_for", "(", "filepath", ")", "types", ".", "empty?", "?", "'application/octet-stream'", ":", "types", ".", "first", "rescue", "LoadError", "raise", "Github", "::", "Error", "::", "UnknownMedia", ".", "new", "(", "filepath", ")", "end" ]
Infer media type of the asset
[ "Infer", "media", "type", "of", "the", "asset" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/releases/assets.rb#L88-L94
12,522
piotrmurach/github
lib/github_api/client/repos/releases/assets.rb
Github.Client::Repos::Releases::Assets.edit
def edit(*args) arguments(args, required: [:owner, :repo, :id]) do permit VALID_ASSET_PARAM_NAMES end patch_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}", arguments.params) end
ruby
def edit(*args) arguments(args, required: [:owner, :repo, :id]) do permit VALID_ASSET_PARAM_NAMES end patch_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}", arguments.params) end
[ "def", "edit", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":owner", ",", ":repo", ",", ":id", "]", ")", "do", "permit", "VALID_ASSET_PARAM_NAMES", "end", "patch_request", "(", "\"/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}\"", ",", "arguments", ".", "params", ")", "end" ]
Edit a release asset Users with push access to the repository can edit a release asset. @param [Hash] params @input params [String] :name Required. The file name of the asset. @input params [String] :label An alternate short description of the asset. Used in place of the filename. @example github = Github.new github.repos.releases.assets.edit 'owner', 'repo', 'id', name: "foo-1.0.0-osx.zip", label: "Mac binary" @api public
[ "Edit", "a", "release", "asset" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/releases/assets.rb#L114-L120
12,523
piotrmurach/github
lib/github_api/client/markdown.rb
Github.Client::Markdown.render
def render(*args) arguments(args) do assert_required ['text'] end params = arguments.params params['raw'] = true post_request("markdown", arguments.params) end
ruby
def render(*args) arguments(args) do assert_required ['text'] end params = arguments.params params['raw'] = true post_request("markdown", arguments.params) end
[ "def", "render", "(", "*", "args", ")", "arguments", "(", "args", ")", "do", "assert_required", "[", "'text'", "]", "end", "params", "=", "arguments", ".", "params", "params", "[", "'raw'", "]", "=", "true", "post_request", "(", "\"markdown\"", ",", "arguments", ".", "params", ")", "end" ]
Render an arbitrary Markdown document = Parameters <tt>:text</tt> - Required string - The Markdown text to render <tt>:mode<tt> - Optional string - The rendering mode * <tt>markdown</tt> to render a document as plain Markdown, just like README files are rendered. * <tt>gfm</tt> to render a document as user-content, e.g. like user comments or issues are rendered. In GFM mode, hard line breaks are always taken into account, and issue and user mentions are linked accordingly. <tt>:context<tt> - Optional string - The repository context, only taken into account when rendering as <tt>gfm</tt> = Examples github = Github.new github.markdown.render "text": "Hello world github/linguist#1 **cool**, and #1!", "mode": "gfm", "context": "github/gollum"
[ "Render", "an", "arbitrary", "Markdown", "document" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/markdown.rb#L29-L37
12,524
piotrmurach/github
lib/github_api/client/markdown.rb
Github.Client::Markdown.render_raw
def render_raw(*args) params = arguments(args).params params['data'] = args.shift params['raw'] = true params['accept'] = params.fetch('accept') { 'text/plain' } post_request("markdown/raw", params) end
ruby
def render_raw(*args) params = arguments(args).params params['data'] = args.shift params['raw'] = true params['accept'] = params.fetch('accept') { 'text/plain' } post_request("markdown/raw", params) end
[ "def", "render_raw", "(", "*", "args", ")", "params", "=", "arguments", "(", "args", ")", ".", "params", "params", "[", "'data'", "]", "=", "args", ".", "shift", "params", "[", "'raw'", "]", "=", "true", "params", "[", "'accept'", "]", "=", "params", ".", "fetch", "(", "'accept'", ")", "{", "'text/plain'", "}", "post_request", "(", "\"markdown/raw\"", ",", "params", ")", "end" ]
Render a Markdown document in raw mode = Input The raw API it not JSON-based. It takes a Markdown document as plaintext <tt>text/plain</tt> or <tt>text/x-markdown</tt> and renders it as plain Markdown without a repository context (just like a README.md file is rendered – this is the simplest way to preview a readme online) = Examples github = Github.new github.markdown.render_raw "Hello github/linguist#1 **cool**, and #1!", "accept": "text/plain",
[ "Render", "a", "Markdown", "document", "in", "raw", "mode" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/markdown.rb#L52-L59
12,525
piotrmurach/github
lib/github_api/client/repos/statuses.rb
Github.Client::Repos::Statuses.create
def create(*args) arguments(args, required: [:user, :repo, :sha]) do permit VALID_STATUS_PARAM_NAMES, recursive: false assert_required REQUIRED_PARAMS end post_request("/repos/#{arguments.user}/#{arguments.repo}/statuses/#{arguments.sha}", arguments.params) end
ruby
def create(*args) arguments(args, required: [:user, :repo, :sha]) do permit VALID_STATUS_PARAM_NAMES, recursive: false assert_required REQUIRED_PARAMS end post_request("/repos/#{arguments.user}/#{arguments.repo}/statuses/#{arguments.sha}", arguments.params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":sha", "]", ")", "do", "permit", "VALID_STATUS_PARAM_NAMES", ",", "recursive", ":", "false", "assert_required", "REQUIRED_PARAMS", "end", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/statuses/#{arguments.sha}\"", ",", "arguments", ".", "params", ")", "end" ]
Create a status @param [Hash] params @input params [String] :state Required. The state of the status. Can be one of pending, success, error, or failure. @input params [String] :target_url The target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the ‘source’ of the Status. For example, if your Continuous Integration system is posting build status, you would want to provide the deep link for the build output for this specific SHA: http://ci.example.com/user/repo/build/sha. @input params [String] :description A short description of the status @input params [String] :context A string label to differentiate this status from the status of other systems. Default: "default" @example github = Github.new github.repos.statuses.create 'user-name', 'repo-name', 'sha', state: "success", target_url: "http://ci.example.com/johndoe/my-repo/builds/sha", description: "Successful build #3 from origin/master" @api public
[ "Create", "a", "status" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/statuses.rb#L82-L89
12,526
piotrmurach/github
lib/github_api/client/activity/starring.rb
Github.Client::Activity::Starring.starring?
def starring?(*args) arguments(args, required: [:user, :repo]) get_request("/user/starred/#{arguments.user}/#{arguments.repo}", arguments.params) true rescue Github::Error::NotFound false end
ruby
def starring?(*args) arguments(args, required: [:user, :repo]) get_request("/user/starred/#{arguments.user}/#{arguments.repo}", arguments.params) true rescue Github::Error::NotFound false end
[ "def", "starring?", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", "]", ")", "get_request", "(", "\"/user/starred/#{arguments.user}/#{arguments.repo}\"", ",", "arguments", ".", "params", ")", "true", "rescue", "Github", "::", "Error", "::", "NotFound", "false", "end" ]
Check if you are starring a repository @see https://developer.github.com/v3/activity/starring/#check-if-you-are-starring-a-repository @example github = Github.new github.activity.starring.starring? 'user-name', 'repo-name' @example github.activity.starring.starring? user: 'user-name', repo: 'repo-name' @return [Boolean] Returns true if this repo is starred by you, false otherwise. @api public
[ "Check", "if", "you", "are", "starring", "a", "repository" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/activity/starring.rb#L81-L88
12,527
piotrmurach/github
lib/github_api/client/gitignore.rb
Github.Client::Gitignore.list
def list(*args) arguments(args) response = get_request("/gitignore/templates", arguments.params) return response unless block_given? response.each { |el| yield el } end
ruby
def list(*args) arguments(args) response = get_request("/gitignore/templates", arguments.params) return response unless block_given? response.each { |el| yield el } end
[ "def", "list", "(", "*", "args", ")", "arguments", "(", "args", ")", "response", "=", "get_request", "(", "\"/gitignore/templates\"", ",", "arguments", ".", "params", ")", "return", "response", "unless", "block_given?", "response", ".", "each", "{", "|", "el", "|", "yield", "el", "}", "end" ]
List all templates available to pass as an option when creating a repository. @see https://developer.github.com/v3/gitignore/#listing-available-templates @example github = Github.new github.gitignore.list github.gitignore.list { |template| ... } @api public
[ "List", "all", "templates", "available", "to", "pass", "as", "an", "option", "when", "creating", "a", "repository", "." ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/gitignore.rb#L20-L26
12,528
piotrmurach/github
lib/github_api/client/gitignore.rb
Github.Client::Gitignore.get
def get(*args) arguments(args, required: [:name]) params = arguments.params if (media = params.delete('accept')) params['accept'] = media params['raw'] = true end get_request("/gitignore/templates/#{arguments.name}", params) end
ruby
def get(*args) arguments(args, required: [:name]) params = arguments.params if (media = params.delete('accept')) params['accept'] = media params['raw'] = true end get_request("/gitignore/templates/#{arguments.name}", params) end
[ "def", "get", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":name", "]", ")", "params", "=", "arguments", ".", "params", "if", "(", "media", "=", "params", ".", "delete", "(", "'accept'", ")", ")", "params", "[", "'accept'", "]", "=", "media", "params", "[", "'raw'", "]", "=", "true", "end", "get_request", "(", "\"/gitignore/templates/#{arguments.name}\"", ",", "params", ")", "end" ]
Get a single template @see https://developer.github.com/v3/gitignore/#get-a-single-template @example 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' @api public
[ "Get", "a", "single", "template" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/gitignore.rb#L44-L54
12,529
piotrmurach/github
lib/github_api/client/issues/labels.rb
Github.Client::Issues::Labels.get
def get(*args) arguments(args, required: [:user, :repo, :label_name]) params = arguments.params get_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", params) end
ruby
def get(*args) arguments(args, required: [:user, :repo, :label_name]) params = arguments.params get_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", params) end
[ "def", "get", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":label_name", "]", ")", "params", "=", "arguments", ".", "params", "get_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}\"", ",", "params", ")", "end" ]
Get a single label @example github = Github.new github.issues.labels.find 'user-name', 'repo-name', 'label-name' @example github = Github.new user: 'user-name', repo: 'repo-name' github.issues.labels.get label_name: 'bug' @api public
[ "Get", "a", "single", "label" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues/labels.rb#L59-L64
12,530
piotrmurach/github
lib/github_api/client/issues/labels.rb
Github.Client::Issues::Labels.create
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_LABEL_INPUTS assert_required VALID_LABEL_INPUTS end post_request("/repos/#{arguments.user}/#{arguments.repo}/labels", arguments.params) end
ruby
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_LABEL_INPUTS assert_required VALID_LABEL_INPUTS end post_request("/repos/#{arguments.user}/#{arguments.repo}/labels", arguments.params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", "]", ")", "do", "permit", "VALID_LABEL_INPUTS", "assert_required", "VALID_LABEL_INPUTS", "end", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/labels\"", ",", "arguments", ".", "params", ")", "end" ]
Create a label @param [Hash] params @option params [String] :name Required string @option params [String] :color Required string - 6 character hex code, without leading @example github = Github.new user: 'user-name', repo: 'repo-name' github.issues.labels.create name: 'API', color: 'FFFFFF' @api public
[ "Create", "a", "label" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues/labels.rb#L80-L87
12,531
piotrmurach/github
lib/github_api/client/issues/labels.rb
Github.Client::Issues::Labels.update
def update(*args) arguments(args, required: [:user, :repo, :label_name]) do permit VALID_LABEL_INPUTS assert_required VALID_LABEL_INPUTS end patch_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", arguments.params) end
ruby
def update(*args) arguments(args, required: [:user, :repo, :label_name]) do permit VALID_LABEL_INPUTS assert_required VALID_LABEL_INPUTS end patch_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", arguments.params) end
[ "def", "update", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":label_name", "]", ")", "do", "permit", "VALID_LABEL_INPUTS", "assert_required", "VALID_LABEL_INPUTS", "end", "patch_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}\"", ",", "arguments", ".", "params", ")", "end" ]
Update a label @param [Hash] params @option params [String] :name Required string @option params [String] :color Required string - 6 character hex code, without leading @example github = Github.new github.issues.labels.update 'user-name', 'repo-name', 'label-name', name: 'API', color: "FFFFFF" @api public
[ "Update", "a", "label" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues/labels.rb#L103-L110
12,532
piotrmurach/github
lib/github_api/client/issues/labels.rb
Github.Client::Issues::Labels.remove
def remove(*args) arguments(args, required: [:user, :repo, :number]) params = arguments.params user = arguments.user repo = arguments.repo number = arguments.number if (label_name = params.delete('label_name')) delete_request("/repos/#{user}/#{repo}/issues/#{number}/labels/#{label_name}", params) else delete_request("/repos/#{user}/#{repo}/issues/#{number}/labels", params) end end
ruby
def remove(*args) arguments(args, required: [:user, :repo, :number]) params = arguments.params user = arguments.user repo = arguments.repo number = arguments.number if (label_name = params.delete('label_name')) delete_request("/repos/#{user}/#{repo}/issues/#{number}/labels/#{label_name}", params) else delete_request("/repos/#{user}/#{repo}/issues/#{number}/labels", params) end end
[ "def", "remove", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":number", "]", ")", "params", "=", "arguments", ".", "params", "user", "=", "arguments", ".", "user", "repo", "=", "arguments", ".", "repo", "number", "=", "arguments", ".", "number", "if", "(", "label_name", "=", "params", ".", "delete", "(", "'label_name'", ")", ")", "delete_request", "(", "\"/repos/#{user}/#{repo}/issues/#{number}/labels/#{label_name}\"", ",", "params", ")", "else", "delete_request", "(", "\"/repos/#{user}/#{repo}/issues/#{number}/labels\"", ",", "params", ")", "end", "end" ]
Remove a label from an issue @example github = Github.new github.issues.labels.remove 'user-name', 'repo-name', 'issue-number', label_name: 'label-name' Remove all labels from an issue @example github = Github.new github.issues.labels.remove 'user-name', 'repo-name', 'issue-number' @api public
[ "Remove", "a", "label", "from", "an", "issue" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues/labels.rb#L157-L169
12,533
piotrmurach/github
lib/github_api/client/issues/labels.rb
Github.Client::Issues::Labels.replace
def replace(*args) arguments(args, required: [:user, :repo, :number]) params = arguments.params params['data'] = arguments.remaining unless arguments.remaining.empty? put_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/labels", params) end
ruby
def replace(*args) arguments(args, required: [:user, :repo, :number]) params = arguments.params params['data'] = arguments.remaining unless arguments.remaining.empty? put_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/labels", params) end
[ "def", "replace", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":number", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "'data'", "]", "=", "arguments", ".", "remaining", "unless", "arguments", ".", "remaining", ".", "empty?", "put_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/labels\"", ",", "params", ")", "end" ]
Replace all labels for an issue Sending an empty array ([]) will remove all Labels from the Issue. @example github = Github.new github.issues.labels.replace 'user-name', 'repo-name', 'issue-number', 'label1', 'label2', ... @api public
[ "Replace", "all", "labels", "for", "an", "issue" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues/labels.rb#L181-L187
12,534
piotrmurach/github
lib/github_api/page_iterator.rb
Github.PageIterator.parse_page_params
def parse_page_params(uri, attr) # :nodoc: return -1 if uri.nil? || uri.empty? parsed = nil begin parsed = URI.parse(uri) rescue URI::Error return -1 end param = parse_query_for_param(parsed.query, attr) return -1 if param.nil? || param.empty? begin return param.to_i rescue ArgumentError return -1 end end
ruby
def parse_page_params(uri, attr) # :nodoc: return -1 if uri.nil? || uri.empty? parsed = nil begin parsed = URI.parse(uri) rescue URI::Error return -1 end param = parse_query_for_param(parsed.query, attr) return -1 if param.nil? || param.empty? begin return param.to_i rescue ArgumentError return -1 end end
[ "def", "parse_page_params", "(", "uri", ",", "attr", ")", "# :nodoc:", "return", "-", "1", "if", "uri", ".", "nil?", "||", "uri", ".", "empty?", "parsed", "=", "nil", "begin", "parsed", "=", "URI", ".", "parse", "(", "uri", ")", "rescue", "URI", "::", "Error", "return", "-", "1", "end", "param", "=", "parse_query_for_param", "(", "parsed", ".", "query", ",", "attr", ")", "return", "-", "1", "if", "param", ".", "nil?", "||", "param", ".", "empty?", "begin", "return", "param", ".", "to_i", "rescue", "ArgumentError", "return", "-", "1", "end", "end" ]
Extracts query string parameter for given name
[ "Extracts", "query", "string", "parameter", "for", "given", "name" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/page_iterator.rb#L113-L128
12,535
piotrmurach/github
lib/github_api/client/scopes.rb
Github.Client::Scopes.list
def list(*args) arguments(args) params = arguments.params token = args.shift if token.is_a?(Hash) && !params['token'].nil? token = params.delete('token') elsif token.nil? token = oauth_token end if token.nil? raise ArgumentError, 'Access token required' end headers = { 'Authorization' => "token #{token}" } params['headers'] = headers response = get_request("/user", params) response.headers.oauth_scopes.split(',').map(&:strip) end
ruby
def list(*args) arguments(args) params = arguments.params token = args.shift if token.is_a?(Hash) && !params['token'].nil? token = params.delete('token') elsif token.nil? token = oauth_token end if token.nil? raise ArgumentError, 'Access token required' end headers = { 'Authorization' => "token #{token}" } params['headers'] = headers response = get_request("/user", params) response.headers.oauth_scopes.split(',').map(&:strip) end
[ "def", "list", "(", "*", "args", ")", "arguments", "(", "args", ")", "params", "=", "arguments", ".", "params", "token", "=", "args", ".", "shift", "if", "token", ".", "is_a?", "(", "Hash", ")", "&&", "!", "params", "[", "'token'", "]", ".", "nil?", "token", "=", "params", ".", "delete", "(", "'token'", ")", "elsif", "token", ".", "nil?", "token", "=", "oauth_token", "end", "if", "token", ".", "nil?", "raise", "ArgumentError", ",", "'Access token required'", "end", "headers", "=", "{", "'Authorization'", "=>", "\"token #{token}\"", "}", "params", "[", "'headers'", "]", "=", "headers", "response", "=", "get_request", "(", "\"/user\"", ",", "params", ")", "response", ".", "headers", ".", "oauth_scopes", ".", "split", "(", "','", ")", ".", "map", "(", ":strip", ")", "end" ]
Check what OAuth scopes you have. @see https://developer.github.com/v3/oauth/#scopes @example github = Github.new oauth_token: 'e72e16c7e42f292c6912e7710c838347ae17' github.scopes.all @example github = Github.new github.scopes.list 'e72e16c7e42f292c6912e7710c838347ae17' @example github = Github.new github.scopes.list token: 'e72e16c7e42f292c6912e7710c838347ae17' @api public
[ "Check", "what", "OAuth", "scopes", "you", "have", "." ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/scopes.rb#L24-L43
12,536
piotrmurach/github
lib/github_api/client/activity/events.rb
Github.Client::Activity::Events.received
def received(*args) arguments(args, required: [:user]) params = arguments.params public_events = if params['public'] params.delete('public') '/public' end response = get_request("/users/#{arguments.user}/received_events#{public_events}", params) return response unless block_given? response.each { |el| yield el } end
ruby
def received(*args) arguments(args, required: [:user]) params = arguments.params public_events = if params['public'] params.delete('public') '/public' end response = get_request("/users/#{arguments.user}/received_events#{public_events}", params) return response unless block_given? response.each { |el| yield el } end
[ "def", "received", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", "]", ")", "params", "=", "arguments", ".", "params", "public_events", "=", "if", "params", "[", "'public'", "]", "params", ".", "delete", "(", "'public'", ")", "'/public'", "end", "response", "=", "get_request", "(", "\"/users/#{arguments.user}/received_events#{public_events}\"", ",", "params", ")", "return", "response", "unless", "block_given?", "response", ".", "each", "{", "|", "el", "|", "yield", "el", "}", "end" ]
List all events that a user has received @see https://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received These are events that you’ve received by watching repos and following users. If you are authenticated as the given user, you will see private events. Otherwise, you’ll only see public events. @example github = Github.new github.activity.events.received 'user-name' github.activity.events.received 'user-name' { |event| ... } List all public events that a user has received @see https://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received @example github = Github.new github.activity.events.received 'user-name', public: true github.activity.events.received 'user-name', public: true { |event| ... } @api public
[ "List", "all", "events", "that", "a", "user", "has", "received" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/activity/events.rb#L150-L162
12,537
piotrmurach/github
lib/github_api/pagination.rb
Github.Pagination.auto_paginate
def auto_paginate(auto=false) if (current_api.auto_pagination? || auto) && self.body.is_a?(Array) resources_bodies = [] each_page { |resource| resources_bodies += resource.body } self.body = resources_bodies end self end
ruby
def auto_paginate(auto=false) if (current_api.auto_pagination? || auto) && self.body.is_a?(Array) resources_bodies = [] each_page { |resource| resources_bodies += resource.body } self.body = resources_bodies end self end
[ "def", "auto_paginate", "(", "auto", "=", "false", ")", "if", "(", "current_api", ".", "auto_pagination?", "||", "auto", ")", "&&", "self", ".", "body", ".", "is_a?", "(", "Array", ")", "resources_bodies", "=", "[", "]", "each_page", "{", "|", "resource", "|", "resources_bodies", "+=", "resource", ".", "body", "}", "self", ".", "body", "=", "resources_bodies", "end", "self", "end" ]
Iterate over results set pages by automatically calling `next_page` until all pages are exhausted. Caution needs to be exercised when using this feature - 100 pages iteration will perform 100 API calls. By default this is off. You can set it on the client, individual API instances or just per given request.
[ "Iterate", "over", "results", "set", "pages", "by", "automatically", "calling", "next_page", "until", "all", "pages", "are", "exhausted", ".", "Caution", "needs", "to", "be", "exercised", "when", "using", "this", "feature", "-", "100", "pages", "iteration", "will", "perform", "100", "API", "calls", ".", "By", "default", "this", "is", "off", ".", "You", "can", "set", "it", "on", "the", "client", "individual", "API", "instances", "or", "just", "per", "given", "request", "." ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/pagination.rb#L28-L35
12,538
piotrmurach/github
lib/github_api/client/projects/columns.rb
Github.Client::Projects::Columns.get
def get(*args) arguments(args, required: [:column_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA get_request("/projects/columns/#{arguments.column_id}", params) end
ruby
def get(*args) arguments(args, required: [:column_id]) params = arguments.params params["accept"] ||= ::Github::Client::Projects::PREVIEW_MEDIA get_request("/projects/columns/#{arguments.column_id}", params) end
[ "def", "get", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":column_id", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "::", "Github", "::", "Client", "::", "Projects", "::", "PREVIEW_MEDIA", "get_request", "(", "\"/projects/columns/#{arguments.column_id}\"", ",", "params", ")", "end" ]
Get a project columns @example github = Github.new github.projects.columns.get :column_id @see https://developer.github.com/v3/projects/columns/#get-a-project-column @api public
[ "Get", "a", "project", "columns" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects/columns.rb#L42-L49
12,539
piotrmurach/github
lib/github_api/client/git_data/trees.rb
Github.Client::GitData::Trees.get
def get(*args) arguments(args, required: [:user, :repo, :sha]) user = arguments.user repo = arguments.repo sha = arguments.sha params = arguments.params response = if params['recursive'] params['recursive'] = 1 get_request("/repos/#{user}/#{repo}/git/trees/#{sha}", params) else get_request("/repos/#{user}/#{repo}/git/trees/#{sha.to_s}", params) end return response unless block_given? response.tree.each { |el| yield el } end
ruby
def get(*args) arguments(args, required: [:user, :repo, :sha]) user = arguments.user repo = arguments.repo sha = arguments.sha params = arguments.params response = if params['recursive'] params['recursive'] = 1 get_request("/repos/#{user}/#{repo}/git/trees/#{sha}", params) else get_request("/repos/#{user}/#{repo}/git/trees/#{sha.to_s}", params) end return response unless block_given? response.tree.each { |el| yield el } end
[ "def", "get", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":sha", "]", ")", "user", "=", "arguments", ".", "user", "repo", "=", "arguments", ".", "repo", "sha", "=", "arguments", ".", "sha", "params", "=", "arguments", ".", "params", "response", "=", "if", "params", "[", "'recursive'", "]", "params", "[", "'recursive'", "]", "=", "1", "get_request", "(", "\"/repos/#{user}/#{repo}/git/trees/#{sha}\"", ",", "params", ")", "else", "get_request", "(", "\"/repos/#{user}/#{repo}/git/trees/#{sha.to_s}\"", ",", "params", ")", "end", "return", "response", "unless", "block_given?", "response", ".", "tree", ".", "each", "{", "|", "el", "|", "yield", "el", "}", "end" ]
Get a tree @example github = Github.new github.git_data.trees.get 'user-name', 'repo-name', 'sha' github.git_data.trees.get 'user-name', 'repo-name', 'sha' do |file| file.path end Get a tree recursively @example github = Github.new github.git_data.trees.get 'user-name', 'repo-name', 'sha', recursive: true @api public
[ "Get", "a", "tree" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/trees.rb#L40-L55
12,540
piotrmurach/github
lib/github_api/client/git_data/trees.rb
Github.Client::GitData::Trees.create
def create(*args) arguments(args, required: [:user, :repo]) do assert_required %w[ tree ] permit VALID_TREE_PARAM_NAMES, 'tree', { recursive: true } assert_values VALID_TREE_PARAM_VALUES, 'tree' end post_request("/repos/#{arguments.user}/#{arguments.repo}/git/trees", arguments.params) end
ruby
def create(*args) arguments(args, required: [:user, :repo]) do assert_required %w[ tree ] permit VALID_TREE_PARAM_NAMES, 'tree', { recursive: true } assert_values VALID_TREE_PARAM_VALUES, 'tree' end post_request("/repos/#{arguments.user}/#{arguments.repo}/git/trees", arguments.params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", "]", ")", "do", "assert_required", "%w[", "tree", "]", "permit", "VALID_TREE_PARAM_NAMES", ",", "'tree'", ",", "{", "recursive", ":", "true", "}", "assert_values", "VALID_TREE_PARAM_VALUES", ",", "'tree'", "end", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/git/trees\"", ",", "arguments", ".", "params", ")", "end" ]
Create a tree The tree creation API will take nested entries as well. If both a tree and a nested path modifying that tree are specified, it will overwrite the contents of that tree with the new path contents and write a new tree out. @param [Hash] params @input params [String] :base_tree The SHA1 of the tree you want to update with new data @input params [Array[Hash]] :tree Required. Objects (of path, mode, type, and sha) specifying a tree structure The tree parameter takes the following keys: @input tree [String] :path The file referenced in the tree @input tree [String] :mode The file mode; one of 100644 for file (blob), 100755 for executable (blob), 040000 for subdirectory (tree), 160000 for submodule (commit), or 120000 for a blob that specifies the path of a symlink @input tree [String] :type Either blob, tree, or commit @input tree [String] :sha The SHA1 checksum ID of the object in the tree @input tree [String] :content The content you want this file to have - GitHub will write this blob out and use the SHA for this entry. Use either this or <tt>tree.sha</tt> @example github = Github.new github.git_data.trees.create 'user-name', 'repo-name', tree: [ { path: "file.rb", mode: "100644", type: "blob", sha: "44b4fc6d56897b048c772eb4087f854f46256132" }, ... ] @api public
[ "Create", "a", "tree" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/trees.rb#L103-L111
12,541
piotrmurach/github
lib/github_api/client/git_data/commits.rb
Github.Client::GitData::Commits.create
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_COMMIT_PARAM_NAMES assert_required REQUIRED_COMMIT_PARAMS end post_request("/repos/#{arguments.user}/#{arguments.repo}/git/commits", arguments.params) end
ruby
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_COMMIT_PARAM_NAMES assert_required REQUIRED_COMMIT_PARAMS end post_request("/repos/#{arguments.user}/#{arguments.repo}/git/commits", arguments.params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", "]", ")", "do", "permit", "VALID_COMMIT_PARAM_NAMES", "assert_required", "REQUIRED_COMMIT_PARAMS", "end", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/git/commits\"", ",", "arguments", ".", "params", ")", "end" ]
Create a commit @param [Hash] params @input params [String] :message The commit message @input params [String] :tree String of the SHA of the tree object this commit points to @input params [Array[String]] :parents Array of the SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided, for a merge commit, an array of more than one should be provided. Optional Parameters You can provide an additional commiter parameter, which is a hash containing information about the committer. Or, you can provide an author parameter, which is a hash containing information about the author. The committer section is optional and will be filled with the author data if omitted. If the author section is omitted, it will be filled in with the authenticated users information and the current date. Both the author and commiter parameters have the same keys: @input params [String] :name String of the name of the author (or commiter) of the commit @input params [String] :email String of the email of the author (or commiter) of the commit @input params [Timestamp] :date Indicates when this commit was authored (or committed). This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. @example github = Github.new github.git_data.commits.create 'user-name', 'repo-name', message: "my commit message", author: { name: "Scott Chacon", email: "schacon@gmail.com", date: "2008-07-09T16:13:30+12:00" }, parents: [ "7d1b31e74ee336d15cbd21741bc88a537ed063a0" ], tree: "827efc6d56897b048c772eb4087f854f46256132"] @api public
[ "Create", "a", "commit" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/commits.rb#L92-L99
12,542
piotrmurach/github
lib/github_api/client/issues/assignees.rb
Github.Client::Issues::Assignees.remove
def remove(*args) arguments(args, required: [:user, :repo, :number]) params = arguments.params params['data'] = { 'assignees' => arguments.remaining } unless arguments.remaining.empty? delete_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/assignees", params) end
ruby
def remove(*args) arguments(args, required: [:user, :repo, :number]) params = arguments.params params['data'] = { 'assignees' => arguments.remaining } unless arguments.remaining.empty? delete_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/assignees", params) end
[ "def", "remove", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":number", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "'data'", "]", "=", "{", "'assignees'", "=>", "arguments", ".", "remaining", "}", "unless", "arguments", ".", "remaining", ".", "empty?", "delete_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/assignees\"", ",", "params", ")", "end" ]
Remove a assignees from an issue @example github = Github.new github.issues.assignees.remove 'user', 'repo', 'issue-number', 'hubot', 'other_assignee' @api public
[ "Remove", "a", "assignees", "from", "an", "issue" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues/assignees.rb#L69-L75
12,543
piotrmurach/github
lib/github_api/api.rb
Github.API.filter_callbacks
def filter_callbacks(kind, action_name) self.class.send("#{kind}_callbacks").select do |callback| callback[:only].nil? || callback[:only].include?(action_name) end end
ruby
def filter_callbacks(kind, action_name) self.class.send("#{kind}_callbacks").select do |callback| callback[:only].nil? || callback[:only].include?(action_name) end end
[ "def", "filter_callbacks", "(", "kind", ",", "action_name", ")", "self", ".", "class", ".", "send", "(", "\"#{kind}_callbacks\"", ")", ".", "select", "do", "|", "callback", "|", "callback", "[", ":only", "]", ".", "nil?", "||", "callback", "[", ":only", "]", ".", "include?", "(", "action_name", ")", "end", "end" ]
Filter callbacks based on kind @param [Symbol] kind one of :before or :after @return [Array[Hash]] @api private
[ "Filter", "callbacks", "based", "on", "kind" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/api.rb#L224-L228
12,544
piotrmurach/github
lib/github_api/api.rb
Github.API.run_callbacks
def run_callbacks(action_name, &block) filter_callbacks(:before, action_name).each { |hook| send hook[:callback] } yield if block_given? filter_callbacks(:after, action_name).each { |hook| send hook[:callback] } end
ruby
def run_callbacks(action_name, &block) filter_callbacks(:before, action_name).each { |hook| send hook[:callback] } yield if block_given? filter_callbacks(:after, action_name).each { |hook| send hook[:callback] } end
[ "def", "run_callbacks", "(", "action_name", ",", "&", "block", ")", "filter_callbacks", "(", ":before", ",", "action_name", ")", ".", "each", "{", "|", "hook", "|", "send", "hook", "[", ":callback", "]", "}", "yield", "if", "block_given?", "filter_callbacks", "(", ":after", ",", "action_name", ")", ".", "each", "{", "|", "hook", "|", "send", "hook", "[", ":callback", "]", "}", "end" ]
Run all callbacks associated with this action @apram [Symbol] action_name @api private
[ "Run", "all", "callbacks", "associated", "with", "this", "action" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/api.rb#L235-L239
12,545
piotrmurach/github
lib/github_api/api.rb
Github.API.set
def set(option, value=(not_set=true), ignore_setter=false, &block) raise ArgumentError, 'value not set' if block and !not_set return self if !not_set and value.nil? if not_set set_options option return self end if respond_to?("#{option}=") and not ignore_setter return __send__("#{option}=", value) end define_accessors option, value self end
ruby
def set(option, value=(not_set=true), ignore_setter=false, &block) raise ArgumentError, 'value not set' if block and !not_set return self if !not_set and value.nil? if not_set set_options option return self end if respond_to?("#{option}=") and not ignore_setter return __send__("#{option}=", value) end define_accessors option, value self end
[ "def", "set", "(", "option", ",", "value", "=", "(", "not_set", "=", "true", ")", ",", "ignore_setter", "=", "false", ",", "&", "block", ")", "raise", "ArgumentError", ",", "'value not set'", "if", "block", "and", "!", "not_set", "return", "self", "if", "!", "not_set", "and", "value", ".", "nil?", "if", "not_set", "set_options", "option", "return", "self", "end", "if", "respond_to?", "(", "\"#{option}=\"", ")", "and", "not", "ignore_setter", "return", "__send__", "(", "\"#{option}=\"", ",", "value", ")", "end", "define_accessors", "option", ",", "value", "self", "end" ]
Set a configuration option for a given namespace @param [String] option @param [Object] value @param [Boolean] ignore_setter @return [self] @api public
[ "Set", "a", "configuration", "option", "for", "a", "given", "namespace" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/api.rb#L294-L309
12,546
piotrmurach/github
lib/github_api/api.rb
Github.API.set_options
def set_options(options) unless options.respond_to?(:each) raise ArgumentError, 'cannot iterate over value' end options.each { |key, value| set(key, value) } end
ruby
def set_options(options) unless options.respond_to?(:each) raise ArgumentError, 'cannot iterate over value' end options.each { |key, value| set(key, value) } end
[ "def", "set_options", "(", "options", ")", "unless", "options", ".", "respond_to?", "(", ":each", ")", "raise", "ArgumentError", ",", "'cannot iterate over value'", "end", "options", ".", "each", "{", "|", "key", ",", "value", "|", "set", "(", "key", ",", "value", ")", "}", "end" ]
Set multiple options @api private
[ "Set", "multiple", "options" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/api.rb#L366-L371
12,547
piotrmurach/github
lib/github_api/api.rb
Github.API.define_accessors
def define_accessors(option, value) setter = proc { |val| set option, val, true } getter = proc { value } define_singleton_method("#{option}=", setter) if setter define_singleton_method(option, getter) if getter end
ruby
def define_accessors(option, value) setter = proc { |val| set option, val, true } getter = proc { value } define_singleton_method("#{option}=", setter) if setter define_singleton_method(option, getter) if getter end
[ "def", "define_accessors", "(", "option", ",", "value", ")", "setter", "=", "proc", "{", "|", "val", "|", "set", "option", ",", "val", ",", "true", "}", "getter", "=", "proc", "{", "value", "}", "define_singleton_method", "(", "\"#{option}=\"", ",", "setter", ")", "if", "setter", "define_singleton_method", "(", "option", ",", "getter", ")", "if", "getter", "end" ]
Define setters and getters @api private
[ "Define", "setters", "and", "getters" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/api.rb#L376-L382
12,548
piotrmurach/github
lib/github_api/api.rb
Github.API.define_singleton_method
def define_singleton_method(method_name, content=Proc.new) (class << self; self; end).class_eval do undef_method(method_name) if method_defined?(method_name) if String === content class_eval("def #{method_name}() #{content}; end") else define_method(method_name, &content) end end end
ruby
def define_singleton_method(method_name, content=Proc.new) (class << self; self; end).class_eval do undef_method(method_name) if method_defined?(method_name) if String === content class_eval("def #{method_name}() #{content}; end") else define_method(method_name, &content) end end end
[ "def", "define_singleton_method", "(", "method_name", ",", "content", "=", "Proc", ".", "new", ")", "(", "class", "<<", "self", ";", "self", ";", "end", ")", ".", "class_eval", "do", "undef_method", "(", "method_name", ")", "if", "method_defined?", "(", "method_name", ")", "if", "String", "===", "content", "class_eval", "(", "\"def #{method_name}() #{content}; end\"", ")", "else", "define_method", "(", "method_name", ",", "content", ")", "end", "end", "end" ]
Dynamically define a method for setting request option @api private
[ "Dynamically", "define", "a", "method", "for", "setting", "request", "option" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/api.rb#L387-L396
12,549
piotrmurach/github
lib/github_api/client/git_data/tags.rb
Github.Client::GitData::Tags.create
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_TAG_PARAM_NAMES assert_values VALID_TAG_PARAM_VALUES end post_request("/repos/#{arguments.user}/#{arguments.repo}/git/tags", arguments.params) end
ruby
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_TAG_PARAM_NAMES assert_values VALID_TAG_PARAM_VALUES end post_request("/repos/#{arguments.user}/#{arguments.repo}/git/tags", arguments.params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", "]", ")", "do", "permit", "VALID_TAG_PARAM_NAMES", "assert_values", "VALID_TAG_PARAM_VALUES", "end", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/git/tags\"", ",", "arguments", ".", "params", ")", "end" ]
Create a tag object Note that creating a tag object does not create the reference that makes a tag in Git. If you want to create an annotated tag in Git, you have to do this call to create the tag object, and then create the refs/tags/[tag] reference. If you want to create a lightweight tag, you simply have to create the reference - this call would be unnecessary. @param [Hash] params @input params [String] :tag The tag @input params [String] :message The tag message @input params [String] :object The SHA of the git object this is tagging @input params [String] :type The type of the object we're tagging. Normally this is a commit but it can also be a tree or a blob @input params [Hash] :tagger A hash with information about the individual creating the tag. The tagger hash contains the following keys: @input tagger [String] :name The name of the author of the tag @input tagger [String] :email The email of the author of the tag @input tagger [String] :date When this object was tagged. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. @xample github = Github.new github.git_data.tags.create 'user-name', 'repo-name', tag: "v0.0.1", message: "initial version\n", type: "commit", object: "c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c", tagger: { name: "Scott Chacon", email: "schacon@gmail.com", date: "2011-06-17T14:53:3" } @api public
[ "Create", "a", "tag", "object" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/tags.rb#L86-L93
12,550
piotrmurach/github
lib/github_api/client/users/followers.rb
Github.Client::Users::Followers.list
def list(*args) params = arguments(args).params response = if user_name = arguments.remaining.first get_request("/users/#{user_name}/followers", params) else get_request("/user/followers", params) end return response unless block_given? response.each { |el| yield el } end
ruby
def list(*args) params = arguments(args).params response = if user_name = arguments.remaining.first get_request("/users/#{user_name}/followers", params) else get_request("/user/followers", params) end return response unless block_given? response.each { |el| yield el } end
[ "def", "list", "(", "*", "args", ")", "params", "=", "arguments", "(", "args", ")", ".", "params", "response", "=", "if", "user_name", "=", "arguments", ".", "remaining", ".", "first", "get_request", "(", "\"/users/#{user_name}/followers\"", ",", "params", ")", "else", "get_request", "(", "\"/user/followers\"", ",", "params", ")", "end", "return", "response", "unless", "block_given?", "response", ".", "each", "{", "|", "el", "|", "yield", "el", "}", "end" ]
List a user's followers @example github = Github.new github.users.followers.list 'user-name' github.users.followers.list 'user-name' { |user| ... } List the authenticated user's followers @example github = Github.new oauth_token: '...' github.users.followers github.users.followers { |user| ... } @api public
[ "List", "a", "user", "s", "followers" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/users/followers.rb#L23-L33
12,551
piotrmurach/github
lib/github_api/client/users/followers.rb
Github.Client::Users::Followers.following?
def following?(*args) arguments(args, required: [:username]) params = arguments.params if target_user = params.delete('target_user') get_request("/users/#{arguments.username}/following/#{target_user}", params) else get_request("/user/following/#{arguments.username}", params) end true rescue Github::Error::NotFound false end
ruby
def following?(*args) arguments(args, required: [:username]) params = arguments.params if target_user = params.delete('target_user') get_request("/users/#{arguments.username}/following/#{target_user}", params) else get_request("/user/following/#{arguments.username}", params) end true rescue Github::Error::NotFound false end
[ "def", "following?", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":username", "]", ")", "params", "=", "arguments", ".", "params", "if", "target_user", "=", "params", ".", "delete", "(", "'target_user'", ")", "get_request", "(", "\"/users/#{arguments.username}/following/#{target_user}\"", ",", "params", ")", "else", "get_request", "(", "\"/user/following/#{arguments.username}\"", ",", "params", ")", "end", "true", "rescue", "Github", "::", "Error", "::", "NotFound", "false", "end" ]
Check if you are following a user @example github = Github.new oauth_token: '...' github.users.followers.following? 'user-name' github.users.followers.following? username: 'user-name' Check if one user follows another @example github = Github.new oauth_token: '...' github.users.followers.following? username: 'user-name', target_user: 'target-user-name' @api public
[ "Check", "if", "you", "are", "following", "a", "user" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/users/followers.rb#L77-L88
12,552
piotrmurach/github
lib/github_api/client/activity/watching.rb
Github.Client::Activity::Watching.watched
def watched(*args) arguments(args) params = arguments.params response = if (user_name = params.delete('user')) get_request("/users/#{user_name}/subscriptions", params) else get_request('/user/subscriptions', params) end return response unless block_given? response.each { |el| yield el } end
ruby
def watched(*args) arguments(args) params = arguments.params response = if (user_name = params.delete('user')) get_request("/users/#{user_name}/subscriptions", params) else get_request('/user/subscriptions', params) end return response unless block_given? response.each { |el| yield el } end
[ "def", "watched", "(", "*", "args", ")", "arguments", "(", "args", ")", "params", "=", "arguments", ".", "params", "response", "=", "if", "(", "user_name", "=", "params", ".", "delete", "(", "'user'", ")", ")", "get_request", "(", "\"/users/#{user_name}/subscriptions\"", ",", "params", ")", "else", "get_request", "(", "'/user/subscriptions'", ",", "params", ")", "end", "return", "response", "unless", "block_given?", "response", ".", "each", "{", "|", "el", "|", "yield", "el", "}", "end" ]
List repos being watched by a user @see https://developer.github.com/v3/activity/watching/#list-repositories-being-watched @example github = Github.new github.activity.watching.watched user: 'user-name' List repos being watched by the authenticated user @example github = Github.new oauth_token: '...' github.activity.watching.watched @api public
[ "List", "repos", "being", "watched", "by", "a", "user" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/activity/watching.rb#L43-L54
12,553
piotrmurach/github
lib/github_api/client/orgs/members.rb
Github.Client::Orgs::Members.member?
def member?(*args) params = arguments(args, required: [:org_name, :user]).params org_name = arguments.org_name user = arguments.user response = if params.delete('public') get_request("/orgs/#{org_name}/public_members/#{user}", params) else get_request("/orgs/#{org_name}/members/#{user}", params) end response.status == 204 rescue Github::Error::NotFound false end
ruby
def member?(*args) params = arguments(args, required: [:org_name, :user]).params org_name = arguments.org_name user = arguments.user response = if params.delete('public') get_request("/orgs/#{org_name}/public_members/#{user}", params) else get_request("/orgs/#{org_name}/members/#{user}", params) end response.status == 204 rescue Github::Error::NotFound false end
[ "def", "member?", "(", "*", "args", ")", "params", "=", "arguments", "(", "args", ",", "required", ":", "[", ":org_name", ",", ":user", "]", ")", ".", "params", "org_name", "=", "arguments", ".", "org_name", "user", "=", "arguments", ".", "user", "response", "=", "if", "params", ".", "delete", "(", "'public'", ")", "get_request", "(", "\"/orgs/#{org_name}/public_members/#{user}\"", ",", "params", ")", "else", "get_request", "(", "\"/orgs/#{org_name}/members/#{user}\"", ",", "params", ")", "end", "response", ".", "status", "==", "204", "rescue", "Github", "::", "Error", "::", "NotFound", "false", "end" ]
Check if user is, publicly or privately, a member of an organization @example github = Github.new github.orgs.members.member? 'org-name', 'member-name' Check if a user is a public member of an organization @example github = Github.new github.orgs.members.member? 'org-name', 'member-name', public: true @api public
[ "Check", "if", "user", "is", "publicly", "or", "privately", "a", "member", "of", "an", "organization" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/orgs/members.rb#L75-L88
12,554
piotrmurach/github
lib/github_api/client/repos/branches/protections.rb
Github.Client::Repos::Branches::Protections.edit
def edit(*args) arguments(args, required: [:user, :repo, :branch]) do permit VALID_PROTECTION_PARAM_NAMES end put_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}/protection", arguments.params) end
ruby
def edit(*args) arguments(args, required: [:user, :repo, :branch]) do permit VALID_PROTECTION_PARAM_NAMES end put_request("/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}/protection", arguments.params) end
[ "def", "edit", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":branch", "]", ")", "do", "permit", "VALID_PROTECTION_PARAM_NAMES", "end", "put_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/branches/#{arguments.branch}/protection\"", ",", "arguments", ".", "params", ")", "end" ]
Edit a branch protection Users with push access to the repository can edit a branch protection. @param [Hash] params @input params [String] :required_status_checks Required. @input params [String] :enforce_admins Required. @input params [String] :restrictions Required. @input params [String] :required_pull_request_reviews Required. Look to the branch protection API to see how to use these https://developer.github.com/v3/repos/branches/#update-branch-protection @example github = Github.new github.repos.branches.protections.edit 'user', 'repo', 'branch', required_pull_request_reviews: {dismiss_stale_reviews: false} @api public
[ "Edit", "a", "branch", "protection" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/branches/protections.rb#L52-L58
12,555
piotrmurach/github
lib/github_api/parameter_filter.rb
Github.ParameterFilter.filter!
def filter!(keys, params, options={:recursive => true}) # :nodoc: case params when Hash, ParamsHash params.keys.each do |k, v| unless (keys.include?(k) or Github::Validations::VALID_API_KEYS.include?(k)) params.delete(k) else filter!(keys, params[k]) if options[:recursive] end end when Array params.map! do |el| filter!(keys, el) if options[:recursive] end else params end return params end
ruby
def filter!(keys, params, options={:recursive => true}) # :nodoc: case params when Hash, ParamsHash params.keys.each do |k, v| unless (keys.include?(k) or Github::Validations::VALID_API_KEYS.include?(k)) params.delete(k) else filter!(keys, params[k]) if options[:recursive] end end when Array params.map! do |el| filter!(keys, el) if options[:recursive] end else params end return params end
[ "def", "filter!", "(", "keys", ",", "params", ",", "options", "=", "{", ":recursive", "=>", "true", "}", ")", "# :nodoc:", "case", "params", "when", "Hash", ",", "ParamsHash", "params", ".", "keys", ".", "each", "do", "|", "k", ",", "v", "|", "unless", "(", "keys", ".", "include?", "(", "k", ")", "or", "Github", "::", "Validations", "::", "VALID_API_KEYS", ".", "include?", "(", "k", ")", ")", "params", ".", "delete", "(", "k", ")", "else", "filter!", "(", "keys", ",", "params", "[", "k", "]", ")", "if", "options", "[", ":recursive", "]", "end", "end", "when", "Array", "params", ".", "map!", "do", "|", "el", "|", "filter!", "(", "keys", ",", "el", ")", "if", "options", "[", ":recursive", "]", "end", "else", "params", "end", "return", "params", "end" ]
Removes any keys from nested hashes that don't match predefiend keys
[ "Removes", "any", "keys", "from", "nested", "hashes", "that", "don", "t", "match", "predefiend", "keys" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/parameter_filter.rb#L14-L32
12,556
piotrmurach/github
lib/github_api/client/orgs/teams.rb
Github.Client::Orgs::Teams.team_repo?
def team_repo?(*args) arguments(args, required: [:id, :user, :repo]) response = get_request("/teams/#{arguments.id}/repos/#{arguments.user}/#{arguments.repo}", arguments.params) response.status == 204 rescue Github::Error::NotFound false end
ruby
def team_repo?(*args) arguments(args, required: [:id, :user, :repo]) response = get_request("/teams/#{arguments.id}/repos/#{arguments.user}/#{arguments.repo}", arguments.params) response.status == 204 rescue Github::Error::NotFound false end
[ "def", "team_repo?", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":id", ",", ":user", ",", ":repo", "]", ")", "response", "=", "get_request", "(", "\"/teams/#{arguments.id}/repos/#{arguments.user}/#{arguments.repo}\"", ",", "arguments", ".", "params", ")", "response", ".", "status", "==", "204", "rescue", "Github", "::", "Error", "::", "NotFound", "false", "end" ]
Check if a repository belongs to a team @see https://developer.github.com/v3/orgs/teams/#get-team-repo @example github = Github.new oauth_token: '...' github.orgs.teams.team_repo? 'team-id', 'user-name', 'repo-name' @api public
[ "Check", "if", "a", "repository", "belongs", "to", "a", "team" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/orgs/teams.rb#L356-L363
12,557
piotrmurach/github
lib/github_api/response/raise_error.rb
Github.Response::RaiseError.on_complete
def on_complete(env) status_code = env[:status].to_i service_error = Github::Error::ServiceError error_class = service_error.error_mapping[status_code] if !error_class and (400...600) === status_code error_class = service_error end raise error_class.new(env) if error_class end
ruby
def on_complete(env) status_code = env[:status].to_i service_error = Github::Error::ServiceError error_class = service_error.error_mapping[status_code] if !error_class and (400...600) === status_code error_class = service_error end raise error_class.new(env) if error_class end
[ "def", "on_complete", "(", "env", ")", "status_code", "=", "env", "[", ":status", "]", ".", "to_i", "service_error", "=", "Github", "::", "Error", "::", "ServiceError", "error_class", "=", "service_error", ".", "error_mapping", "[", "status_code", "]", "if", "!", "error_class", "and", "(", "400", "...", "600", ")", "===", "status_code", "error_class", "=", "service_error", "end", "raise", "error_class", ".", "new", "(", "env", ")", "if", "error_class", "end" ]
Check if status code requires raising a ServiceError @api private
[ "Check", "if", "status", "code", "requires", "raising", "a", "ServiceError" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/response/raise_error.rb#L12-L20
12,558
piotrmurach/github
lib/github_api/client/repos/deployments.rb
Github.Client::Repos::Deployments.create
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_DEPLOYMENTS_OPTIONS assert_required %w[ ref ] end params = arguments.params params['accept'] ||= PREVIEW_MEDIA post_request("repos/#{arguments.user}/#{arguments.repo}/deployments", arguments.params) end
ruby
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_DEPLOYMENTS_OPTIONS assert_required %w[ ref ] end params = arguments.params params['accept'] ||= PREVIEW_MEDIA post_request("repos/#{arguments.user}/#{arguments.repo}/deployments", arguments.params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", "]", ")", "do", "permit", "VALID_DEPLOYMENTS_OPTIONS", "assert_required", "%w[", "ref", "]", "end", "params", "=", "arguments", ".", "params", "params", "[", "'accept'", "]", "||=", "PREVIEW_MEDIA", "post_request", "(", "\"repos/#{arguments.user}/#{arguments.repo}/deployments\"", ",", "arguments", ".", "params", ")", "end" ]
Create a deployment @param [Hash] params @option params [String] :ref Required string. The ref to deploy. This can be a branch, tag, or sha. @option params [Boolean] :auto_merge Optional boolean. Merge the default branch into the requested. @option params [Array] :required_contexts Optional array of status contexts verified against commit status checks. If this parameter is omitted from the parameters then all unique contexts will be verified before a deployment is created. To bypass checking entirely pass an empty array. Defaults to all unique contexts. @option params [String] :payload Optional JSON payload with extra information about the deployment. Default: "" @option params [String] :payload Optional String. Name for the target deployment environment (e.g., production, staging, qa). Default: "production" @option params [String] :description Optional string. Optional short description. @example github = Github.new github.repos.deployments.create 'user-name', 'repo-name', ref: '...' github.repos.deployments.create 'user-name', 'repo-name', ref: '...', description: 'New deploy', force: true @api public
[ "Create", "a", "deployment" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/deployments.rb#L76-L85
12,559
piotrmurach/github
lib/github_api/client/repos/deployments.rb
Github.Client::Repos::Deployments.statuses
def statuses(*args) arguments(args, required: [:user, :repo, :id]) params = arguments.params params['accept'] ||= PREVIEW_MEDIA statuses = get_request("repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses", params) return statuses unless block_given? statuses.each { |status| yield status } end
ruby
def statuses(*args) arguments(args, required: [:user, :repo, :id]) params = arguments.params params['accept'] ||= PREVIEW_MEDIA statuses = get_request("repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses", params) return statuses unless block_given? statuses.each { |status| yield status } end
[ "def", "statuses", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":id", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "'accept'", "]", "||=", "PREVIEW_MEDIA", "statuses", "=", "get_request", "(", "\"repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses\"", ",", "params", ")", "return", "statuses", "unless", "block_given?", "statuses", ".", "each", "{", "|", "status", "|", "yield", "status", "}", "end" ]
List the statuses of a deployment. @param [Hash] params @option params [String] :id Required string. Id of the deployment being queried. @example github = Github.new github.repos.deployments.statuses 'user-name', 'repo-name', DEPLOYMENT_ID github.repos.deployments.statuses 'user-name', 'repo-name', DEPLOYMENT_ID { |status| ... } @api public
[ "List", "the", "statuses", "of", "a", "deployment", "." ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/deployments.rb#L99-L107
12,560
piotrmurach/github
lib/github_api/client/repos/deployments.rb
Github.Client::Repos::Deployments.create_status
def create_status(*args) arguments(args, required: [:user, :repo, :id]) do assert_required %w[ state ] permit VALID_STATUS_OPTIONS end params = arguments.params params['accept'] ||= PREVIEW_MEDIA post_request("repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses", params) end
ruby
def create_status(*args) arguments(args, required: [:user, :repo, :id]) do assert_required %w[ state ] permit VALID_STATUS_OPTIONS end params = arguments.params params['accept'] ||= PREVIEW_MEDIA post_request("repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses", params) end
[ "def", "create_status", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":id", "]", ")", "do", "assert_required", "%w[", "state", "]", "permit", "VALID_STATUS_OPTIONS", "end", "params", "=", "arguments", ".", "params", "params", "[", "'accept'", "]", "||=", "PREVIEW_MEDIA", "post_request", "(", "\"repos/#{arguments.user}/#{arguments.repo}/deployments/#{arguments.id}/statuses\"", ",", "params", ")", "end" ]
Create a deployment status @param [Hash] params @option params [String] :id Required string. Id of the deployment being referenced. @option params [String] :state Required string. State of the deployment. Can be one of: pending, success, error, or failure. @option params [String] :target_url Optional string. The URL associated with the status. @option params [String] :description Optional string. A short description of the status. @example github = Github.new github.repos.deployments.create_status 'user-name', 'repo-name', DEPLOYMENT_ID, state: '...' @api public
[ "Create", "a", "deployment", "status" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/deployments.rb#L127-L136
12,561
piotrmurach/github
lib/github_api/params_hash.rb
Github.ParamsHash.options
def options opts = fetch('options', {}) headers = fetch('headers', {}) if value = accept headers[:accept] = value end opts[:raw] = key?('raw') ? self['raw'] : false opts[:headers] = headers unless headers.empty? opts end
ruby
def options opts = fetch('options', {}) headers = fetch('headers', {}) if value = accept headers[:accept] = value end opts[:raw] = key?('raw') ? self['raw'] : false opts[:headers] = headers unless headers.empty? opts end
[ "def", "options", "opts", "=", "fetch", "(", "'options'", ",", "{", "}", ")", "headers", "=", "fetch", "(", "'headers'", ",", "{", "}", ")", "if", "value", "=", "accept", "headers", "[", ":accept", "]", "=", "value", "end", "opts", "[", ":raw", "]", "=", "key?", "(", "'raw'", ")", "?", "self", "[", "'raw'", "]", ":", "false", "opts", "[", ":headers", "]", "=", "headers", "unless", "headers", ".", "empty?", "opts", "end" ]
Configuration options from request @return [Hash] @api public
[ "Configuration", "options", "from", "request" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/params_hash.rb#L71-L80
12,562
piotrmurach/github
lib/github_api/params_hash.rb
Github.ParamsHash.merge_default
def merge_default(defaults) if defaults && !defaults.empty? defaults.each do |key, value| self[key] = value unless self.key?(key) end end self end
ruby
def merge_default(defaults) if defaults && !defaults.empty? defaults.each do |key, value| self[key] = value unless self.key?(key) end end self end
[ "def", "merge_default", "(", "defaults", ")", "if", "defaults", "&&", "!", "defaults", ".", "empty?", "defaults", ".", "each", "do", "|", "key", ",", "value", "|", "self", "[", "key", "]", "=", "value", "unless", "self", ".", "key?", "(", "key", ")", "end", "end", "self", "end" ]
Update hash with default parameters for non existing keys
[ "Update", "hash", "with", "default", "parameters", "for", "non", "existing", "keys" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/params_hash.rb#L84-L91
12,563
piotrmurach/github
lib/github_api/params_hash.rb
Github.ParamsHash.strict_encode64
def strict_encode64(key) value = self[key] encoded = if Base64.respond_to?(:strict_encode64) Base64.strict_encode64(value) else [value].pack('m0') end self[key] = encoded.delete("\n\r") end
ruby
def strict_encode64(key) value = self[key] encoded = if Base64.respond_to?(:strict_encode64) Base64.strict_encode64(value) else [value].pack('m0') end self[key] = encoded.delete("\n\r") end
[ "def", "strict_encode64", "(", "key", ")", "value", "=", "self", "[", "key", "]", "encoded", "=", "if", "Base64", ".", "respond_to?", "(", ":strict_encode64", ")", "Base64", ".", "strict_encode64", "(", "value", ")", "else", "[", "value", "]", ".", "pack", "(", "'m0'", ")", "end", "self", "[", "key", "]", "=", "encoded", ".", "delete", "(", "\"\\n\\r\"", ")", "end" ]
Base64 encode string removing newline characters @api public
[ "Base64", "encode", "string", "removing", "newline", "characters" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/params_hash.rb#L96-L104
12,564
piotrmurach/github
lib/github_api/client/repos/comments.rb
Github.Client::Repos::Comments.create
def create(*args) arguments(args, required: [:user, :repo, :sha]) do assert_required REQUIRED_COMMENT_OPTIONS end post_request("/repos/#{arguments.user}/#{arguments.repo}/commits/#{arguments.sha}/comments", arguments.params) end
ruby
def create(*args) arguments(args, required: [:user, :repo, :sha]) do assert_required REQUIRED_COMMENT_OPTIONS end post_request("/repos/#{arguments.user}/#{arguments.repo}/commits/#{arguments.sha}/comments", arguments.params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":sha", "]", ")", "do", "assert_required", "REQUIRED_COMMENT_OPTIONS", "end", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/commits/#{arguments.sha}/comments\"", ",", "arguments", ".", "params", ")", "end" ]
Creates a commit comment @param [Hash] params @option params [String] :body Required. The contents of the comment. @option params [String] :path Required. Relative path of the file to comment on. @option params [Number] :position Required number - Line index in the diff to comment on. @option params [Number] :line Required number - Line number in the file to comment on. @example github = Github.new github.repos.comments.create 'user-name', 'repo-name', 'sha-key', body: "Nice change", position: 4, line: 1, path: "file1.txt" @api public
[ "Creates", "a", "commit", "comment" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/comments.rb#L84-L90
12,565
piotrmurach/github
lib/github_api/client/repos/comments.rb
Github.Client::Repos::Comments.update
def update(*args) arguments(args, required: [:user, :repo, :id]) do assert_required REQUIRED_COMMENT_OPTIONS end patch_request("/repos/#{arguments.user}/#{arguments.repo}/comments/#{arguments.id}", arguments.params) end
ruby
def update(*args) arguments(args, required: [:user, :repo, :id]) do assert_required REQUIRED_COMMENT_OPTIONS end patch_request("/repos/#{arguments.user}/#{arguments.repo}/comments/#{arguments.id}", arguments.params) end
[ "def", "update", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":id", "]", ")", "do", "assert_required", "REQUIRED_COMMENT_OPTIONS", "end", "patch_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/comments/#{arguments.id}\"", ",", "arguments", ".", "params", ")", "end" ]
Update a commit comment @param [Hash] params @option params [String] :body Required. The contents of the comment. @example github = Github.new github.repos.comments.update 'user-name', 'repo-name', 'id', body: "Nice change" @api public
[ "Update", "a", "commit", "comment" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/comments.rb#L104-L110
12,566
piotrmurach/github
lib/github_api/client/repos/contents.rb
Github.Client::Repos::Contents.create
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/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}", params) end
ruby
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/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}", params) end
[ "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/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}\"", ",", "params", ")", "end" ]
Create a file This method creates a new file in a repository @param [Hash] params @option params [String] :path Required string. The content path @option params [String] @option params [String] :message Required string. The commit message. @option params [String] :content Required string. The new file content, which will be Base64 encoded @option params [String] :branch 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. Both the author and commiter parameters have the same keys: @option params [String] :name The name of the author (or commiter) of the commit @option params [String] :email The email of the author (or commiter) of the commit @example github = Github.new github.repos.contents.create 'user-name', 'repo-name', 'path', path: 'hello.rb', content: "puts 'hello ruby'", message: "my commit message" @api public
[ "Create", "a", "file" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/contents.rb#L104-L112
12,567
piotrmurach/github
lib/github_api/client/repos/contents.rb
Github.Client::Repos::Contents.delete
def delete(*args) arguments(args, required: [:user, :repo, :path]) do assert_required %w[ path message sha ] end delete_request("/repos/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}", arguments.params) end
ruby
def delete(*args) arguments(args, required: [:user, :repo, :path]) do assert_required %w[ path message sha ] end delete_request("/repos/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}", arguments.params) end
[ "def", "delete", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":path", "]", ")", "do", "assert_required", "%w[", "path", "message", "sha", "]", "end", "delete_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/contents/#{arguments.path}\"", ",", "arguments", ".", "params", ")", "end" ]
Delete a file This method deletes a file in a repository @param [Hash] params @option params [String] :path Requried string. The content path @option params [String] @option params [String] :message Requried string. The commit message. @option params [String] :sha Required string. The blob SHA of the file being replaced. @option params [String] :branch 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. Both the author and commiter parameters have the same keys: @option params [String] :name The name of the author (or commiter) of the commit @option params [String] :email The email of the author (or commiter) of the commit @example github = Github.new github.repos.contents.delete 'user-name', 'repo-name', 'path', path: 'hello.rb', message: "delete hello.rb file", sha: "329688480d39049927147c162b9d2deaf885005f"
[ "Delete", "a", "file" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/contents.rb#L202-L208
12,568
piotrmurach/github
lib/github_api/client/repos/contents.rb
Github.Client::Repos::Contents.archive
def archive(*args) arguments(args, required: [:user, :repo]) params = arguments.params archive_format = params.delete('archive_format') || 'tarball' ref = params.delete('ref') || 'master' disable_redirects do response = get_request("/repos/#{arguments.user}/#{arguments.repo}/#{archive_format}/#{ref}", params) response.headers.location end end
ruby
def archive(*args) arguments(args, required: [:user, :repo]) params = arguments.params archive_format = params.delete('archive_format') || 'tarball' ref = params.delete('ref') || 'master' disable_redirects do response = get_request("/repos/#{arguments.user}/#{arguments.repo}/#{archive_format}/#{ref}", params) response.headers.location end end
[ "def", "archive", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", "]", ")", "params", "=", "arguments", ".", "params", "archive_format", "=", "params", ".", "delete", "(", "'archive_format'", ")", "||", "'tarball'", "ref", "=", "params", ".", "delete", "(", "'ref'", ")", "||", "'master'", "disable_redirects", "do", "response", "=", "get_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/#{archive_format}/#{ref}\"", ",", "params", ")", "response", ".", "headers", ".", "location", "end", "end" ]
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. @param [Hash] params @input params [String] :archive_format Required string. Either tarball or zipball. Default: tarball @input params [String] :ref Optional string. A valid Git reference. Default: the repository’s default branch (usually master) @example github = Github.new github.repos.contents.archive 'user-name', 'repo-name', archive_format: "tarball", ref: "master" @api public
[ "Get", "archive", "link" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/contents.rb#L234-L244
12,569
piotrmurach/github
lib/github_api/normalizer.rb
Github.Normalizer.normalize!
def normalize!(params) case params when Hash params.keys.each do |k| params[k.to_s] = params.delete(k) normalize!(params[k.to_s]) end when Array params.map! do |el| normalize!(el) end end params end
ruby
def normalize!(params) case params when Hash params.keys.each do |k| params[k.to_s] = params.delete(k) normalize!(params[k.to_s]) end when Array params.map! do |el| normalize!(el) end end params end
[ "def", "normalize!", "(", "params", ")", "case", "params", "when", "Hash", "params", ".", "keys", ".", "each", "do", "|", "k", "|", "params", "[", "k", ".", "to_s", "]", "=", "params", ".", "delete", "(", "k", ")", "normalize!", "(", "params", "[", "k", ".", "to_s", "]", ")", "end", "when", "Array", "params", ".", "map!", "do", "|", "el", "|", "normalize!", "(", "el", ")", "end", "end", "params", "end" ]
Turns any keys from nested hashes including nested arrays into strings
[ "Turns", "any", "keys", "from", "nested", "hashes", "including", "nested", "arrays", "into", "strings" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/normalizer.rb#L8-L21
12,570
piotrmurach/github
lib/github_api/client/authorizations/app.rb
Github.Client::Authorizations::App.create
def create(*args) raise_authentication_error unless authenticated? arguments(args, required: [:client_id]) if arguments.client_id put_request("/authorizations/clients/#{arguments.client_id}", arguments.params) else raise raise_app_authentication_error end end
ruby
def create(*args) raise_authentication_error unless authenticated? arguments(args, required: [:client_id]) if arguments.client_id put_request("/authorizations/clients/#{arguments.client_id}", arguments.params) else raise raise_app_authentication_error end end
[ "def", "create", "(", "*", "args", ")", "raise_authentication_error", "unless", "authenticated?", "arguments", "(", "args", ",", "required", ":", "[", ":client_id", "]", ")", "if", "arguments", ".", "client_id", "put_request", "(", "\"/authorizations/clients/#{arguments.client_id}\"", ",", "arguments", ".", "params", ")", "else", "raise", "raise_app_authentication_error", "end", "end" ]
Get-or-create an authorization for a specific app @see https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app @param [Hash] params @option params [String] client_secret The 40 character OAuth app client secret associated with the client ID specified in the URL. @option params [Array] :scopes Optional array - A list of scopes that this authorization is in. @option params [String] :note Optional string - A note to remind you what the OAuth token is for. @option params [String] :note_url Optional string - A URL to remind you what the OAuth token is for. @example github = Github.new github.oauth.app.create 'client-id', client_secret: '...' @api public
[ "Get", "-", "or", "-", "create", "an", "authorization", "for", "a", "specific", "app" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/authorizations/app.rb#L27-L36
12,571
piotrmurach/github
lib/github_api/client/authorizations/app.rb
Github.Client::Authorizations::App.check
def check(*args) raise_authentication_error unless authenticated? params = arguments(args, required: [:client_id, :access_token]).params if arguments.client_id begin get_request("/applications/#{arguments.client_id}/tokens/#{arguments.access_token}", params) rescue Github::Error::NotFound nil end else raise raise_app_authentication_error end end
ruby
def check(*args) raise_authentication_error unless authenticated? params = arguments(args, required: [:client_id, :access_token]).params if arguments.client_id begin get_request("/applications/#{arguments.client_id}/tokens/#{arguments.access_token}", params) rescue Github::Error::NotFound nil end else raise raise_app_authentication_error end end
[ "def", "check", "(", "*", "args", ")", "raise_authentication_error", "unless", "authenticated?", "params", "=", "arguments", "(", "args", ",", "required", ":", "[", ":client_id", ",", ":access_token", "]", ")", ".", "params", "if", "arguments", ".", "client_id", "begin", "get_request", "(", "\"/applications/#{arguments.client_id}/tokens/#{arguments.access_token}\"", ",", "params", ")", "rescue", "Github", "::", "Error", "::", "NotFound", "nil", "end", "else", "raise", "raise_app_authentication_error", "end", "end" ]
Check if an access token is a valid authorization for an application @example github = Github.new basic_auth: "client_id:client_secret" github.oauth.app.check 'client_id', 'access-token' @api public
[ "Check", "if", "an", "access", "token", "is", "a", "valid", "authorization", "for", "an", "application" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/authorizations/app.rb#L45-L58
12,572
piotrmurach/github
lib/github_api/client/authorizations/app.rb
Github.Client::Authorizations::App.delete
def delete(*args) raise_authentication_error unless authenticated? params = arguments(args, required: [:client_id]).params if arguments.client_id if access_token = (params.delete('access_token') || args[1]) delete_request("/applications/#{arguments.client_id}/tokens/#{access_token}", params) else # Revokes all tokens delete_request("/applications/#{arguments.client_id}/tokens", params) end else raise raise_app_authentication_error end end
ruby
def delete(*args) raise_authentication_error unless authenticated? params = arguments(args, required: [:client_id]).params if arguments.client_id if access_token = (params.delete('access_token') || args[1]) delete_request("/applications/#{arguments.client_id}/tokens/#{access_token}", params) else # Revokes all tokens delete_request("/applications/#{arguments.client_id}/tokens", params) end else raise raise_app_authentication_error end end
[ "def", "delete", "(", "*", "args", ")", "raise_authentication_error", "unless", "authenticated?", "params", "=", "arguments", "(", "args", ",", "required", ":", "[", ":client_id", "]", ")", ".", "params", "if", "arguments", ".", "client_id", "if", "access_token", "=", "(", "params", ".", "delete", "(", "'access_token'", ")", "||", "args", "[", "1", "]", ")", "delete_request", "(", "\"/applications/#{arguments.client_id}/tokens/#{access_token}\"", ",", "params", ")", "else", "# Revokes all tokens", "delete_request", "(", "\"/applications/#{arguments.client_id}/tokens\"", ",", "params", ")", "end", "else", "raise", "raise_app_authentication_error", "end", "end" ]
Revoke all authorizations for an application @example github = Github.new basic_auth: "client_id:client_secret" github.oauth.app.delete 'client-id' Revoke an authorization for an application @example github = Github.new basic_auth: "client_id:client_secret" github.oauth.app.delete 'client-id', 'access-token' @api public
[ "Revoke", "all", "authorizations", "for", "an", "application" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/authorizations/app.rb#L73-L87
12,573
piotrmurach/github
lib/github_api/client/projects.rb
Github.Client::Projects.edit
def edit(*args) arguments(args, required: [:id]) params = arguments.params params["accept"] ||= PREVIEW_MEDIA patch_request("/projects/#{arguments.id}", params) end
ruby
def edit(*args) arguments(args, required: [:id]) params = arguments.params params["accept"] ||= PREVIEW_MEDIA patch_request("/projects/#{arguments.id}", params) end
[ "def", "edit", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":id", "]", ")", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "PREVIEW_MEDIA", "patch_request", "(", "\"/projects/#{arguments.id}\"", ",", "params", ")", "end" ]
Edit a project @param [Hash] params @option params [String] :name Optional string @option params [String] :body Optional string @option params [String] :state Optional string @example github = Github.new github.projects.edit 1002604, name: "Outcomes Tracker", body: "The board to track work for the Outcomes application." @api public
[ "Edit", "a", "project" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects.rb#L57-L64
12,574
piotrmurach/github
lib/github_api/client/gists.rb
Github.Client::Gists.list
def list(*args) params = arguments(args).params response = if (user = params.delete('user')) get_request("/users/#{user}/gists", params) elsif args.map(&:to_s).include?('public') get_request("/gists/public", params) else get_request("/gists", params) end return response unless block_given? response.each { |el| yield el } end
ruby
def list(*args) params = arguments(args).params response = if (user = params.delete('user')) get_request("/users/#{user}/gists", params) elsif args.map(&:to_s).include?('public') get_request("/gists/public", params) else get_request("/gists", params) end return response unless block_given? response.each { |el| yield el } end
[ "def", "list", "(", "*", "args", ")", "params", "=", "arguments", "(", "args", ")", ".", "params", "response", "=", "if", "(", "user", "=", "params", ".", "delete", "(", "'user'", ")", ")", "get_request", "(", "\"/users/#{user}/gists\"", ",", "params", ")", "elsif", "args", ".", "map", "(", ":to_s", ")", ".", "include?", "(", "'public'", ")", "get_request", "(", "\"/gists/public\"", ",", "params", ")", "else", "get_request", "(", "\"/gists\"", ",", "params", ")", "end", "return", "response", "unless", "block_given?", "response", ".", "each", "{", "|", "el", "|", "yield", "el", "}", "end" ]
List a user's gists @see https://developer.github.com/v3/gists/#list-a-users-gists @example github = Github.new github.gists.list user: 'user-name' List the authenticated user’s gists or if called anonymously, this will returns all public gists @example github = Github.new oauth_token: '...' github.gists.list List all public gists @see https://developer.github.com/v3/gists/#list-all-public-gists github = Github.new github.gists.list :public @return [Hash] @api public
[ "List", "a", "user", "s", "gists" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/gists.rb#L38-L50
12,575
piotrmurach/github
lib/github_api/client/gists.rb
Github.Client::Gists.get
def get(*args) arguments(args, required: [:id]) if (sha = arguments.params.delete('sha')) get_request("/gists/#{arguments.id}/#{sha}") else get_request("/gists/#{arguments.id}", arguments.params) end end
ruby
def get(*args) arguments(args, required: [:id]) if (sha = arguments.params.delete('sha')) get_request("/gists/#{arguments.id}/#{sha}") else get_request("/gists/#{arguments.id}", arguments.params) end end
[ "def", "get", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":id", "]", ")", "if", "(", "sha", "=", "arguments", ".", "params", ".", "delete", "(", "'sha'", ")", ")", "get_request", "(", "\"/gists/#{arguments.id}/#{sha}\"", ")", "else", "get_request", "(", "\"/gists/#{arguments.id}\"", ",", "arguments", ".", "params", ")", "end", "end" ]
Get a single gist @see https://developer.github.com/v3/gists/#get-a-single-gist @example github = Github.new github.gists.get 'gist-id' Get a specific revision of gist @see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist @example github = Github.new github.gists.get 'gist-id', sha: ' @return [Hash] @api public
[ "Get", "a", "single", "gist" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/gists.rb#L90-L98
12,576
piotrmurach/github
lib/github_api/authorization.rb
Github.Authorization.client
def client @client ||= ::OAuth2::Client.new(client_id, client_secret, { :site => current_options.fetch(:site) { Github.site }, :authorize_url => 'login/oauth/authorize', :token_url => 'login/oauth/access_token', :ssl => { :verify => false } } ) end
ruby
def client @client ||= ::OAuth2::Client.new(client_id, client_secret, { :site => current_options.fetch(:site) { Github.site }, :authorize_url => 'login/oauth/authorize', :token_url => 'login/oauth/access_token', :ssl => { :verify => false } } ) end
[ "def", "client", "@client", "||=", "::", "OAuth2", "::", "Client", ".", "new", "(", "client_id", ",", "client_secret", ",", "{", ":site", "=>", "current_options", ".", "fetch", "(", ":site", ")", "{", "Github", ".", "site", "}", ",", ":authorize_url", "=>", "'login/oauth/authorize'", ",", ":token_url", "=>", "'login/oauth/access_token'", ",", ":ssl", "=>", "{", ":verify", "=>", "false", "}", "}", ")", "end" ]
Setup OAuth2 instance
[ "Setup", "OAuth2", "instance" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/authorization.rb#L9-L18
12,577
piotrmurach/github
lib/github_api/client/orgs/projects.rb
Github.Client::Orgs::Projects.create
def create(*args) arguments(args, required: [:org_name]) do assert_required %w[ name ] end params = arguments.params params["accept"] ||= PREVIEW_MEDIA post_request("/orgs/#{arguments.org_name}/projects", params) end
ruby
def create(*args) arguments(args, required: [:org_name]) do assert_required %w[ name ] end params = arguments.params params["accept"] ||= PREVIEW_MEDIA post_request("/orgs/#{arguments.org_name}/projects", params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":org_name", "]", ")", "do", "assert_required", "%w[", "name", "]", "end", "params", "=", "arguments", ".", "params", "params", "[", "\"accept\"", "]", "||=", "PREVIEW_MEDIA", "post_request", "(", "\"/orgs/#{arguments.org_name}/projects\"", ",", "params", ")", "end" ]
Create a new project for the specified repo @param [Hash] params @option params [String] :name Required string - The name of the project. @option params [String] :body Optional string - The body of the project. @example github = Github.new github.repos.create 'owner-name', 'repo-name', name: 'project-name' github.repos.create name: 'project-name', body: 'project-body', owner: 'owner-name', repo: 'repo-name'
[ "Create", "a", "new", "project", "for", "the", "specified", "repo" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/orgs/projects.rb#L46-L55
12,578
piotrmurach/github
lib/github_api/request.rb
Github.Request.call
def call(current_options, params) unless HTTP_METHODS.include?(action) raise ArgumentError, "unknown http method: #{method}" end puts "EXECUTED: #{action} - #{path} with PARAMS: #{params.request_params}" if ENV['DEBUG'] request_options = params.options connection_options = current_options.merge(request_options) conn = connection(api, connection_options) self.path = Utils::Url.normalize(self.path) if conn.path_prefix != '/' && self.path.index(conn.path_prefix) != 0 self.path = (conn.path_prefix + self.path).gsub(/\/(\/)*/, '/') end response = conn.send(action) do |request| case action.to_sym when *(HTTP_METHODS - METHODS_WITH_BODIES) request.body = params.data if params.key?('data') if params.key?('encoder') request.params.params_encoder(params.encoder) end request.url(self.path, params.request_params) when *METHODS_WITH_BODIES request.url(self.path, connection_options[:query] || {}) request.body = params.data unless params.empty? end end ResponseWrapper.new(response, api) end
ruby
def call(current_options, params) unless HTTP_METHODS.include?(action) raise ArgumentError, "unknown http method: #{method}" end puts "EXECUTED: #{action} - #{path} with PARAMS: #{params.request_params}" if ENV['DEBUG'] request_options = params.options connection_options = current_options.merge(request_options) conn = connection(api, connection_options) self.path = Utils::Url.normalize(self.path) if conn.path_prefix != '/' && self.path.index(conn.path_prefix) != 0 self.path = (conn.path_prefix + self.path).gsub(/\/(\/)*/, '/') end response = conn.send(action) do |request| case action.to_sym when *(HTTP_METHODS - METHODS_WITH_BODIES) request.body = params.data if params.key?('data') if params.key?('encoder') request.params.params_encoder(params.encoder) end request.url(self.path, params.request_params) when *METHODS_WITH_BODIES request.url(self.path, connection_options[:query] || {}) request.body = params.data unless params.empty? end end ResponseWrapper.new(response, api) end
[ "def", "call", "(", "current_options", ",", "params", ")", "unless", "HTTP_METHODS", ".", "include?", "(", "action", ")", "raise", "ArgumentError", ",", "\"unknown http method: #{method}\"", "end", "puts", "\"EXECUTED: #{action} - #{path} with PARAMS: #{params.request_params}\"", "if", "ENV", "[", "'DEBUG'", "]", "request_options", "=", "params", ".", "options", "connection_options", "=", "current_options", ".", "merge", "(", "request_options", ")", "conn", "=", "connection", "(", "api", ",", "connection_options", ")", "self", ".", "path", "=", "Utils", "::", "Url", ".", "normalize", "(", "self", ".", "path", ")", "if", "conn", ".", "path_prefix", "!=", "'/'", "&&", "self", ".", "path", ".", "index", "(", "conn", ".", "path_prefix", ")", "!=", "0", "self", ".", "path", "=", "(", "conn", ".", "path_prefix", "+", "self", ".", "path", ")", ".", "gsub", "(", "/", "\\/", "\\/", "/", ",", "'/'", ")", "end", "response", "=", "conn", ".", "send", "(", "action", ")", "do", "|", "request", "|", "case", "action", ".", "to_sym", "when", "(", "HTTP_METHODS", "-", "METHODS_WITH_BODIES", ")", "request", ".", "body", "=", "params", ".", "data", "if", "params", ".", "key?", "(", "'data'", ")", "if", "params", ".", "key?", "(", "'encoder'", ")", "request", ".", "params", ".", "params_encoder", "(", "params", ".", "encoder", ")", "end", "request", ".", "url", "(", "self", ".", "path", ",", "params", ".", "request_params", ")", "when", "METHODS_WITH_BODIES", "request", ".", "url", "(", "self", ".", "path", ",", "connection_options", "[", ":query", "]", "||", "{", "}", ")", "request", ".", "body", "=", "params", ".", "data", "unless", "params", ".", "empty?", "end", "end", "ResponseWrapper", ".", "new", "(", "response", ",", "api", ")", "end" ]
Create a new Request @return [Github::Request] @api public Performs a request @param [Symbol] method - The Symbol the HTTP verb @param [String] path - String relative URL to access @param [ParamsHash] params - ParamsHash to configure the request API @return [Github::ResponseWrapper] @api private
[ "Create", "a", "new", "Request" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/request.rb#L53-L83
12,579
piotrmurach/github
lib/github_api/client/authorizations.rb
Github.Client::Authorizations.get
def get(*args) raise_authentication_error unless authenticated? arguments(args, required: [:id]) get_request("/authorizations/#{arguments.id}", arguments.params) end
ruby
def get(*args) raise_authentication_error unless authenticated? arguments(args, required: [:id]) get_request("/authorizations/#{arguments.id}", arguments.params) end
[ "def", "get", "(", "*", "args", ")", "raise_authentication_error", "unless", "authenticated?", "arguments", "(", "args", ",", "required", ":", "[", ":id", "]", ")", "get_request", "(", "\"/authorizations/#{arguments.id}\"", ",", "arguments", ".", "params", ")", "end" ]
Get a single authorization @see https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization @example github = Github.new basic_auth: 'login:password' github.oauth.get 'authorization-id' @return [ResponseWrapper] @api public
[ "Get", "a", "single", "authorization" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/authorizations.rb#L45-L50
12,580
piotrmurach/github
lib/github_api/client/authorizations.rb
Github.Client::Authorizations.create
def create(*args) raise_authentication_error unless authenticated? arguments(args) do assert_required :note, :scopes end post_request('/authorizations', arguments.params) end
ruby
def create(*args) raise_authentication_error unless authenticated? arguments(args) do assert_required :note, :scopes end post_request('/authorizations', arguments.params) end
[ "def", "create", "(", "*", "args", ")", "raise_authentication_error", "unless", "authenticated?", "arguments", "(", "args", ")", "do", "assert_required", ":note", ",", ":scopes", "end", "post_request", "(", "'/authorizations'", ",", "arguments", ".", "params", ")", "end" ]
Create a new authorization @see https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization @param [Hash] params @option params [Array[String]] :scopes A list of scopes that this authorization is in. @option params [String] :note Required. A note to remind you what the OAuth token is for. @option params [String] :note_url A URL to remind you what the OAuth token is for. @option params [String] :client_id The 20 character OAuth app client key for which to create the token. @option params [String] :client_secret The 40 character OAuth app client secret for which to create the token. @option params [String] :fingerprint A unique string to distinguish an authorization from others created for the same client ID and user. @example github = Github.new basic_auth: 'login:password' github.oauth.create scopes: ["public_repo"], note: 'amdmin script' @api public
[ "Create", "a", "new", "authorization" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/authorizations.rb#L77-L84
12,581
piotrmurach/github
lib/github_api/client/authorizations.rb
Github.Client::Authorizations.update
def update(*args) raise_authentication_error unless authenticated? arguments(args, required: [:id]) patch_request("/authorizations/#{arguments.id}", arguments.params) end
ruby
def update(*args) raise_authentication_error unless authenticated? arguments(args, required: [:id]) patch_request("/authorizations/#{arguments.id}", arguments.params) end
[ "def", "update", "(", "*", "args", ")", "raise_authentication_error", "unless", "authenticated?", "arguments", "(", "args", ",", "required", ":", "[", ":id", "]", ")", "patch_request", "(", "\"/authorizations/#{arguments.id}\"", ",", "arguments", ".", "params", ")", "end" ]
Update an existing authorization @see https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization @param [Hash] inputs @option inputs [Array] :scopes Optional array - A list of scopes that this authorization is in. @option inputs [Array] :add_scopes Optional array - A list of scopes to add to this authorization. @option inputs [Array] :remove_scopes Optional array - A list of scopes to remove from this authorization. @option inputs [String] :note Optional string - A note to remind you what the OAuth token is for. @optoin inputs [String] :note_url Optional string - A URL to remind you what the OAuth token is for. @option params [String] :fingerprint A unique string to distinguish an authorization from others created for the same client ID and user. @example github = Github.new basic_auth: 'login:password' github.oauth.update "authorization-id", add_scopes: ["repo"] @api public
[ "Update", "an", "existing", "authorization" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/authorizations.rb#L110-L115
12,582
piotrmurach/github
lib/github_api/client/authorizations.rb
Github.Client::Authorizations.delete
def delete(*args) raise_authentication_error unless authenticated? arguments(args, required: [:id]) delete_request("/authorizations/#{arguments.id}", arguments.params) end
ruby
def delete(*args) raise_authentication_error unless authenticated? arguments(args, required: [:id]) delete_request("/authorizations/#{arguments.id}", arguments.params) end
[ "def", "delete", "(", "*", "args", ")", "raise_authentication_error", "unless", "authenticated?", "arguments", "(", "args", ",", "required", ":", "[", ":id", "]", ")", "delete_request", "(", "\"/authorizations/#{arguments.id}\"", ",", "arguments", ".", "params", ")", "end" ]
Delete an authorization @see https://developer.github.com/v3/oauth_authorizations/#delete-an-authorization @example github = Github.new github.oauth.delete 'authorization-id' @api public
[ "Delete", "an", "authorization" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/authorizations.rb#L127-L132
12,583
piotrmurach/github
lib/github_api/client/activity/notifications.rb
Github.Client::Activity::Notifications.list
def list(*args) arguments(args) params = arguments.params response = if ( (user_name = params.delete('user')) && (repo_name = params.delete('repo')) ) get_request("/repos/#{user_name}/#{repo_name}/notifications", params) else get_request('/notifications', params) end return response unless block_given? response.each { |el| yield el } end
ruby
def list(*args) arguments(args) params = arguments.params response = if ( (user_name = params.delete('user')) && (repo_name = params.delete('repo')) ) get_request("/repos/#{user_name}/#{repo_name}/notifications", params) else get_request('/notifications', params) end return response unless block_given? response.each { |el| yield el } end
[ "def", "list", "(", "*", "args", ")", "arguments", "(", "args", ")", "params", "=", "arguments", ".", "params", "response", "=", "if", "(", "(", "user_name", "=", "params", ".", "delete", "(", "'user'", ")", ")", "&&", "(", "repo_name", "=", "params", ".", "delete", "(", "'repo'", ")", ")", ")", "get_request", "(", "\"/repos/#{user_name}/#{repo_name}/notifications\"", ",", "params", ")", "else", "get_request", "(", "'/notifications'", ",", "params", ")", "end", "return", "response", "unless", "block_given?", "response", ".", "each", "{", "|", "el", "|", "yield", "el", "}", "end" ]
List your notifications List all notifications for the current user, grouped by repository. @see https://developer.github.com/v3/activity/notifications/#list-your-notifications @param [Hash] params @option params [Boolean] :all If true, show notifications marked as read. Default: false @option params [Boolean] :participating If true, only shows notifications in which the user is directly participating or mentioned. Default: false @option params [String] :since Filters out any notifications updated before the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Default: Time.now @example github = Github.new oauth_token: 'token' github.activity.notifications.list List your notifications in a repository @see https://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository @example github = Github.new github.activity.notifications.list user: 'user-name', repo: 'repo-name' @api public
[ "List", "your", "notifications" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/activity/notifications.rb#L38-L50
12,584
piotrmurach/github
lib/github_api/client/activity/notifications.rb
Github.Client::Activity::Notifications.mark
def mark(*args) arguments(args) params = arguments.params if ( (user_name = params.delete('user')) && (repo_name = params.delete('repo')) ) put_request("/repos/#{user_name}/#{repo_name}/notifications", params) elsif (thread_id = params.delete("id")) patch_request("/notifications/threads/#{thread_id}", params) else put_request('/notifications', params) end end
ruby
def mark(*args) arguments(args) params = arguments.params if ( (user_name = params.delete('user')) && (repo_name = params.delete('repo')) ) put_request("/repos/#{user_name}/#{repo_name}/notifications", params) elsif (thread_id = params.delete("id")) patch_request("/notifications/threads/#{thread_id}", params) else put_request('/notifications', params) end end
[ "def", "mark", "(", "*", "args", ")", "arguments", "(", "args", ")", "params", "=", "arguments", ".", "params", "if", "(", "(", "user_name", "=", "params", ".", "delete", "(", "'user'", ")", ")", "&&", "(", "repo_name", "=", "params", ".", "delete", "(", "'repo'", ")", ")", ")", "put_request", "(", "\"/repos/#{user_name}/#{repo_name}/notifications\"", ",", "params", ")", "elsif", "(", "thread_id", "=", "params", ".", "delete", "(", "\"id\"", ")", ")", "patch_request", "(", "\"/notifications/threads/#{thread_id}\"", ",", "params", ")", "else", "put_request", "(", "'/notifications'", ",", "params", ")", "end", "end" ]
Mark as read Marking a notification as “read” removes it from the default view on GitHub.com. @see https://developer.github.com/v3/activity/notifications/#mark-as-read @param [Hash] params @option params [String] :last_read_at Describes the last point that notifications were checked. Anything updated since this time will not be updated. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Default: Time.now @example github = Github.new oauth_token: 'token' github.activity.notifications.mark Mark notifications as read in a repository @see https://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository @example github.activity.notifications.mark user: 'user-name', repo: 'repo-name' Mark a thread as read @see https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read @example github.activity.notifications.mark id: 'thread-id' @api public
[ "Mark", "as", "read" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/activity/notifications.rb#L104-L117
12,585
piotrmurach/github
lib/github_api/paged_request.rb
Github.PagedRequest.page_request
def page_request(path, params={}) if params[PARAM_PER_PAGE] == NOT_FOUND params[PARAM_PER_PAGE] = default_page_size end if params[PARAM_PAGE] && params[PARAM_PAGE] == NOT_FOUND params[PARAM_PAGE] = default_page end current_api.get_request(path, ParamsHash.new(params)) end
ruby
def page_request(path, params={}) if params[PARAM_PER_PAGE] == NOT_FOUND params[PARAM_PER_PAGE] = default_page_size end if params[PARAM_PAGE] && params[PARAM_PAGE] == NOT_FOUND params[PARAM_PAGE] = default_page end current_api.get_request(path, ParamsHash.new(params)) end
[ "def", "page_request", "(", "path", ",", "params", "=", "{", "}", ")", "if", "params", "[", "PARAM_PER_PAGE", "]", "==", "NOT_FOUND", "params", "[", "PARAM_PER_PAGE", "]", "=", "default_page_size", "end", "if", "params", "[", "PARAM_PAGE", "]", "&&", "params", "[", "PARAM_PAGE", "]", "==", "NOT_FOUND", "params", "[", "PARAM_PAGE", "]", "=", "default_page", "end", "current_api", ".", "get_request", "(", "path", ",", "ParamsHash", ".", "new", "(", "params", ")", ")", "end" ]
Perform http get request with pagination parameters
[ "Perform", "http", "get", "request", "with", "pagination", "parameters" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/paged_request.rb#L30-L39
12,586
piotrmurach/github
lib/github_api/client/say.rb
Github.Client::Say.say
def say(*args) params = arguments(*args).params params[:s] = args.shift unless args.empty? params['raw'] = true get_request('/octocat', params) end
ruby
def say(*args) params = arguments(*args).params params[:s] = args.shift unless args.empty? params['raw'] = true get_request('/octocat', params) end
[ "def", "say", "(", "*", "args", ")", "params", "=", "arguments", "(", "args", ")", ".", "params", "params", "[", ":s", "]", "=", "args", ".", "shift", "unless", "args", ".", "empty?", "params", "[", "'raw'", "]", "=", "true", "get_request", "(", "'/octocat'", ",", "params", ")", "end" ]
Generate ASCII octocat with speech bubble. @example Github::Client::Say.new.say "My custom string..." @example github = Github.new github.octocat.say "My custom string..."
[ "Generate", "ASCII", "octocat", "with", "speech", "bubble", "." ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/say.rb#L17-L23
12,587
piotrmurach/github
lib/github_api/response_wrapper.rb
Github.ResponseWrapper.each
def each body_parts = self.body.respond_to?(:each) ? self.body : [self.body] return body_parts.to_enum unless block_given? body_parts.each { |part| yield(part) } end
ruby
def each body_parts = self.body.respond_to?(:each) ? self.body : [self.body] return body_parts.to_enum unless block_given? body_parts.each { |part| yield(part) } end
[ "def", "each", "body_parts", "=", "self", ".", "body", ".", "respond_to?", "(", ":each", ")", "?", "self", ".", "body", ":", "[", "self", ".", "body", "]", "return", "body_parts", ".", "to_enum", "unless", "block_given?", "body_parts", ".", "each", "{", "|", "part", "|", "yield", "(", "part", ")", "}", "end" ]
Iterate over each resource inside the body
[ "Iterate", "over", "each", "resource", "inside", "the", "body" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/response_wrapper.rb#L113-L117
12,588
piotrmurach/github
lib/github_api/api/actions.rb
Github.API.api_methods_in
def api_methods_in(klass) methods = klass.send(:instance_methods, false) - [:actions] methods.sort.each_with_object([]) do |method_name, accumulator| unless method_name.to_s.include?('with') || method_name.to_s.include?('without') accumulator << method_name end accumulator end end
ruby
def api_methods_in(klass) methods = klass.send(:instance_methods, false) - [:actions] methods.sort.each_with_object([]) do |method_name, accumulator| unless method_name.to_s.include?('with') || method_name.to_s.include?('without') accumulator << method_name end accumulator end end
[ "def", "api_methods_in", "(", "klass", ")", "methods", "=", "klass", ".", "send", "(", ":instance_methods", ",", "false", ")", "-", "[", ":actions", "]", "methods", ".", "sort", ".", "each_with_object", "(", "[", "]", ")", "do", "|", "method_name", ",", "accumulator", "|", "unless", "method_name", ".", "to_s", ".", "include?", "(", "'with'", ")", "||", "method_name", ".", "to_s", ".", "include?", "(", "'without'", ")", "accumulator", "<<", "method_name", "end", "accumulator", "end", "end" ]
Finds api methods in a class @param [Class] klass The klass to inspect for methods. @api private
[ "Finds", "api", "methods", "in", "a", "class" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/api/actions.rb#L32-L41
12,589
piotrmurach/github
lib/github_api/connection.rb
Github.Connection.default_options
def default_options(options = {}) headers = default_headers.merge(options[:headers] || {}) headers.merge!({USER_AGENT => options[:user_agent]}) { headers: headers, ssl: options[:ssl], url: options[:endpoint] } end
ruby
def default_options(options = {}) headers = default_headers.merge(options[:headers] || {}) headers.merge!({USER_AGENT => options[:user_agent]}) { headers: headers, ssl: options[:ssl], url: options[:endpoint] } end
[ "def", "default_options", "(", "options", "=", "{", "}", ")", "headers", "=", "default_headers", ".", "merge", "(", "options", "[", ":headers", "]", "||", "{", "}", ")", "headers", ".", "merge!", "(", "{", "USER_AGENT", "=>", "options", "[", ":user_agent", "]", "}", ")", "{", "headers", ":", "headers", ",", "ssl", ":", "options", "[", ":ssl", "]", ",", "url", ":", "options", "[", ":endpoint", "]", "}", "end" ]
Create default connection options @return [Hash[Symbol]] the default options @api private
[ "Create", "default", "connection", "options" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/connection.rb#L41-L49
12,590
piotrmurach/github
lib/github_api/connection.rb
Github.Connection.connection
def connection(api, options = {}) connection_options = default_options(options) connection_options.merge!(builder: stack(options.merge!(api: api))) if options[:connection_options] connection_options.deep_merge!(options[:connection_options]) end if ENV['DEBUG'] p "Connection options : \n" pp connection_options end Faraday.new(connection_options) end
ruby
def connection(api, options = {}) connection_options = default_options(options) connection_options.merge!(builder: stack(options.merge!(api: api))) if options[:connection_options] connection_options.deep_merge!(options[:connection_options]) end if ENV['DEBUG'] p "Connection options : \n" pp connection_options end Faraday.new(connection_options) end
[ "def", "connection", "(", "api", ",", "options", "=", "{", "}", ")", "connection_options", "=", "default_options", "(", "options", ")", "connection_options", ".", "merge!", "(", "builder", ":", "stack", "(", "options", ".", "merge!", "(", "api", ":", "api", ")", ")", ")", "if", "options", "[", ":connection_options", "]", "connection_options", ".", "deep_merge!", "(", "options", "[", ":connection_options", "]", ")", "end", "if", "ENV", "[", "'DEBUG'", "]", "p", "\"Connection options : \\n\"", "pp", "connection_options", "end", "Faraday", ".", "new", "(", "connection_options", ")", "end" ]
Creates http connection Returns a Fraday::Connection object
[ "Creates", "http", "connection" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/connection.rb#L69-L80
12,591
piotrmurach/github
lib/github_api/client/users/keys.rb
Github.Client::Users::Keys.update
def update(*args) arguments(args, required: [:id]) do permit VALID_KEY_PARAM_NAMES end patch_request("/user/keys/#{arguments.id}", arguments.params) end
ruby
def update(*args) arguments(args, required: [:id]) do permit VALID_KEY_PARAM_NAMES end patch_request("/user/keys/#{arguments.id}", arguments.params) end
[ "def", "update", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":id", "]", ")", "do", "permit", "VALID_KEY_PARAM_NAMES", "end", "patch_request", "(", "\"/user/keys/#{arguments.id}\"", ",", "arguments", ".", "params", ")", "end" ]
Update a public key for the authenticated user @param [Hash] params @option [String] :title Required string @option [String] :key Required string. sha key @example github = Github.new oauth_token: '...' github.users.keys.update 'key-id', "title": "octocat@octomac", "key": "ssh-rsa AAA..." @api public
[ "Update", "a", "public", "key", "for", "the", "authenticated", "user" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/users/keys.rb#L85-L90
12,592
piotrmurach/github
lib/github_api/mime_type.rb
Github.MimeType.parse
def parse(media) version = 'v3' media.sub!(/^[.]*|[.]*$/,"") media = media.include?('+') ? media.split('+')[0] : media version, media = media.split('.') if media.include?('.') media_type = lookup_media(media) "application/vnd.github.#{version}.#{media_type}" end
ruby
def parse(media) version = 'v3' media.sub!(/^[.]*|[.]*$/,"") media = media.include?('+') ? media.split('+')[0] : media version, media = media.split('.') if media.include?('.') media_type = lookup_media(media) "application/vnd.github.#{version}.#{media_type}" end
[ "def", "parse", "(", "media", ")", "version", "=", "'v3'", "media", ".", "sub!", "(", "/", "/", ",", "\"\"", ")", "media", "=", "media", ".", "include?", "(", "'+'", ")", "?", "media", ".", "split", "(", "'+'", ")", "[", "0", "]", ":", "media", "version", ",", "media", "=", "media", ".", "split", "(", "'.'", ")", "if", "media", ".", "include?", "(", "'.'", ")", "media_type", "=", "lookup_media", "(", "media", ")", "\"application/vnd.github.#{version}.#{media_type}\"", "end" ]
Parse media type param
[ "Parse", "media", "type", "param" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/mime_type.rb#L17-L24
12,593
piotrmurach/github
lib/github_api/client/orgs/hooks.rb
Github.Client::Orgs::Hooks.create
def create(*args) arguments(args, required: [:org_name]) do assert_required REQUIRED_PARAMS end post_request("/orgs/#{arguments.org_name}/hooks", arguments.params) end
ruby
def create(*args) arguments(args, required: [:org_name]) do assert_required REQUIRED_PARAMS end post_request("/orgs/#{arguments.org_name}/hooks", arguments.params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":org_name", "]", ")", "do", "assert_required", "REQUIRED_PARAMS", "end", "post_request", "(", "\"/orgs/#{arguments.org_name}/hooks\"", ",", "arguments", ".", "params", ")", "end" ]
Create a hook @see https://developer.github.com/v3/orgs/hooks/#create-a-hook @param [Hash] params @input params [String] :name Required. The name of the service that is being called. @input params [Hash] :config Required. Key/value pairs to provide settings for this hook. These settings vary between the services and are defined in the github-services repository. Booleans are stored internally as "1" for true, and "0" for false. Any JSON true/false values will be converted automatically. @input params [Array] :events Determines what events the hook is triggered for. Default: ["push"] @input params [Boolean] :active Determines whether the hook is actually triggered on pushes. To create a webhook, the following fields are required by the config: @input config [String] :url A required string defining the URL to which the payloads will be delivered. @input config [String] :content_type An optional string defining the media type used to serialize the payloads. Supported values include json and form. The default is form. @input config [String] :secret An optional string that’s passed with the HTTP requests as an X-Hub-Signature header. The value of this header is computed as the HMAC hex digest of the body, using the secret as the key. @input config [String] :insecure_ssl An optional string that determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include "0" (verification is performed) and "1" (verification is not performed). The default is "0".or instance, if the library doesn't get updated to permit a given parameter the api call won't work, however if we skip permission all together, the endpoint should always work provided the actual resource path doesn't change. I'm in the process of completely removing the permit functionality. @example github = Github.new github.orgs.hooks.create 'org-name', name: "web", active: true, config: { url: "http://something.com/webhook" } } @api public
[ "Create", "a", "hook" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/orgs/hooks.rb#L97-L103
12,594
piotrmurach/github
lib/github_api/client/issues/milestones.rb
Github.Client::Issues::Milestones.create
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_MILESTONE_INPUTS assert_required %w[ title ] end post_request("/repos/#{arguments.user}/#{arguments.repo}/milestones", arguments.params) end
ruby
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_MILESTONE_INPUTS assert_required %w[ title ] end post_request("/repos/#{arguments.user}/#{arguments.repo}/milestones", arguments.params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", "]", ")", "do", "permit", "VALID_MILESTONE_INPUTS", "assert_required", "%w[", "title", "]", "end", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/milestones\"", ",", "arguments", ".", "params", ")", "end" ]
Create a milestone @param [Hash] params @option params [String] :title Required string. The title of the milestone @option params [String] :state The state of the milestone. Either open or closed. Default: open. @option params [String] :description A description of the milestone @option params [String] :due_on The milestone due date. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. @example github = Github.new user: 'user-name', repo: 'repo-name' github.issues.milestones.create title: 'hello-world', state: "open or closed", description: "String", due_on: "Time" @api public
[ "Create", "a", "milestone" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues/milestones.rb#L94-L101
12,595
piotrmurach/github
lib/github_api/client/git_data/references.rb
Github.Client::GitData::References.get
def get(*args) arguments(args, required: [:user, :repo, :ref]) validate_reference arguments.ref params = arguments.params get_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}", params) end
ruby
def get(*args) arguments(args, required: [:user, :repo, :ref]) validate_reference arguments.ref params = arguments.params get_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}", params) end
[ "def", "get", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":ref", "]", ")", "validate_reference", "arguments", ".", "ref", "params", "=", "arguments", ".", "params", "get_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}\"", ",", "params", ")", "end" ]
Get a reference The ref in the URL must be formatted as <tt>heads/branch</tt>, not just branch. For example, the call to get the data for a branch named sc/featureA would be formatted as heads/sc/featureA @example github = Github.new github.git_data.references.get 'user-name', 'repo-name', 'heads/branch' @api public
[ "Get", "a", "reference" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/references.rb#L59-L65
12,596
piotrmurach/github
lib/github_api/client/git_data/references.rb
Github.Client::GitData::References.create
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_REF_PARAM_NAMES assert_required REQUIRED_REF_PARAMS end params = arguments.params validate_reference params['ref'] post_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs", params) end
ruby
def create(*args) arguments(args, required: [:user, :repo]) do permit VALID_REF_PARAM_NAMES assert_required REQUIRED_REF_PARAMS end params = arguments.params validate_reference params['ref'] post_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs", params) end
[ "def", "create", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", "]", ")", "do", "permit", "VALID_REF_PARAM_NAMES", "assert_required", "REQUIRED_REF_PARAMS", "end", "params", "=", "arguments", ".", "params", "validate_reference", "params", "[", "'ref'", "]", "post_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/git/refs\"", ",", "params", ")", "end" ]
Create a reference @param [Hash] params @input params [String] :ref The name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and have at least two slashes, it will be rejected. @input params [String] :sha The SHA1 value to set this reference to @example github = Github.new github.git_data.references.create 'user-name', 'repo-name', ref: "refs/heads/master", sha: "827efc6d56897b048c772eb4087f854f46256132" @api public
[ "Create", "a", "reference" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/references.rb#L85-L94
12,597
piotrmurach/github
lib/github_api/client/git_data/references.rb
Github.Client::GitData::References.update
def update(*args) arguments(args, required: [:user, :repo, :ref]) do permit VALID_REF_PARAM_NAMES assert_required %w[ sha ] end patch_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}", arguments.params) end
ruby
def update(*args) arguments(args, required: [:user, :repo, :ref]) do permit VALID_REF_PARAM_NAMES assert_required %w[ sha ] end patch_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}", arguments.params) end
[ "def", "update", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":ref", "]", ")", "do", "permit", "VALID_REF_PARAM_NAMES", "assert_required", "%w[", "sha", "]", "end", "patch_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}\"", ",", "arguments", ".", "params", ")", "end" ]
Update a reference @param [Hash] params @input params [String] :sha The SHA1 value to set this reference to @input params [Boolean] :force Indicates whether to force the update or to make sure the update is a fast-forward update. Leaving this out or setting it to false will make sure you’re not overwriting work. Default: false @example github = Github.new github.git_data.references.update 'user-name', 'repo-name', 'heads/master', sha: "827efc6d56897b048c772eb4087f854f46256132", force: true @api public
[ "Update", "a", "reference" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/references.rb#L113-L120
12,598
piotrmurach/github
lib/github_api/client/git_data/references.rb
Github.Client::GitData::References.delete
def delete(*args) arguments(args, required: [:user, :repo, :ref]) params = arguments.params delete_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}", params) end
ruby
def delete(*args) arguments(args, required: [:user, :repo, :ref]) params = arguments.params delete_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}", params) end
[ "def", "delete", "(", "*", "args", ")", "arguments", "(", "args", ",", "required", ":", "[", ":user", ",", ":repo", ",", ":ref", "]", ")", "params", "=", "arguments", ".", "params", "delete_request", "(", "\"/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}\"", ",", "params", ")", "end" ]
Delete a reference @example github = Github.new github.git_data.references.delete 'user-name', 'repo-name', "heads/master" @api public
[ "Delete", "a", "reference" ]
8702452c66bea33c9388550aed9e9974f76aaef1
https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/references.rb#L130-L135
12,599
ruby-i18n/i18n
lib/i18n/config.rb
I18n.Config.available_locales_set
def available_locales_set #:nodoc: @@available_locales_set ||= available_locales.inject(Set.new) do |set, locale| set << locale.to_s << locale.to_sym end end
ruby
def available_locales_set #:nodoc: @@available_locales_set ||= available_locales.inject(Set.new) do |set, locale| set << locale.to_s << locale.to_sym end end
[ "def", "available_locales_set", "#:nodoc:", "@@available_locales_set", "||=", "available_locales", ".", "inject", "(", "Set", ".", "new", ")", "do", "|", "set", ",", "locale", "|", "set", "<<", "locale", ".", "to_s", "<<", "locale", ".", "to_sym", "end", "end" ]
Caches the available locales list as both strings and symbols in a Set, so that we can have faster lookups to do the available locales enforce check.
[ "Caches", "the", "available", "locales", "list", "as", "both", "strings", "and", "symbols", "in", "a", "Set", "so", "that", "we", "can", "have", "faster", "lookups", "to", "do", "the", "available", "locales", "enforce", "check", "." ]
0c5dab494d9b043e00662d8e789229c33045c024
https://github.com/ruby-i18n/i18n/blob/0c5dab494d9b043e00662d8e789229c33045c024/lib/i18n/config.rb#L50-L54