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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
godfat/rib | lib/rib/shell.rb | Rib.Shell.loop | def loop
before_loop
set_trap
start
in_loop
stop
self
rescue Exception => e
Rib.warn("Error while running loop:\n #{format_error(e)}")
raise
ensure
release_trap
after_loop
end | ruby | def loop
before_loop
set_trap
start
in_loop
stop
self
rescue Exception => e
Rib.warn("Error while running loop:\n #{format_error(e)}")
raise
ensure
release_trap
after_loop
end | [
"def",
"loop",
"before_loop",
"set_trap",
"start",
"in_loop",
"stop",
"self",
"rescue",
"Exception",
"=>",
"e",
"Rib",
".",
"warn",
"(",
"\"Error while running loop:\\n #{format_error(e)}\"",
")",
"raise",
"ensure",
"release_trap",
"after_loop",
"end"
] | Create a new shell.
@api public
@param config [Hash] The config of the shell.
@option config [String] :config ('~/.rib/config.rb')
The path to Rib config file.
@option config [String] :name ('rib')
The name of the shell. Used for Rib application.
@option config [String] :result_prompt ('=> ')
@option confi... | [
"Create",
"a",
"new",
"shell",
"."
] | fbbf62ac27751f930b8a606acdd0b12ca9276d33 | https://github.com/godfat/rib/blob/fbbf62ac27751f930b8a606acdd0b12ca9276d33/lib/rib/shell.rb#L47-L60 | train |
godfat/rib | lib/rib/extra/paging.rb | Rib.Paging.one_screen? | def one_screen? str
cols, lines = `tput cols`.to_i, `tput lines`.to_i
(str.count("\n") + 2) <= lines && # count last line and prompt
str.gsub(/\e\[[^m]*m/, '').size <= cols * lines
end | ruby | def one_screen? str
cols, lines = `tput cols`.to_i, `tput lines`.to_i
(str.count("\n") + 2) <= lines && # count last line and prompt
str.gsub(/\e\[[^m]*m/, '').size <= cols * lines
end | [
"def",
"one_screen?",
"str",
"cols",
",",
"lines",
"=",
"`",
"`",
".",
"to_i",
",",
"`",
"`",
".",
"to_i",
"(",
"str",
".",
"count",
"(",
"\"\\n\"",
")",
"+",
"2",
")",
"<=",
"lines",
"&&",
"str",
".",
"gsub",
"(",
"/",
"\\e",
"\\[",
"/",
","... | `less -F` can't cat the output, so we need to detect by ourselves.
`less -X` would mess up the buffers, so it's not desired, either. | [
"less",
"-",
"F",
"can",
"t",
"cat",
"the",
"output",
"so",
"we",
"need",
"to",
"detect",
"by",
"ourselves",
".",
"less",
"-",
"X",
"would",
"mess",
"up",
"the",
"buffers",
"so",
"it",
"s",
"not",
"desired",
"either",
"."
] | fbbf62ac27751f930b8a606acdd0b12ca9276d33 | https://github.com/godfat/rib/blob/fbbf62ac27751f930b8a606acdd0b12ca9276d33/lib/rib/extra/paging.rb#L22-L26 | train |
quirkey/vegas | lib/vegas/runner.rb | Vegas.Runner.daemonize! | def daemonize!
if JRUBY
# It's not a true daemon but when executed with & works like one
thread = Thread.new {daemon_execute}
thread.join
elsif RUBY_VERSION < "1.9"
logger.debug "Parent Process: #{Process.pid}"
exit!(0) if fork
logger.debug "Child Process: #{... | ruby | def daemonize!
if JRUBY
# It's not a true daemon but when executed with & works like one
thread = Thread.new {daemon_execute}
thread.join
elsif RUBY_VERSION < "1.9"
logger.debug "Parent Process: #{Process.pid}"
exit!(0) if fork
logger.debug "Child Process: #{... | [
"def",
"daemonize!",
"if",
"JRUBY",
"thread",
"=",
"Thread",
".",
"new",
"{",
"daemon_execute",
"}",
"thread",
".",
"join",
"elsif",
"RUBY_VERSION",
"<",
"\"1.9\"",
"logger",
".",
"debug",
"\"Parent Process: #{Process.pid}\"",
"exit!",
"(",
"0",
")",
"if",
"fo... | Adapted from Rackup | [
"Adapted",
"from",
"Rackup"
] | 2aee90e0be1971115dd2b765540036b39d367dca | https://github.com/quirkey/vegas/blob/2aee90e0be1971115dd2b765540036b39d367dca/lib/vegas/runner.rb#L184-L200 | train |
quirkey/vegas | lib/vegas/runner.rb | Vegas.Runner.load_config_file | def load_config_file(config_path)
abort "Can not find config file at #{config_path}" if !File.readable?(config_path)
config = File.read(config_path)
# trim off anything after __END__
config.sub!(/^__END__\n.*/, '')
@app.module_eval(config)
end | ruby | def load_config_file(config_path)
abort "Can not find config file at #{config_path}" if !File.readable?(config_path)
config = File.read(config_path)
# trim off anything after __END__
config.sub!(/^__END__\n.*/, '')
@app.module_eval(config)
end | [
"def",
"load_config_file",
"(",
"config_path",
")",
"abort",
"\"Can not find config file at #{config_path}\"",
"if",
"!",
"File",
".",
"readable?",
"(",
"config_path",
")",
"config",
"=",
"File",
".",
"read",
"(",
"config_path",
")",
"config",
".",
"sub!",
"(",
... | Loads a config file at config_path and evals it in the context of the @app. | [
"Loads",
"a",
"config",
"file",
"at",
"config_path",
"and",
"evals",
"it",
"in",
"the",
"context",
"of",
"the"
] | 2aee90e0be1971115dd2b765540036b39d367dca | https://github.com/quirkey/vegas/blob/2aee90e0be1971115dd2b765540036b39d367dca/lib/vegas/runner.rb#L240-L246 | train |
evanphx/kpeg | lib/kpeg/code_generator.rb | KPeg.CodeGenerator.output_grammar | def output_grammar(code)
code << " # :stopdoc:\n"
handle_ast(code)
fg = @grammar.foreign_grammars
if fg.empty?
if @standalone
code << " def setup_foreign_grammar; end\n"
end
else
code << " def setup_foreign_grammar\n"
@grammar.foreign_grammars... | ruby | def output_grammar(code)
code << " # :stopdoc:\n"
handle_ast(code)
fg = @grammar.foreign_grammars
if fg.empty?
if @standalone
code << " def setup_foreign_grammar; end\n"
end
else
code << " def setup_foreign_grammar\n"
@grammar.foreign_grammars... | [
"def",
"output_grammar",
"(",
"code",
")",
"code",
"<<",
"\" # :stopdoc:\\n\"",
"handle_ast",
"(",
"code",
")",
"fg",
"=",
"@grammar",
".",
"foreign_grammars",
"if",
"fg",
".",
"empty?",
"if",
"@standalone",
"code",
"<<",
"\" def setup_foreign_grammar; end\\n\"",
... | Output of grammar and rules | [
"Output",
"of",
"grammar",
"and",
"rules"
] | 7ebf2e58e1248ffcbd0fe2cb552cc3bd12466eb9 | https://github.com/evanphx/kpeg/blob/7ebf2e58e1248ffcbd0fe2cb552cc3bd12466eb9/lib/kpeg/code_generator.rb#L361-L429 | train |
evanphx/kpeg | lib/kpeg/code_generator.rb | KPeg.CodeGenerator.output_header | def output_header(code)
if header = @grammar.directives['header']
code << header.action.strip
code << "\n"
end
pre_class = @grammar.directives['pre-class']
if @standalone
if pre_class
code << pre_class.action.strip
code << "\n"
end
co... | ruby | def output_header(code)
if header = @grammar.directives['header']
code << header.action.strip
code << "\n"
end
pre_class = @grammar.directives['pre-class']
if @standalone
if pre_class
code << pre_class.action.strip
code << "\n"
end
co... | [
"def",
"output_header",
"(",
"code",
")",
"if",
"header",
"=",
"@grammar",
".",
"directives",
"[",
"'header'",
"]",
"code",
"<<",
"header",
".",
"action",
".",
"strip",
"code",
"<<",
"\"\\n\"",
"end",
"pre_class",
"=",
"@grammar",
".",
"directives",
"[",
... | Output up to the user-defined setup actions | [
"Output",
"up",
"to",
"the",
"user",
"-",
"defined",
"setup",
"actions"
] | 7ebf2e58e1248ffcbd0fe2cb552cc3bd12466eb9 | https://github.com/evanphx/kpeg/blob/7ebf2e58e1248ffcbd0fe2cb552cc3bd12466eb9/lib/kpeg/code_generator.rb#L434-L470 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/transactions_api.rb | YNAB.TransactionsApi.create_transaction | def create_transaction(budget_id, data, opts = {})
data, _status_code, _headers = create_transaction_with_http_info(budget_id, data, opts)
data
end | ruby | def create_transaction(budget_id, data, opts = {})
data, _status_code, _headers = create_transaction_with_http_info(budget_id, data, opts)
data
end | [
"def",
"create_transaction",
"(",
"budget_id",
",",
"data",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_transaction_with_http_info",
"(",
"budget_id",
",",
"data",
",",
"opts",
")",
"data",
"end"
] | Create a single transaction or multiple transactions
Creates a single transaction or multiple transactions. If you provide a body containing a 'transaction' object, a single transaction will be created and if you provide a body containing a 'transactions' array, multiple transactions will be created.
@param budget_i... | [
"Create",
"a",
"single",
"transaction",
"or",
"multiple",
"transactions",
"Creates",
"a",
"single",
"transaction",
"or",
"multiple",
"transactions",
".",
"If",
"you",
"provide",
"a",
"body",
"containing",
"a",
"transaction",
"object",
"a",
"single",
"transaction",... | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/transactions_api.rb#L28-L31 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/transactions_api.rb | YNAB.TransactionsApi.get_transaction_by_id | def get_transaction_by_id(budget_id, transaction_id, opts = {})
data, _status_code, _headers = get_transaction_by_id_with_http_info(budget_id, transaction_id, opts)
data
end | ruby | def get_transaction_by_id(budget_id, transaction_id, opts = {})
data, _status_code, _headers = get_transaction_by_id_with_http_info(budget_id, transaction_id, opts)
data
end | [
"def",
"get_transaction_by_id",
"(",
"budget_id",
",",
"transaction_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_transaction_by_id_with_http_info",
"(",
"budget_id",
",",
"transaction_id",
",",
"opts",
")",
"data",
... | Single transaction
Returns a single transaction
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param transaction_id The id of the transaction
@param [Hash] opts the optional parameters
@return [TransactionResponse] | [
"Single",
"transaction",
"Returns",
"a",
"single",
"transaction"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/transactions_api.rb#L86-L89 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/transactions_api.rb | YNAB.TransactionsApi.get_transactions | def get_transactions(budget_id, opts = {})
data, _status_code, _headers = get_transactions_with_http_info(budget_id, opts)
data
end | ruby | def get_transactions(budget_id, opts = {})
data, _status_code, _headers = get_transactions_with_http_info(budget_id, opts)
data
end | [
"def",
"get_transactions",
"(",
"budget_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_transactions_with_http_info",
"(",
"budget_id",
",",
"opts",
")",
"data",
"end"
] | List transactions
Returns budget transactions
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param [Hash] opts the optional parameters
@option opts [Date] :since_date If specified, only transactions on or after this date will be included. The date ... | [
"List",
"transactions",
"Returns",
"budget",
"transactions"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/transactions_api.rb#L146-L149 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/transactions_api.rb | YNAB.TransactionsApi.get_transactions_by_account | def get_transactions_by_account(budget_id, account_id, opts = {})
data, _status_code, _headers = get_transactions_by_account_with_http_info(budget_id, account_id, opts)
data
end | ruby | def get_transactions_by_account(budget_id, account_id, opts = {})
data, _status_code, _headers = get_transactions_by_account_with_http_info(budget_id, account_id, opts)
data
end | [
"def",
"get_transactions_by_account",
"(",
"budget_id",
",",
"account_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_transactions_by_account_with_http_info",
"(",
"budget_id",
",",
"account_id",
",",
"opts",
")",
"dat... | List account transactions
Returns all transactions for a specified account
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param account_id The id of the account
@param [Hash] opts the optional parameters
@option opts [Date] :since_date If specified... | [
"List",
"account",
"transactions",
"Returns",
"all",
"transactions",
"for",
"a",
"specified",
"account"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/transactions_api.rb#L211-L214 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/transactions_api.rb | YNAB.TransactionsApi.get_transactions_by_category | def get_transactions_by_category(budget_id, category_id, opts = {})
data, _status_code, _headers = get_transactions_by_category_with_http_info(budget_id, category_id, opts)
data
end | ruby | def get_transactions_by_category(budget_id, category_id, opts = {})
data, _status_code, _headers = get_transactions_by_category_with_http_info(budget_id, category_id, opts)
data
end | [
"def",
"get_transactions_by_category",
"(",
"budget_id",
",",
"category_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_transactions_by_category_with_http_info",
"(",
"budget_id",
",",
"category_id",
",",
"opts",
")",
... | List category transactions
Returns all transactions for a specified category
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param category_id The id of the category
@param [Hash] opts the optional parameters
@option opts [Date] :since_date If speci... | [
"List",
"category",
"transactions",
"Returns",
"all",
"transactions",
"for",
"a",
"specified",
"category"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/transactions_api.rb#L281-L284 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/transactions_api.rb | YNAB.TransactionsApi.get_transactions_by_payee | def get_transactions_by_payee(budget_id, payee_id, opts = {})
data, _status_code, _headers = get_transactions_by_payee_with_http_info(budget_id, payee_id, opts)
data
end | ruby | def get_transactions_by_payee(budget_id, payee_id, opts = {})
data, _status_code, _headers = get_transactions_by_payee_with_http_info(budget_id, payee_id, opts)
data
end | [
"def",
"get_transactions_by_payee",
"(",
"budget_id",
",",
"payee_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_transactions_by_payee_with_http_info",
"(",
"budget_id",
",",
"payee_id",
",",
"opts",
")",
"data",
"e... | List payee transactions
Returns all transactions for a specified payee
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param payee_id The id of the payee
@param [Hash] opts the optional parameters
@option opts [Date] :since_date If specified, only t... | [
"List",
"payee",
"transactions",
"Returns",
"all",
"transactions",
"for",
"a",
"specified",
"payee"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/transactions_api.rb#L351-L354 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/transactions_api.rb | YNAB.TransactionsApi.update_transaction | def update_transaction(budget_id, transaction_id, data, opts = {})
data, _status_code, _headers = update_transaction_with_http_info(budget_id, transaction_id, data, opts)
data
end | ruby | def update_transaction(budget_id, transaction_id, data, opts = {})
data, _status_code, _headers = update_transaction_with_http_info(budget_id, transaction_id, data, opts)
data
end | [
"def",
"update_transaction",
"(",
"budget_id",
",",
"transaction_id",
",",
"data",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"update_transaction_with_http_info",
"(",
"budget_id",
",",
"transaction_id",
",",
"data",
",",... | Updates an existing transaction
Updates a transaction
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param transaction_id The id of the transaction
@param data The transaction to update
@param [Hash] opts the optional parameters
@return [Transacti... | [
"Updates",
"an",
"existing",
"transaction",
"Updates",
"a",
"transaction"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/transactions_api.rb#L419-L422 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/transactions_api.rb | YNAB.TransactionsApi.update_transactions | def update_transactions(budget_id, data, opts = {})
data, _status_code, _headers = update_transactions_with_http_info(budget_id, data, opts)
data
end | ruby | def update_transactions(budget_id, data, opts = {})
data, _status_code, _headers = update_transactions_with_http_info(budget_id, data, opts)
data
end | [
"def",
"update_transactions",
"(",
"budget_id",
",",
"data",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"update_transactions_with_http_info",
"(",
"budget_id",
",",
"data",
",",
"opts",
")",
"data",
"end"
] | Update multiple transactions
Updates multiple transactions, by 'id' or 'import_id'.
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param data The transactions to update. Optionally, transaction 'id' value(s) can be specified as null and an &... | [
"Update",
"multiple",
"transactions",
"Updates",
"multiple",
"transactions",
"by",
"id",
"or",
"import_id",
"."
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/transactions_api.rb#L482-L485 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/accounts_api.rb | YNAB.AccountsApi.get_account_by_id | def get_account_by_id(budget_id, account_id, opts = {})
data, _status_code, _headers = get_account_by_id_with_http_info(budget_id, account_id, opts)
data
end | ruby | def get_account_by_id(budget_id, account_id, opts = {})
data, _status_code, _headers = get_account_by_id_with_http_info(budget_id, account_id, opts)
data
end | [
"def",
"get_account_by_id",
"(",
"budget_id",
",",
"account_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_account_by_id_with_http_info",
"(",
"budget_id",
",",
"account_id",
",",
"opts",
")",
"data",
"end"
] | Single account
Returns a single account
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param account_id The id of the account
@param [Hash] opts the optional parameters
@return [AccountResponse] | [
"Single",
"account",
"Returns",
"a",
"single",
"account"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/accounts_api.rb#L28-L31 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/accounts_api.rb | YNAB.AccountsApi.get_accounts | def get_accounts(budget_id, opts = {})
data, _status_code, _headers = get_accounts_with_http_info(budget_id, opts)
data
end | ruby | def get_accounts(budget_id, opts = {})
data, _status_code, _headers = get_accounts_with_http_info(budget_id, opts)
data
end | [
"def",
"get_accounts",
"(",
"budget_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_accounts_with_http_info",
"(",
"budget_id",
",",
"opts",
")",
"data",
"end"
] | Account list
Returns all accounts
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param [Hash] opts the optional parameters
@option opts [Integer] :last_knowledge_of_server The starting server knowledge. If provided, only entities that have changed ... | [
"Account",
"list",
"Returns",
"all",
"accounts"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/accounts_api.rb#L86-L89 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/months_api.rb | YNAB.MonthsApi.get_budget_month | def get_budget_month(budget_id, month, opts = {})
data, _status_code, _headers = get_budget_month_with_http_info(budget_id, month, opts)
data
end | ruby | def get_budget_month(budget_id, month, opts = {})
data, _status_code, _headers = get_budget_month_with_http_info(budget_id, month, opts)
data
end | [
"def",
"get_budget_month",
"(",
"budget_id",
",",
"month",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_budget_month_with_http_info",
"(",
"budget_id",
",",
"month",
",",
"opts",
")",
"data",
"end"
] | Single budget month
Returns a single budget month
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param month The budget month in ISO format (e.g. 2016-12-01) (\"current\" can also be used to specify the current calendar month (UTC))
@param... | [
"Single",
"budget",
"month",
"Returns",
"a",
"single",
"budget",
"month"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/months_api.rb#L28-L31 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/months_api.rb | YNAB.MonthsApi.get_budget_months | def get_budget_months(budget_id, opts = {})
data, _status_code, _headers = get_budget_months_with_http_info(budget_id, opts)
data
end | ruby | def get_budget_months(budget_id, opts = {})
data, _status_code, _headers = get_budget_months_with_http_info(budget_id, opts)
data
end | [
"def",
"get_budget_months",
"(",
"budget_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_budget_months_with_http_info",
"(",
"budget_id",
",",
"opts",
")",
"data",
"end"
] | List budget months
Returns all budget months
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param [Hash] opts the optional parameters
@option opts [Integer] :last_knowledge_of_server The starting server knowledge. If provided, only entities that ha... | [
"List",
"budget",
"months",
"Returns",
"all",
"budget",
"months"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/months_api.rb#L86-L89 | train |
pioz/chess | lib/chess/pgn.rb | Chess.Pgn.to_s | def to_s
s = ''
TAGS.each do |t|
tag = instance_variable_get("@#{t}")
s << "[#{t.capitalize} \"#{tag}\"]\n"
end
s << "\n"
m = ''
@moves.each_with_index do |move, i|
m << "#{i/2+1}. " if i % 2 == 0
m << "#{move} "
end
m << @result unless @re... | ruby | def to_s
s = ''
TAGS.each do |t|
tag = instance_variable_get("@#{t}")
s << "[#{t.capitalize} \"#{tag}\"]\n"
end
s << "\n"
m = ''
@moves.each_with_index do |move, i|
m << "#{i/2+1}. " if i % 2 == 0
m << "#{move} "
end
m << @result unless @re... | [
"def",
"to_s",
"s",
"=",
"''",
"TAGS",
".",
"each",
"do",
"|",
"t",
"|",
"tag",
"=",
"instance_variable_get",
"(",
"\"@#{t}\"",
")",
"s",
"<<",
"\"[#{t.capitalize} \\\"#{tag}\\\"]\\n\"",
"end",
"s",
"<<",
"\"\\n\"",
"m",
"=",
"''",
"@moves",
".",
"each_wit... | PGN to string. | [
"PGN",
"to",
"string",
"."
] | 80744d1f351d45ecece8058e208c0f381a0569f5 | https://github.com/pioz/chess/blob/80744d1f351d45ecece8058e208c0f381a0569f5/lib/chess/pgn.rb#L76-L90 | train |
pioz/chess | lib/chess/game.rb | Chess.Game.pgn | def pgn
pgn = Chess::Pgn.new
pgn.moves = self.moves
pgn.result = self.result
return pgn
end | ruby | def pgn
pgn = Chess::Pgn.new
pgn.moves = self.moves
pgn.result = self.result
return pgn
end | [
"def",
"pgn",
"pgn",
"=",
"Chess",
"::",
"Pgn",
".",
"new",
"pgn",
".",
"moves",
"=",
"self",
".",
"moves",
"pgn",
".",
"result",
"=",
"self",
".",
"result",
"return",
"pgn",
"end"
] | Returns the PGN rappresenting the game.
@return [String] | [
"Returns",
"the",
"PGN",
"rappresenting",
"the",
"game",
"."
] | 80744d1f351d45ecece8058e208c0f381a0569f5 | https://github.com/pioz/chess/blob/80744d1f351d45ecece8058e208c0f381a0569f5/lib/chess/game.rb#L154-L159 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/payee_locations_api.rb | YNAB.PayeeLocationsApi.get_payee_location_by_id | def get_payee_location_by_id(budget_id, payee_location_id, opts = {})
data, _status_code, _headers = get_payee_location_by_id_with_http_info(budget_id, payee_location_id, opts)
data
end | ruby | def get_payee_location_by_id(budget_id, payee_location_id, opts = {})
data, _status_code, _headers = get_payee_location_by_id_with_http_info(budget_id, payee_location_id, opts)
data
end | [
"def",
"get_payee_location_by_id",
"(",
"budget_id",
",",
"payee_location_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_payee_location_by_id_with_http_info",
"(",
"budget_id",
",",
"payee_location_id",
",",
"opts",
")"... | Single payee location
Returns a single payee location
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param payee_location_id id of payee location
@param [Hash] opts the optional parameters
@return [PayeeLocationResponse] | [
"Single",
"payee",
"location",
"Returns",
"a",
"single",
"payee",
"location"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/payee_locations_api.rb#L28-L31 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/payee_locations_api.rb | YNAB.PayeeLocationsApi.get_payee_locations | def get_payee_locations(budget_id, opts = {})
data, _status_code, _headers = get_payee_locations_with_http_info(budget_id, opts)
data
end | ruby | def get_payee_locations(budget_id, opts = {})
data, _status_code, _headers = get_payee_locations_with_http_info(budget_id, opts)
data
end | [
"def",
"get_payee_locations",
"(",
"budget_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_payee_locations_with_http_info",
"(",
"budget_id",
",",
"opts",
")",
"data",
"end"
] | List payee locations
Returns all payee locations
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param [Hash] opts the optional parameters
@return [PayeeLocationsResponse] | [
"List",
"payee",
"locations",
"Returns",
"all",
"payee",
"locations"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/payee_locations_api.rb#L85-L88 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/payee_locations_api.rb | YNAB.PayeeLocationsApi.get_payee_locations_by_payee | def get_payee_locations_by_payee(budget_id, payee_id, opts = {})
data, _status_code, _headers = get_payee_locations_by_payee_with_http_info(budget_id, payee_id, opts)
data
end | ruby | def get_payee_locations_by_payee(budget_id, payee_id, opts = {})
data, _status_code, _headers = get_payee_locations_by_payee_with_http_info(budget_id, payee_id, opts)
data
end | [
"def",
"get_payee_locations_by_payee",
"(",
"budget_id",
",",
"payee_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_payee_locations_by_payee_with_http_info",
"(",
"budget_id",
",",
"payee_id",
",",
"opts",
")",
"data"... | List locations for a payee
Returns all payee locations for the specified payee
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param payee_id id of payee
@param [Hash] opts the optional parameters
@return [PayeeLocationsResponse] | [
"List",
"locations",
"for",
"a",
"payee",
"Returns",
"all",
"payee",
"locations",
"for",
"the",
"specified",
"payee"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/payee_locations_api.rb#L138-L141 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/categories_api.rb | YNAB.CategoriesApi.update_month_category | def update_month_category(budget_id, month, category_id, data, opts = {})
data, _status_code, _headers = update_month_category_with_http_info(budget_id, month, category_id, data, opts)
data
end | ruby | def update_month_category(budget_id, month, category_id, data, opts = {})
data, _status_code, _headers = update_month_category_with_http_info(budget_id, month, category_id, data, opts)
data
end | [
"def",
"update_month_category",
"(",
"budget_id",
",",
"month",
",",
"category_id",
",",
"data",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"update_month_category_with_http_info",
"(",
"budget_id",
",",
"month",
",",
"c... | Update a category for a specific month
Update a category for a specific month
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param month The budget month in ISO format (e.g. 2016-12-01) (\"current\" can also be used to specify the current c... | [
"Update",
"a",
"category",
"for",
"a",
"specific",
"month",
"Update",
"a",
"category",
"for",
"a",
"specific",
"month"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/categories_api.rb#L207-L210 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/budgets_api.rb | YNAB.BudgetsApi.get_budget_by_id | def get_budget_by_id(budget_id, opts = {})
data, _status_code, _headers = get_budget_by_id_with_http_info(budget_id, opts)
data
end | ruby | def get_budget_by_id(budget_id, opts = {})
data, _status_code, _headers = get_budget_by_id_with_http_info(budget_id, opts)
data
end | [
"def",
"get_budget_by_id",
"(",
"budget_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_budget_by_id_with_http_info",
"(",
"budget_id",
",",
"opts",
")",
"data",
"end"
] | Single budget
Returns a single budget with all related entities. This resource is effectively a full budget export.
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param [Hash] opts the optional parameters
@option opts [Integer] :last_knowledge_of_s... | [
"Single",
"budget",
"Returns",
"a",
"single",
"budget",
"with",
"all",
"related",
"entities",
".",
"This",
"resource",
"is",
"effectively",
"a",
"full",
"budget",
"export",
"."
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/budgets_api.rb#L28-L31 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/budgets_api.rb | YNAB.BudgetsApi.get_budget_settings_by_id | def get_budget_settings_by_id(budget_id, opts = {})
data, _status_code, _headers = get_budget_settings_by_id_with_http_info(budget_id, opts)
data
end | ruby | def get_budget_settings_by_id(budget_id, opts = {})
data, _status_code, _headers = get_budget_settings_by_id_with_http_info(budget_id, opts)
data
end | [
"def",
"get_budget_settings_by_id",
"(",
"budget_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_budget_settings_by_id_with_http_info",
"(",
"budget_id",
",",
"opts",
")",
"data",
"end"
] | Budget Settings
Returns settings for a budget
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param [Hash] opts the optional parameters
@return [BudgetSettingsResponse] | [
"Budget",
"Settings",
"Returns",
"settings",
"for",
"a",
"budget"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/budgets_api.rb#L82-L85 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/scheduled_transactions_api.rb | YNAB.ScheduledTransactionsApi.get_scheduled_transaction_by_id | def get_scheduled_transaction_by_id(budget_id, scheduled_transaction_id, opts = {})
data, _status_code, _headers = get_scheduled_transaction_by_id_with_http_info(budget_id, scheduled_transaction_id, opts)
data
end | ruby | def get_scheduled_transaction_by_id(budget_id, scheduled_transaction_id, opts = {})
data, _status_code, _headers = get_scheduled_transaction_by_id_with_http_info(budget_id, scheduled_transaction_id, opts)
data
end | [
"def",
"get_scheduled_transaction_by_id",
"(",
"budget_id",
",",
"scheduled_transaction_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_scheduled_transaction_by_id_with_http_info",
"(",
"budget_id",
",",
"scheduled_transaction... | Single scheduled transaction
Returns a single scheduled transaction
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param scheduled_transaction_id The id of the scheduled transaction
@param [Hash] opts the optional parameters
@return [ScheduledTrans... | [
"Single",
"scheduled",
"transaction",
"Returns",
"a",
"single",
"scheduled",
"transaction"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/scheduled_transactions_api.rb#L28-L31 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/scheduled_transactions_api.rb | YNAB.ScheduledTransactionsApi.get_scheduled_transactions | def get_scheduled_transactions(budget_id, opts = {})
data, _status_code, _headers = get_scheduled_transactions_with_http_info(budget_id, opts)
data
end | ruby | def get_scheduled_transactions(budget_id, opts = {})
data, _status_code, _headers = get_scheduled_transactions_with_http_info(budget_id, opts)
data
end | [
"def",
"get_scheduled_transactions",
"(",
"budget_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_scheduled_transactions_with_http_info",
"(",
"budget_id",
",",
"opts",
")",
"data",
"end"
] | List scheduled transactions
Returns all scheduled transactions
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param [Hash] opts the optional parameters
@return [ScheduledTransactionsResponse] | [
"List",
"scheduled",
"transactions",
"Returns",
"all",
"scheduled",
"transactions"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/scheduled_transactions_api.rb#L85-L88 | train |
pioz/chess | lib/chess/gnuchess.rb | Chess.Gnuchess.gnuchess_move | def gnuchess_move
pipe = IO.popen('gnuchess -x', 'r+')
begin
pipe.puts('depth 1')
pipe.puts('manual')
self.coord_moves.each do |m|
pipe.puts(m)
end
pipe.puts('go')
while line = pipe.gets
raise IllegalMoveError if line.include?('Invalid move... | ruby | def gnuchess_move
pipe = IO.popen('gnuchess -x', 'r+')
begin
pipe.puts('depth 1')
pipe.puts('manual')
self.coord_moves.each do |m|
pipe.puts(m)
end
pipe.puts('go')
while line = pipe.gets
raise IllegalMoveError if line.include?('Invalid move... | [
"def",
"gnuchess_move",
"pipe",
"=",
"IO",
".",
"popen",
"(",
"'gnuchess -x'",
",",
"'r+'",
")",
"begin",
"pipe",
".",
"puts",
"(",
"'depth 1'",
")",
"pipe",
".",
"puts",
"(",
"'manual'",
")",
"self",
".",
"coord_moves",
".",
"each",
"do",
"|",
"m",
... | Returns the next move calculated by Gnuchess.
@return [String] Returns the short algebraic chess notation of the move. | [
"Returns",
"the",
"next",
"move",
"calculated",
"by",
"Gnuchess",
"."
] | 80744d1f351d45ecece8058e208c0f381a0569f5 | https://github.com/pioz/chess/blob/80744d1f351d45ecece8058e208c0f381a0569f5/lib/chess/gnuchess.rb#L18-L37 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/payees_api.rb | YNAB.PayeesApi.get_payee_by_id | def get_payee_by_id(budget_id, payee_id, opts = {})
data, _status_code, _headers = get_payee_by_id_with_http_info(budget_id, payee_id, opts)
data
end | ruby | def get_payee_by_id(budget_id, payee_id, opts = {})
data, _status_code, _headers = get_payee_by_id_with_http_info(budget_id, payee_id, opts)
data
end | [
"def",
"get_payee_by_id",
"(",
"budget_id",
",",
"payee_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_payee_by_id_with_http_info",
"(",
"budget_id",
",",
"payee_id",
",",
"opts",
")",
"data",
"end"
] | Single payee
Returns single payee
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param payee_id The id of the payee
@param [Hash] opts the optional parameters
@return [PayeeResponse] | [
"Single",
"payee",
"Returns",
"single",
"payee"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/payees_api.rb#L28-L31 | train |
ynab/ynab-sdk-ruby | lib/ynab/api/payees_api.rb | YNAB.PayeesApi.get_payees | def get_payees(budget_id, opts = {})
data, _status_code, _headers = get_payees_with_http_info(budget_id, opts)
data
end | ruby | def get_payees(budget_id, opts = {})
data, _status_code, _headers = get_payees_with_http_info(budget_id, opts)
data
end | [
"def",
"get_payees",
"(",
"budget_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"get_payees_with_http_info",
"(",
"budget_id",
",",
"opts",
")",
"data",
"end"
] | List payees
Returns all payees
@param budget_id The id of the budget (\"last-used\" can also be used to specify the last used budget)
@param [Hash] opts the optional parameters
@option opts [Integer] :last_knowledge_of_server The starting server knowledge. If provided, only entities that have changed sin... | [
"List",
"payees",
"Returns",
"all",
"payees"
] | 389a959e482b6fa9643c7e7bfb55d8640cc952fd | https://github.com/ynab/ynab-sdk-ruby/blob/389a959e482b6fa9643c7e7bfb55d8640cc952fd/lib/ynab/api/payees_api.rb#L86-L89 | train |
r7kamura/jdoc | lib/jdoc/resource.rb | Jdoc.Resource.links | def links
@links ||= @schema.links.map do |link|
if link.method && link.href
Link.new(link)
end
end.compact
end | ruby | def links
@links ||= @schema.links.map do |link|
if link.method && link.href
Link.new(link)
end
end.compact
end | [
"def",
"links",
"@links",
"||=",
"@schema",
".",
"links",
".",
"map",
"do",
"|",
"link",
"|",
"if",
"link",
".",
"method",
"&&",
"link",
".",
"href",
"Link",
".",
"new",
"(",
"link",
")",
"end",
"end",
".",
"compact",
"end"
] | Defined to change uniqueness in Hash key
Defined to change uniqueness in Hash key | [
"Defined",
"to",
"change",
"uniqueness",
"in",
"Hash",
"key",
"Defined",
"to",
"change",
"uniqueness",
"in",
"Hash",
"key"
] | 42fb0d063313bf6b8eae39ddd8bc1e55381d2890 | https://github.com/r7kamura/jdoc/blob/42fb0d063313bf6b8eae39ddd8bc1e55381d2890/lib/jdoc/resource.rb#L59-L65 | train |
propublica/daybreak | lib/daybreak/db.rb | Daybreak.DB.hash_default | def hash_default(_, key)
if @default != nil
value = @default.respond_to?(:call) ? @default.call(key) : @default
@journal << [key, value]
@table[key] = value
end
end | ruby | def hash_default(_, key)
if @default != nil
value = @default.respond_to?(:call) ? @default.call(key) : @default
@journal << [key, value]
@table[key] = value
end
end | [
"def",
"hash_default",
"(",
"_",
",",
"key",
")",
"if",
"@default",
"!=",
"nil",
"value",
"=",
"@default",
".",
"respond_to?",
"(",
":call",
")",
"?",
"@default",
".",
"call",
"(",
"key",
")",
":",
"@default",
"@journal",
"<<",
"[",
"key",
",",
"valu... | The block used in @table for new records | [
"The",
"block",
"used",
"in"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/db.rb#L274-L280 | train |
propublica/daybreak | lib/daybreak/journal.rb | Daybreak.Journal.clear | def clear
flush
with_tmpfile do |path, file|
file.write(@format.header)
file.close
# Clear replaces the database file like a compactification does
with_flock(File::LOCK_EX) do
File.rename(path, @file)
end
end
open
end | ruby | def clear
flush
with_tmpfile do |path, file|
file.write(@format.header)
file.close
# Clear replaces the database file like a compactification does
with_flock(File::LOCK_EX) do
File.rename(path, @file)
end
end
open
end | [
"def",
"clear",
"flush",
"with_tmpfile",
"do",
"|",
"path",
",",
"file",
"|",
"file",
".",
"write",
"(",
"@format",
".",
"header",
")",
"file",
".",
"close",
"with_flock",
"(",
"File",
"::",
"LOCK_EX",
")",
"do",
"File",
".",
"rename",
"(",
"path",
"... | Clear the database log and yield | [
"Clear",
"the",
"database",
"log",
"and",
"yield"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/journal.rb#L51-L62 | train |
propublica/daybreak | lib/daybreak/journal.rb | Daybreak.Journal.compact | def compact
load
with_tmpfile do |path, file|
# Compactified database has the same size -> return
return self if @pos == file.write(dump(yield, @format.header))
with_flock(File::LOCK_EX) do
# Database was replaced (cleared or compactified) in the meantime
if @pos ... | ruby | def compact
load
with_tmpfile do |path, file|
# Compactified database has the same size -> return
return self if @pos == file.write(dump(yield, @format.header))
with_flock(File::LOCK_EX) do
# Database was replaced (cleared or compactified) in the meantime
if @pos ... | [
"def",
"compact",
"load",
"with_tmpfile",
"do",
"|",
"path",
",",
"file",
"|",
"return",
"self",
"if",
"@pos",
"==",
"file",
".",
"write",
"(",
"dump",
"(",
"yield",
",",
"@format",
".",
"header",
")",
")",
"with_flock",
"(",
"File",
"::",
"LOCK_EX",
... | Compact the logfile to represent the in-memory state | [
"Compact",
"the",
"logfile",
"to",
"represent",
"the",
"in",
"-",
"memory",
"state"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/journal.rb#L65-L82 | train |
propublica/daybreak | lib/daybreak/journal.rb | Daybreak.Journal.open | def open
@fd.close if @fd
@fd = File.open(@file, 'ab+')
@fd.advise(:sequential) if @fd.respond_to? :advise
stat = @fd.stat
@inode = stat.ino
write(@format.header) if stat.size == 0
@pos = nil
end | ruby | def open
@fd.close if @fd
@fd = File.open(@file, 'ab+')
@fd.advise(:sequential) if @fd.respond_to? :advise
stat = @fd.stat
@inode = stat.ino
write(@format.header) if stat.size == 0
@pos = nil
end | [
"def",
"open",
"@fd",
".",
"close",
"if",
"@fd",
"@fd",
"=",
"File",
".",
"open",
"(",
"@file",
",",
"'ab+'",
")",
"@fd",
".",
"advise",
"(",
":sequential",
")",
"if",
"@fd",
".",
"respond_to?",
":advise",
"stat",
"=",
"@fd",
".",
"stat",
"@inode",
... | Open or reopen file | [
"Open",
"or",
"reopen",
"file"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/journal.rb#L98-L106 | train |
propublica/daybreak | lib/daybreak/journal.rb | Daybreak.Journal.read | def read
with_flock(File::LOCK_SH) do
# File was opened
unless @pos
@fd.pos = 0
@format.read_header(@fd)
@size = 0
@emit.call(nil)
else
@fd.pos = @pos
end
buf = @fd.read
@pos = @fd.pos
buf
end
end | ruby | def read
with_flock(File::LOCK_SH) do
# File was opened
unless @pos
@fd.pos = 0
@format.read_header(@fd)
@size = 0
@emit.call(nil)
else
@fd.pos = @pos
end
buf = @fd.read
@pos = @fd.pos
buf
end
end | [
"def",
"read",
"with_flock",
"(",
"File",
"::",
"LOCK_SH",
")",
"do",
"unless",
"@pos",
"@fd",
".",
"pos",
"=",
"0",
"@format",
".",
"read_header",
"(",
"@fd",
")",
"@size",
"=",
"0",
"@emit",
".",
"call",
"(",
"nil",
")",
"else",
"@fd",
".",
"pos"... | Read new file content | [
"Read",
"new",
"file",
"content"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/journal.rb#L109-L124 | train |
propublica/daybreak | lib/daybreak/journal.rb | Daybreak.Journal.dump | def dump(records, dump = '')
# each is faster than inject
records.each do |record|
record[1] = @serializer.dump(record.last)
dump << @format.dump(record)
end
dump
end | ruby | def dump(records, dump = '')
# each is faster than inject
records.each do |record|
record[1] = @serializer.dump(record.last)
dump << @format.dump(record)
end
dump
end | [
"def",
"dump",
"(",
"records",
",",
"dump",
"=",
"''",
")",
"records",
".",
"each",
"do",
"|",
"record",
"|",
"record",
"[",
"1",
"]",
"=",
"@serializer",
".",
"dump",
"(",
"record",
".",
"last",
")",
"dump",
"<<",
"@format",
".",
"dump",
"(",
"r... | Return database dump as string | [
"Return",
"database",
"dump",
"as",
"string"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/journal.rb#L127-L134 | train |
propublica/daybreak | lib/daybreak/journal.rb | Daybreak.Journal.write | def write(dump)
with_flock(File::LOCK_EX) do
@fd.write(dump)
# Flush to make sure the file is really updated
@fd.flush
end
@pos = @fd.pos if @pos && @fd.pos == @pos + dump.bytesize
end | ruby | def write(dump)
with_flock(File::LOCK_EX) do
@fd.write(dump)
# Flush to make sure the file is really updated
@fd.flush
end
@pos = @fd.pos if @pos && @fd.pos == @pos + dump.bytesize
end | [
"def",
"write",
"(",
"dump",
")",
"with_flock",
"(",
"File",
"::",
"LOCK_EX",
")",
"do",
"@fd",
".",
"write",
"(",
"dump",
")",
"@fd",
".",
"flush",
"end",
"@pos",
"=",
"@fd",
".",
"pos",
"if",
"@pos",
"&&",
"@fd",
".",
"pos",
"==",
"@pos",
"+",
... | Write data to output stream and advance @pos | [
"Write",
"data",
"to",
"output",
"stream",
"and",
"advance"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/journal.rb#L164-L171 | train |
propublica/daybreak | lib/daybreak/journal.rb | Daybreak.Journal.with_flock | def with_flock(mode)
return yield if @locked
begin
loop do
# HACK: JRuby returns false if the process is already hold by the same process
# see https://github.com/jruby/jruby/issues/496
Thread.pass until @fd.flock(mode)
# Check if database was replaced (cleare... | ruby | def with_flock(mode)
return yield if @locked
begin
loop do
# HACK: JRuby returns false if the process is already hold by the same process
# see https://github.com/jruby/jruby/issues/496
Thread.pass until @fd.flock(mode)
# Check if database was replaced (cleare... | [
"def",
"with_flock",
"(",
"mode",
")",
"return",
"yield",
"if",
"@locked",
"begin",
"loop",
"do",
"Thread",
".",
"pass",
"until",
"@fd",
".",
"flock",
"(",
"mode",
")",
"stat",
"=",
"@fd",
".",
"stat",
"break",
"if",
"stat",
".",
"nlink",
">",
"0",
... | Block with file lock | [
"Block",
"with",
"file",
"lock"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/journal.rb#L174-L193 | train |
propublica/daybreak | lib/daybreak/journal.rb | Daybreak.Journal.with_tmpfile | def with_tmpfile
path = [@file, $$.to_s(36), Thread.current.object_id.to_s(36)].join
file = File.open(path, 'wb')
yield(path, file)
ensure
file.close unless file.closed?
File.unlink(path) if File.exists?(path)
end | ruby | def with_tmpfile
path = [@file, $$.to_s(36), Thread.current.object_id.to_s(36)].join
file = File.open(path, 'wb')
yield(path, file)
ensure
file.close unless file.closed?
File.unlink(path) if File.exists?(path)
end | [
"def",
"with_tmpfile",
"path",
"=",
"[",
"@file",
",",
"$$",
".",
"to_s",
"(",
"36",
")",
",",
"Thread",
".",
"current",
".",
"object_id",
".",
"to_s",
"(",
"36",
")",
"]",
".",
"join",
"file",
"=",
"File",
".",
"open",
"(",
"path",
",",
"'wb'",
... | Open temporary file and pass it to the block | [
"Open",
"temporary",
"file",
"and",
"pass",
"it",
"to",
"the",
"block"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/journal.rb#L196-L203 | train |
propublica/daybreak | lib/daybreak/format.rb | Daybreak.Format.read_header | def read_header(input)
raise 'Not a Daybreak database' if input.read(MAGIC.bytesize) != MAGIC
ver = input.read(2).unpack('n').first
raise "Expected database version #{VERSION}, got #{ver}" if ver != VERSION
end | ruby | def read_header(input)
raise 'Not a Daybreak database' if input.read(MAGIC.bytesize) != MAGIC
ver = input.read(2).unpack('n').first
raise "Expected database version #{VERSION}, got #{ver}" if ver != VERSION
end | [
"def",
"read_header",
"(",
"input",
")",
"raise",
"'Not a Daybreak database'",
"if",
"input",
".",
"read",
"(",
"MAGIC",
".",
"bytesize",
")",
"!=",
"MAGIC",
"ver",
"=",
"input",
".",
"read",
"(",
"2",
")",
".",
"unpack",
"(",
"'n'",
")",
".",
"first",... | Read database header from input stream
@param [#read] input the input stream
@return void | [
"Read",
"database",
"header",
"from",
"input",
"stream"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/format.rb#L10-L14 | train |
propublica/daybreak | lib/daybreak/format.rb | Daybreak.Format.dump | def dump(record)
data =
if record.size == 1
[record[0].bytesize, DELETE].pack('NN') << record[0]
else
[record[0].bytesize, record[1].bytesize].pack('NN') << record[0] << record[1]
end
data << crc32(data)
end | ruby | def dump(record)
data =
if record.size == 1
[record[0].bytesize, DELETE].pack('NN') << record[0]
else
[record[0].bytesize, record[1].bytesize].pack('NN') << record[0] << record[1]
end
data << crc32(data)
end | [
"def",
"dump",
"(",
"record",
")",
"data",
"=",
"if",
"record",
".",
"size",
"==",
"1",
"[",
"record",
"[",
"0",
"]",
".",
"bytesize",
",",
"DELETE",
"]",
".",
"pack",
"(",
"'NN'",
")",
"<<",
"record",
"[",
"0",
"]",
"else",
"[",
"record",
"[",... | Serialize record and return string
@param [Array] record an array with [key, value] or [key] if the record is deleted
@return [String] serialized record | [
"Serialize",
"record",
"and",
"return",
"string"
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/format.rb#L25-L33 | train |
propublica/daybreak | lib/daybreak/format.rb | Daybreak.Format.parse | def parse(buf)
n, count = 0, 0
while n < buf.size
key_size, value_size = buf[n, 8].unpack('NN')
data_size = key_size + 8
data_size += value_size if value_size != DELETE
data = buf[n, data_size]
n += data_size
raise 'CRC mismatch: your data might be corrupted!'... | ruby | def parse(buf)
n, count = 0, 0
while n < buf.size
key_size, value_size = buf[n, 8].unpack('NN')
data_size = key_size + 8
data_size += value_size if value_size != DELETE
data = buf[n, data_size]
n += data_size
raise 'CRC mismatch: your data might be corrupted!'... | [
"def",
"parse",
"(",
"buf",
")",
"n",
",",
"count",
"=",
"0",
",",
"0",
"while",
"n",
"<",
"buf",
".",
"size",
"key_size",
",",
"value_size",
"=",
"buf",
"[",
"n",
",",
"8",
"]",
".",
"unpack",
"(",
"'NN'",
")",
"data_size",
"=",
"key_size",
"+... | Deserialize records from buffer, and yield them.
@param [String] buf the buffer to read from
@yield [Array] blk deserialized record [key, value] or [key] if the record is deleted
@return [Fixnum] number of records | [
"Deserialize",
"records",
"from",
"buffer",
"and",
"yield",
"them",
"."
] | b963a911fb68c294f02d0502570915cfb6b8a58d | https://github.com/propublica/daybreak/blob/b963a911fb68c294f02d0502570915cfb6b8a58d/lib/daybreak/format.rb#L39-L53 | train |
ronin-ruby/ronin | lib/ronin/url.rb | Ronin.URL.query_string | def query_string
params = {}
self.query_params.each do |param|
params[param.name] = param.value
end
return ::URI::QueryParams.dump(params)
end | ruby | def query_string
params = {}
self.query_params.each do |param|
params[param.name] = param.value
end
return ::URI::QueryParams.dump(params)
end | [
"def",
"query_string",
"params",
"=",
"{",
"}",
"self",
".",
"query_params",
".",
"each",
"do",
"|",
"param",
"|",
"params",
"[",
"param",
".",
"name",
"]",
"=",
"param",
".",
"value",
"end",
"return",
"::",
"URI",
"::",
"QueryParams",
".",
"dump",
"... | Dumps the URL query params into a URI query string.
@return [String]
The URI query string.
@since 1.0.0
@api public | [
"Dumps",
"the",
"URL",
"query",
"params",
"into",
"a",
"URI",
"query",
"string",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/url.rb#L418-L426 | train |
ronin-ruby/ronin | lib/ronin/url.rb | Ronin.URL.query_string= | def query_string=(query)
self.query_params.clear
::URI::QueryParams.parse(query).each do |name,value|
self.query_params.new(
:name => URLQueryParamName.first_or_new(:name => name),
:value => value
)
end
return query
end | ruby | def query_string=(query)
self.query_params.clear
::URI::QueryParams.parse(query).each do |name,value|
self.query_params.new(
:name => URLQueryParamName.first_or_new(:name => name),
:value => value
)
end
return query
end | [
"def",
"query_string",
"=",
"(",
"query",
")",
"self",
".",
"query_params",
".",
"clear",
"::",
"URI",
"::",
"QueryParams",
".",
"parse",
"(",
"query",
")",
".",
"each",
"do",
"|",
"name",
",",
"value",
"|",
"self",
".",
"query_params",
".",
"new",
"... | Sets the query params of the URL.
@param [String] query
The query string to parse.
@return [String]
The given query string.
@since 1.0.0
@api public | [
"Sets",
"the",
"query",
"params",
"of",
"the",
"URL",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/url.rb#L441-L452 | train |
ronin-ruby/ronin | lib/ronin/url.rb | Ronin.URL.to_uri | def to_uri
# map the URL scheme to a URI class
url_class = SCHEMES.fetch(self.scheme.name,::URI::Generic)
host = if self.host_name
self.host_name.address
end
port = if self.port
self.port.number
end
query = unless self.query_params.... | ruby | def to_uri
# map the URL scheme to a URI class
url_class = SCHEMES.fetch(self.scheme.name,::URI::Generic)
host = if self.host_name
self.host_name.address
end
port = if self.port
self.port.number
end
query = unless self.query_params.... | [
"def",
"to_uri",
"url_class",
"=",
"SCHEMES",
".",
"fetch",
"(",
"self",
".",
"scheme",
".",
"name",
",",
"::",
"URI",
"::",
"Generic",
")",
"host",
"=",
"if",
"self",
".",
"host_name",
"self",
".",
"host_name",
".",
"address",
"end",
"port",
"=",
"i... | Builds a URI object from the URL.
@return [URI::HTTP, URI::HTTPS]
The URI object created from the URL attributes.
@since 1.0.0
@api public | [
"Builds",
"a",
"URI",
"object",
"from",
"the",
"URL",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/url.rb#L464-L488 | train |
ronin-ruby/ronin | lib/ronin/host_name.rb | Ronin.HostName.lookup! | def lookup!(nameserver=nil)
resolver = Resolv.resolver(nameserver)
ips = begin
resolver.getaddresses(self.address)
rescue
[]
end
ips.map! do |addr|
IPAddress.first_or_create(
:address => addr,
:host_names => [self]
... | ruby | def lookup!(nameserver=nil)
resolver = Resolv.resolver(nameserver)
ips = begin
resolver.getaddresses(self.address)
rescue
[]
end
ips.map! do |addr|
IPAddress.first_or_create(
:address => addr,
:host_names => [self]
... | [
"def",
"lookup!",
"(",
"nameserver",
"=",
"nil",
")",
"resolver",
"=",
"Resolv",
".",
"resolver",
"(",
"nameserver",
")",
"ips",
"=",
"begin",
"resolver",
".",
"getaddresses",
"(",
"self",
".",
"address",
")",
"rescue",
"[",
"]",
"end",
"ips",
".",
"ma... | Looks up all IP Addresses for the host name.
@param [String] nameserver
The optional nameserver to query.
@return [Array<IPAddress>]
The IP Addresses for the host name.
@since 1.0.0
@api public | [
"Looks",
"up",
"all",
"IP",
"Addresses",
"for",
"the",
"host",
"name",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/host_name.rb#L218-L234 | train |
ronin-ruby/ronin | lib/ronin/campaign.rb | Ronin.Campaign.target! | def target!(addr)
unless (address = Address.first(:address => addr))
raise("unknown address #{addr.dump}")
end
return Target.first_or_create(:campaign => self, :address => address)
end | ruby | def target!(addr)
unless (address = Address.first(:address => addr))
raise("unknown address #{addr.dump}")
end
return Target.first_or_create(:campaign => self, :address => address)
end | [
"def",
"target!",
"(",
"addr",
")",
"unless",
"(",
"address",
"=",
"Address",
".",
"first",
"(",
":address",
"=>",
"addr",
")",
")",
"raise",
"(",
"\"unknown address #{addr.dump}\"",
")",
"end",
"return",
"Target",
".",
"first_or_create",
"(",
":campaign",
"... | Adds an address to the campaign.
@param [String] addr
The address that will be targeted.
@return [Target]
The new target of the campaign.
@raise [RuntimeError]
The given address could not be found.
@since 1.0.0
@api public | [
"Adds",
"an",
"address",
"to",
"the",
"campaign",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/campaign.rb#L120-L126 | train |
ronin-ruby/ronin | lib/ronin/ip_address.rb | Ronin.IPAddress.lookup! | def lookup!(nameserver=nil)
resolver = Resolv.resolver(nameserver)
hosts = begin
resolver.getnames(self.address.to_s)
rescue
[]
end
hosts.map! do |name|
HostName.first_or_create(
:address => name,
:ip_addresses =>... | ruby | def lookup!(nameserver=nil)
resolver = Resolv.resolver(nameserver)
hosts = begin
resolver.getnames(self.address.to_s)
rescue
[]
end
hosts.map! do |name|
HostName.first_or_create(
:address => name,
:ip_addresses =>... | [
"def",
"lookup!",
"(",
"nameserver",
"=",
"nil",
")",
"resolver",
"=",
"Resolv",
".",
"resolver",
"(",
"nameserver",
")",
"hosts",
"=",
"begin",
"resolver",
".",
"getnames",
"(",
"self",
".",
"address",
".",
"to_s",
")",
"rescue",
"[",
"]",
"end",
"hos... | Performs a reverse lookup on the IP address.
@param [String] nameserver
Optional nameserver to query.
@return [Array<HostName>]
The host-names associated with the IP Address.
@since 1.0.0
@api public | [
"Performs",
"a",
"reverse",
"lookup",
"on",
"the",
"IP",
"address",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/ip_address.rb#L236-L252 | train |
ronin-ruby/ronin | lib/ronin/repository.rb | Ronin.Repository.find_script | def find_script(sub_path)
paths = @script_dirs.map { |dir| File.join(dir,sub_path) }
return script_paths.first(:path => paths)
end | ruby | def find_script(sub_path)
paths = @script_dirs.map { |dir| File.join(dir,sub_path) }
return script_paths.first(:path => paths)
end | [
"def",
"find_script",
"(",
"sub_path",
")",
"paths",
"=",
"@script_dirs",
".",
"map",
"{",
"|",
"dir",
"|",
"File",
".",
"join",
"(",
"dir",
",",
"sub_path",
")",
"}",
"return",
"script_paths",
".",
"first",
"(",
":path",
"=>",
"paths",
")",
"end"
] | Finds a cached script.
@param [String] sub_path
The sub-path within the repository to search for.
@return [Script::Path, nil]
The matching script path.
@since 1.1.0
@api private | [
"Finds",
"a",
"cached",
"script",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/repository.rb#L550-L554 | train |
ronin-ruby/ronin | lib/ronin/repository.rb | Ronin.Repository.update! | def update!
local_repo = Pullr::LocalRepository.new(
:path => self.path,
:scm => self.scm
)
# only update if we have a repository
local_repo.update(self.uri)
# re-initialize the metadata
initialize_metadata
# save the repository
if save
# syncs... | ruby | def update!
local_repo = Pullr::LocalRepository.new(
:path => self.path,
:scm => self.scm
)
# only update if we have a repository
local_repo.update(self.uri)
# re-initialize the metadata
initialize_metadata
# save the repository
if save
# syncs... | [
"def",
"update!",
"local_repo",
"=",
"Pullr",
"::",
"LocalRepository",
".",
"new",
"(",
":path",
"=>",
"self",
".",
"path",
",",
":scm",
"=>",
"self",
".",
"scm",
")",
"local_repo",
".",
"update",
"(",
"self",
".",
"uri",
")",
"initialize_metadata",
"if"... | Updates the repository, reloads it's metadata and syncs the
cached files of the repository.
@yield [repo]
If a block is given, it will be passed after the repository has
been updated.
@yieldparam [Repository] repo
The updated repository.
@return [Repository]
The updated repository.
@since 1.0.0
@... | [
"Updates",
"the",
"repository",
"reloads",
"it",
"s",
"metadata",
"and",
"syncs",
"the",
"cached",
"files",
"of",
"the",
"repository",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/repository.rb#L646-L666 | train |
ronin-ruby/ronin | lib/ronin/repository.rb | Ronin.Repository.uninstall! | def uninstall!
deactivate!
FileUtils.rm_rf(self.path) if self.installed?
# destroy any cached files first
clean_scripts!
# remove the repository from the database
destroy if saved?
yield self if block_given?
return self
end | ruby | def uninstall!
deactivate!
FileUtils.rm_rf(self.path) if self.installed?
# destroy any cached files first
clean_scripts!
# remove the repository from the database
destroy if saved?
yield self if block_given?
return self
end | [
"def",
"uninstall!",
"deactivate!",
"FileUtils",
".",
"rm_rf",
"(",
"self",
".",
"path",
")",
"if",
"self",
".",
"installed?",
"clean_scripts!",
"destroy",
"if",
"saved?",
"yield",
"self",
"if",
"block_given?",
"return",
"self",
"end"
] | Deletes the contents of the repository.
@yield [repo]
If a block is given, it will be passed the repository after it's
contents have been deleted.
@yieldparam [Repository] repo
The deleted repository.
@return [Repository]
The deleted repository.
@since 1.0.0
@api private | [
"Deletes",
"the",
"contents",
"of",
"the",
"repository",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/repository.rb#L685-L698 | train |
ronin-ruby/ronin | lib/ronin/password.rb | Ronin.Password.digest | def digest(algorithm,options={})
digest_class = begin
Digest.const_get(algorithm.to_s.upcase)
rescue LoadError
raise(ArgumentError,"Unknown Digest algorithm #{algorithm}")
end
hash = digest_class.new
if options[:... | ruby | def digest(algorithm,options={})
digest_class = begin
Digest.const_get(algorithm.to_s.upcase)
rescue LoadError
raise(ArgumentError,"Unknown Digest algorithm #{algorithm}")
end
hash = digest_class.new
if options[:... | [
"def",
"digest",
"(",
"algorithm",
",",
"options",
"=",
"{",
"}",
")",
"digest_class",
"=",
"begin",
"Digest",
".",
"const_get",
"(",
"algorithm",
".",
"to_s",
".",
"upcase",
")",
"rescue",
"LoadError",
"raise",
"(",
"ArgumentError",
",",
"\"Unknown Digest a... | Hashes the password.
@param [Symbol, String] algorithm
The digest algorithm to use.
@param [Hash] options
Additional options.
@option options [String] :prepend_salt
The salt data to prepend to the password.
@option options [String] :append_salt
The salt data to append to the password.
@return [Str... | [
"Hashes",
"the",
"password",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/password.rb#L100-L120 | train |
ronin-ruby/ronin | lib/ronin/mac_address.rb | Ronin.MACAddress.to_i | def to_i
self.address.split(':').inject(0) do |bits,char|
bits = ((bits << 8) | char.hex)
end
end | ruby | def to_i
self.address.split(':').inject(0) do |bits,char|
bits = ((bits << 8) | char.hex)
end
end | [
"def",
"to_i",
"self",
".",
"address",
".",
"split",
"(",
"':'",
")",
".",
"inject",
"(",
"0",
")",
"do",
"|",
"bits",
",",
"char",
"|",
"bits",
"=",
"(",
"(",
"bits",
"<<",
"8",
")",
"|",
"char",
".",
"hex",
")",
"end",
"end"
] | Converts the MAC address to an Integer.
@return [Integer]
The network representation of the MAC address.
@since 1.0.0
@api public | [
"Converts",
"the",
"MAC",
"address",
"to",
"an",
"Integer",
"."
] | 10474c197f2c130f1e09975716955322a848b20a | https://github.com/ronin-ruby/ronin/blob/10474c197f2c130f1e09975716955322a848b20a/lib/ronin/mac_address.rb#L104-L108 | train |
SeanNieuwoudt/plugg | lib/plugg.rb | Plugg.Dispatcher.start | def start(paths, params = {})
@registry = []
paths.each do |path|
if path[-1] == '/'
path.chop!
end
Dir["#{path}/*.rb"].each do |f|
require File.expand_path(f)
begin
instance = Object.const_get(File.basename(f, '.rb')).new
# ... | ruby | def start(paths, params = {})
@registry = []
paths.each do |path|
if path[-1] == '/'
path.chop!
end
Dir["#{path}/*.rb"].each do |f|
require File.expand_path(f)
begin
instance = Object.const_get(File.basename(f, '.rb')).new
# ... | [
"def",
"start",
"(",
"paths",
",",
"params",
"=",
"{",
"}",
")",
"@registry",
"=",
"[",
"]",
"paths",
".",
"each",
"do",
"|",
"path",
"|",
"if",
"path",
"[",
"-",
"1",
"]",
"==",
"'/'",
"path",
".",
"chop!",
"end",
"Dir",
"[",
"\"#{path}/*.rb\"",... | Assign a path where plugins should be loaded from
@param mixed path
@param hash params
@return void | [
"Assign",
"a",
"path",
"where",
"plugins",
"should",
"be",
"loaded",
"from"
] | f078d76aa17aa651f4c89ba39553a5436e98384b | https://github.com/SeanNieuwoudt/plugg/blob/f078d76aa17aa651f4c89ba39553a5436e98384b/lib/plugg.rb#L126-L158 | train |
SeanNieuwoudt/plugg | lib/plugg.rb | Plugg.Dispatcher.on | def on(method, *args, &block)
if [:initialize, :before, :setup, :after].include? method
raise "#{method} should not be called directly"
end
buffer = [] # Container for the response buffer
threads = [] # Container for the execution threads
@registry.each do |s|
if s.resp... | ruby | def on(method, *args, &block)
if [:initialize, :before, :setup, :after].include? method
raise "#{method} should not be called directly"
end
buffer = [] # Container for the response buffer
threads = [] # Container for the execution threads
@registry.each do |s|
if s.resp... | [
"def",
"on",
"(",
"method",
",",
"*",
"args",
",",
"&",
"block",
")",
"if",
"[",
":initialize",
",",
":before",
",",
":setup",
",",
":after",
"]",
".",
"include?",
"method",
"raise",
"\"#{method} should not be called directly\"",
"end",
"buffer",
"=",
"[",
... | Initialize the dispatcher instance with a default timeout of 5s
@return void
Loop through all services and fire off the supported messages
@param string method
@return void | [
"Initialize",
"the",
"dispatcher",
"instance",
"with",
"a",
"default",
"timeout",
"of",
"5s"
] | f078d76aa17aa651f4c89ba39553a5436e98384b | https://github.com/SeanNieuwoudt/plugg/blob/f078d76aa17aa651f4c89ba39553a5436e98384b/lib/plugg.rb#L182-L214 | train |
shunhikita/action_messenger | lib/action_messenger/base.rb | ActionMessenger.Base.message_to_slack | def message_to_slack(channel:, options: {})
@caller_method_name = caller[0][/`([^']*)'/, 1]
options = apply_defaults(options)
message = nil
ActiveSupport::Notifications.instrument('message_to_slack.action_messenger', channel: channel, body: options[:text]) do
message = slack_client.messa... | ruby | def message_to_slack(channel:, options: {})
@caller_method_name = caller[0][/`([^']*)'/, 1]
options = apply_defaults(options)
message = nil
ActiveSupport::Notifications.instrument('message_to_slack.action_messenger', channel: channel, body: options[:text]) do
message = slack_client.messa... | [
"def",
"message_to_slack",
"(",
"channel",
":",
",",
"options",
":",
"{",
"}",
")",
"@caller_method_name",
"=",
"caller",
"[",
"0",
"]",
"[",
"/",
"/",
",",
"1",
"]",
"options",
"=",
"apply_defaults",
"(",
"options",
")",
"message",
"=",
"nil",
"Active... | message to slack
@param [String] channel slack channel.
ex. #general
@param [Hash] options Slack API Request Options
ex. https://api.slack.com/methods/chat.postMessage
ex. message_to_slack(channel: '#general', options: {text: 'sample'}) | [
"message",
"to",
"slack"
] | 0bfed768917de491cf51898bfc0124c423dd6474 | https://github.com/shunhikita/action_messenger/blob/0bfed768917de491cf51898bfc0124c423dd6474/lib/action_messenger/base.rb#L51-L61 | train |
shunhikita/action_messenger | lib/action_messenger/base.rb | ActionMessenger.Base.upload_file_to_slack | def upload_file_to_slack(channels: ,file: ,options: {})
upload_file = nil
ActiveSupport::Notifications.instrument('upload_file_to_slack.action_messenger', channels: channels) do
upload_file = slack_client.upload_file(channels, file, options)
end
upload_file
ensure
self.deliveri... | ruby | def upload_file_to_slack(channels: ,file: ,options: {})
upload_file = nil
ActiveSupport::Notifications.instrument('upload_file_to_slack.action_messenger', channels: channels) do
upload_file = slack_client.upload_file(channels, file, options)
end
upload_file
ensure
self.deliveri... | [
"def",
"upload_file_to_slack",
"(",
"channels",
":",
",",
"file",
":",
",",
"options",
":",
"{",
"}",
")",
"upload_file",
"=",
"nil",
"ActiveSupport",
"::",
"Notifications",
".",
"instrument",
"(",
"'upload_file_to_slack.action_messenger'",
",",
"channels",
":",
... | upload file to slack
@param [String] channels slack channel
ex. #general, #hoge
@param [Faraday::UploadIO] file upload file
ex. Faraday::UploadIO.new('/path/to/sample.jpg', 'image/jpg')
@param [Hash] options | [
"upload",
"file",
"to",
"slack"
] | 0bfed768917de491cf51898bfc0124c423dd6474 | https://github.com/shunhikita/action_messenger/blob/0bfed768917de491cf51898bfc0124c423dd6474/lib/action_messenger/base.rb#L70-L78 | train |
tdak/worldcatapi | lib/worldcatapi/sru_search_response.rb | WORLDCATAPI.SruSearchResponse.extract_multiple | def extract_multiple(record, field, tag)
a = Array.new
record.fields(field).each do |field|
a.push field[tag]
end
return a
end | ruby | def extract_multiple(record, field, tag)
a = Array.new
record.fields(field).each do |field|
a.push field[tag]
end
return a
end | [
"def",
"extract_multiple",
"(",
"record",
",",
"field",
",",
"tag",
")",
"a",
"=",
"Array",
".",
"new",
"record",
".",
"fields",
"(",
"field",
")",
".",
"each",
"do",
"|",
"field",
"|",
"a",
".",
"push",
"field",
"[",
"tag",
"]",
"end",
"return",
... | Extract Multiple fields for record | [
"Extract",
"Multiple",
"fields",
"for",
"record"
] | ed6d0cb849e86a032dc84741a5d169da19b8e385 | https://github.com/tdak/worldcatapi/blob/ed6d0cb849e86a032dc84741a5d169da19b8e385/lib/worldcatapi/sru_search_response.rb#L60-L66 | train |
conduit/conduit-braintree | lib/conduit/braintree/actions/base.rb | Conduit::Driver::Braintree.Base.perform | def perform
body = perform_action
parser = parser_class.new(body)
Conduit::ApiResponse.new(raw_response: @raw_response, body: body, parser: parser)
rescue Braintree::NotFoundError => error
report_braintree_exceptions(error)
rescue ArgumentError => error
respond_with_error(error.mes... | ruby | def perform
body = perform_action
parser = parser_class.new(body)
Conduit::ApiResponse.new(raw_response: @raw_response, body: body, parser: parser)
rescue Braintree::NotFoundError => error
report_braintree_exceptions(error)
rescue ArgumentError => error
respond_with_error(error.mes... | [
"def",
"perform",
"body",
"=",
"perform_action",
"parser",
"=",
"parser_class",
".",
"new",
"(",
"body",
")",
"Conduit",
"::",
"ApiResponse",
".",
"new",
"(",
"raw_response",
":",
"@raw_response",
",",
"body",
":",
"body",
",",
"parser",
":",
"parser",
")"... | Performs the request, with mocking if requested | [
"Performs",
"the",
"request",
"with",
"mocking",
"if",
"requested"
] | 67fd15ac223eb3118da5fe75177e9e6e42430504 | https://github.com/conduit/conduit-braintree/blob/67fd15ac223eb3118da5fe75177e9e6e42430504/lib/conduit/braintree/actions/base.rb#L23-L35 | train |
daanforever/settingson | app/models/concerns/settingson/base.rb | Settingson::Base.ClassMethods.defaults | def defaults
@__defaults = Settingson::Store::Default.new( klass: self )
if block_given?
Rails.application.config.after_initialize do
yield @__defaults
end
end
@__defaults
end | ruby | def defaults
@__defaults = Settingson::Store::Default.new( klass: self )
if block_given?
Rails.application.config.after_initialize do
yield @__defaults
end
end
@__defaults
end | [
"def",
"defaults",
"@__defaults",
"=",
"Settingson",
"::",
"Store",
"::",
"Default",
".",
"new",
"(",
"klass",
":",
"self",
")",
"if",
"block_given?",
"Rails",
".",
"application",
".",
"config",
".",
"after_initialize",
"do",
"yield",
"@__defaults",
"end",
"... | Settings.defaults do |default|
default.server.host = 'host'
default.server.port = 80
end | [
"Settings",
".",
"defaults",
"do",
"|default|",
"default",
".",
"server",
".",
"host",
"=",
"host",
"default",
".",
"server",
".",
"port",
"=",
"80",
"end"
] | a3aa6ace98479841b6c9a6f3af7ed01a6cd7269e | https://github.com/daanforever/settingson/blob/a3aa6ace98479841b6c9a6f3af7ed01a6cd7269e/app/models/concerns/settingson/base.rb#L26-L36 | train |
ianpurvis/police_state | lib/police_state/transition_helpers.rb | PoliceState.TransitionHelpers.attribute_transitioning? | def attribute_transitioning?(attr, options={})
options = _transform_options_for_attribute(attr, options)
attribute_changed?(attr, options)
end | ruby | def attribute_transitioning?(attr, options={})
options = _transform_options_for_attribute(attr, options)
attribute_changed?(attr, options)
end | [
"def",
"attribute_transitioning?",
"(",
"attr",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"_transform_options_for_attribute",
"(",
"attr",
",",
"options",
")",
"attribute_changed?",
"(",
"attr",
",",
"options",
")",
"end"
] | Returns +true+ if +attribute+ is currently transitioning but not saved, otherwise +false+.
You can specify origin and destination states using the +:from+ and +:to+
options. If +attribute+ is an +ActiveRecord::Enum+, these may be
specified as either symbol or their native enum value.
model = Model.new(status: :c... | [
"Returns",
"+",
"true",
"+",
"if",
"+",
"attribute",
"+",
"is",
"currently",
"transitioning",
"but",
"not",
"saved",
"otherwise",
"+",
"false",
"+",
"."
] | d827e74a0b2eb2a698a018d5367fb63c49b6b699 | https://github.com/ianpurvis/police_state/blob/d827e74a0b2eb2a698a018d5367fb63c49b6b699/lib/police_state/transition_helpers.rb#L54-L57 | train |
shunhikita/action_messenger | lib/action_messenger/message_delivery.rb | ActionMessenger.MessageDelivery.deliver_now! | def deliver_now!
messenger.handle_exceptions do
ActiveSupport::Notifications.instrument('deliver_now!.action_messenger', method_name: method_name, args: args) do
if args.present?
messenger.public_send(method_name, *args)
else
messenger.public_send(method_name)
... | ruby | def deliver_now!
messenger.handle_exceptions do
ActiveSupport::Notifications.instrument('deliver_now!.action_messenger', method_name: method_name, args: args) do
if args.present?
messenger.public_send(method_name, *args)
else
messenger.public_send(method_name)
... | [
"def",
"deliver_now!",
"messenger",
".",
"handle_exceptions",
"do",
"ActiveSupport",
"::",
"Notifications",
".",
"instrument",
"(",
"'deliver_now!.action_messenger'",
",",
"method_name",
":",
"method_name",
",",
"args",
":",
"args",
")",
"do",
"if",
"args",
".",
"... | send a message now | [
"send",
"a",
"message",
"now"
] | 0bfed768917de491cf51898bfc0124c423dd6474 | https://github.com/shunhikita/action_messenger/blob/0bfed768917de491cf51898bfc0124c423dd6474/lib/action_messenger/message_delivery.rb#L15-L25 | train |
shunhikita/action_messenger | lib/action_messenger/message_delivery.rb | ActionMessenger.MessageDelivery.deliver_later! | def deliver_later!
ActionMessenger::MessageDeliveryJob.perform_later(self.class.name, 'deliver_now!', messenger_class.to_s, method_name.to_s, *args)
end | ruby | def deliver_later!
ActionMessenger::MessageDeliveryJob.perform_later(self.class.name, 'deliver_now!', messenger_class.to_s, method_name.to_s, *args)
end | [
"def",
"deliver_later!",
"ActionMessenger",
"::",
"MessageDeliveryJob",
".",
"perform_later",
"(",
"self",
".",
"class",
".",
"name",
",",
"'deliver_now!'",
",",
"messenger_class",
".",
"to_s",
",",
"method_name",
".",
"to_s",
",",
"*",
"args",
")",
"end"
] | send a message asynchronously | [
"send",
"a",
"message",
"asynchronously"
] | 0bfed768917de491cf51898bfc0124c423dd6474 | https://github.com/shunhikita/action_messenger/blob/0bfed768917de491cf51898bfc0124c423dd6474/lib/action_messenger/message_delivery.rb#L28-L30 | train |
ateamlunchbox/graphql_grpc | lib/graphql_grpc/proxy.rb | GraphqlGrpc.Proxy.map_functions | def map_functions(stub_services)
return @function_map unless @function_map.empty?
stub_services.keys.each do |service_name|
stub = @services[service_name] = stub_services[service_name]
stub.class.to_s.gsub('::Stub', '::Service').constantize.rpc_descs.values.each do |d|
next if d.n... | ruby | def map_functions(stub_services)
return @function_map unless @function_map.empty?
stub_services.keys.each do |service_name|
stub = @services[service_name] = stub_services[service_name]
stub.class.to_s.gsub('::Stub', '::Service').constantize.rpc_descs.values.each do |d|
next if d.n... | [
"def",
"map_functions",
"(",
"stub_services",
")",
"return",
"@function_map",
"unless",
"@function_map",
".",
"empty?",
"stub_services",
".",
"keys",
".",
"each",
"do",
"|",
"service_name",
"|",
"stub",
"=",
"@services",
"[",
"service_name",
"]",
"=",
"stub_serv... | Add to the function_map by inspecting each service for the RPCs it provides. | [
"Add",
"to",
"the",
"function_map",
"by",
"inspecting",
"each",
"service",
"for",
"the",
"RPCs",
"it",
"provides",
"."
] | dfb51f32457584007ea03895d12f4e089f3a4946 | https://github.com/ateamlunchbox/graphql_grpc/blob/dfb51f32457584007ea03895d12f4e089f3a4946/lib/graphql_grpc/proxy.rb#L85-L103 | train |
ateamlunchbox/graphql_grpc | lib/graphql_grpc/function.rb | GraphqlGrpc.Function.arg | def arg(params)
rpc_desc.input.decode_json(params.reject { |k, _v| k == :selections }.to_json)
end | ruby | def arg(params)
rpc_desc.input.decode_json(params.reject { |k, _v| k == :selections }.to_json)
end | [
"def",
"arg",
"(",
"params",
")",
"rpc_desc",
".",
"input",
".",
"decode_json",
"(",
"params",
".",
"reject",
"{",
"|",
"k",
",",
"_v",
"|",
"k",
"==",
":selections",
"}",
".",
"to_json",
")",
"end"
] | Build arguments to a func | [
"Build",
"arguments",
"to",
"a",
"func"
] | dfb51f32457584007ea03895d12f4e089f3a4946 | https://github.com/ateamlunchbox/graphql_grpc/blob/dfb51f32457584007ea03895d12f4e089f3a4946/lib/graphql_grpc/function.rb#L108-L110 | train |
conduit/conduit-braintree | lib/conduit/braintree/actions/update_credit_card.rb | Conduit::Driver::Braintree.UpdateCreditCard.whitelist_options | def whitelist_options
@options[:options] ||= {}.tap do |h|
h[:verify_card] = @options.fetch(:verify_card, true)
@options.delete(:verify_card)
if @options.key?(:verification_merchant_account_id)
h[:verification_merchant_account_id] = @options.delete(:verification_merchant_account_... | ruby | def whitelist_options
@options[:options] ||= {}.tap do |h|
h[:verify_card] = @options.fetch(:verify_card, true)
@options.delete(:verify_card)
if @options.key?(:verification_merchant_account_id)
h[:verification_merchant_account_id] = @options.delete(:verification_merchant_account_... | [
"def",
"whitelist_options",
"@options",
"[",
":options",
"]",
"||=",
"{",
"}",
".",
"tap",
"do",
"|",
"h",
"|",
"h",
"[",
":verify_card",
"]",
"=",
"@options",
".",
"fetch",
"(",
":verify_card",
",",
"true",
")",
"@options",
".",
"delete",
"(",
":verif... | Request verification when the card is
stored, using the merchant account id
if one is provided | [
"Request",
"verification",
"when",
"the",
"card",
"is",
"stored",
"using",
"the",
"merchant",
"account",
"id",
"if",
"one",
"is",
"provided"
] | 67fd15ac223eb3118da5fe75177e9e6e42430504 | https://github.com/conduit/conduit-braintree/blob/67fd15ac223eb3118da5fe75177e9e6e42430504/lib/conduit/braintree/actions/update_credit_card.rb#L27-L36 | train |
robmiller/ruby-wpdb | lib/ruby-wpdb/term.rb | WPDB.Termable.add_term | def add_term(term, taxonomy, description, count)
if term.respond_to?(:term_id)
term_id = term.term_id
else
term_id = term.to_i
end
term_taxonomy = WPDB::TermTaxonomy.where(term_id: term_id, taxonomy: taxonomy).first
unless term_taxonomy
term_taxonomy = WPDB::TermTa... | ruby | def add_term(term, taxonomy, description, count)
if term.respond_to?(:term_id)
term_id = term.term_id
else
term_id = term.to_i
end
term_taxonomy = WPDB::TermTaxonomy.where(term_id: term_id, taxonomy: taxonomy).first
unless term_taxonomy
term_taxonomy = WPDB::TermTa... | [
"def",
"add_term",
"(",
"term",
",",
"taxonomy",
",",
"description",
",",
"count",
")",
"if",
"term",
".",
"respond_to?",
"(",
":term_id",
")",
"term_id",
"=",
"term",
".",
"term_id",
"else",
"term_id",
"=",
"term",
".",
"to_i",
"end",
"term_taxonomy",
"... | For objects that have a relationship with termtaxonomies, this
module can be mixed in and gives the ability to add a term
directly to the model, rather than creating the relationship
yourself. Used by Post and Link. | [
"For",
"objects",
"that",
"have",
"a",
"relationship",
"with",
"termtaxonomies",
"this",
"module",
"can",
"be",
"mixed",
"in",
"and",
"gives",
"the",
"ability",
"to",
"add",
"a",
"term",
"directly",
"to",
"the",
"model",
"rather",
"than",
"creating",
"the",
... | 2252be12baa3b9607c26fc8cc5e167ae3b82a94d | https://github.com/robmiller/ruby-wpdb/blob/2252be12baa3b9607c26fc8cc5e167ae3b82a94d/lib/ruby-wpdb/term.rb#L19-L39 | train |
TailorBrands/noun-project-api | lib/noun-project-api/retriever.rb | NounProjectApi.Retriever.find | def find(id)
raise ArgumentError.new("Missing id/slug") unless id
result = access_token.get("#{API_BASE}#{self.class::API_PATH}#{id}")
raise ServiceError.new(result.code, result.body) unless result.code == "200"
self.class::ITEM_CLASS.new(result.body)
end | ruby | def find(id)
raise ArgumentError.new("Missing id/slug") unless id
result = access_token.get("#{API_BASE}#{self.class::API_PATH}#{id}")
raise ServiceError.new(result.code, result.body) unless result.code == "200"
self.class::ITEM_CLASS.new(result.body)
end | [
"def",
"find",
"(",
"id",
")",
"raise",
"ArgumentError",
".",
"new",
"(",
"\"Missing id/slug\"",
")",
"unless",
"id",
"result",
"=",
"access_token",
".",
"get",
"(",
"\"#{API_BASE}#{self.class::API_PATH}#{id}\"",
")",
"raise",
"ServiceError",
".",
"new",
"(",
"r... | Find an item based on it's id. | [
"Find",
"an",
"item",
"based",
"on",
"it",
"s",
"id",
"."
] | b4fbd0836fd80aee843af03569bdfa2a6ffe79f9 | https://github.com/TailorBrands/noun-project-api/blob/b4fbd0836fd80aee843af03569bdfa2a6ffe79f9/lib/noun-project-api/retriever.rb#L7-L14 | train |
vaharoni/trusted-sandbox | lib/trusted_sandbox/uid_pool.rb | TrustedSandbox.UidPool.lock | def lock
retries.times do
atomically(timeout) do
uid = available_uid
if uid
lock_uid uid
return uid.to_i
end
end
sleep(delay)
end
raise PoolTimeoutError.new('No available UIDs in the pool. Please try again later.')
end | ruby | def lock
retries.times do
atomically(timeout) do
uid = available_uid
if uid
lock_uid uid
return uid.to_i
end
end
sleep(delay)
end
raise PoolTimeoutError.new('No available UIDs in the pool. Please try again later.')
end | [
"def",
"lock",
"retries",
".",
"times",
"do",
"atomically",
"(",
"timeout",
")",
"do",
"uid",
"=",
"available_uid",
"if",
"uid",
"lock_uid",
"uid",
"return",
"uid",
".",
"to_i",
"end",
"end",
"sleep",
"(",
"delay",
")",
"end",
"raise",
"PoolTimeoutError",
... | Locks one UID from the pool, in a cross-process atomic manner
@return [Integer]
@raise [PoolTimeoutError] if no ID is available after retries | [
"Locks",
"one",
"UID",
"from",
"the",
"pool",
"in",
"a",
"cross",
"-",
"process",
"atomic",
"manner"
] | e5d5e99bebfeab9e88c2512e30742b392bc09677 | https://github.com/vaharoni/trusted-sandbox/blob/e5d5e99bebfeab9e88c2512e30742b392bc09677/lib/trusted_sandbox/uid_pool.rb#L56-L68 | train |
vaharoni/trusted-sandbox | lib/trusted_sandbox/response.rb | TrustedSandbox.Response.parse! | def parse!
unless File.exists? output_file_path
@status = 'error'
@error = ContainerError.new('User code did not finish properly')
@error_to_raise = @error
return
end
begin
data = File.binread output_file_path
@raw_response = Marshal.load(data)
re... | ruby | def parse!
unless File.exists? output_file_path
@status = 'error'
@error = ContainerError.new('User code did not finish properly')
@error_to_raise = @error
return
end
begin
data = File.binread output_file_path
@raw_response = Marshal.load(data)
re... | [
"def",
"parse!",
"unless",
"File",
".",
"exists?",
"output_file_path",
"@status",
"=",
"'error'",
"@error",
"=",
"ContainerError",
".",
"new",
"(",
"'User code did not finish properly'",
")",
"@error_to_raise",
"=",
"@error",
"return",
"end",
"begin",
"data",
"=",
... | Parses the output file and stores the values in the appropriate ivars
@return [nil] | [
"Parses",
"the",
"output",
"file",
"and",
"stores",
"the",
"values",
"in",
"the",
"appropriate",
"ivars"
] | e5d5e99bebfeab9e88c2512e30742b392bc09677 | https://github.com/vaharoni/trusted-sandbox/blob/e5d5e99bebfeab9e88c2512e30742b392bc09677/lib/trusted_sandbox/response.rb#L64-L94 | train |
trishume/pro | lib/pro/commands.rb | Pro.Commands.find_repo | def find_repo(name)
return @index.base_dirs.first unless name
match = FuzzyMatch.new(@index.to_a, :read => :name).find(name)
match[1] unless match.nil?
end | ruby | def find_repo(name)
return @index.base_dirs.first unless name
match = FuzzyMatch.new(@index.to_a, :read => :name).find(name)
match[1] unless match.nil?
end | [
"def",
"find_repo",
"(",
"name",
")",
"return",
"@index",
".",
"base_dirs",
".",
"first",
"unless",
"name",
"match",
"=",
"FuzzyMatch",
".",
"new",
"(",
"@index",
".",
"to_a",
",",
":read",
"=>",
":name",
")",
".",
"find",
"(",
"name",
")",
"match",
... | Fuzzy search for a git repository by name
Returns the full path to the repository.
If name is nil return the pro base. | [
"Fuzzy",
"search",
"for",
"a",
"git",
"repository",
"by",
"name",
"Returns",
"the",
"full",
"path",
"to",
"the",
"repository",
"."
] | 646098c7514eb5346dd2942f90b888c0de30b6ba | https://github.com/trishume/pro/blob/646098c7514eb5346dd2942f90b888c0de30b6ba/lib/pro/commands.rb#L46-L50 | train |
trishume/pro | lib/pro/commands.rb | Pro.Commands.status | def status()
max_name = @index.map {|repo| repo.name.length}.max + 1
@index.each do |r|
next unless Dir.exists?(r.path)
status = repo_status(r.path)
next if status.empty?
name = format("%-#{max_name}s",r.name).bold
puts "#{name} > #{status}"
end
end | ruby | def status()
max_name = @index.map {|repo| repo.name.length}.max + 1
@index.each do |r|
next unless Dir.exists?(r.path)
status = repo_status(r.path)
next if status.empty?
name = format("%-#{max_name}s",r.name).bold
puts "#{name} > #{status}"
end
end | [
"def",
"status",
"(",
")",
"max_name",
"=",
"@index",
".",
"map",
"{",
"|",
"repo",
"|",
"repo",
".",
"name",
".",
"length",
"}",
".",
"max",
"+",
"1",
"@index",
".",
"each",
"do",
"|",
"r",
"|",
"next",
"unless",
"Dir",
".",
"exists?",
"(",
"r... | prints a status list showing repos with
unpushed commits or uncommitted changes | [
"prints",
"a",
"status",
"list",
"showing",
"repos",
"with",
"unpushed",
"commits",
"or",
"uncommitted",
"changes"
] | 646098c7514eb5346dd2942f90b888c0de30b6ba | https://github.com/trishume/pro/blob/646098c7514eb5346dd2942f90b888c0de30b6ba/lib/pro/commands.rb#L88-L97 | train |
trishume/pro | lib/pro/commands.rb | Pro.Commands.repo_status | def repo_status(path)
messages = []
messages << EMPTY_MESSAGE if repo_empty?(path)
messages << UNCOMMITTED_MESSAGE if commit_pending?(path)
messages << UNTRACKED_MESSAGE if untracked_files?(path)
messages << UNPUSHED_MESSAGE if repo_unpushed?(path)
messages.join(JOIN_STRING)
end | ruby | def repo_status(path)
messages = []
messages << EMPTY_MESSAGE if repo_empty?(path)
messages << UNCOMMITTED_MESSAGE if commit_pending?(path)
messages << UNTRACKED_MESSAGE if untracked_files?(path)
messages << UNPUSHED_MESSAGE if repo_unpushed?(path)
messages.join(JOIN_STRING)
end | [
"def",
"repo_status",
"(",
"path",
")",
"messages",
"=",
"[",
"]",
"messages",
"<<",
"EMPTY_MESSAGE",
"if",
"repo_empty?",
"(",
"path",
")",
"messages",
"<<",
"UNCOMMITTED_MESSAGE",
"if",
"commit_pending?",
"(",
"path",
")",
"messages",
"<<",
"UNTRACKED_MESSAGE"... | returns a short status message for the repo | [
"returns",
"a",
"short",
"status",
"message",
"for",
"the",
"repo"
] | 646098c7514eb5346dd2942f90b888c0de30b6ba | https://github.com/trishume/pro/blob/646098c7514eb5346dd2942f90b888c0de30b6ba/lib/pro/commands.rb#L100-L107 | train |
trishume/pro | lib/pro/commands.rb | Pro.Commands.install_cd | def install_cd
puts CD_INFO
print "Continue with installation (yN)? "
return unless gets.chomp.downcase == "y"
# get name
print "Name of pro cd command (default 'pd'): "
name = gets.strip
name = 'pd' if name.empty?
# sub into function
func = SHELL_FUNCTION.sub("{{na... | ruby | def install_cd
puts CD_INFO
print "Continue with installation (yN)? "
return unless gets.chomp.downcase == "y"
# get name
print "Name of pro cd command (default 'pd'): "
name = gets.strip
name = 'pd' if name.empty?
# sub into function
func = SHELL_FUNCTION.sub("{{na... | [
"def",
"install_cd",
"puts",
"CD_INFO",
"print",
"\"Continue with installation (yN)? \"",
"return",
"unless",
"gets",
".",
"chomp",
".",
"downcase",
"==",
"\"y\"",
"print",
"\"Name of pro cd command (default 'pd'): \"",
"name",
"=",
"gets",
".",
"strip",
"name",
"=",
... | Adds a shell function to the shell config files that
allows easy directory changing. | [
"Adds",
"a",
"shell",
"function",
"to",
"the",
"shell",
"config",
"files",
"that",
"allows",
"easy",
"directory",
"changing",
"."
] | 646098c7514eb5346dd2942f90b888c0de30b6ba | https://github.com/trishume/pro/blob/646098c7514eb5346dd2942f90b888c0de30b6ba/lib/pro/commands.rb#L149-L179 | train |
trishume/pro | lib/pro/indexer.rb | Pro.Indexer.read_cache | def read_cache
return nil unless File.readable_real?(CACHE_PATH)
index = YAML::load_file(CACHE_PATH)
return nil unless index.created_version == Pro::VERSION
return nil unless index.base_dirs == @base_dirs
index
end | ruby | def read_cache
return nil unless File.readable_real?(CACHE_PATH)
index = YAML::load_file(CACHE_PATH)
return nil unless index.created_version == Pro::VERSION
return nil unless index.base_dirs == @base_dirs
index
end | [
"def",
"read_cache",
"return",
"nil",
"unless",
"File",
".",
"readable_real?",
"(",
"CACHE_PATH",
")",
"index",
"=",
"YAML",
"::",
"load_file",
"(",
"CACHE_PATH",
")",
"return",
"nil",
"unless",
"index",
".",
"created_version",
"==",
"Pro",
"::",
"VERSION",
... | unserializes the cache file and returns
the index object | [
"unserializes",
"the",
"cache",
"file",
"and",
"returns",
"the",
"index",
"object"
] | 646098c7514eb5346dd2942f90b888c0de30b6ba | https://github.com/trishume/pro/blob/646098c7514eb5346dd2942f90b888c0de30b6ba/lib/pro/indexer.rb#L28-L34 | train |
trishume/pro | lib/pro/indexer.rb | Pro.Indexer.run_index_process | def run_index_process
readme, writeme = IO.pipe
p1 = fork {
# Stop cd function from blocking on fork
STDOUT.reopen(writeme)
readme.close
index_process unless File.exists?(INDEXER_LOCK_PATH)
}
Process.detach(p1)
end | ruby | def run_index_process
readme, writeme = IO.pipe
p1 = fork {
# Stop cd function from blocking on fork
STDOUT.reopen(writeme)
readme.close
index_process unless File.exists?(INDEXER_LOCK_PATH)
}
Process.detach(p1)
end | [
"def",
"run_index_process",
"readme",
",",
"writeme",
"=",
"IO",
".",
"pipe",
"p1",
"=",
"fork",
"{",
"STDOUT",
".",
"reopen",
"(",
"writeme",
")",
"readme",
".",
"close",
"index_process",
"unless",
"File",
".",
"exists?",
"(",
"INDEXER_LOCK_PATH",
")",
"}... | spins off a background process to update the cache file | [
"spins",
"off",
"a",
"background",
"process",
"to",
"update",
"the",
"cache",
"file"
] | 646098c7514eb5346dd2942f90b888c0de30b6ba | https://github.com/trishume/pro/blob/646098c7514eb5346dd2942f90b888c0de30b6ba/lib/pro/indexer.rb#L37-L47 | train |
trishume/pro | lib/pro/indexer.rb | Pro.Indexer.cache_index | def cache_index(index)
# TODO: atomic rename. Right now we just hope.
File.open(CACHE_PATH, 'w' ) do |out|
YAML::dump( index, out )
end
end | ruby | def cache_index(index)
# TODO: atomic rename. Right now we just hope.
File.open(CACHE_PATH, 'w' ) do |out|
YAML::dump( index, out )
end
end | [
"def",
"cache_index",
"(",
"index",
")",
"File",
".",
"open",
"(",
"CACHE_PATH",
",",
"'w'",
")",
"do",
"|",
"out",
"|",
"YAML",
"::",
"dump",
"(",
"index",
",",
"out",
")",
"end",
"end"
] | serialize the index to a cache file | [
"serialize",
"the",
"index",
"to",
"a",
"cache",
"file"
] | 646098c7514eb5346dd2942f90b888c0de30b6ba | https://github.com/trishume/pro/blob/646098c7514eb5346dd2942f90b888c0de30b6ba/lib/pro/indexer.rb#L70-L75 | train |
trishume/pro | lib/pro/indexer.rb | Pro.Indexer.index_repos_slow | def index_repos_slow(base)
STDERR.puts "WARNING: pro is indexing slowly, please install the 'find' command."
repos = []
Find.find(base) do |path|
target = path
# additionally, index repos symlinked directly from a base root
if FileTest.symlink?(path)
next if File.dirn... | ruby | def index_repos_slow(base)
STDERR.puts "WARNING: pro is indexing slowly, please install the 'find' command."
repos = []
Find.find(base) do |path|
target = path
# additionally, index repos symlinked directly from a base root
if FileTest.symlink?(path)
next if File.dirn... | [
"def",
"index_repos_slow",
"(",
"base",
")",
"STDERR",
".",
"puts",
"\"WARNING: pro is indexing slowly, please install the 'find' command.\"",
"repos",
"=",
"[",
"]",
"Find",
".",
"find",
"(",
"base",
")",
"do",
"|",
"path",
"|",
"target",
"=",
"path",
"if",
"Fi... | recursive walk in ruby | [
"recursive",
"walk",
"in",
"ruby"
] | 646098c7514eb5346dd2942f90b888c0de30b6ba | https://github.com/trishume/pro/blob/646098c7514eb5346dd2942f90b888c0de30b6ba/lib/pro/indexer.rb#L129-L147 | train |
trishume/pro | lib/pro/indexer.rb | Pro.Indexer.find_base_dirs | def find_base_dirs()
bases = []
# check environment first
base = ENV['PRO_BASE']
bases << base if base
# next check proBase file
path = ENV['HOME'] + "/.proBase"
if File.exists?(path)
# read lines of the pro base file
bases += IO.read(path).split("\n").map {|p| ... | ruby | def find_base_dirs()
bases = []
# check environment first
base = ENV['PRO_BASE']
bases << base if base
# next check proBase file
path = ENV['HOME'] + "/.proBase"
if File.exists?(path)
# read lines of the pro base file
bases += IO.read(path).split("\n").map {|p| ... | [
"def",
"find_base_dirs",
"(",
")",
"bases",
"=",
"[",
"]",
"base",
"=",
"ENV",
"[",
"'PRO_BASE'",
"]",
"bases",
"<<",
"base",
"if",
"base",
"path",
"=",
"ENV",
"[",
"'HOME'",
"]",
"+",
"\"/.proBase\"",
"if",
"File",
".",
"exists?",
"(",
"path",
")",
... | Finds the base directory where repos are kept
Checks the environment variable PRO_BASE and the
file .proBase | [
"Finds",
"the",
"base",
"directory",
"where",
"repos",
"are",
"kept",
"Checks",
"the",
"environment",
"variable",
"PRO_BASE",
"and",
"the",
"file",
".",
"proBase"
] | 646098c7514eb5346dd2942f90b888c0de30b6ba | https://github.com/trishume/pro/blob/646098c7514eb5346dd2942f90b888c0de30b6ba/lib/pro/indexer.rb#L152-L169 | train |
jethrocarr/pupistry | lib/pupistry/gpg.rb | Pupistry.GPG.artifact_sign | def artifact_sign
@signature = 'unsigned'
# Clean up the existing signature file
signature_cleanup
Dir.chdir("#{$config['general']['app_cache']}/artifacts/") do
# Generate the signature file and pick up the signature data
unless system "gpg --use-agent --detach-sign artifact.#{... | ruby | def artifact_sign
@signature = 'unsigned'
# Clean up the existing signature file
signature_cleanup
Dir.chdir("#{$config['general']['app_cache']}/artifacts/") do
# Generate the signature file and pick up the signature data
unless system "gpg --use-agent --detach-sign artifact.#{... | [
"def",
"artifact_sign",
"@signature",
"=",
"'unsigned'",
"signature_cleanup",
"Dir",
".",
"chdir",
"(",
"\"#{$config['general']['app_cache']}/artifacts/\"",
")",
"do",
"unless",
"system",
"\"gpg --use-agent --detach-sign artifact.#{@checksum}.tar.gz\"",
"$logger",
".",
"error",
... | Sign the artifact and return the signature. Does not validation of the signature.
false Failure
base64 Encoded signature | [
"Sign",
"the",
"artifact",
"and",
"return",
"the",
"signature",
".",
"Does",
"not",
"validation",
"of",
"the",
"signature",
"."
] | a80e7a3d01f68ef4544e047719bfe14c5f75235d | https://github.com/jethrocarr/pupistry/blob/a80e7a3d01f68ef4544e047719bfe14c5f75235d/lib/pupistry/gpg.rb#L37-L74 | train |
jethrocarr/pupistry | lib/pupistry/gpg.rb | Pupistry.GPG.signature_extract | def signature_extract
manifest = YAML.load(File.open($config['general']['app_cache'] + "/artifacts/manifest.#{@checksum}.yaml"), safe: true, raise_on_unknown_tag: true)
if manifest['gpgsig']
# We have the base64 version
@signature = manifest['gpgsig']
# Decode the base64 and write ... | ruby | def signature_extract
manifest = YAML.load(File.open($config['general']['app_cache'] + "/artifacts/manifest.#{@checksum}.yaml"), safe: true, raise_on_unknown_tag: true)
if manifest['gpgsig']
# We have the base64 version
@signature = manifest['gpgsig']
# Decode the base64 and write ... | [
"def",
"signature_extract",
"manifest",
"=",
"YAML",
".",
"load",
"(",
"File",
".",
"open",
"(",
"$config",
"[",
"'general'",
"]",
"[",
"'app_cache'",
"]",
"+",
"\"/artifacts/manifest.#{@checksum}.yaml\"",
")",
",",
"safe",
":",
"true",
",",
"raise_on_unknown_ta... | Extract the signature from the manifest file and write it to file in native binary format.
false Unable to extract
unsigned Manifest shows that the artifact is not signed
base64 Encoded signature | [
"Extract",
"the",
"signature",
"from",
"the",
"manifest",
"file",
"and",
"write",
"it",
"to",
"file",
"in",
"native",
"binary",
"format",
"."
] | a80e7a3d01f68ef4544e047719bfe14c5f75235d | https://github.com/jethrocarr/pupistry/blob/a80e7a3d01f68ef4544e047719bfe14c5f75235d/lib/pupistry/gpg.rb#L136-L154 | train |
jethrocarr/pupistry | lib/pupistry/gpg.rb | Pupistry.GPG.signature_save | def signature_save
manifest = YAML.load(File.open($config['general']['app_cache'] + "/artifacts/manifest.#{@checksum}.yaml"), safe: true, raise_on_unknown_tag: true)
manifest['gpgsig'] = @signature
File.open("#{$config['general']['app_cache']}/artifacts/manifest.#{@checksum}.yaml", 'w') d... | ruby | def signature_save
manifest = YAML.load(File.open($config['general']['app_cache'] + "/artifacts/manifest.#{@checksum}.yaml"), safe: true, raise_on_unknown_tag: true)
manifest['gpgsig'] = @signature
File.open("#{$config['general']['app_cache']}/artifacts/manifest.#{@checksum}.yaml", 'w') d... | [
"def",
"signature_save",
"manifest",
"=",
"YAML",
".",
"load",
"(",
"File",
".",
"open",
"(",
"$config",
"[",
"'general'",
"]",
"[",
"'app_cache'",
"]",
"+",
"\"/artifacts/manifest.#{@checksum}.yaml\"",
")",
",",
"safe",
":",
"true",
",",
"raise_on_unknown_tag",... | Save the signature into the manifest file | [
"Save",
"the",
"signature",
"into",
"the",
"manifest",
"file"
] | a80e7a3d01f68ef4544e047719bfe14c5f75235d | https://github.com/jethrocarr/pupistry/blob/a80e7a3d01f68ef4544e047719bfe14c5f75235d/lib/pupistry/gpg.rb#L158-L171 | train |
jethrocarr/pupistry | lib/pupistry/gpg.rb | Pupistry.GPG.pubkey_upload | def pubkey_upload
unless File.exist?("#{$config['general']['app_cache']}/artifacts/#{$config['general']['gpg_signing_key']}.publickey")
# GPG key does not exist locally, we therefore assume it's not in the S3
# bucket either, so we should export out and upload. Technically this may
# resu... | ruby | def pubkey_upload
unless File.exist?("#{$config['general']['app_cache']}/artifacts/#{$config['general']['gpg_signing_key']}.publickey")
# GPG key does not exist locally, we therefore assume it's not in the S3
# bucket either, so we should export out and upload. Technically this may
# resu... | [
"def",
"pubkey_upload",
"unless",
"File",
".",
"exist?",
"(",
"\"#{$config['general']['app_cache']}/artifacts/#{$config['general']['gpg_signing_key']}.publickey\"",
")",
"$logger",
".",
"info",
"\"Exporting GPG key #{$config['general']['gpg_signing_key']} and uploading to S3 bucket...\"",
... | Extract & upload the public key to the s3 bucket for other users | [
"Extract",
"&",
"upload",
"the",
"public",
"key",
"to",
"the",
"s3",
"bucket",
"for",
"other",
"users"
] | a80e7a3d01f68ef4544e047719bfe14c5f75235d | https://github.com/jethrocarr/pupistry/blob/a80e7a3d01f68ef4544e047719bfe14c5f75235d/lib/pupistry/gpg.rb#L188-L219 | train |
jethrocarr/pupistry | lib/pupistry/gpg.rb | Pupistry.GPG.pubkey_install | def pubkey_install
$logger.warn "Installing GPG key #{$config['general']['gpg_signing_key']}..."
s3 = Pupistry::StorageAWS.new 'agent'
unless s3.download "#{$config['general']['gpg_signing_key']}.publickey", "#{$config['general']['app_cache']}/artifacts/#{$config['general']['gpg_signing_key']}.publi... | ruby | def pubkey_install
$logger.warn "Installing GPG key #{$config['general']['gpg_signing_key']}..."
s3 = Pupistry::StorageAWS.new 'agent'
unless s3.download "#{$config['general']['gpg_signing_key']}.publickey", "#{$config['general']['app_cache']}/artifacts/#{$config['general']['gpg_signing_key']}.publi... | [
"def",
"pubkey_install",
"$logger",
".",
"warn",
"\"Installing GPG key #{$config['general']['gpg_signing_key']}...\"",
"s3",
"=",
"Pupistry",
"::",
"StorageAWS",
".",
"new",
"'agent'",
"unless",
"s3",
".",
"download",
"\"#{$config['general']['gpg_signing_key']}.publickey\"",
",... | Install the public key. This is a potential avenue for exploit, if a
machine is being built for the first time, it has no existing trust of
the GPG key, other than transit encryption to the S3 bucket. To protect
against attacks at the bootstrap time, you should pre-load your machine
images with the public GPG key.
... | [
"Install",
"the",
"public",
"key",
".",
"This",
"is",
"a",
"potential",
"avenue",
"for",
"exploit",
"if",
"a",
"machine",
"is",
"being",
"built",
"for",
"the",
"first",
"time",
"it",
"has",
"no",
"existing",
"trust",
"of",
"the",
"GPG",
"key",
"other",
... | a80e7a3d01f68ef4544e047719bfe14c5f75235d | https://github.com/jethrocarr/pupistry/blob/a80e7a3d01f68ef4544e047719bfe14c5f75235d/lib/pupistry/gpg.rb#L230-L248 | train |
kaelaela/danger-auto_label | lib/auto_label/plugin.rb | Danger.DangerAutoLabel.wip= | def wip=(pr)
label_names = []
labels.each do |label|
label_names << label.name
end
puts("exist labels:" + label_names.join(", "))
unless wip?
begin
add_label("WIP")
rescue Octokit::UnprocessableEntity => e
puts "WIP label is already exists."
... | ruby | def wip=(pr)
label_names = []
labels.each do |label|
label_names << label.name
end
puts("exist labels:" + label_names.join(", "))
unless wip?
begin
add_label("WIP")
rescue Octokit::UnprocessableEntity => e
puts "WIP label is already exists."
... | [
"def",
"wip",
"=",
"(",
"pr",
")",
"label_names",
"=",
"[",
"]",
"labels",
".",
"each",
"do",
"|",
"label",
"|",
"label_names",
"<<",
"label",
".",
"name",
"end",
"puts",
"(",
"\"exist labels:\"",
"+",
"label_names",
".",
"join",
"(",
"\", \"",
")",
... | Set WIP label to PR.
@param [Number] pr
A number of issue or pull request for set label.
@return [void] | [
"Set",
"WIP",
"label",
"to",
"PR",
"."
] | f07eb95ec9933e9fb16040cb5d618a4d7d3e5fc4 | https://github.com/kaelaela/danger-auto_label/blob/f07eb95ec9933e9fb16040cb5d618a4d7d3e5fc4/lib/auto_label/plugin.rb#L21-L36 | train |
kaelaela/danger-auto_label | lib/auto_label/plugin.rb | Danger.DangerAutoLabel.set | def set(pr, name, color)
message = ""
if label?(name)
message = "Set #{name} label. (Color: #{color})"
else
message = "Add #{name} new label. (Color: #{color})"
add_label(name, color)
end
github.api.add_labels_to_an_issue(repo, pr, [name])
puts message
end | ruby | def set(pr, name, color)
message = ""
if label?(name)
message = "Set #{name} label. (Color: #{color})"
else
message = "Add #{name} new label. (Color: #{color})"
add_label(name, color)
end
github.api.add_labels_to_an_issue(repo, pr, [name])
puts message
end | [
"def",
"set",
"(",
"pr",
",",
"name",
",",
"color",
")",
"message",
"=",
"\"\"",
"if",
"label?",
"(",
"name",
")",
"message",
"=",
"\"Set #{name} label. (Color: #{color})\"",
"else",
"message",
"=",
"\"Add #{name} new label. (Color: #{color})\"",
"add_label",
"(",
... | Set any labels to PR by this.
@param [Number] pr
A number of issue or pull request for set label.
@param [String] name
A new label name.
@param [String] color
A color, in hex, without the leading #. Default is "fef2c0"
@return [void] | [
"Set",
"any",
"labels",
"to",
"PR",
"by",
"this",
"."
] | f07eb95ec9933e9fb16040cb5d618a4d7d3e5fc4 | https://github.com/kaelaela/danger-auto_label/blob/f07eb95ec9933e9fb16040cb5d618a4d7d3e5fc4/lib/auto_label/plugin.rb#L46-L56 | train |
kaelaela/danger-auto_label | lib/auto_label/plugin.rb | Danger.DangerAutoLabel.delete | def delete(name)
begin
github.api.delete_label!(repo, name)
rescue Octokit::Error => e
puts "Error message: \"#{name}\" label is not existing."
puts e
end
end | ruby | def delete(name)
begin
github.api.delete_label!(repo, name)
rescue Octokit::Error => e
puts "Error message: \"#{name}\" label is not existing."
puts e
end
end | [
"def",
"delete",
"(",
"name",
")",
"begin",
"github",
".",
"api",
".",
"delete_label!",
"(",
"repo",
",",
"name",
")",
"rescue",
"Octokit",
"::",
"Error",
"=>",
"e",
"puts",
"\"Error message: \\\"#{name}\\\" label is not existing.\"",
"puts",
"e",
"end",
"end"
] | Delete label from repository.
@param [String] name
Delete label name.
@return [void] | [
"Delete",
"label",
"from",
"repository",
"."
] | f07eb95ec9933e9fb16040cb5d618a4d7d3e5fc4 | https://github.com/kaelaela/danger-auto_label/blob/f07eb95ec9933e9fb16040cb5d618a4d7d3e5fc4/lib/auto_label/plugin.rb#L62-L69 | train |
kaelaela/danger-auto_label | lib/auto_label/plugin.rb | Danger.DangerAutoLabel.remove | def remove(name)
begin
github.api.remove_label(repo, number, name)
rescue Octokit::Error => e
puts "Error message: \"#{name}\" label is not existing."
puts e
end
end | ruby | def remove(name)
begin
github.api.remove_label(repo, number, name)
rescue Octokit::Error => e
puts "Error message: \"#{name}\" label is not existing."
puts e
end
end | [
"def",
"remove",
"(",
"name",
")",
"begin",
"github",
".",
"api",
".",
"remove_label",
"(",
"repo",
",",
"number",
",",
"name",
")",
"rescue",
"Octokit",
"::",
"Error",
"=>",
"e",
"puts",
"\"Error message: \\\"#{name}\\\" label is not existing.\"",
"puts",
"e",
... | Remove label from PR.
@param [String] name
Remove label name.
@return [void] | [
"Remove",
"label",
"from",
"PR",
"."
] | f07eb95ec9933e9fb16040cb5d618a4d7d3e5fc4 | https://github.com/kaelaela/danger-auto_label/blob/f07eb95ec9933e9fb16040cb5d618a4d7d3e5fc4/lib/auto_label/plugin.rb#L75-L82 | train |
mame/coverage-helpers | lib/coverage/helpers.rb | Coverage.Helpers.diff | def diff(cov1, cov2)
ncov = {}
old_format = true
cov1.each do |path1, runs1|
if cov2[path1]
runs2 = cov2[path1]
if runs1.is_a?(Array) && runs2.is_a?(Array) && old_format
# diff two old-format (ruby 2.4 or before) coverage results
ncov[path1] = diff... | ruby | def diff(cov1, cov2)
ncov = {}
old_format = true
cov1.each do |path1, runs1|
if cov2[path1]
runs2 = cov2[path1]
if runs1.is_a?(Array) && runs2.is_a?(Array) && old_format
# diff two old-format (ruby 2.4 or before) coverage results
ncov[path1] = diff... | [
"def",
"diff",
"(",
"cov1",
",",
"cov2",
")",
"ncov",
"=",
"{",
"}",
"old_format",
"=",
"true",
"cov1",
".",
"each",
"do",
"|",
"path1",
",",
"runs1",
"|",
"if",
"cov2",
"[",
"path1",
"]",
"runs2",
"=",
"cov2",
"[",
"path1",
"]",
"if",
"runs1",
... | Extract the coverage results that is covered by `cov1` but not covered by `cov2`. | [
"Extract",
"the",
"coverage",
"results",
"that",
"is",
"covered",
"by",
"cov1",
"but",
"not",
"covered",
"by",
"cov2",
"."
] | 4d2a33d3dec8c8bbf51bb21a3cdaf57d2481472e | https://github.com/mame/coverage-helpers/blob/4d2a33d3dec8c8bbf51bb21a3cdaf57d2481472e/lib/coverage/helpers.rb#L114-L174 | train |
mame/coverage-helpers | lib/coverage/helpers.rb | Coverage.Helpers.sanitize | def sanitize(cov)
ncov = {}
cov.each do |path, runs|
if runs.is_a?(Array)
ncov[path] = runs
next
end
ncov[path] = {}
ncov[path][:lines] = runs[:lines] if runs[:lines]
ncov[path][:branches] = runs[:branches] if runs[:branches]
if runs[:met... | ruby | def sanitize(cov)
ncov = {}
cov.each do |path, runs|
if runs.is_a?(Array)
ncov[path] = runs
next
end
ncov[path] = {}
ncov[path][:lines] = runs[:lines] if runs[:lines]
ncov[path][:branches] = runs[:branches] if runs[:branches]
if runs[:met... | [
"def",
"sanitize",
"(",
"cov",
")",
"ncov",
"=",
"{",
"}",
"cov",
".",
"each",
"do",
"|",
"path",
",",
"runs",
"|",
"if",
"runs",
".",
"is_a?",
"(",
"Array",
")",
"ncov",
"[",
"path",
"]",
"=",
"runs",
"next",
"end",
"ncov",
"[",
"path",
"]",
... | Make the covearge result able to marshal. | [
"Make",
"the",
"covearge",
"result",
"able",
"to",
"marshal",
"."
] | 4d2a33d3dec8c8bbf51bb21a3cdaf57d2481472e | https://github.com/mame/coverage-helpers/blob/4d2a33d3dec8c8bbf51bb21a3cdaf57d2481472e/lib/coverage/helpers.rb#L177-L204 | train |
mame/coverage-helpers | lib/coverage/helpers.rb | Coverage.Helpers.save | def save(path, cov)
File.binwrite(path, Marshal.dump(sanitize(cov)))
end | ruby | def save(path, cov)
File.binwrite(path, Marshal.dump(sanitize(cov)))
end | [
"def",
"save",
"(",
"path",
",",
"cov",
")",
"File",
".",
"binwrite",
"(",
"path",
",",
"Marshal",
".",
"dump",
"(",
"sanitize",
"(",
"cov",
")",
")",
")",
"end"
] | Save the coverage result to a file. | [
"Save",
"the",
"coverage",
"result",
"to",
"a",
"file",
"."
] | 4d2a33d3dec8c8bbf51bb21a3cdaf57d2481472e | https://github.com/mame/coverage-helpers/blob/4d2a33d3dec8c8bbf51bb21a3cdaf57d2481472e/lib/coverage/helpers.rb#L207-L209 | train |
mame/coverage-helpers | lib/coverage/helpers.rb | Coverage.Helpers.to_lcov_info | def to_lcov_info(cov, out: "", test_name: nil)
out << "TN:#{ test_name }\n"
cov.each do |path, runs|
out << "SF:#{ path }\n"
# function coverage
if runs.is_a?(Hash) && runs[:methods]
total = covered = 0
runs[:methods].each do |(klass, name, lineno), run|
... | ruby | def to_lcov_info(cov, out: "", test_name: nil)
out << "TN:#{ test_name }\n"
cov.each do |path, runs|
out << "SF:#{ path }\n"
# function coverage
if runs.is_a?(Hash) && runs[:methods]
total = covered = 0
runs[:methods].each do |(klass, name, lineno), run|
... | [
"def",
"to_lcov_info",
"(",
"cov",
",",
"out",
":",
"\"\"",
",",
"test_name",
":",
"nil",
")",
"out",
"<<",
"\"TN:#{ test_name }\\n\"",
"cov",
".",
"each",
"do",
"|",
"path",
",",
"runs",
"|",
"out",
"<<",
"\"SF:#{ path }\\n\"",
"if",
"runs",
".",
"is_a?... | Translate the result into LCOV info format. | [
"Translate",
"the",
"result",
"into",
"LCOV",
"info",
"format",
"."
] | 4d2a33d3dec8c8bbf51bb21a3cdaf57d2481472e | https://github.com/mame/coverage-helpers/blob/4d2a33d3dec8c8bbf51bb21a3cdaf57d2481472e/lib/coverage/helpers.rb#L217-L273 | train |
kymmt90/hatenablog | lib/hatenablog/entry.rb | Hatenablog.AfterHook.after_hook | def after_hook(hook, *methods)
methods.each do |method|
origin_method = "#{method}_origin".to_sym
if instance_methods.include? origin_method
raise NameError, "#{origin_method} isn't a unique name"
end
alias_method origin_method, method
define_method(method) do |... | ruby | def after_hook(hook, *methods)
methods.each do |method|
origin_method = "#{method}_origin".to_sym
if instance_methods.include? origin_method
raise NameError, "#{origin_method} isn't a unique name"
end
alias_method origin_method, method
define_method(method) do |... | [
"def",
"after_hook",
"(",
"hook",
",",
"*",
"methods",
")",
"methods",
".",
"each",
"do",
"|",
"method",
"|",
"origin_method",
"=",
"\"#{method}_origin\"",
".",
"to_sym",
"if",
"instance_methods",
".",
"include?",
"origin_method",
"raise",
"NameError",
",",
"\... | Register a hooking method for given methods.
The hook method is executed after calling given methods.
@param [Symbol] hooking method name
@param [Array] hooked methods name array | [
"Register",
"a",
"hooking",
"method",
"for",
"given",
"methods",
".",
"The",
"hook",
"method",
"is",
"executed",
"after",
"calling",
"given",
"methods",
"."
] | 61b1015073cba9a11dfb4fd35d34922757abd70b | https://github.com/kymmt90/hatenablog/blob/61b1015073cba9a11dfb4fd35d34922757abd70b/lib/hatenablog/entry.rb#L10-L24 | train |
kymmt90/hatenablog | lib/hatenablog/client.rb | Hatenablog.Client.next_feed | def next_feed(feed = nil)
return Feed.load_xml(get_collection(collection_uri).body) if feed.nil?
return nil unless feed.has_next?
Feed.load_xml(get_collection(feed.next_uri).body)
end | ruby | def next_feed(feed = nil)
return Feed.load_xml(get_collection(collection_uri).body) if feed.nil?
return nil unless feed.has_next?
Feed.load_xml(get_collection(feed.next_uri).body)
end | [
"def",
"next_feed",
"(",
"feed",
"=",
"nil",
")",
"return",
"Feed",
".",
"load_xml",
"(",
"get_collection",
"(",
"collection_uri",
")",
".",
"body",
")",
"if",
"feed",
".",
"nil?",
"return",
"nil",
"unless",
"feed",
".",
"has_next?",
"Feed",
".",
"load_x... | Get the next feed of the given feed.
Return the first feed if no argument is passed.
@param [Hatenablog::Feed] feed blog feed
@return [Hatenablog::Feed] next blog feed | [
"Get",
"the",
"next",
"feed",
"of",
"the",
"given",
"feed",
".",
"Return",
"the",
"first",
"feed",
"if",
"no",
"argument",
"is",
"passed",
"."
] | 61b1015073cba9a11dfb4fd35d34922757abd70b | https://github.com/kymmt90/hatenablog/blob/61b1015073cba9a11dfb4fd35d34922757abd70b/lib/hatenablog/client.rb#L69-L73 | train |
kymmt90/hatenablog | lib/hatenablog/client.rb | Hatenablog.Client.get_entry | def get_entry(entry_id)
response = get(member_uri(entry_id))
Entry.load_xml(response.body)
end | ruby | def get_entry(entry_id)
response = get(member_uri(entry_id))
Entry.load_xml(response.body)
end | [
"def",
"get_entry",
"(",
"entry_id",
")",
"response",
"=",
"get",
"(",
"member_uri",
"(",
"entry_id",
")",
")",
"Entry",
".",
"load_xml",
"(",
"response",
".",
"body",
")",
"end"
] | Get a blog entry specified by its ID.
@param [String] entry_id entry ID
@return [Hatenablog::BlogEntry] entry | [
"Get",
"a",
"blog",
"entry",
"specified",
"by",
"its",
"ID",
"."
] | 61b1015073cba9a11dfb4fd35d34922757abd70b | https://github.com/kymmt90/hatenablog/blob/61b1015073cba9a11dfb4fd35d34922757abd70b/lib/hatenablog/client.rb#L85-L88 | train |
kymmt90/hatenablog | lib/hatenablog/client.rb | Hatenablog.Client.post_entry | def post_entry(title = '', content = '', categories = [], draft = 'no')
entry_xml = entry_xml(title, content, categories, draft)
response = post(entry_xml)
Entry.load_xml(response.body)
end | ruby | def post_entry(title = '', content = '', categories = [], draft = 'no')
entry_xml = entry_xml(title, content, categories, draft)
response = post(entry_xml)
Entry.load_xml(response.body)
end | [
"def",
"post_entry",
"(",
"title",
"=",
"''",
",",
"content",
"=",
"''",
",",
"categories",
"=",
"[",
"]",
",",
"draft",
"=",
"'no'",
")",
"entry_xml",
"=",
"entry_xml",
"(",
"title",
",",
"content",
",",
"categories",
",",
"draft",
")",
"response",
... | Post a blog entry.
@param [String] title entry title
@param [String] content entry content
@param [Array] categories entry categories
@param [String] draft this entry is draft if 'yes', otherwise it is not draft
@return [Hatenablog::BlogEntry] posted entry | [
"Post",
"a",
"blog",
"entry",
"."
] | 61b1015073cba9a11dfb4fd35d34922757abd70b | https://github.com/kymmt90/hatenablog/blob/61b1015073cba9a11dfb4fd35d34922757abd70b/lib/hatenablog/client.rb#L96-L100 | train |
kymmt90/hatenablog | lib/hatenablog/client.rb | Hatenablog.Client.update_entry | def update_entry(entry_id, title = '', content = '', categories = [], draft = 'no', updated = '')
entry_xml = entry_xml(title, content, categories, draft, updated)
response = put(entry_xml, member_uri(entry_id))
Entry.load_xml(response.body)
end | ruby | def update_entry(entry_id, title = '', content = '', categories = [], draft = 'no', updated = '')
entry_xml = entry_xml(title, content, categories, draft, updated)
response = put(entry_xml, member_uri(entry_id))
Entry.load_xml(response.body)
end | [
"def",
"update_entry",
"(",
"entry_id",
",",
"title",
"=",
"''",
",",
"content",
"=",
"''",
",",
"categories",
"=",
"[",
"]",
",",
"draft",
"=",
"'no'",
",",
"updated",
"=",
"''",
")",
"entry_xml",
"=",
"entry_xml",
"(",
"title",
",",
"content",
",",... | Update a blog entry specified by its ID.
@param [String] entry_id updated entry ID
@param [String] title entry title
@param [String] content entry content
@param [Array] categories entry categories
@param [String] draft this entry is draft if 'yes', otherwise it is not draft
@param [String] updated entry updated ... | [
"Update",
"a",
"blog",
"entry",
"specified",
"by",
"its",
"ID",
"."
] | 61b1015073cba9a11dfb4fd35d34922757abd70b | https://github.com/kymmt90/hatenablog/blob/61b1015073cba9a11dfb4fd35d34922757abd70b/lib/hatenablog/client.rb#L110-L114 | train |
kymmt90/hatenablog | lib/hatenablog/client.rb | Hatenablog.Client.entry_xml | def entry_xml(title = '', content = '', categories = [], draft = 'no', updated = '', author_name = @user_id)
builder = Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|
xml.entry('xmlns' => 'http://www.w3.org/2005/Atom',
'xmlns:app' => 'http://www.w3.org/2007/app') do
... | ruby | def entry_xml(title = '', content = '', categories = [], draft = 'no', updated = '', author_name = @user_id)
builder = Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|
xml.entry('xmlns' => 'http://www.w3.org/2005/Atom',
'xmlns:app' => 'http://www.w3.org/2007/app') do
... | [
"def",
"entry_xml",
"(",
"title",
"=",
"''",
",",
"content",
"=",
"''",
",",
"categories",
"=",
"[",
"]",
",",
"draft",
"=",
"'no'",
",",
"updated",
"=",
"''",
",",
"author_name",
"=",
"@user_id",
")",
"builder",
"=",
"Nokogiri",
"::",
"XML",
"::",
... | Build a entry XML from arguments.
@param [String] title entry title
@param [String] content entry content
@param [Array] categories entry categories
@param [String] draft this entry is draft if 'yes', otherwise it is not draft
@param [String] updated entry updated datetime (ISO 8601)
@param [String] author_name e... | [
"Build",
"a",
"entry",
"XML",
"from",
"arguments",
"."
] | 61b1015073cba9a11dfb4fd35d34922757abd70b | https://github.com/kymmt90/hatenablog/blob/61b1015073cba9a11dfb4fd35d34922757abd70b/lib/hatenablog/client.rb#L155-L175 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.