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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/locksmith.rb | SidekiqUniqueJobs.Locksmith.unlock! | def unlock!(token = nil)
token ||= jid
Scripts.call(
:unlock,
redis_pool,
keys: [exists_key, grabbed_key, available_key, version_key, UNIQUE_SET, unique_digest],
argv: [token, ttl, lock_type],
)
end | ruby | def unlock!(token = nil)
token ||= jid
Scripts.call(
:unlock,
redis_pool,
keys: [exists_key, grabbed_key, available_key, version_key, UNIQUE_SET, unique_digest],
argv: [token, ttl, lock_type],
)
end | [
"def",
"unlock!",
"(",
"token",
"=",
"nil",
")",
"token",
"||=",
"jid",
"Scripts",
".",
"call",
"(",
":unlock",
",",
"redis_pool",
",",
"keys",
":",
"[",
"exists_key",
",",
"grabbed_key",
",",
"available_key",
",",
"version_key",
",",
"UNIQUE_SET",
",",
... | Removes the lock keys from Redis
@param [String] token the token to unlock (defaults to jid)
@return [false] unless locked?
@return [String] Sidekiq job_id (jid) if successful | [
"Removes",
"the",
"lock",
"keys",
"from",
"Redis"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/locksmith.rb#L91-L100 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/connection.rb | SidekiqUniqueJobs.Connection.redis | def redis(redis_pool = nil)
if redis_pool
redis_pool.with { |conn| yield conn }
else
Sidekiq.redis { |conn| yield conn }
end
end | ruby | def redis(redis_pool = nil)
if redis_pool
redis_pool.with { |conn| yield conn }
else
Sidekiq.redis { |conn| yield conn }
end
end | [
"def",
"redis",
"(",
"redis_pool",
"=",
"nil",
")",
"if",
"redis_pool",
"redis_pool",
".",
"with",
"{",
"|",
"conn",
"|",
"yield",
"conn",
"}",
"else",
"Sidekiq",
".",
"redis",
"{",
"|",
"conn",
"|",
"yield",
"conn",
"}",
"end",
"end"
] | Creates a connection to redis
@return [Sidekiq::RedisConnection, ConnectionPool] a connection to redis | [
"Creates",
"a",
"connection",
"to",
"redis"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/connection.rb#L14-L20 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/digests.rb | SidekiqUniqueJobs.Digests.all | def all(pattern: SCAN_PATTERN, count: DEFAULT_COUNT)
redis { |conn| conn.sscan_each(UNIQUE_SET, match: pattern, count: count).to_a }
end | ruby | def all(pattern: SCAN_PATTERN, count: DEFAULT_COUNT)
redis { |conn| conn.sscan_each(UNIQUE_SET, match: pattern, count: count).to_a }
end | [
"def",
"all",
"(",
"pattern",
":",
"SCAN_PATTERN",
",",
"count",
":",
"DEFAULT_COUNT",
")",
"redis",
"{",
"|",
"conn",
"|",
"conn",
".",
"sscan_each",
"(",
"UNIQUE_SET",
",",
"match",
":",
"pattern",
",",
"count",
":",
"count",
")",
".",
"to_a",
"}",
... | Return unique digests matching pattern
@param [String] pattern a pattern to match with
@param [Integer] count the maximum number to match
@return [Array<String>] with unique digests | [
"Return",
"unique",
"digests",
"matching",
"pattern"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/digests.rb#L21-L23 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/digests.rb | SidekiqUniqueJobs.Digests.page | def page(pattern: SCAN_PATTERN, cursor: 0, page_size: 100)
redis do |conn|
total_size, digests = conn.multi do
conn.scard(UNIQUE_SET)
conn.sscan(UNIQUE_SET, cursor, match: pattern, count: page_size)
end
[total_size, digests[0], digests[1]]
end
end | ruby | def page(pattern: SCAN_PATTERN, cursor: 0, page_size: 100)
redis do |conn|
total_size, digests = conn.multi do
conn.scard(UNIQUE_SET)
conn.sscan(UNIQUE_SET, cursor, match: pattern, count: page_size)
end
[total_size, digests[0], digests[1]]
end
end | [
"def",
"page",
"(",
"pattern",
":",
"SCAN_PATTERN",
",",
"cursor",
":",
"0",
",",
"page_size",
":",
"100",
")",
"redis",
"do",
"|",
"conn",
"|",
"total_size",
",",
"digests",
"=",
"conn",
".",
"multi",
"do",
"conn",
".",
"scard",
"(",
"UNIQUE_SET",
"... | Paginate unique digests
@param [String] pattern a pattern to match with
@param [Integer] cursor the maximum number to match
@param [Integer] page_size the current cursor position
@return [Array<String>] with unique digests | [
"Paginate",
"unique",
"digests"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/digests.rb#L32-L41 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/digests.rb | SidekiqUniqueJobs.Digests.del | def del(digest: nil, pattern: nil, count: DEFAULT_COUNT)
return delete_by_pattern(pattern, count: count) if pattern
return delete_by_digest(digest) if digest
raise ArgumentError, "either digest or pattern need to be provided"
end | ruby | def del(digest: nil, pattern: nil, count: DEFAULT_COUNT)
return delete_by_pattern(pattern, count: count) if pattern
return delete_by_digest(digest) if digest
raise ArgumentError, "either digest or pattern need to be provided"
end | [
"def",
"del",
"(",
"digest",
":",
"nil",
",",
"pattern",
":",
"nil",
",",
"count",
":",
"DEFAULT_COUNT",
")",
"return",
"delete_by_pattern",
"(",
"pattern",
",",
"count",
":",
"count",
")",
"if",
"pattern",
"return",
"delete_by_digest",
"(",
"digest",
")",... | Deletes unique digest either by a digest or pattern
@param [String] digest the full digest to delete
@param [String] pattern a key pattern to match with
@param [Integer] count the maximum number
@raise [ArgumentError] when both pattern and digest are nil
@return [Array<String>] with unique digests | [
"Deletes",
"unique",
"digest",
"either",
"by",
"a",
"digest",
"or",
"pattern"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/digests.rb#L57-L62 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/digests.rb | SidekiqUniqueJobs.Digests.delete_by_pattern | def delete_by_pattern(pattern, count: DEFAULT_COUNT)
result, elapsed = timed do
digests = all(pattern: pattern, count: count)
batch_delete(digests)
digests.size
end
log_info("#{__method__}(#{pattern}, count: #{count}) completed in #{elapsed}ms")
result
end | ruby | def delete_by_pattern(pattern, count: DEFAULT_COUNT)
result, elapsed = timed do
digests = all(pattern: pattern, count: count)
batch_delete(digests)
digests.size
end
log_info("#{__method__}(#{pattern}, count: #{count}) completed in #{elapsed}ms")
result
end | [
"def",
"delete_by_pattern",
"(",
"pattern",
",",
"count",
":",
"DEFAULT_COUNT",
")",
"result",
",",
"elapsed",
"=",
"timed",
"do",
"digests",
"=",
"all",
"(",
"pattern",
":",
"pattern",
",",
"count",
":",
"count",
")",
"batch_delete",
"(",
"digests",
")",
... | Deletes unique digests by pattern
@param [String] pattern a key pattern to match with
@param [Integer] count the maximum number
@return [Array<String>] with unique digests | [
"Deletes",
"unique",
"digests",
"by",
"pattern"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/digests.rb#L71-L81 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/digests.rb | SidekiqUniqueJobs.Digests.delete_by_digest | def delete_by_digest(digest)
result, elapsed = timed do
Scripts.call(:delete_by_digest, nil, keys: [UNIQUE_SET, digest])
count
end
log_info("#{__method__}(#{digest}) completed in #{elapsed}ms")
result
end | ruby | def delete_by_digest(digest)
result, elapsed = timed do
Scripts.call(:delete_by_digest, nil, keys: [UNIQUE_SET, digest])
count
end
log_info("#{__method__}(#{digest}) completed in #{elapsed}ms")
result
end | [
"def",
"delete_by_digest",
"(",
"digest",
")",
"result",
",",
"elapsed",
"=",
"timed",
"do",
"Scripts",
".",
"call",
"(",
":delete_by_digest",
",",
"nil",
",",
"keys",
":",
"[",
"UNIQUE_SET",
",",
"digest",
"]",
")",
"count",
"end",
"log_info",
"(",
"\"#... | Get a total count of unique digests
@param [String] digest a key pattern to match with | [
"Get",
"a",
"total",
"count",
"of",
"unique",
"digests"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/digests.rb#L86-L95 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb | SidekiqUniqueJobs.SidekiqWorkerMethods.worker_class_constantize | def worker_class_constantize(klazz = @worker_class)
return klazz unless klazz.is_a?(String)
Object.const_get(klazz)
rescue NameError => ex
case ex.message
when /uninitialized constant/
klazz
else
raise
end
end | ruby | def worker_class_constantize(klazz = @worker_class)
return klazz unless klazz.is_a?(String)
Object.const_get(klazz)
rescue NameError => ex
case ex.message
when /uninitialized constant/
klazz
else
raise
end
end | [
"def",
"worker_class_constantize",
"(",
"klazz",
"=",
"@worker_class",
")",
"return",
"klazz",
"unless",
"klazz",
".",
"is_a?",
"(",
"String",
")",
"Object",
".",
"const_get",
"(",
"klazz",
")",
"rescue",
"NameError",
"=>",
"ex",
"case",
"ex",
".",
"message"... | Attempt to constantize a string worker_class argument, always
failing back to the original argument when the constant can't be found
@return [Sidekiq::Worker] | [
"Attempt",
"to",
"constantize",
"a",
"string",
"worker_class",
"argument",
"always",
"failing",
"back",
"to",
"the",
"original",
"argument",
"when",
"the",
"constant",
"can",
"t",
"be",
"found"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb#L45-L56 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/config.rb | SidekiqUniqueJobs.Config.add_lock | def add_lock(name, klass)
raise ArgumentError, "Lock #{name} already defined, please use another name" if locks.key?(name.to_sym)
new_locks = locks.dup.merge(name.to_sym => klass).freeze
self.locks = new_locks
end | ruby | def add_lock(name, klass)
raise ArgumentError, "Lock #{name} already defined, please use another name" if locks.key?(name.to_sym)
new_locks = locks.dup.merge(name.to_sym => klass).freeze
self.locks = new_locks
end | [
"def",
"add_lock",
"(",
"name",
",",
"klass",
")",
"raise",
"ArgumentError",
",",
"\"Lock #{name} already defined, please use another name\"",
"if",
"locks",
".",
"key?",
"(",
"name",
".",
"to_sym",
")",
"new_locks",
"=",
"locks",
".",
"dup",
".",
"merge",
"(",
... | Adds a lock type to the configuration. It will raise if the lock exists already
@param [String] name the name of the lock
@param [Class] klass the class describing the lock | [
"Adds",
"a",
"lock",
"type",
"to",
"the",
"configuration",
".",
"It",
"will",
"raise",
"if",
"the",
"lock",
"exists",
"already"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/config.rb#L50-L55 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/config.rb | SidekiqUniqueJobs.Config.add_strategy | def add_strategy(name, klass)
raise ArgumentError, "strategy #{name} already defined, please use another name" if strategies.key?(name.to_sym)
new_strategies = strategies.dup.merge(name.to_sym => klass).freeze
self.strategies = new_strategies
end | ruby | def add_strategy(name, klass)
raise ArgumentError, "strategy #{name} already defined, please use another name" if strategies.key?(name.to_sym)
new_strategies = strategies.dup.merge(name.to_sym => klass).freeze
self.strategies = new_strategies
end | [
"def",
"add_strategy",
"(",
"name",
",",
"klass",
")",
"raise",
"ArgumentError",
",",
"\"strategy #{name} already defined, please use another name\"",
"if",
"strategies",
".",
"key?",
"(",
"name",
".",
"to_sym",
")",
"new_strategies",
"=",
"strategies",
".",
"dup",
... | Adds an on_conflict strategy to the configuration.
It will raise if the strategy exists already
@param [String] name the name of the custom strategy
@param [Class] klass the class describing the strategy | [
"Adds",
"an",
"on_conflict",
"strategy",
"to",
"the",
"configuration",
".",
"It",
"will",
"raise",
"if",
"the",
"strategy",
"exists",
"already"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/config.rb#L62-L67 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/unique_args.rb | SidekiqUniqueJobs.UniqueArgs.digestable_hash | def digestable_hash
@item.slice(CLASS_KEY, QUEUE_KEY, UNIQUE_ARGS_KEY).tap do |hash|
hash.delete(QUEUE_KEY) if unique_across_queues?
hash.delete(CLASS_KEY) if unique_across_workers?
end
end | ruby | def digestable_hash
@item.slice(CLASS_KEY, QUEUE_KEY, UNIQUE_ARGS_KEY).tap do |hash|
hash.delete(QUEUE_KEY) if unique_across_queues?
hash.delete(CLASS_KEY) if unique_across_workers?
end
end | [
"def",
"digestable_hash",
"@item",
".",
"slice",
"(",
"CLASS_KEY",
",",
"QUEUE_KEY",
",",
"UNIQUE_ARGS_KEY",
")",
".",
"tap",
"do",
"|",
"hash",
"|",
"hash",
".",
"delete",
"(",
"QUEUE_KEY",
")",
"if",
"unique_across_queues?",
"hash",
".",
"delete",
"(",
"... | Filter a hash to use for digest
@return [Hash] to use for digest | [
"Filter",
"a",
"hash",
"to",
"use",
"for",
"digest"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/unique_args.rb#L62-L67 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/unique_args.rb | SidekiqUniqueJobs.UniqueArgs.filtered_args | def filtered_args(args)
return args if args.empty?
json_args = Normalizer.jsonify(args)
case unique_args_method
when Proc
filter_by_proc(json_args)
when Symbol
filter_by_symbol(json_args)
else
log_debug("#{__method__} arguments not filtered (using all argume... | ruby | def filtered_args(args)
return args if args.empty?
json_args = Normalizer.jsonify(args)
case unique_args_method
when Proc
filter_by_proc(json_args)
when Symbol
filter_by_symbol(json_args)
else
log_debug("#{__method__} arguments not filtered (using all argume... | [
"def",
"filtered_args",
"(",
"args",
")",
"return",
"args",
"if",
"args",
".",
"empty?",
"json_args",
"=",
"Normalizer",
".",
"jsonify",
"(",
"args",
")",
"case",
"unique_args_method",
"when",
"Proc",
"filter_by_proc",
"(",
"json_args",
")",
"when",
"Symbol",
... | Filters unique arguments by proc or symbol
@param [Array] args the arguments passed to the sidekiq worker
@return [Array] {#filter_by_proc} when {#unique_args_method} is a Proc
@return [Array] {#filter_by_symbol} when {#unique_args_method} is a Symbol
@return [Array] args unfiltered when neither of the above | [
"Filters",
"unique",
"arguments",
"by",
"proc",
"or",
"symbol"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/unique_args.rb#L101-L115 | train |
mhenrixon/sidekiq-unique-jobs | lib/sidekiq_unique_jobs/unique_args.rb | SidekiqUniqueJobs.UniqueArgs.filter_by_symbol | def filter_by_symbol(args)
return args unless worker_method_defined?(unique_args_method)
worker_class.send(unique_args_method, args)
rescue ArgumentError => ex
log_fatal(ex)
args
end | ruby | def filter_by_symbol(args)
return args unless worker_method_defined?(unique_args_method)
worker_class.send(unique_args_method, args)
rescue ArgumentError => ex
log_fatal(ex)
args
end | [
"def",
"filter_by_symbol",
"(",
"args",
")",
"return",
"args",
"unless",
"worker_method_defined?",
"(",
"unique_args_method",
")",
"worker_class",
".",
"send",
"(",
"unique_args_method",
",",
"args",
")",
"rescue",
"ArgumentError",
"=>",
"ex",
"log_fatal",
"(",
"e... | Filters unique arguments by method configured in the sidekiq worker
@param [Array] args the arguments passed to the sidekiq worker
@return [Array] unfiltered unless {#worker_method_defined?}
@return [Array] with the filtered arguments | [
"Filters",
"unique",
"arguments",
"by",
"method",
"configured",
"in",
"the",
"sidekiq",
"worker"
] | 2944b97c720528f53962ccfd17d43ac939a77f46 | https://github.com/mhenrixon/sidekiq-unique-jobs/blob/2944b97c720528f53962ccfd17d43ac939a77f46/lib/sidekiq_unique_jobs/unique_args.rb#L128-L135 | train |
k1LoW/awspec | lib/awspec/helper/client_wrap.rb | Awspec::Helper.ClientWrap.method_missing | def method_missing(m, *args, &block)
begin
results = client.send(m, *args, &block)
rescue Exception => e # rubocop:disable Lint/RescueException
raise unless e.class.to_s == symbol.to_s && backoff < backoff_limit
@backoff = backoff + (iteration * iteration * 0.5)
@iteration +... | ruby | def method_missing(m, *args, &block)
begin
results = client.send(m, *args, &block)
rescue Exception => e # rubocop:disable Lint/RescueException
raise unless e.class.to_s == symbol.to_s && backoff < backoff_limit
@backoff = backoff + (iteration * iteration * 0.5)
@iteration +... | [
"def",
"method_missing",
"(",
"m",
",",
"*",
"args",
",",
"&",
"block",
")",
"begin",
"results",
"=",
"client",
".",
"send",
"(",
"m",
",",
"args",
",",
"block",
")",
"rescue",
"Exception",
"=>",
"e",
"# rubocop:disable Lint/RescueException",
"raise",
"unl... | used to capture only the "RequestLimitExceeded" error from an aws
client api call. In the case of matching it we want to try again,
backing off successively each time, until the backoff_limit is reached or
exceeded, in which case, the error will be re-raised and it should fail
as expected. | [
"used",
"to",
"capture",
"only",
"the",
"RequestLimitExceeded",
"error",
"from",
"an",
"aws",
"client",
"api",
"call",
".",
"In",
"the",
"case",
"of",
"matching",
"it",
"we",
"want",
"to",
"try",
"again",
"backing",
"off",
"successively",
"each",
"time",
"... | d33365040c42c79fa4c8233451d7fe8f24f2c503 | https://github.com/k1LoW/awspec/blob/d33365040c42c79fa4c8233451d7fe8f24f2c503/lib/awspec/helper/client_wrap.rb#L24-L39 | train |
palkan/logidze | lib/logidze/history.rb | Logidze.History.changes_to | def changes_to(time: nil, version: nil, data: {}, from: 0)
raise ArgumentError, "Time or version must be specified" if time.nil? && version.nil?
filter = time.nil? ? method(:version_filter) : method(:time_filter)
versions.each_with_object(data.dup) do |v, acc|
next if v.version < from
... | ruby | def changes_to(time: nil, version: nil, data: {}, from: 0)
raise ArgumentError, "Time or version must be specified" if time.nil? && version.nil?
filter = time.nil? ? method(:version_filter) : method(:time_filter)
versions.each_with_object(data.dup) do |v, acc|
next if v.version < from
... | [
"def",
"changes_to",
"(",
"time",
":",
"nil",
",",
"version",
":",
"nil",
",",
"data",
":",
"{",
"}",
",",
"from",
":",
"0",
")",
"raise",
"ArgumentError",
",",
"\"Time or version must be specified\"",
"if",
"time",
".",
"nil?",
"&&",
"version",
".",
"ni... | Return diff from the initial state to specified time or version.
Optional `data` paramater can be used as initial diff state. | [
"Return",
"diff",
"from",
"the",
"initial",
"state",
"to",
"specified",
"time",
"or",
"version",
".",
"Optional",
"data",
"paramater",
"can",
"be",
"used",
"as",
"initial",
"diff",
"state",
"."
] | ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8 | https://github.com/palkan/logidze/blob/ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8/lib/logidze/history.rb#L60-L70 | train |
palkan/logidze | lib/logidze/history.rb | Logidze.History.diff_from | def diff_from(time: nil, version: nil)
raise ArgumentError, "Time or version must be specified" if time.nil? && version.nil?
from_version = version.nil? ? find_by_time(time) : find_by_version(version)
from_version ||= versions.first
base = changes_to(version: from_version.version)
diff =... | ruby | def diff_from(time: nil, version: nil)
raise ArgumentError, "Time or version must be specified" if time.nil? && version.nil?
from_version = version.nil? ? find_by_time(time) : find_by_version(version)
from_version ||= versions.first
base = changes_to(version: from_version.version)
diff =... | [
"def",
"diff_from",
"(",
"time",
":",
"nil",
",",
"version",
":",
"nil",
")",
"raise",
"ArgumentError",
",",
"\"Time or version must be specified\"",
"if",
"time",
".",
"nil?",
"&&",
"version",
".",
"nil?",
"from_version",
"=",
"version",
".",
"nil?",
"?",
"... | Return diff object representing changes since specified time or version.
@example
diff_from(time: 2.days.ago)
#=> { "id" => 1, "changes" => { "title" => { "old" => "Hello!", "new" => "World" } } }
rubocop:disable Metrics/AbcSize | [
"Return",
"diff",
"object",
"representing",
"changes",
"since",
"specified",
"time",
"or",
"version",
"."
] | ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8 | https://github.com/palkan/logidze/blob/ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8/lib/logidze/history.rb#L79-L89 | train |
palkan/logidze | lib/logidze/history.rb | Logidze.History.current_ts? | def current_ts?(time)
(current_version.time <= time) &&
(next_version.nil? || (next_version.time < time))
end | ruby | def current_ts?(time)
(current_version.time <= time) &&
(next_version.nil? || (next_version.time < time))
end | [
"def",
"current_ts?",
"(",
"time",
")",
"(",
"current_version",
".",
"time",
"<=",
"time",
")",
"&&",
"(",
"next_version",
".",
"nil?",
"||",
"(",
"next_version",
".",
"time",
"<",
"time",
")",
")",
"end"
] | Return true iff time corresponds to current version | [
"Return",
"true",
"iff",
"time",
"corresponds",
"to",
"current",
"version"
] | ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8 | https://github.com/palkan/logidze/blob/ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8/lib/logidze/history.rb#L98-L101 | train |
palkan/logidze | lib/logidze/model.rb | Logidze.Model.at_version | def at_version(version)
return self if log_data.version == version
log_entry = log_data.find_by_version(version)
return nil unless log_entry
build_dup(log_entry)
end | ruby | def at_version(version)
return self if log_data.version == version
log_entry = log_data.find_by_version(version)
return nil unless log_entry
build_dup(log_entry)
end | [
"def",
"at_version",
"(",
"version",
")",
"return",
"self",
"if",
"log_data",
".",
"version",
"==",
"version",
"log_entry",
"=",
"log_data",
".",
"find_by_version",
"(",
"version",
")",
"return",
"nil",
"unless",
"log_entry",
"build_dup",
"(",
"log_entry",
")"... | Return a dirty copy of specified version of record | [
"Return",
"a",
"dirty",
"copy",
"of",
"specified",
"version",
"of",
"record"
] | ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8 | https://github.com/palkan/logidze/blob/ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8/lib/logidze/model.rb#L111-L118 | train |
palkan/logidze | lib/logidze/model.rb | Logidze.Model.diff_from | def diff_from(ts = nil, version: nil, time: nil)
Deprecations.show_ts_deprecation_for("#diff_from") if ts
time ||= ts
time = parse_time(time) if time
changes = log_data.diff_from(time: time, version: version).tap do |v|
deserialize_changes!(v)
end
changes.delete_if { |k, _v|... | ruby | def diff_from(ts = nil, version: nil, time: nil)
Deprecations.show_ts_deprecation_for("#diff_from") if ts
time ||= ts
time = parse_time(time) if time
changes = log_data.diff_from(time: time, version: version).tap do |v|
deserialize_changes!(v)
end
changes.delete_if { |k, _v|... | [
"def",
"diff_from",
"(",
"ts",
"=",
"nil",
",",
"version",
":",
"nil",
",",
"time",
":",
"nil",
")",
"Deprecations",
".",
"show_ts_deprecation_for",
"(",
"\"#diff_from\"",
")",
"if",
"ts",
"time",
"||=",
"ts",
"time",
"=",
"parse_time",
"(",
"time",
")",... | Return diff object representing changes since specified time.
@example
post.diff_from(time: 2.days.ago) # or post.diff_from(version: 2)
#=> { "id" => 1, "changes" => { "title" => { "old" => "Hello!", "new" => "World" } } } | [
"Return",
"diff",
"object",
"representing",
"changes",
"since",
"specified",
"time",
"."
] | ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8 | https://github.com/palkan/logidze/blob/ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8/lib/logidze/model.rb#L134-L145 | train |
palkan/logidze | lib/logidze/model.rb | Logidze.Model.undo! | def undo!(append: Logidze.append_on_undo)
version = log_data.previous_version
return false if version.nil?
switch_to!(version.version, append: append)
end | ruby | def undo!(append: Logidze.append_on_undo)
version = log_data.previous_version
return false if version.nil?
switch_to!(version.version, append: append)
end | [
"def",
"undo!",
"(",
"append",
":",
"Logidze",
".",
"append_on_undo",
")",
"version",
"=",
"log_data",
".",
"previous_version",
"return",
"false",
"if",
"version",
".",
"nil?",
"switch_to!",
"(",
"version",
".",
"version",
",",
"append",
":",
"append",
")",
... | Restore record to the previous version.
Return false if no previous version found, otherwise return updated record. | [
"Restore",
"record",
"to",
"the",
"previous",
"version",
".",
"Return",
"false",
"if",
"no",
"previous",
"version",
"found",
"otherwise",
"return",
"updated",
"record",
"."
] | ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8 | https://github.com/palkan/logidze/blob/ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8/lib/logidze/model.rb#L149-L154 | train |
palkan/logidze | lib/logidze/model.rb | Logidze.Model.switch_to! | def switch_to!(version, append: Logidze.append_on_undo)
return false unless at_version(version)
if append && version < log_version
update!(log_data.changes_to(version: version))
else
at_version!(version)
self.class.without_logging { save! }
end
end | ruby | def switch_to!(version, append: Logidze.append_on_undo)
return false unless at_version(version)
if append && version < log_version
update!(log_data.changes_to(version: version))
else
at_version!(version)
self.class.without_logging { save! }
end
end | [
"def",
"switch_to!",
"(",
"version",
",",
"append",
":",
"Logidze",
".",
"append_on_undo",
")",
"return",
"false",
"unless",
"at_version",
"(",
"version",
")",
"if",
"append",
"&&",
"version",
"<",
"log_version",
"update!",
"(",
"log_data",
".",
"changes_to",
... | Restore record to the specified version.
Return false if version is unknown. | [
"Restore",
"record",
"to",
"the",
"specified",
"version",
".",
"Return",
"false",
"if",
"version",
"is",
"unknown",
"."
] | ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8 | https://github.com/palkan/logidze/blob/ffa0f793cb9c6fab96fa67a285341ca9aaa7ded8/lib/logidze/model.rb#L167-L176 | train |
markdownlint/markdownlint | lib/mdl/doc.rb | MarkdownLint.Doc.find_type | def find_type(type, nested=true)
find_type_elements(type, nested).map { |e| e.options }
end | ruby | def find_type(type, nested=true)
find_type_elements(type, nested).map { |e| e.options }
end | [
"def",
"find_type",
"(",
"type",
",",
"nested",
"=",
"true",
")",
"find_type_elements",
"(",
"type",
",",
"nested",
")",
".",
"map",
"{",
"|",
"e",
"|",
"e",
".",
"options",
"}",
"end"
] | Find all elements of a given type, returning their options hash. The
options hash has most of the useful data about an element and often you
can just use this in your rules.
# Returns [ { :location => 1, :element_level => 2 }, ... ]
elements = find_type(:li)
If +nested+ is set to false, this returns only top... | [
"Find",
"all",
"elements",
"of",
"a",
"given",
"type",
"returning",
"their",
"options",
"hash",
".",
"The",
"options",
"hash",
"has",
"most",
"of",
"the",
"useful",
"data",
"about",
"an",
"element",
"and",
"often",
"you",
"can",
"just",
"use",
"this",
"i... | a9e80fcf3989d73b654b00bb2225a00be53983e8 | https://github.com/markdownlint/markdownlint/blob/a9e80fcf3989d73b654b00bb2225a00be53983e8/lib/mdl/doc.rb#L72-L74 | train |
markdownlint/markdownlint | lib/mdl/doc.rb | MarkdownLint.Doc.find_type_elements | def find_type_elements(type, nested=true, elements=@elements)
results = []
if type.class == Symbol
type = [type]
end
elements.each do |e|
results.push(e) if type.include?(e.type)
if nested and not e.children.empty?
results.concat(find_type_elements(type, nested,... | ruby | def find_type_elements(type, nested=true, elements=@elements)
results = []
if type.class == Symbol
type = [type]
end
elements.each do |e|
results.push(e) if type.include?(e.type)
if nested and not e.children.empty?
results.concat(find_type_elements(type, nested,... | [
"def",
"find_type_elements",
"(",
"type",
",",
"nested",
"=",
"true",
",",
"elements",
"=",
"@elements",
")",
"results",
"=",
"[",
"]",
"if",
"type",
".",
"class",
"==",
"Symbol",
"type",
"=",
"[",
"type",
"]",
"end",
"elements",
".",
"each",
"do",
"... | Find all elements of a given type, returning a list of the element
objects themselves.
Instead of a single type, a list of types can be provided instead to
find all types.
If +nested+ is set to false, this returns only top level elements of a
given type. | [
"Find",
"all",
"elements",
"of",
"a",
"given",
"type",
"returning",
"a",
"list",
"of",
"the",
"element",
"objects",
"themselves",
"."
] | a9e80fcf3989d73b654b00bb2225a00be53983e8 | https://github.com/markdownlint/markdownlint/blob/a9e80fcf3989d73b654b00bb2225a00be53983e8/lib/mdl/doc.rb#L86-L98 | train |
markdownlint/markdownlint | lib/mdl/doc.rb | MarkdownLint.Doc.find_type_elements_except | def find_type_elements_except(type, nested_except=[], elements=@elements)
results = []
if type.class == Symbol
type = [type]
end
if nested_except.class == Symbol
nested_except = [nested_except]
end
elements.each do |e|
results.push(e) if type.include?(e.type)
... | ruby | def find_type_elements_except(type, nested_except=[], elements=@elements)
results = []
if type.class == Symbol
type = [type]
end
if nested_except.class == Symbol
nested_except = [nested_except]
end
elements.each do |e|
results.push(e) if type.include?(e.type)
... | [
"def",
"find_type_elements_except",
"(",
"type",
",",
"nested_except",
"=",
"[",
"]",
",",
"elements",
"=",
"@elements",
")",
"results",
"=",
"[",
"]",
"if",
"type",
".",
"class",
"==",
"Symbol",
"type",
"=",
"[",
"type",
"]",
"end",
"if",
"nested_except... | A variation on find_type_elements that allows you to skip drilling down
into children of specific element types.
Instead of a single type, a list of types can be provided instead to
find all types.
Unlike find_type_elements, this method will always search for nested
elements, and skip the element types given to ... | [
"A",
"variation",
"on",
"find_type_elements",
"that",
"allows",
"you",
"to",
"skip",
"drilling",
"down",
"into",
"children",
"of",
"specific",
"element",
"types",
"."
] | a9e80fcf3989d73b654b00bb2225a00be53983e8 | https://github.com/markdownlint/markdownlint/blob/a9e80fcf3989d73b654b00bb2225a00be53983e8/lib/mdl/doc.rb#L110-L125 | train |
markdownlint/markdownlint | lib/mdl/doc.rb | MarkdownLint.Doc.element_linenumber | def element_linenumber(element)
element = element.options if element.is_a?(Kramdown::Element)
element[:location]
end | ruby | def element_linenumber(element)
element = element.options if element.is_a?(Kramdown::Element)
element[:location]
end | [
"def",
"element_linenumber",
"(",
"element",
")",
"element",
"=",
"element",
".",
"options",
"if",
"element",
".",
"is_a?",
"(",
"Kramdown",
"::",
"Element",
")",
"element",
"[",
":location",
"]",
"end"
] | Returns the line number a given element is located on in the source
file. You can pass in either an element object or an options hash here. | [
"Returns",
"the",
"line",
"number",
"a",
"given",
"element",
"is",
"located",
"on",
"in",
"the",
"source",
"file",
".",
"You",
"can",
"pass",
"in",
"either",
"an",
"element",
"object",
"or",
"an",
"options",
"hash",
"here",
"."
] | a9e80fcf3989d73b654b00bb2225a00be53983e8 | https://github.com/markdownlint/markdownlint/blob/a9e80fcf3989d73b654b00bb2225a00be53983e8/lib/mdl/doc.rb#L131-L134 | train |
markdownlint/markdownlint | lib/mdl/doc.rb | MarkdownLint.Doc.matching_lines | def matching_lines(re)
@lines.each_with_index.select{|text, linenum| re.match(text)}.map{
|i| i[1]+1}
end | ruby | def matching_lines(re)
@lines.each_with_index.select{|text, linenum| re.match(text)}.map{
|i| i[1]+1}
end | [
"def",
"matching_lines",
"(",
"re",
")",
"@lines",
".",
"each_with_index",
".",
"select",
"{",
"|",
"text",
",",
"linenum",
"|",
"re",
".",
"match",
"(",
"text",
")",
"}",
".",
"map",
"{",
"|",
"i",
"|",
"i",
"[",
"1",
"]",
"+",
"1",
"}",
"end"... | Returns line numbers for lines that match the given regular expression | [
"Returns",
"line",
"numbers",
"for",
"lines",
"that",
"match",
"the",
"given",
"regular",
"expression"
] | a9e80fcf3989d73b654b00bb2225a00be53983e8 | https://github.com/markdownlint/markdownlint/blob/a9e80fcf3989d73b654b00bb2225a00be53983e8/lib/mdl/doc.rb#L220-L223 | train |
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, wh... | 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, wh... | [
"def",
"extract_text",
"(",
"element",
",",
"prefix",
"=",
"\"\"",
",",
"restore_whitespace",
"=",
"true",
")",
"quotes",
"=",
"{",
":rdquo",
"=>",
"'\"'",
",",
":ldquo",
"=>",
"'\"'",
",",
":lsquo",
"=>",
"\"'\"",
",",
":rsquo",
"=>",
"\"'\"",
"}",
"#... | 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 | train |
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",
")",
"e... | 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 | train |
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... | 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 | train |
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"... | 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 | train |
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",
"(",
... | Handle ordinal this month | [
"Handle",
"ordinal",
"this",
"month"
] | 2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c | https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/handlers.rb#L54-L58 | train |
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 | train |
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 = ni... | 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 = ni... | [
"def",
"handle_orr",
"(",
"tokens",
",",
"outer_span",
",",
"options",
")",
"repeater",
"=",
"tokens",
"[",
"1",
"]",
".",
"get_tag",
"(",
"Repeater",
")",
"repeater",
".",
"start",
"=",
"outer_span",
".",
"begin",
"-",
"1",
"ordinal",
"=",
"tokens",
"... | narrows
Handle oridinal repeaters | [
"narrows",
"Handle",
"oridinal",
"repeaters"
] | 2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c | https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/handlers.rb#L488-L504 | train |
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)
... | 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)
... | [
"def",
"find_within",
"(",
"tags",
",",
"span",
",",
"pointer",
")",
"puts",
"\"--#{span}\"",
"if",
"Chronic",
".",
"debug",
"return",
"span",
"if",
"tags",
".",
"empty?",
"head",
"=",
"tags",
".",
"shift",
"head",
".",
"start",
"=",
"(",
"pointer",
"=... | 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 | train |
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 optio... | 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 optio... | [
"def",
"match",
"(",
"tokens",
",",
"definitions",
")",
"token_index",
"=",
"0",
"@pattern",
".",
"each",
"do",
"|",
"elements",
"|",
"was_optional",
"=",
"false",
"elements",
"=",
"[",
"elements",
"]",
"unless",
"elements",
".",
"is_a?",
"(",
"Array",
"... | 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",
"o... | 2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c | https://github.com/mojombo/chronic/blob/2b1eae7ec440d767c09e0b1a7f0e9bcf30ce1d6c/lib/chronic/handler.rb#L20-L68 | train |
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
... | 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
... | [
"def",
"create",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
")",
"do",
"assert_required",
"%w[",
"name",
"]",
"end",
"params",
"=",
"arguments",
".",
"params",
"# Requires authenticated user",
"if",
"(",
"org",
"=",
"params",
".",
"delete",
"(",
"'or... | 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 r... | [
"Create",
"a",
"new",
"repository",
"for",
"the",
"authenticated",
"user",
"."
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos.rb#L240-L252 | train |
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",... | 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 | train |
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_reque... | 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]... | [
"Create",
"a",
"pull",
"request",
"review"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/pull_requests/reviews.rb#L86-L93 | train |
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... | 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]... | [
"Update",
"a",
"pull",
"request",
"review"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/pull_requests/reviews.rb#L112-L119 | train |
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",
"... | 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 | train |
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... | 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... | [
"def",
"list",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":column_id",
"]",
")",
"params",
"=",
"arguments",
".",
"params",
"params",
"[",
"\"accept\"",
"]",
"||=",
"::",
"Github",
"::",
"Client",
"::",
"Projects",
"::... | 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 | train |
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",
"... | 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 wit... | [
"Create",
"a",
"project",
"card",
"for",
"a",
"column"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects/cards.rb#L75-L82 | train |
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",
"::... | 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_i... | [
"Update",
"a",
"project",
"card"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects/cards.rb#L99-L106 | train |
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",
"::... | 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 | train |
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\"",
"]",
"||=",
... | 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'
... | [
"Move",
"a",
"project",
"card"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects/cards.rb#L147-L156 | train |
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'))
... | 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'))
... | [
"def",
"list",
"(",
"*",
"args",
")",
"params",
"=",
"arguments",
"(",
"args",
")",
"do",
"assert_values",
"VALID_ISSUE_PARAM_VALUES",
"end",
".",
"params",
"response",
"=",
"if",
"(",
"org",
"=",
"params",
".",
"delete",
"(",
"'org'",
")",
")",
"get_req... | 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
authent... | [
"List",
"your",
"issues"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues.rb#L125-L144 | train |
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.filepa... | 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.filepa... | [
"def",
"upload",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":owner",
",",
":repo",
",",
":id",
",",
":filepath",
"]",
")",
"do",
"permit",
"VALID_ASSET_PARAM_NAMES",
"end",
"params",
"=",
"arguments",
".",
"params",
"unl... | 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 'own... | [
"Upload",
"a",
"release",
"asset"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/releases/assets.rb#L62-L84 | train |
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",
"ra... | 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 | train |
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... | 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 = ... | [
"Edit",
"a",
"release",
"asset"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/releases/assets.rb#L114-L120 | train |
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\"",
",",
"arg... | 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",
"an",
"arbitrary",
"Markdown",
"document"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/markdown.rb#L29-L37 | train |
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",... | 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 ... | [
"Render",
"a",
"Markdown",
"document",
"in",
"raw",
"mode"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/markdown.rb#L52-L59 | train |
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"... | 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 se... | [
"Create",
"a",
"status"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/statuses.rb#L82-L89 | train |
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",
... | 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'
... | [
"Check",
"if",
"you",
"are",
"starring",
"a",
"repository"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/activity/starring.rb#L81-L88 | train |
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... | 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 | train |
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",
"[",
"'ac... | 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... | [
"Get",
"a",
"single",
"template"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/gitignore.rb#L44-L54 | train |
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/#{a... | 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 | train |
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}/#{a... | 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 pu... | [
"Create",
"a",
"label"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues/labels.rb#L80-L87 | train |
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",
"(",
"\"/re... | 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"
... | [
"Update",
"a",
"label"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/issues/labels.rb#L103-L110 | train |
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}/labe... | 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}/labe... | [
"def",
"remove",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":user",
",",
":repo",
",",
":number",
"]",
")",
"params",
"=",
"arguments",
".",
"params",
"user",
"=",
"arguments",
".",
"user",
"repo",
"=",
"arguments",
... | 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 | train |
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",
... | 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 | train |
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
... | 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
... | [
"def",
"parse_page_params",
"(",
"uri",
",",
"attr",
")",
"# :nodoc:",
"return",
"-",
"1",
"if",
"uri",
".",
"nil?",
"||",
"uri",
".",
"empty?",
"parsed",
"=",
"nil",
"begin",
"parsed",
"=",
"URI",
".",
"parse",
"(",
"uri",
")",
"rescue",
"URI",
"::"... | 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 | train |
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... | 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... | [
"def",
"list",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
")",
"params",
"=",
"arguments",
".",
"params",
"token",
"=",
"args",
".",
"shift",
"if",
"token",
".",
"is_a?",
"(",
"Hash",
")",
"&&",
"!",
"params",
"[",
"'token'",
"]",
".",
"nil?"... | 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.n... | [
"Check",
"what",
"OAuth",
"scopes",
"you",
"have",
"."
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/scopes.rb#L24-L43 | train |
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 unle... | 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 unle... | [
"def",
"received",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":user",
"]",
")",
"params",
"=",
"arguments",
".",
"params",
"public_events",
"=",
"if",
"params",
"[",
"'public'",
"]",
"params",
".",
"delete",
"(",
"'pub... | 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 publi... | [
"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 | train |
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"... | 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",
"w... | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/pagination.rb#L28-L35 | train |
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",
"::"... | 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 | train |
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/#{s... | 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/#{s... | [
"def",
"get",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":user",
",",
":repo",
",",
":sha",
"]",
")",
"user",
"=",
"arguments",
".",
"user",
"repo",
"=",
"arguments",
".",
"repo",
"sha",
"=",
"arguments",
".",
"sha... | 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', recursi... | [
"Get",
"a",
"tree"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/trees.rb#L40-L55 | train |
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... | 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... | [
"def",
"create",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":user",
",",
":repo",
"]",
")",
"do",
"assert_required",
"%w[",
"tree",
"]",
"permit",
"VALID_TREE_PARAM_NAMES",
",",
"'tree'",
",",
"{",
"recursive",
":",
"tru... | 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 tre... | [
"Create",
"a",
"tree"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/trees.rb#L103-L111 | train |
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... | 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 emp... | [
"Create",
"a",
"commit"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/commits.rb#L92-L99 | train |
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)
... | 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)
... | [
"def",
"remove",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":user",
",",
":repo",
",",
":number",
"]",
")",
"params",
"=",
"arguments",
".",
"params",
"params",
"[",
"'data'",
"]",
"=",
"{",
"'assignees'",
"=>",
"arg... | 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 | train |
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",
... | 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 | train |
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"... | 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 | train |
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
re... | 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
re... | [
"def",
"set",
"(",
"option",
",",
"value",
"=",
"(",
"not_set",
"=",
"true",
")",
",",
"ignore_setter",
"=",
"false",
",",
"&",
"block",
")",
"raise",
"ArgumentError",
",",
"'value not set'",
"if",
"block",
"and",
"!",
"not_set",
"return",
"self",
"if",
... | 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 | train |
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",
",",
... | Set multiple options
@api private | [
"Set",
"multiple",
"options"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/api.rb#L366-L371 | train |
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}=\"",
",",
"set... | 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 | train |
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, &conten... | 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, &conten... | [
"def",
"define_singleton_method",
"(",
"method_name",
",",
"content",
"=",
"Proc",
".",
"new",
")",
"(",
"class",
"<<",
"self",
";",
"self",
";",
"end",
")",
".",
"class_eval",
"do",
"undef_method",
"(",
"method_name",
")",
"if",
"method_defined?",
"(",
"m... | 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 | train |
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... | 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 cr... | [
"Create",
"a",
"tag",
"object"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/git_data/tags.rb#L86-L93 | train |
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 ... | 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 ... | [
"def",
"list",
"(",
"*",
"args",
")",
"params",
"=",
"arguments",
"(",
"args",
")",
".",
"params",
"response",
"=",
"if",
"user_name",
"=",
"arguments",
".",
"remaining",
".",
"first",
"get_request",
"(",
"\"/users/#{user_name}/followers\"",
",",
"params",
"... | 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| ... }
@ap... | [
"List",
"a",
"user",
"s",
"followers"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/users/followers.rb#L23-L33 | train |
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)
... | 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)
... | [
"def",
"following?",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":username",
"]",
")",
"params",
"=",
"arguments",
".",
"params",
"if",
"target_user",
"=",
"params",
".",
"delete",
"(",
"'target_user'",
")",
"get_request",
... | 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?... | [
"Check",
"if",
"you",
"are",
"following",
"a",
"user"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/users/followers.rb#L77-L88 | train |
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?
respo... | 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?
respo... | [
"def",
"watched",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
")",
"params",
"=",
"arguments",
".",
"params",
"response",
"=",
"if",
"(",
"user_name",
"=",
"params",
".",
"delete",
"(",
"'user'",
")",
")",
"get_request",
"(",
"\"/users/#{user_name}/su... | 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: '...'
... | [
"List",
"repos",
"being",
"watched",
"by",
"a",
"user"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/activity/watching.rb#L43-L54 | train |
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
... | 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
... | [
"def",
"member?",
"(",
"*",
"args",
")",
"params",
"=",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":org_name",
",",
":user",
"]",
")",
".",
"params",
"org_name",
"=",
"arguments",
".",
"org_name",
"user",
"=",
"arguments",
".",
"user",
"resp... | 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... | [
"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 | train |
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}/bra... | 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_... | [
"Edit",
"a",
"branch",
"protection"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/branches/protections.rb#L52-L58 | train |
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 o... | 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 o... | [
"def",
"filter!",
"(",
"keys",
",",
"params",
",",
"options",
"=",
"{",
":recursive",
"=>",
"true",
"}",
")",
"# :nodoc:",
"case",
"params",
"when",
"Hash",
",",
"ParamsHash",
"params",
".",
"keys",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"unless... | 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 | train |
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}\"",
",",
"argumen... | 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 | train |
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
... | 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
... | [
"def",
"on_complete",
"(",
"env",
")",
"status_code",
"=",
"env",
"[",
":status",
"]",
".",
"to_i",
"service_error",
"=",
"Github",
"::",
"Error",
"::",
"ServiceError",
"error_class",
"=",
"service_error",
".",
"error_mapping",
"[",
"status_code",
"]",
"if",
... | 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 | train |
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... | 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... | [
"def",
"create",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":user",
",",
":repo",
"]",
")",
"do",
"permit",
"VALID_DEPLOYMENTS_OPTIONS",
"assert_required",
"%w[",
"ref",
"]",
"end",
"params",
"=",
"arguments",
".",
"params... | 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 statu... | [
"Create",
"a",
"deployment"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/deployments.rb#L76-L85 | train |
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?
status... | 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?
status... | [
"def",
"statuses",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":user",
",",
":repo",
",",
":id",
"]",
")",
"params",
"=",
"arguments",
".",
"params",
"params",
"[",
"'accept'",
"]",
"||=",
"PREVIEW_MEDIA",
"statuses",
"... | 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', DEPLOY... | [
"List",
"the",
"statuses",
"of",
"a",
"deployment",
"."
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/deployments.rb#L99-L107 | train |
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/#{argumen... | 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/#{argumen... | [
"def",
"create_status",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":user",
",",
":repo",
",",
":id",
"]",
")",
"do",
"assert_required",
"%w[",
"state",
"]",
"permit",
"VALID_STATUS_OPTIONS",
"end",
"params",
"=",
"argument... | 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 s... | [
"Create",
"a",
"deployment",
"status"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/deployments.rb#L127-L136 | train |
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",
"]"... | 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 | train |
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",
")",... | 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 | train |
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... | 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 | train |
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... | 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 [Num... | [
"Creates",
"a",
"commit",
"comment"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/comments.rb#L84-L90 | train |
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... | 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 | train |
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",
"."... | 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 ... | [
"Create",
"a",
"file"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/contents.rb#L104-L112 | train |
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.u... | 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 f... | [
"Delete",
"a",
"file"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/contents.rb#L202-L208 | train |
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}/#{ar... | 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}/#{ar... | [
"def",
"archive",
"(",
"*",
"args",
")",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":user",
",",
":repo",
"]",
")",
"params",
"=",
"arguments",
".",
"params",
"archive_format",
"=",
"params",
".",
"delete",
"(",
"'archive_format'",
")",
"||",
... | 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 te... | [
"Get",
"archive",
"link"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/repos/contents.rb#L234-L244 | train |
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",
"[",... | 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 | train |
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/#{argum... | 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.
... | [
"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 | train |
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::E... | 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::E... | [
"def",
"check",
"(",
"*",
"args",
")",
"raise_authentication_error",
"unless",
"authenticated?",
"params",
"=",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":client_id",
",",
":access_token",
"]",
")",
".",
"params",
"if",
"arguments",
".",
"client_id... | 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 | train |
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}"... | 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}"... | [
"def",
"delete",
"(",
"*",
"args",
")",
"raise_authentication_error",
"unless",
"authenticated?",
"params",
"=",
"arguments",
"(",
"args",
",",
"required",
":",
"[",
":client_id",
"]",
")",
".",
"params",
"if",
"arguments",
".",
"client_id",
"if",
"access_toke... | 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-tok... | [
"Revoke",
"all",
"authorizations",
"for",
"an",
"application"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/authorizations/app.rb#L73-L87 | train |
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... | 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 f... | [
"Edit",
"a",
"project"
] | 8702452c66bea33c9388550aed9e9974f76aaef1 | https://github.com/piotrmurach/github/blob/8702452c66bea33c9388550aed9e9974f76aaef1/lib/github_api/client/projects.rb#L57-L64 | train |
Subsets and Splits
SQL Console for semeru/code-text-ruby
Retrieves 20,000 non-null code samples labeled as Ruby, providing a basic overview of the dataset but without deeper analysis.