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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.deleteDuplicateRecords | def deleteDuplicateRecords( fnames, fids = nil, options = nil, dbid = @dbid )
num_deleted = 0
if options and not options.is_a?( Hash )
raise "deleteDuplicateRecords: 'options' parameter must be a Hash"
else
options = {}
options[ "keeplastrecord" ] = true
opt... | ruby | def deleteDuplicateRecords( fnames, fids = nil, options = nil, dbid = @dbid )
num_deleted = 0
if options and not options.is_a?( Hash )
raise "deleteDuplicateRecords: 'options' parameter must be a Hash"
else
options = {}
options[ "keeplastrecord" ] = true
opt... | [
"def",
"deleteDuplicateRecords",
"(",
"fnames",
",",
"fids",
"=",
"nil",
",",
"options",
"=",
"nil",
",",
"dbid",
"=",
"@dbid",
")",
"num_deleted",
"=",
"0",
"if",
"options",
"and",
"not",
"options",
".",
"is_a?",
"(",
"Hash",
")",
"raise",
"\"deleteDupl... | Finds records with the same values in a specified
list of fields and deletes all but the first or last duplicate record.
The field list may be a list of field IDs or a list of field names.
The 'options' parameter can be used to keep the oldest record instead of the
newest record, and to control whether to ignore th... | [
"Finds",
"records",
"with",
"the",
"same",
"values",
"in",
"a",
"specified",
"list",
"of",
"fields",
"and",
"deletes",
"all",
"but",
"the",
"first",
"or",
"last",
"duplicate",
"record",
".",
"The",
"field",
"list",
"may",
"be",
"a",
"list",
"of",
"field"... | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4257-L4274 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.copyRecord | def copyRecord( rid, numCopies = 1, dbid = @dbid )
clearFieldValuePairList
getRecordInfo( dbid, rid ) { |field|
if field and field.elements[ "value" ] and field.elements[ "value" ].has_text?
if field.elements[ "fid" ].text.to_i > 5 #skip built-in fields
addFieldValu... | ruby | def copyRecord( rid, numCopies = 1, dbid = @dbid )
clearFieldValuePairList
getRecordInfo( dbid, rid ) { |field|
if field and field.elements[ "value" ] and field.elements[ "value" ].has_text?
if field.elements[ "fid" ].text.to_i > 5 #skip built-in fields
addFieldValu... | [
"def",
"copyRecord",
"(",
"rid",
",",
"numCopies",
"=",
"1",
",",
"dbid",
"=",
"@dbid",
")",
"clearFieldValuePairList",
"getRecordInfo",
"(",
"dbid",
",",
"rid",
")",
"{",
"|",
"field",
"|",
"if",
"field",
"and",
"field",
".",
"elements",
"[",
"\"value\"... | Make one or more copies of a record. | [
"Make",
"one",
"or",
"more",
"copies",
"of",
"a",
"record",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4277-L4298 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client._importFromExcel | def _importFromExcel(excelFilename,lastColumn = 'j',lastDataRow = 0,worksheetNumber = 1,fieldNameRow = 1,firstDataRow = 2,firstColumn = 'a')
importFromExcel( @dbid, excelFilename, lastColumn, lastDataRow, worksheetNumber, fieldNameRow, firstDataRow, firstColumn )
end | ruby | def _importFromExcel(excelFilename,lastColumn = 'j',lastDataRow = 0,worksheetNumber = 1,fieldNameRow = 1,firstDataRow = 2,firstColumn = 'a')
importFromExcel( @dbid, excelFilename, lastColumn, lastDataRow, worksheetNumber, fieldNameRow, firstDataRow, firstColumn )
end | [
"def",
"_importFromExcel",
"(",
"excelFilename",
",",
"lastColumn",
"=",
"'j'",
",",
"lastDataRow",
"=",
"0",
",",
"worksheetNumber",
"=",
"1",
",",
"fieldNameRow",
"=",
"1",
",",
"firstDataRow",
"=",
"2",
",",
"firstColumn",
"=",
"'a'",
")",
"importFromExce... | Import data directly from an Excel file into the active table. | [
"Import",
"data",
"directly",
"from",
"an",
"Excel",
"file",
"into",
"the",
"active",
"table",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4380-L4382 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.importCSVFile | def importCSVFile( filename, dbid = @dbid, targetFieldNames = nil, validateLines = true )
importSVFile( filename, ",", dbid, targetFieldNames, validateLines )
end | ruby | def importCSVFile( filename, dbid = @dbid, targetFieldNames = nil, validateLines = true )
importSVFile( filename, ",", dbid, targetFieldNames, validateLines )
end | [
"def",
"importCSVFile",
"(",
"filename",
",",
"dbid",
"=",
"@dbid",
",",
"targetFieldNames",
"=",
"nil",
",",
"validateLines",
"=",
"true",
")",
"importSVFile",
"(",
"filename",
",",
"\",\"",
",",
"dbid",
",",
"targetFieldNames",
",",
"validateLines",
")",
"... | Add records from lines in a CSV file.
If dbid is not specified, the active table will be used.
values in subsequent lines. The file must not contain commas inside field names or values. | [
"Add",
"records",
"from",
"lines",
"in",
"a",
"CSV",
"file",
".",
"If",
"dbid",
"is",
"not",
"specified",
"the",
"active",
"table",
"will",
"be",
"used",
".",
"values",
"in",
"subsequent",
"lines",
".",
"The",
"file",
"must",
"not",
"contain",
"commas",
... | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4387-L4389 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.importTSVFile | def importTSVFile( filename, dbid = @dbid, targetFieldNames = nil, validateLines = true )
importSVFile( filename, "\t", dbid, targetFieldNames, validateLines )
end | ruby | def importTSVFile( filename, dbid = @dbid, targetFieldNames = nil, validateLines = true )
importSVFile( filename, "\t", dbid, targetFieldNames, validateLines )
end | [
"def",
"importTSVFile",
"(",
"filename",
",",
"dbid",
"=",
"@dbid",
",",
"targetFieldNames",
"=",
"nil",
",",
"validateLines",
"=",
"true",
")",
"importSVFile",
"(",
"filename",
",",
"\"\\t\"",
",",
"dbid",
",",
"targetFieldNames",
",",
"validateLines",
")",
... | Import records from a text file in Tab-Separated-Values format. | [
"Import",
"records",
"from",
"a",
"text",
"file",
"in",
"Tab",
"-",
"Separated",
"-",
"Values",
"format",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4392-L4394 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.makeSVFile | def makeSVFile( filename, fieldSeparator = ",", dbid = @dbid, query = nil, qid = nil, qname = nil )
File.open( filename, "w" ) { |file|
if dbid
doQuery( dbid, query, qid, qname )
end
if @records and @fields
# ------------- write field names on first l... | ruby | def makeSVFile( filename, fieldSeparator = ",", dbid = @dbid, query = nil, qid = nil, qname = nil )
File.open( filename, "w" ) { |file|
if dbid
doQuery( dbid, query, qid, qname )
end
if @records and @fields
# ------------- write field names on first l... | [
"def",
"makeSVFile",
"(",
"filename",
",",
"fieldSeparator",
"=",
"\",\"",
",",
"dbid",
"=",
"@dbid",
",",
"query",
"=",
"nil",
",",
"qid",
"=",
"nil",
",",
"qname",
"=",
"nil",
")",
"File",
".",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"{",
"|"... | Make a CSV file using the results of a query.
Specify a different separator in the second paramater.
Fields containing the separator will be double-quoted.
e.g. makeSVFile( "contacts.txt", "\t", nil )
e.g. makeSVFile( "contacts.txt", ",", "dhnju5y7", nil, nil, "List Changes" ) | [
"Make",
"a",
"CSV",
"file",
"using",
"the",
"results",
"of",
"a",
"query",
".",
"Specify",
"a",
"different",
"separator",
"in",
"the",
"second",
"paramater",
".",
"Fields",
"containing",
"the",
"separator",
"will",
"be",
"double",
"-",
"quoted",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4489-L4544 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.makeCSVFileForReport | def makeCSVFileForReport(filename,dbid=@dbid,query=nil,qid=nil,qname=nil)
csv = getCSVForReport(dbid,query,qid,qname)
File.open(filename,"w"){|f|f.write(csv || "")}
end | ruby | def makeCSVFileForReport(filename,dbid=@dbid,query=nil,qid=nil,qname=nil)
csv = getCSVForReport(dbid,query,qid,qname)
File.open(filename,"w"){|f|f.write(csv || "")}
end | [
"def",
"makeCSVFileForReport",
"(",
"filename",
",",
"dbid",
"=",
"@dbid",
",",
"query",
"=",
"nil",
",",
"qid",
"=",
"nil",
",",
"qname",
"=",
"nil",
")",
"csv",
"=",
"getCSVForReport",
"(",
"dbid",
",",
"query",
",",
"qid",
",",
"qname",
")",
"File... | Create a CSV file using the records for a Report. | [
"Create",
"a",
"CSV",
"file",
"using",
"the",
"records",
"for",
"a",
"Report",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4547-L4550 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.getCSVForReport | def getCSVForReport(dbid,query=nil,qid=nil,qname=nil)
genResultsTable(dbid,query,nil,nil,nil,nil,"csv",qid,qname)
end | ruby | def getCSVForReport(dbid,query=nil,qid=nil,qname=nil)
genResultsTable(dbid,query,nil,nil,nil,nil,"csv",qid,qname)
end | [
"def",
"getCSVForReport",
"(",
"dbid",
",",
"query",
"=",
"nil",
",",
"qid",
"=",
"nil",
",",
"qname",
"=",
"nil",
")",
"genResultsTable",
"(",
"dbid",
",",
"query",
",",
"nil",
",",
"nil",
",",
"nil",
",",
"nil",
",",
"\"csv\"",
",",
"qid",
",",
... | Get the CSV data for a Report. | [
"Get",
"the",
"CSV",
"data",
"for",
"a",
"Report",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4553-L4555 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.doSQLUpdate | def doSQLUpdate(sqlString)
sql = sqlString.dup
dbname = ""
state = nil
fieldName = ""
fieldValue = ""
sqlQuery = "SELECT 3 FROM "
clearFieldValuePairList
sql.split(' ').each{ |token|
case token
when "UPDATE"
s... | ruby | def doSQLUpdate(sqlString)
sql = sqlString.dup
dbname = ""
state = nil
fieldName = ""
fieldValue = ""
sqlQuery = "SELECT 3 FROM "
clearFieldValuePairList
sql.split(' ').each{ |token|
case token
when "UPDATE"
s... | [
"def",
"doSQLUpdate",
"(",
"sqlString",
")",
"sql",
"=",
"sqlString",
".",
"dup",
"dbname",
"=",
"\"\"",
"state",
"=",
"nil",
"fieldName",
"=",
"\"\"",
"fieldValue",
"=",
"\"\"",
"sqlQuery",
"=",
"\"SELECT 3 FROM \"",
"clearFieldValuePairList",
"sql",
".",
"sp... | Translate a simple SQL UPDATE statement to a QuickBase editRecord call.
Note: This method is here primarily for Rails integration.
Note: This assumes, like SQL, that your column (i.e. field) names do not contain spaces.
Note: This assumes that Record ID# is the key field in your table. | [
"Translate",
"a",
"simple",
"SQL",
"UPDATE",
"statement",
"to",
"a",
"QuickBase",
"editRecord",
"call",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4828-L4892 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.doSQLInsert | def doSQLInsert(sqlString)
sql = sqlString.dup
dbname = ""
state = nil
fieldName = ""
fieldValue = ""
fieldNames = []
fieldValues = []
index = 0
clearFieldValuePairList
sql.gsub!("("," ")
sql.gsub!(")"," ")
sql.sp... | ruby | def doSQLInsert(sqlString)
sql = sqlString.dup
dbname = ""
state = nil
fieldName = ""
fieldValue = ""
fieldNames = []
fieldValues = []
index = 0
clearFieldValuePairList
sql.gsub!("("," ")
sql.gsub!(")"," ")
sql.sp... | [
"def",
"doSQLInsert",
"(",
"sqlString",
")",
"sql",
"=",
"sqlString",
".",
"dup",
"dbname",
"=",
"\"\"",
"state",
"=",
"nil",
"fieldName",
"=",
"\"\"",
"fieldValue",
"=",
"\"\"",
"fieldNames",
"=",
"[",
"]",
"fieldValues",
"=",
"[",
"]",
"index",
"=",
... | Translate a simple SQL INSERT statement to a QuickBase addRecord call.
Note: This method is here primarily for Rails integration.
Note: This assumes, like SQL, that your column (i.e. field) names do not contain spaces. | [
"Translate",
"a",
"simple",
"SQL",
"INSERT",
"statement",
"to",
"a",
"QuickBase",
"addRecord",
"call",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4898-L4971 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.eachField | def eachField( record = @record )
if record and block_given?
record.each{ |field|
if field.is_a?( REXML::Element) and field.name == "f" and field.attributes["id"]
@field = field
yield field
end
}
end
nil
end | ruby | def eachField( record = @record )
if record and block_given?
record.each{ |field|
if field.is_a?( REXML::Element) and field.name == "f" and field.attributes["id"]
@field = field
yield field
end
}
end
nil
end | [
"def",
"eachField",
"(",
"record",
"=",
"@record",
")",
"if",
"record",
"and",
"block_given?",
"record",
".",
"each",
"{",
"|",
"field",
"|",
"if",
"field",
".",
"is_a?",
"(",
"REXML",
"::",
"Element",
")",
"and",
"field",
".",
"name",
"==",
"\"f\"",
... | Iterate record XML and yield only 'f' elements. | [
"Iterate",
"record",
"XML",
"and",
"yield",
"only",
"f",
"elements",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L4987-L4997 | train |
garethlatwork/quickbase_client | lib/QuickBaseClient.rb | QuickBase.Client.alias_methods | def alias_methods
aliased_methods = []
public_methods.each{|old_method|
if old_method.match(/[A-Z]+/)
new_method = old_method.gsub(/[A-Z]+/){|uc| "_#{uc.downcase}"}
aliased_methods << new_method
instance_eval( "alias #{new_method} #{old_method}")
end
}
... | ruby | def alias_methods
aliased_methods = []
public_methods.each{|old_method|
if old_method.match(/[A-Z]+/)
new_method = old_method.gsub(/[A-Z]+/){|uc| "_#{uc.downcase}"}
aliased_methods << new_method
instance_eval( "alias #{new_method} #{old_method}")
end
}
... | [
"def",
"alias_methods",
"aliased_methods",
"=",
"[",
"]",
"public_methods",
".",
"each",
"{",
"|",
"old_method",
"|",
"if",
"old_method",
".",
"match",
"(",
"/",
"/",
")",
"new_method",
"=",
"old_method",
".",
"gsub",
"(",
"/",
"/",
")",
"{",
"|",
"uc"... | Add method aliases that follow the ruby method naming convention.
E.g. sendRequest will be aliased as send_request. | [
"Add",
"method",
"aliases",
"that",
"follow",
"the",
"ruby",
"method",
"naming",
"convention",
".",
"E",
".",
"g",
".",
"sendRequest",
"will",
"be",
"aliased",
"as",
"send_request",
"."
] | 13d754de1f22a466806c5a0da74b0ded26c23f05 | https://github.com/garethlatwork/quickbase_client/blob/13d754de1f22a466806c5a0da74b0ded26c23f05/lib/QuickBaseClient.rb#L5007-L5017 | train |
sethvargo/community-zero | lib/community_zero/objects/cookbook.rb | CommunityZero.Cookbook.to_hash | def to_hash
methods = instance_variables.map { |i| i.to_s.gsub('@', '') }
Hash[*methods.map { |m| [m, send(m.to_sym)] }.flatten]
end | ruby | def to_hash
methods = instance_variables.map { |i| i.to_s.gsub('@', '') }
Hash[*methods.map { |m| [m, send(m.to_sym)] }.flatten]
end | [
"def",
"to_hash",
"methods",
"=",
"instance_variables",
".",
"map",
"{",
"|",
"i",
"|",
"i",
".",
"to_s",
".",
"gsub",
"(",
"'@'",
",",
"''",
")",
"}",
"Hash",
"[",
"*",
"methods",
".",
"map",
"{",
"|",
"m",
"|",
"[",
"m",
",",
"send",
"(",
"... | Create a new cookbook from the given hash.
@param [Hash] hash
the hash from which to create the cookbook
Dump this cookbook to a hash.
@return [Hash]
the hash representation of this cookbook | [
"Create",
"a",
"new",
"cookbook",
"from",
"the",
"given",
"hash",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/objects/cookbook.rb#L36-L39 | train |
scrapper/perobs | lib/perobs/Array.rb | PEROBS.Array._referenced_object_ids | def _referenced_object_ids
@data.each.select do |v|
v && v.respond_to?(:is_poxreference?)
end.map { |o| o.id }
end | ruby | def _referenced_object_ids
@data.each.select do |v|
v && v.respond_to?(:is_poxreference?)
end.map { |o| o.id }
end | [
"def",
"_referenced_object_ids",
"@data",
".",
"each",
".",
"select",
"do",
"|",
"v",
"|",
"v",
"&&",
"v",
".",
"respond_to?",
"(",
":is_poxreference?",
")",
"end",
".",
"map",
"{",
"|",
"o",
"|",
"o",
".",
"id",
"}",
"end"
] | Return a list of all object IDs of all persistend objects that this Array
is referencing.
@return [Array of Integer] IDs of referenced objects | [
"Return",
"a",
"list",
"of",
"all",
"object",
"IDs",
"of",
"all",
"persistend",
"objects",
"that",
"this",
"Array",
"is",
"referencing",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Array.rb#L145-L149 | train |
pupeno/assert_difference | lib/assert_difference/expectation.rb | AssertDifference.Expectation.generate_expected_value | def generate_expected_value
if expected_difference.is_a? Range
(before_value + expected_difference.first)..(before_value + expected_difference.end)
else
before_value + expected_difference
end
end | ruby | def generate_expected_value
if expected_difference.is_a? Range
(before_value + expected_difference.first)..(before_value + expected_difference.end)
else
before_value + expected_difference
end
end | [
"def",
"generate_expected_value",
"if",
"expected_difference",
".",
"is_a?",
"Range",
"(",
"before_value",
"+",
"expected_difference",
".",
"first",
")",
"..",
"(",
"before_value",
"+",
"expected_difference",
".",
"end",
")",
"else",
"before_value",
"+",
"expected_d... | Generate the expected value.
@return [Integer, Range] Generate the expected value. | [
"Generate",
"the",
"expected",
"value",
"."
] | 56490e7157dd975caed8080abd910a559e3bd785 | https://github.com/pupeno/assert_difference/blob/56490e7157dd975caed8080abd910a559e3bd785/lib/assert_difference/expectation.rb#L77-L83 | train |
PublicHealthEngland/ndr_support | lib/ndr_support/obfuscator.rb | NdrSupport.Obfuscator.obfuscate | def obfuscate(name, seed = nil)
rnd = Random.new(seed || @seed)
vowels = %w(A E I O U)
consonants = ('A'..'Z').to_a - vowels
digits = ('0'..'9').to_a
dict = Hash[(vowels + consonants + digits).zip(vowels.shuffle(random: rnd) +
consonants... | ruby | def obfuscate(name, seed = nil)
rnd = Random.new(seed || @seed)
vowels = %w(A E I O U)
consonants = ('A'..'Z').to_a - vowels
digits = ('0'..'9').to_a
dict = Hash[(vowels + consonants + digits).zip(vowels.shuffle(random: rnd) +
consonants... | [
"def",
"obfuscate",
"(",
"name",
",",
"seed",
"=",
"nil",
")",
"rnd",
"=",
"Random",
".",
"new",
"(",
"seed",
"||",
"@seed",
")",
"vowels",
"=",
"%w(",
"A",
"E",
"I",
"O",
"U",
")",
"consonants",
"=",
"(",
"'A'",
"..",
"'Z'",
")",
".",
"to_a",
... | Obfuscate a name or address, either with the given seed, or default seed | [
"Obfuscate",
"a",
"name",
"or",
"address",
"either",
"with",
"the",
"given",
"seed",
"or",
"default",
"seed"
] | 6daf98ca972e79de1c8457eb720f058b03ead21c | https://github.com/PublicHealthEngland/ndr_support/blob/6daf98ca972e79de1c8457eb720f058b03ead21c/lib/ndr_support/obfuscator.rb#L13-L22 | train |
sethvargo/community-zero | lib/community_zero/server.rb | CommunityZero.Server.start_background | def start_background(wait = 5)
@server = WEBrick::HTTPServer.new(
:BindAddress => @options[:host],
:Port => @options[:port],
:AccessLog => [],
:Logger => WEBrick::Log.new(StringIO.new, 7)
)
@server.mount('/', Rack::Handler::WEBrick, app)
@thread = T... | ruby | def start_background(wait = 5)
@server = WEBrick::HTTPServer.new(
:BindAddress => @options[:host],
:Port => @options[:port],
:AccessLog => [],
:Logger => WEBrick::Log.new(StringIO.new, 7)
)
@server.mount('/', Rack::Handler::WEBrick, app)
@thread = T... | [
"def",
"start_background",
"(",
"wait",
"=",
"5",
")",
"@server",
"=",
"WEBrick",
"::",
"HTTPServer",
".",
"new",
"(",
":BindAddress",
"=>",
"@options",
"[",
":host",
"]",
",",
":Port",
"=>",
"@options",
"[",
":port",
"]",
",",
":AccessLog",
"=>",
"[",
... | Start a Community Zero server in a forked process. This method returns
the PID to the forked process.
@param [Fixnum] wait
the number of seconds to wait for the server to start
@return [Thread]
the thread the background process is running in | [
"Start",
"a",
"Community",
"Zero",
"server",
"in",
"a",
"forked",
"process",
".",
"This",
"method",
"returns",
"the",
"PID",
"to",
"the",
"forked",
"process",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/server.rb#L121-L133 | train |
sethvargo/community-zero | lib/community_zero/server.rb | CommunityZero.Server.running? | def running?
if @server.nil? || @server.status != :Running
return false
end
uri = URI.join(url, 'cookbooks')
headers = { 'Accept' => 'application/json' }
Timeout.timeout(0.1) { !open(uri, headers).nil? }
rescue SocketError, Errno::ECONNREFUSED, Timeout::Error
false
... | ruby | def running?
if @server.nil? || @server.status != :Running
return false
end
uri = URI.join(url, 'cookbooks')
headers = { 'Accept' => 'application/json' }
Timeout.timeout(0.1) { !open(uri, headers).nil? }
rescue SocketError, Errno::ECONNREFUSED, Timeout::Error
false
... | [
"def",
"running?",
"if",
"@server",
".",
"nil?",
"||",
"@server",
".",
"status",
"!=",
":Running",
"return",
"false",
"end",
"uri",
"=",
"URI",
".",
"join",
"(",
"url",
",",
"'cookbooks'",
")",
"headers",
"=",
"{",
"'Accept'",
"=>",
"'application/json'",
... | Boolean method to determine if the server is currently ready to accept
requests. This method will attempt to make an HTTP request against the
server. If this method returns true, you are safe to make a request.
@return [Boolean]
true if the server is accepting requests, false otherwise | [
"Boolean",
"method",
"to",
"determine",
"if",
"the",
"server",
"is",
"currently",
"ready",
"to",
"accept",
"requests",
".",
"This",
"method",
"will",
"attempt",
"to",
"make",
"an",
"HTTP",
"request",
"against",
"the",
"server",
".",
"If",
"this",
"method",
... | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/server.rb#L143-L154 | train |
sethvargo/community-zero | lib/community_zero/server.rb | CommunityZero.Server.stop | def stop(wait = 5)
Timeout.timeout(wait) do
@server.shutdown
@thread.join(wait) if @thread
end
rescue Timeout::Error
if @thread
$stderr.puts("Community Zero did not stop within #{wait} seconds! Killing...")
@thread.kill
end
ensure
@server = nil
... | ruby | def stop(wait = 5)
Timeout.timeout(wait) do
@server.shutdown
@thread.join(wait) if @thread
end
rescue Timeout::Error
if @thread
$stderr.puts("Community Zero did not stop within #{wait} seconds! Killing...")
@thread.kill
end
ensure
@server = nil
... | [
"def",
"stop",
"(",
"wait",
"=",
"5",
")",
"Timeout",
".",
"timeout",
"(",
"wait",
")",
"do",
"@server",
".",
"shutdown",
"@thread",
".",
"join",
"(",
"wait",
")",
"if",
"@thread",
"end",
"rescue",
"Timeout",
"::",
"Error",
"if",
"@thread",
"$stderr",
... | Gracefully stop the Community Zero server.
@param [Fixnum] wait
the number of seconds to wait before raising force-terminating the
server | [
"Gracefully",
"stop",
"the",
"Community",
"Zero",
"server",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/server.rb#L163-L176 | train |
sethvargo/community-zero | lib/community_zero/server.rb | CommunityZero.Server.app | def app
lambda do |env|
request = Request.new(env)
response = router.call(request)
response[-1] = Array(response[-1])
response
end
end | ruby | def app
lambda do |env|
request = Request.new(env)
response = router.call(request)
response[-1] = Array(response[-1])
response
end
end | [
"def",
"app",
"lambda",
"do",
"|",
"env",
"|",
"request",
"=",
"Request",
".",
"new",
"(",
"env",
")",
"response",
"=",
"router",
".",
"call",
"(",
"request",
")",
"response",
"[",
"-",
"1",
"]",
"=",
"Array",
"(",
"response",
"[",
"-",
"1",
"]",... | The actual application the server will respond to.
@return [RackApp] | [
"The",
"actual",
"application",
"the",
"server",
"will",
"respond",
"to",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/server.rb#L199-L207 | train |
sethvargo/community-zero | lib/community_zero/endpoints/cookbooks_endpoint.rb | CommunityZero.CookbooksEndpoint.create_cookbook | def create_cookbook(metadata, overrides = {})
cookbook = Cookbook.new({
:name => metadata.name,
:category => nil,
:maintainer => metadata.maintainer,
:description => metadata.description,
:version => metadata.version
}.merge(overrides))
... | ruby | def create_cookbook(metadata, overrides = {})
cookbook = Cookbook.new({
:name => metadata.name,
:category => nil,
:maintainer => metadata.maintainer,
:description => metadata.description,
:version => metadata.version
}.merge(overrides))
... | [
"def",
"create_cookbook",
"(",
"metadata",
",",
"overrides",
"=",
"{",
"}",
")",
"cookbook",
"=",
"Cookbook",
".",
"new",
"(",
"{",
":name",
"=>",
"metadata",
".",
"name",
",",
":category",
"=>",
"nil",
",",
":maintainer",
"=>",
"metadata",
".",
"maintai... | Create the cookbook from the metadata.
@param [CommunityZero::Metadata] metadata
the metadata to create the cookbook from | [
"Create",
"the",
"cookbook",
"from",
"the",
"metadata",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/endpoints/cookbooks_endpoint.rb#L71-L83 | train |
sethvargo/community-zero | lib/community_zero/endpoints/cookbooks_endpoint.rb | CommunityZero.CookbooksEndpoint.find_metadata | def find_metadata(tarball)
gzip = Zlib::GzipReader.new(tarball[:tempfile])
tar = Gem::Package::TarReader.new(gzip)
tar.each do |entry|
if entry.full_name =~ /metadata\.json$/
return Metadata.from_json(entry.read)
elsif entry.full_name =~ /metadata\.rb$/
... | ruby | def find_metadata(tarball)
gzip = Zlib::GzipReader.new(tarball[:tempfile])
tar = Gem::Package::TarReader.new(gzip)
tar.each do |entry|
if entry.full_name =~ /metadata\.json$/
return Metadata.from_json(entry.read)
elsif entry.full_name =~ /metadata\.rb$/
... | [
"def",
"find_metadata",
"(",
"tarball",
")",
"gzip",
"=",
"Zlib",
"::",
"GzipReader",
".",
"new",
"(",
"tarball",
"[",
":tempfile",
"]",
")",
"tar",
"=",
"Gem",
"::",
"Package",
"::",
"TarReader",
".",
"new",
"(",
"gzip",
")",
"tar",
".",
"each",
"do... | Parse the metadata from the tarball.
@param [Tempfile] tarball
the temporarily uploaded file
@return [Metadata] | [
"Parse",
"the",
"metadata",
"from",
"the",
"tarball",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/endpoints/cookbooks_endpoint.rb#L91-L104 | train |
holtrop/ruby-gnucash | lib/gnucash/account.rb | Gnucash.Account.finalize | def finalize
@transactions.sort! { |a, b| a.date <=> b.date }
balance = Value.new(0)
@balances = @transactions.map do |act_txn|
balance += act_txn.value
{
date: act_txn.date,
value: balance,
}
end
end | ruby | def finalize
@transactions.sort! { |a, b| a.date <=> b.date }
balance = Value.new(0)
@balances = @transactions.map do |act_txn|
balance += act_txn.value
{
date: act_txn.date,
value: balance,
}
end
end | [
"def",
"finalize",
"@transactions",
".",
"sort!",
"{",
"|",
"a",
",",
"b",
"|",
"a",
".",
"date",
"<=>",
"b",
".",
"date",
"}",
"balance",
"=",
"Value",
".",
"new",
"(",
"0",
")",
"@balances",
"=",
"@transactions",
".",
"map",
"do",
"|",
"act_txn",... | Internal method used to complete initialization of the Account after
all transactions have been associated with it.
@return [void] | [
"Internal",
"method",
"used",
"to",
"complete",
"initialization",
"of",
"the",
"Account",
"after",
"all",
"transactions",
"have",
"been",
"associated",
"with",
"it",
"."
] | a233cc4da0f36b13bc3f7a17264adb82c8a12c6b | https://github.com/holtrop/ruby-gnucash/blob/a233cc4da0f36b13bc3f7a17264adb82c8a12c6b/lib/gnucash/account.rb#L78-L88 | train |
snowplow/iglu-ruby-client | lib/iglu-client/resolver.rb | Iglu.Resolver.lookup_schema | def lookup_schema(schema_key)
lookup_time = Time.now.getutc
if schema_key.is_a?(String)
schema_key = SchemaKey.parse_key(schema_key)
end
failures = []
cache_result = @cache[schema_key]
if not cache_result.nil?
if not @cacheTtl.nil?
store_time = cache_result... | ruby | def lookup_schema(schema_key)
lookup_time = Time.now.getutc
if schema_key.is_a?(String)
schema_key = SchemaKey.parse_key(schema_key)
end
failures = []
cache_result = @cache[schema_key]
if not cache_result.nil?
if not @cacheTtl.nil?
store_time = cache_result... | [
"def",
"lookup_schema",
"(",
"schema_key",
")",
"lookup_time",
"=",
"Time",
".",
"now",
".",
"getutc",
"if",
"schema_key",
".",
"is_a?",
"(",
"String",
")",
"schema_key",
"=",
"SchemaKey",
".",
"parse_key",
"(",
"schema_key",
")",
"end",
"failures",
"=",
"... | Lookup schema in cache or try to fetch | [
"Lookup",
"schema",
"in",
"cache",
"or",
"try",
"to",
"fetch"
] | 6d41668dc3e5615e3358a952e193812b5c4b3d6b | https://github.com/snowplow/iglu-ruby-client/blob/6d41668dc3e5615e3358a952e193812b5c4b3d6b/lib/iglu-client/resolver.rb#L28-L74 | train |
snowplow/iglu-ruby-client | lib/iglu-client/resolver.rb | Iglu.Resolver.validate | def validate(json)
schema_key = Resolver.get_schema_key json
data = Resolver.get_data json
schema = lookup_schema schema_key
JSON::Validator.validate!(schema, data)
end | ruby | def validate(json)
schema_key = Resolver.get_schema_key json
data = Resolver.get_data json
schema = lookup_schema schema_key
JSON::Validator.validate!(schema, data)
end | [
"def",
"validate",
"(",
"json",
")",
"schema_key",
"=",
"Resolver",
".",
"get_schema_key",
"json",
"data",
"=",
"Resolver",
".",
"get_data",
"json",
"schema",
"=",
"lookup_schema",
"schema_key",
"JSON",
"::",
"Validator",
".",
"validate!",
"(",
"schema",
",",
... | Return true or throw exception | [
"Return",
"true",
"or",
"throw",
"exception"
] | 6d41668dc3e5615e3358a952e193812b5c4b3d6b | https://github.com/snowplow/iglu-ruby-client/blob/6d41668dc3e5615e3358a952e193812b5c4b3d6b/lib/iglu-client/resolver.rb#L119-L124 | train |
code-and-effect/effective_pages | app/models/effective/menu_item.rb | Effective.MenuItem.visible_for? | def visible_for?(user)
can_view_page = (
if dropdown?
true
elsif menuable.kind_of?(Effective::Page)
menuable.roles_permit?(user)
else
true
end
)
can_view_menu_item = (
if roles_mask == nil
true
elsif roles_mask ==... | ruby | def visible_for?(user)
can_view_page = (
if dropdown?
true
elsif menuable.kind_of?(Effective::Page)
menuable.roles_permit?(user)
else
true
end
)
can_view_menu_item = (
if roles_mask == nil
true
elsif roles_mask ==... | [
"def",
"visible_for?",
"(",
"user",
")",
"can_view_page",
"=",
"(",
"if",
"dropdown?",
"true",
"elsif",
"menuable",
".",
"kind_of?",
"(",
"Effective",
"::",
"Page",
")",
"menuable",
".",
"roles_permit?",
"(",
"user",
")",
"else",
"true",
"end",
")",
"can_v... | For now it's just logged in or not?
This will work with effective_roles one day... | [
"For",
"now",
"it",
"s",
"just",
"logged",
"in",
"or",
"not?",
"This",
"will",
"work",
"with",
"effective_roles",
"one",
"day",
"..."
] | ff00e2d76055985ab65f570747bc9a5f2748f817 | https://github.com/code-and-effect/effective_pages/blob/ff00e2d76055985ab65f570747bc9a5f2748f817/app/models/effective/menu_item.rb#L51-L75 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store.copy | def copy(dir, options = {})
# Make sure all objects are persisted.
sync
# Create a new store with the specified directory and options.
new_db = Store.new(dir, options)
# Clear the cache.
new_db.sync
# Copy all objects of the existing store to the new store.
i = 0
e... | ruby | def copy(dir, options = {})
# Make sure all objects are persisted.
sync
# Create a new store with the specified directory and options.
new_db = Store.new(dir, options)
# Clear the cache.
new_db.sync
# Copy all objects of the existing store to the new store.
i = 0
e... | [
"def",
"copy",
"(",
"dir",
",",
"options",
"=",
"{",
"}",
")",
"sync",
"new_db",
"=",
"Store",
".",
"new",
"(",
"dir",
",",
"options",
")",
"new_db",
".",
"sync",
"i",
"=",
"0",
"each",
"do",
"|",
"ref_obj",
"|",
"obj",
"=",
"ref_obj",
".",
"_r... | Create a new Store.
@param data_base [String] the name of the database
@param options [Hash] various options to affect the operation of the
database. Currently the following options are supported:
:engine : The class that provides the back-end storage
engine. By default FlatF... | [
"Create",
"a",
"new",
"Store",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L183-L204 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store.exit | def exit
if @cache && @cache.in_transaction?
@cache.abort_transaction
@cache.flush
@db.close if @db
PEROBS.log.fatal "You cannot call exit() during a transaction: #{Kernel.caller}"
end
@cache.flush if @cache
@db.close if @db
@db = @class_map = @in_memory_obj... | ruby | def exit
if @cache && @cache.in_transaction?
@cache.abort_transaction
@cache.flush
@db.close if @db
PEROBS.log.fatal "You cannot call exit() during a transaction: #{Kernel.caller}"
end
@cache.flush if @cache
@db.close if @db
@db = @class_map = @in_memory_obj... | [
"def",
"exit",
"if",
"@cache",
"&&",
"@cache",
".",
"in_transaction?",
"@cache",
".",
"abort_transaction",
"@cache",
".",
"flush",
"@db",
".",
"close",
"if",
"@db",
"PEROBS",
".",
"log",
".",
"fatal",
"\"You cannot call exit() during a transaction: #{Kernel.caller}\""... | Close the store and ensure that all in-memory objects are written out to
the storage backend. The Store object is no longer usable after this
method was called. | [
"Close",
"the",
"store",
"and",
"ensure",
"that",
"all",
"in",
"-",
"memory",
"objects",
"are",
"written",
"out",
"to",
"the",
"storage",
"backend",
".",
"The",
"Store",
"object",
"is",
"no",
"longer",
"usable",
"after",
"this",
"method",
"was",
"called",
... | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L210-L221 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store.new | def new(klass, *args)
unless klass.is_a?(BasicObject)
PEROBS.log.fatal "#{klass} is not a BasicObject derivative"
end
obj = _construct_po(klass, _new_id, *args)
# Mark the new object as modified so it gets pushed into the database.
@cache.cache_write(obj)
# Return a POXRefer... | ruby | def new(klass, *args)
unless klass.is_a?(BasicObject)
PEROBS.log.fatal "#{klass} is not a BasicObject derivative"
end
obj = _construct_po(klass, _new_id, *args)
# Mark the new object as modified so it gets pushed into the database.
@cache.cache_write(obj)
# Return a POXRefer... | [
"def",
"new",
"(",
"klass",
",",
"*",
"args",
")",
"unless",
"klass",
".",
"is_a?",
"(",
"BasicObject",
")",
"PEROBS",
".",
"log",
".",
"fatal",
"\"#{klass} is not a BasicObject derivative\"",
"end",
"obj",
"=",
"_construct_po",
"(",
"klass",
",",
"_new_id",
... | You need to call this method to create new PEROBS objects that belong to
this Store.
@param klass [Class] The class of the object you want to create. This
must be a derivative of ObjectBase.
@param args Optional list of other arguments that are passed to the
constructor of the specified class.
@retu... | [
"You",
"need",
"to",
"call",
"this",
"method",
"to",
"create",
"new",
"PEROBS",
"objects",
"that",
"belong",
"to",
"this",
"Store",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L231-L241 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store._construct_po | def _construct_po(klass, id, *args)
klass.new(Handle.new(self, id), *args)
end | ruby | def _construct_po(klass, id, *args)
klass.new(Handle.new(self, id), *args)
end | [
"def",
"_construct_po",
"(",
"klass",
",",
"id",
",",
"*",
"args",
")",
"klass",
".",
"new",
"(",
"Handle",
".",
"new",
"(",
"self",
",",
"id",
")",
",",
"*",
"args",
")",
"end"
] | For library internal use only!
This method will create a new PEROBS object.
@param klass [BasicObject] Class of the object to create
@param id [Integer] Requested object ID
@param args [Array] Arguments to pass to the object constructor.
@return [BasicObject] Newly constructed PEROBS object | [
"For",
"library",
"internal",
"use",
"only!",
"This",
"method",
"will",
"create",
"a",
"new",
"PEROBS",
"object",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L249-L251 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store.sync | def sync
if @cache.in_transaction?
@cache.abort_transaction
@cache.flush
PEROBS.log.fatal "You cannot call sync() during a transaction: \n" +
Kernel.caller.join("\n")
end
@cache.flush
end | ruby | def sync
if @cache.in_transaction?
@cache.abort_transaction
@cache.flush
PEROBS.log.fatal "You cannot call sync() during a transaction: \n" +
Kernel.caller.join("\n")
end
@cache.flush
end | [
"def",
"sync",
"if",
"@cache",
".",
"in_transaction?",
"@cache",
".",
"abort_transaction",
"@cache",
".",
"flush",
"PEROBS",
".",
"log",
".",
"fatal",
"\"You cannot call sync() during a transaction: \\n\"",
"+",
"Kernel",
".",
"caller",
".",
"join",
"(",
"\"\\n\"",
... | Flush out all modified objects to disk and shrink the in-memory list if
needed. | [
"Flush",
"out",
"all",
"modified",
"objects",
"to",
"disk",
"and",
"shrink",
"the",
"in",
"-",
"memory",
"list",
"if",
"needed",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L313-L321 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store.object_by_id | def object_by_id(id)
if (ruby_object_id = @in_memory_objects[id])
# We have the object in memory so we can just return it.
begin
object = ObjectSpace._id2ref(ruby_object_id)
# Let's make sure the object is really the object we are looking
# for. The GC might have recy... | ruby | def object_by_id(id)
if (ruby_object_id = @in_memory_objects[id])
# We have the object in memory so we can just return it.
begin
object = ObjectSpace._id2ref(ruby_object_id)
# Let's make sure the object is really the object we are looking
# for. The GC might have recy... | [
"def",
"object_by_id",
"(",
"id",
")",
"if",
"(",
"ruby_object_id",
"=",
"@in_memory_objects",
"[",
"id",
"]",
")",
"begin",
"object",
"=",
"ObjectSpace",
".",
"_id2ref",
"(",
"ruby_object_id",
")",
"if",
"object",
".",
"is_a?",
"(",
"ObjectBase",
")",
"&&... | Return the object with the provided ID. This method is not part of the
public API and should never be called by outside users. It's purely
intended for internal use. | [
"Return",
"the",
"object",
"with",
"the",
"provided",
"ID",
".",
"This",
"method",
"is",
"not",
"part",
"of",
"the",
"public",
"API",
"and",
"should",
"never",
"be",
"called",
"by",
"outside",
"users",
".",
"It",
"s",
"purely",
"intended",
"for",
"intern... | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L347-L384 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store.check | def check(repair = false)
stats = { :errors => 0, :object_cnt => 0 }
# All objects must have in-db version.
sync
# Run basic consistency checks first.
stats[:errors] += @db.check_db(repair)
# We will use the mark to mark all objects that we have checked already.
# Before we s... | ruby | def check(repair = false)
stats = { :errors => 0, :object_cnt => 0 }
# All objects must have in-db version.
sync
# Run basic consistency checks first.
stats[:errors] += @db.check_db(repair)
# We will use the mark to mark all objects that we have checked already.
# Before we s... | [
"def",
"check",
"(",
"repair",
"=",
"false",
")",
"stats",
"=",
"{",
":errors",
"=>",
"0",
",",
":object_cnt",
"=>",
"0",
"}",
"sync",
"stats",
"[",
":errors",
"]",
"+=",
"@db",
".",
"check_db",
"(",
"repair",
")",
"@db",
".",
"clear_marks",
"@progre... | This method can be used to check the database and optionally repair it.
The repair is a pure structural repair. It cannot ensure that the stored
data is still correct. E. g. if a reference to a non-existing or
unreadable object is found, the reference will simply be deleted.
@param repair [TrueClass/FalseClass] tru... | [
"This",
"method",
"can",
"be",
"used",
"to",
"check",
"the",
"database",
"and",
"optionally",
"repair",
"it",
".",
"The",
"repair",
"is",
"a",
"pure",
"structural",
"repair",
".",
"It",
"cannot",
"ensure",
"that",
"the",
"stored",
"data",
"is",
"still",
... | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L393-L439 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store.each | def each
@db.clear_marks
# Start with the object 0 and the indexes of the root objects. Push them
# onto the work stack.
stack = [ 0 ] + @root_objects.values
while !stack.empty?
# Get an object index from the stack.
id = stack.pop
next if @db.is_marked?(id)
... | ruby | def each
@db.clear_marks
# Start with the object 0 and the indexes of the root objects. Push them
# onto the work stack.
stack = [ 0 ] + @root_objects.values
while !stack.empty?
# Get an object index from the stack.
id = stack.pop
next if @db.is_marked?(id)
... | [
"def",
"each",
"@db",
".",
"clear_marks",
"stack",
"=",
"[",
"0",
"]",
"+",
"@root_objects",
".",
"values",
"while",
"!",
"stack",
".",
"empty?",
"id",
"=",
"stack",
".",
"pop",
"next",
"if",
"@db",
".",
"is_marked?",
"(",
"id",
")",
"unless",
"(",
... | Calls the given block once for each object, passing that object as a
parameter. | [
"Calls",
"the",
"given",
"block",
"once",
"for",
"each",
"object",
"passing",
"that",
"object",
"as",
"a",
"parameter",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L460-L482 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store.mark | def mark
classes = Set.new
marked_objects = 0
@progressmeter.start("Marking linked objects", @db.item_counter) do
each do |obj|
classes.add(obj.class)
@progressmeter.update(marked_objects += 1)
end
end
@class_map.keep(classes.map { |c| c.to_s })
#... | ruby | def mark
classes = Set.new
marked_objects = 0
@progressmeter.start("Marking linked objects", @db.item_counter) do
each do |obj|
classes.add(obj.class)
@progressmeter.update(marked_objects += 1)
end
end
@class_map.keep(classes.map { |c| c.to_s })
#... | [
"def",
"mark",
"classes",
"=",
"Set",
".",
"new",
"marked_objects",
"=",
"0",
"@progressmeter",
".",
"start",
"(",
"\"Marking linked objects\"",
",",
"@db",
".",
"item_counter",
")",
"do",
"each",
"do",
"|",
"obj",
"|",
"classes",
".",
"add",
"(",
"obj",
... | Mark phase of a mark-and-sweep garbage collector. It will mark all
objects that are reachable from the root objects. | [
"Mark",
"phase",
"of",
"a",
"mark",
"-",
"and",
"-",
"sweep",
"garbage",
"collector",
".",
"It",
"will",
"mark",
"all",
"objects",
"that",
"are",
"reachable",
"from",
"the",
"root",
"objects",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L538-L554 | train |
scrapper/perobs | lib/perobs/Store.rb | PEROBS.Store.check_object | def check_object(start_id, repair, stats)
@db.mark(start_id)
# The todo list holds a touple for each object that still needs to be
# checked. The first item is the referring object and the second is the
# ID of the object to check.
todo_list = [ [ nil, start_id ] ]
while !todo_list.... | ruby | def check_object(start_id, repair, stats)
@db.mark(start_id)
# The todo list holds a touple for each object that still needs to be
# checked. The first item is the referring object and the second is the
# ID of the object to check.
todo_list = [ [ nil, start_id ] ]
while !todo_list.... | [
"def",
"check_object",
"(",
"start_id",
",",
"repair",
",",
"stats",
")",
"@db",
".",
"mark",
"(",
"start_id",
")",
"todo_list",
"=",
"[",
"[",
"nil",
",",
"start_id",
"]",
"]",
"while",
"!",
"todo_list",
".",
"empty?",
"ref_obj",
",",
"id",
"=",
"to... | Check the object with the given start_id and all other objects that are
somehow reachable from the start object.
@param start_id [Integer] ID of the top-level object to start
with
@param repair [Boolean] Delete refernces to broken objects if true
@return [Integer] The number of references to bad objects. | [
"Check",
"the",
"object",
"with",
"the",
"given",
"start_id",
"and",
"all",
"other",
"objects",
"that",
"are",
"somehow",
"reachable",
"from",
"the",
"start",
"object",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Store.rb#L571-L616 | train |
scrapper/perobs | lib/perobs/Object.rb | PEROBS.Object._referenced_object_ids | def _referenced_object_ids
ids = []
_all_attributes.each do |attr|
value = instance_variable_get(('@' + attr.to_s).to_sym)
ids << value.id if value && value.respond_to?(:is_poxreference?)
end
ids
end | ruby | def _referenced_object_ids
ids = []
_all_attributes.each do |attr|
value = instance_variable_get(('@' + attr.to_s).to_sym)
ids << value.id if value && value.respond_to?(:is_poxreference?)
end
ids
end | [
"def",
"_referenced_object_ids",
"ids",
"=",
"[",
"]",
"_all_attributes",
".",
"each",
"do",
"|",
"attr",
"|",
"value",
"=",
"instance_variable_get",
"(",
"(",
"'@'",
"+",
"attr",
".",
"to_s",
")",
".",
"to_sym",
")",
"ids",
"<<",
"value",
".",
"id",
"... | Return a list of all object IDs that the attributes of this instance are
referencing.
@return [Array of Integer] IDs of referenced objects | [
"Return",
"a",
"list",
"of",
"all",
"object",
"IDs",
"that",
"the",
"attributes",
"of",
"this",
"instance",
"are",
"referencing",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Object.rb#L149-L156 | train |
scrapper/perobs | lib/perobs/Object.rb | PEROBS.Object._delete_reference_to_id | def _delete_reference_to_id(id)
_all_attributes.each do |attr|
ivar = ('@' + attr.to_s).to_sym
value = instance_variable_get(ivar)
if value && value.respond_to?(:is_poxreference?) && value.id == id
instance_variable_set(ivar, nil)
end
end
mark_as_modified
... | ruby | def _delete_reference_to_id(id)
_all_attributes.each do |attr|
ivar = ('@' + attr.to_s).to_sym
value = instance_variable_get(ivar)
if value && value.respond_to?(:is_poxreference?) && value.id == id
instance_variable_set(ivar, nil)
end
end
mark_as_modified
... | [
"def",
"_delete_reference_to_id",
"(",
"id",
")",
"_all_attributes",
".",
"each",
"do",
"|",
"attr",
"|",
"ivar",
"=",
"(",
"'@'",
"+",
"attr",
".",
"to_s",
")",
".",
"to_sym",
"value",
"=",
"instance_variable_get",
"(",
"ivar",
")",
"if",
"value",
"&&",... | This method should only be used during store repair operations. It will
delete all references to the given object ID.
@param id [Integer] targeted object ID | [
"This",
"method",
"should",
"only",
"be",
"used",
"during",
"store",
"repair",
"operations",
".",
"It",
"will",
"delete",
"all",
"references",
"to",
"the",
"given",
"object",
"ID",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Object.rb#L161-L170 | train |
scrapper/perobs | lib/perobs/Object.rb | PEROBS.Object.inspect | def inspect
"<#{self.class}:#{@_id}>\n{\n" +
_all_attributes.map do |attr|
ivar = ('@' + attr.to_s).to_sym
if (value = instance_variable_get(ivar)).respond_to?(:is_poxreference?)
" #{attr} => <PEROBS::ObjectBase:#{value._id}>"
else
" #{attr} => #{value.inspect}"... | ruby | def inspect
"<#{self.class}:#{@_id}>\n{\n" +
_all_attributes.map do |attr|
ivar = ('@' + attr.to_s).to_sym
if (value = instance_variable_get(ivar)).respond_to?(:is_poxreference?)
" #{attr} => <PEROBS::ObjectBase:#{value._id}>"
else
" #{attr} => #{value.inspect}"... | [
"def",
"inspect",
"\"<#{self.class}:#{@_id}>\\n{\\n\"",
"+",
"_all_attributes",
".",
"map",
"do",
"|",
"attr",
"|",
"ivar",
"=",
"(",
"'@'",
"+",
"attr",
".",
"to_s",
")",
".",
"to_sym",
"if",
"(",
"value",
"=",
"instance_variable_get",
"(",
"ivar",
")",
"... | Textual dump for debugging purposes
@return [String] | [
"Textual",
"dump",
"for",
"debugging",
"purposes"
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Object.rb#L186-L197 | train |
scrapper/perobs | lib/perobs/Object.rb | PEROBS.Object._serialize | def _serialize
attributes = {}
_all_attributes.each do |attr|
ivar = ('@' + attr.to_s).to_sym
value = instance_variable_get(ivar)
attributes[attr.to_s] = value.respond_to?(:is_poxreference?) ?
POReference.new(value.id) : value
end
attributes
end | ruby | def _serialize
attributes = {}
_all_attributes.each do |attr|
ivar = ('@' + attr.to_s).to_sym
value = instance_variable_get(ivar)
attributes[attr.to_s] = value.respond_to?(:is_poxreference?) ?
POReference.new(value.id) : value
end
attributes
end | [
"def",
"_serialize",
"attributes",
"=",
"{",
"}",
"_all_attributes",
".",
"each",
"do",
"|",
"attr",
"|",
"ivar",
"=",
"(",
"'@'",
"+",
"attr",
".",
"to_s",
")",
".",
"to_sym",
"value",
"=",
"instance_variable_get",
"(",
"ivar",
")",
"attributes",
"[",
... | Return a single data structure that holds all persistent data for this
class. | [
"Return",
"a",
"single",
"data",
"structure",
"that",
"holds",
"all",
"persistent",
"data",
"for",
"this",
"class",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Object.rb#L203-L212 | train |
danielpclark/PolyBelongsTo | lib/poly_belongs_to/singleton_set.rb | PolyBelongsTo.SingletonSet.add? | def add?(record)
result = @set.add?( formatted_name( record ) )
return result if result
flag(record)
result
end | ruby | def add?(record)
result = @set.add?( formatted_name( record ) )
return result if result
flag(record)
result
end | [
"def",
"add?",
"(",
"record",
")",
"result",
"=",
"@set",
".",
"add?",
"(",
"formatted_name",
"(",
"record",
")",
")",
"return",
"result",
"if",
"result",
"flag",
"(",
"record",
")",
"result",
"end"
] | Add record to set. Flag if covered already.
@param record [Object] ActiveRecord object instance
@return [Object, nil] Object if added safely, nil otherwise | [
"Add",
"record",
"to",
"set",
".",
"Flag",
"if",
"covered",
"already",
"."
] | 38d51d37f9148613519d6b6d56bdf4d0884f0e86 | https://github.com/danielpclark/PolyBelongsTo/blob/38d51d37f9148613519d6b6d56bdf4d0884f0e86/lib/poly_belongs_to/singleton_set.rb#L24-L29 | train |
danielpclark/PolyBelongsTo | lib/poly_belongs_to/singleton_set.rb | PolyBelongsTo.SingletonSet.method_missing | def method_missing(mthd, *args, &block)
new_recs = args.reduce([]) {|a, i| a.push(formatted_name(i)) if i.class.ancestors.include?(ActiveRecord::Base); a}
result = @set.send(mthd,
*(args.map do |arg|
arg.class.ancestors.include?(ActiveRecord::Base) ? formatted_name(arg) : arg
e... | ruby | def method_missing(mthd, *args, &block)
new_recs = args.reduce([]) {|a, i| a.push(formatted_name(i)) if i.class.ancestors.include?(ActiveRecord::Base); a}
result = @set.send(mthd,
*(args.map do |arg|
arg.class.ancestors.include?(ActiveRecord::Base) ? formatted_name(arg) : arg
e... | [
"def",
"method_missing",
"(",
"mthd",
",",
"*",
"args",
",",
"&",
"block",
")",
"new_recs",
"=",
"args",
".",
"reduce",
"(",
"[",
"]",
")",
"{",
"|",
"a",
",",
"i",
"|",
"a",
".",
"push",
"(",
"formatted_name",
"(",
"i",
")",
")",
"if",
"i",
... | method_missing will transform any record argument into a formatted string and pass the
method and arguments on to the internal Set. Also will flag any existing records covered. | [
"method_missing",
"will",
"transform",
"any",
"record",
"argument",
"into",
"a",
"formatted",
"string",
"and",
"pass",
"the",
"method",
"and",
"arguments",
"on",
"to",
"the",
"internal",
"Set",
".",
"Also",
"will",
"flag",
"any",
"existing",
"records",
"covere... | 38d51d37f9148613519d6b6d56bdf4d0884f0e86 | https://github.com/danielpclark/PolyBelongsTo/blob/38d51d37f9148613519d6b6d56bdf4d0884f0e86/lib/poly_belongs_to/singleton_set.rb#L56-L67 | train |
Absolight/epp-client | lib/epp-client/xml.rb | EPPClient.XML.get_result | def get_result(args)
xml = case args
when Hash
args.delete(:xml)
else
xml = args
args = {}
xml
end
args[:range] ||= 1000..1999
if !(mq = xml.xpath('epp:epp/epp:response/epp:msgQ', EPPClient::SCHEMAS_URL)).emp... | ruby | def get_result(args)
xml = case args
when Hash
args.delete(:xml)
else
xml = args
args = {}
xml
end
args[:range] ||= 1000..1999
if !(mq = xml.xpath('epp:epp/epp:response/epp:msgQ', EPPClient::SCHEMAS_URL)).emp... | [
"def",
"get_result",
"(",
"args",
")",
"xml",
"=",
"case",
"args",
"when",
"Hash",
"args",
".",
"delete",
"(",
":xml",
")",
"else",
"xml",
"=",
"args",
"args",
"=",
"{",
"}",
"xml",
"end",
"args",
"[",
":range",
"]",
"||=",
"1000",
"..",
"1999",
... | Takes a xml response and checks that the result is in the right range of
results, that is, between 1000 and 1999, which are results meaning all
went well.
In case all went well, it either calls the callback if given, or returns
true.
In case there was a problem, an EPPErrorResponse exception is raised. | [
"Takes",
"a",
"xml",
"response",
"and",
"checks",
"that",
"the",
"result",
"is",
"in",
"the",
"right",
"range",
"of",
"results",
"that",
"is",
"between",
"1000",
"and",
"1999",
"which",
"are",
"results",
"meaning",
"all",
"went",
"well",
"."
] | c0025daee5e7087f60b654595a8e7d92e966c54e | https://github.com/Absolight/epp-client/blob/c0025daee5e7087f60b654595a8e7d92e966c54e/lib/epp-client/xml.rb#L50-L88 | train |
Absolight/epp-client | lib/epp-client/xml.rb | EPPClient.XML.command | def command(*args, &_block)
builder do |xml|
xml.command do
if block_given?
yield xml
else
command = args.shift
command.call(xml)
args.each do |ext|
xml.extension do
ext.call(xml)
end
... | ruby | def command(*args, &_block)
builder do |xml|
xml.command do
if block_given?
yield xml
else
command = args.shift
command.call(xml)
args.each do |ext|
xml.extension do
ext.call(xml)
end
... | [
"def",
"command",
"(",
"*",
"args",
",",
"&",
"_block",
")",
"builder",
"do",
"|",
"xml",
"|",
"xml",
".",
"command",
"do",
"if",
"block_given?",
"yield",
"xml",
"else",
"command",
"=",
"args",
".",
"shift",
"command",
".",
"call",
"(",
"xml",
")",
... | Creates the xml for the command.
You can either pass a block to it, in that case, it's the command body,
or a series of procs, the first one being the commands, the other ones
being the extensions.
command do |xml|
xml.logout
end
or
command(lambda do |xml|
xml.logout
end, lambda do |... | [
"Creates",
"the",
"xml",
"for",
"the",
"command",
"."
] | c0025daee5e7087f60b654595a8e7d92e966c54e | https://github.com/Absolight/epp-client/blob/c0025daee5e7087f60b654595a8e7d92e966c54e/lib/epp-client/xml.rb#L114-L131 | train |
regru/reg_api2-ruby | lib/reg_api2/action.rb | RegApi2.Action.create_http | def create_http
http = Net::HTTP.new(
API_URI.host,
API_URI.port
)
http.use_ssl = true
apply_ca_cert_path(http)
apply_pem(http)
http
end | ruby | def create_http
http = Net::HTTP.new(
API_URI.host,
API_URI.port
)
http.use_ssl = true
apply_ca_cert_path(http)
apply_pem(http)
http
end | [
"def",
"create_http",
"http",
"=",
"Net",
"::",
"HTTP",
".",
"new",
"(",
"API_URI",
".",
"host",
",",
"API_URI",
".",
"port",
")",
"http",
".",
"use_ssl",
"=",
"true",
"apply_ca_cert_path",
"(",
"http",
")",
"apply_pem",
"(",
"http",
")",
"http",
"end"... | Creates HTTPS handler.
@return [Net::HTTP] HTTPS handler.
@see #http | [
"Creates",
"HTTPS",
"handler",
"."
] | 82fadffc9da6534761003b8a33edb77ab617df70 | https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/action.rb#L48-L57 | train |
regru/reg_api2-ruby | lib/reg_api2/action.rb | RegApi2.Action.get_form_data | def get_form_data(defopts, opts)
# HACK: REG.API doesn't know about utf-8.
io_encoding = 'utf8' if !io_encoding || io_encoding == DEFAULT_IO_ENCODING
opts = opts.to_hash if opts.respond_to?(:to_hash)
req_contract = RegApi2::RequestContract.new(defopts)
opts = req_contract.validate(opts)
... | ruby | def get_form_data(defopts, opts)
# HACK: REG.API doesn't know about utf-8.
io_encoding = 'utf8' if !io_encoding || io_encoding == DEFAULT_IO_ENCODING
opts = opts.to_hash if opts.respond_to?(:to_hash)
req_contract = RegApi2::RequestContract.new(defopts)
opts = req_contract.validate(opts)
... | [
"def",
"get_form_data",
"(",
"defopts",
",",
"opts",
")",
"io_encoding",
"=",
"'utf8'",
"if",
"!",
"io_encoding",
"||",
"io_encoding",
"==",
"DEFAULT_IO_ENCODING",
"opts",
"=",
"opts",
".",
"to_hash",
"if",
"opts",
".",
"respond_to?",
"(",
":to_hash",
")",
"... | Gets form data for POST request
@param [Hash] defopts
@param [Hash] opts
@return [Hash] Form data to be sent.
@raise [ContractError] | [
"Gets",
"form",
"data",
"for",
"POST",
"request"
] | 82fadffc9da6534761003b8a33edb77ab617df70 | https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/action.rb#L83-L102 | train |
radar/summer | lib/summer.rb | Summer.Connection.startup! | def startup!
@started = true
try(:did_start_up)
if config['nickserv_password']
privmsg("identify #{config['nickserv_password']}", "nickserv")
# Wait 10 seconds for nickserv to get back to us.
Thread.new do
sleep(10)
finalize_startup
end
else
... | ruby | def startup!
@started = true
try(:did_start_up)
if config['nickserv_password']
privmsg("identify #{config['nickserv_password']}", "nickserv")
# Wait 10 seconds for nickserv to get back to us.
Thread.new do
sleep(10)
finalize_startup
end
else
... | [
"def",
"startup!",
"@started",
"=",
"true",
"try",
"(",
":did_start_up",
")",
"if",
"config",
"[",
"'nickserv_password'",
"]",
"privmsg",
"(",
"\"identify #{config['nickserv_password']}\"",
",",
"\"nickserv\"",
")",
"Thread",
".",
"new",
"do",
"sleep",
"(",
"10",
... | Will join channels specified in configuration. | [
"Will",
"join",
"channels",
"specified",
"in",
"configuration",
"."
] | 7c08c6a8b2e986030db3718ca71daf2ca8dd668d | https://github.com/radar/summer/blob/7c08c6a8b2e986030db3718ca71daf2ca8dd668d/lib/summer.rb#L69-L83 | train |
radar/summer | lib/summer.rb | Summer.Connection.parse | def parse(message)
puts "<< #{message.to_s.strip}"
words = message.split(" ")
sender = words[0]
raw = words[1]
channel = words[2]
# Handling pings
if /^PING (.*?)\s$/.match(message)
response("PONG #{$1}")
# Handling raws
elsif /\d+/.match(raw)
send("... | ruby | def parse(message)
puts "<< #{message.to_s.strip}"
words = message.split(" ")
sender = words[0]
raw = words[1]
channel = words[2]
# Handling pings
if /^PING (.*?)\s$/.match(message)
response("PONG #{$1}")
# Handling raws
elsif /\d+/.match(raw)
send("... | [
"def",
"parse",
"(",
"message",
")",
"puts",
"\"<< #{message.to_s.strip}\"",
"words",
"=",
"message",
".",
"split",
"(",
"\" \"",
")",
"sender",
"=",
"words",
"[",
"0",
"]",
"raw",
"=",
"words",
"[",
"1",
"]",
"channel",
"=",
"words",
"[",
"2",
"]",
... | What did they say? | [
"What",
"did",
"they",
"say?"
] | 7c08c6a8b2e986030db3718ca71daf2ca8dd668d | https://github.com/radar/summer/blob/7c08c6a8b2e986030db3718ca71daf2ca8dd668d/lib/summer.rb#L107-L145 | train |
apeiros/swissmatch-location | lib/swissmatch/zipcodes.rb | SwissMatch.ZipCodes.[] | def [](key, add_on=nil)
case key
when /\A(\d{4})(\d\d)\z/
by_code_and_add_on($1.to_i, $2.to_i)
when 100_000..999_999
by_code_and_add_on(*key.divmod(100))
when 0..9999, /\A\d{4}\z/
case add_on
when nil
by_code(key.to_i)
whe... | ruby | def [](key, add_on=nil)
case key
when /\A(\d{4})(\d\d)\z/
by_code_and_add_on($1.to_i, $2.to_i)
when 100_000..999_999
by_code_and_add_on(*key.divmod(100))
when 0..9999, /\A\d{4}\z/
case add_on
when nil
by_code(key.to_i)
whe... | [
"def",
"[]",
"(",
"key",
",",
"add_on",
"=",
"nil",
")",
"case",
"key",
"when",
"/",
"\\A",
"\\d",
"\\d",
"\\d",
"\\z",
"/",
"by_code_and_add_on",
"(",
"$1",
".",
"to_i",
",",
"$2",
".",
"to_i",
")",
"when",
"100_000",
"..",
"999_999",
"by_code_and_a... | A convenience method to get one or many zip codes by code, code and add-on, code and city or just
city.
There are various allowed styles to pass those values.
All numeric values can be passed either as Integer or String.
You can pass the code and add-on as six-digit number, or you can pass the code
as four digit n... | [
"A",
"convenience",
"method",
"to",
"get",
"one",
"or",
"many",
"zip",
"codes",
"by",
"code",
"code",
"and",
"add",
"-",
"on",
"code",
"and",
"city",
"or",
"just",
"city",
".",
"There",
"are",
"various",
"allowed",
"styles",
"to",
"pass",
"those",
"val... | 9d360149f29a3e876a55338833e5e6fe89e3622f | https://github.com/apeiros/swissmatch-location/blob/9d360149f29a3e876a55338833e5e6fe89e3622f/lib/swissmatch/zipcodes.rb#L67-L94 | train |
pboling/csv_pirate | lib/csv_pirate/the_capn.rb | CsvPirate.TheCapn.poop_deck | def poop_deck(brig)
if BRIGANTINE_OPTIONS.include?(brig) && !self.flies.empty?
self.old_csv_dump(brig)
elsif brig.is_a?(String)
"#{self.analemma}#{brig}"
else
"#{self.analemma}#{self.swabbie}#{self.aft}"
end
end | ruby | def poop_deck(brig)
if BRIGANTINE_OPTIONS.include?(brig) && !self.flies.empty?
self.old_csv_dump(brig)
elsif brig.is_a?(String)
"#{self.analemma}#{brig}"
else
"#{self.analemma}#{self.swabbie}#{self.aft}"
end
end | [
"def",
"poop_deck",
"(",
"brig",
")",
"if",
"BRIGANTINE_OPTIONS",
".",
"include?",
"(",
"brig",
")",
"&&",
"!",
"self",
".",
"flies",
".",
"empty?",
"self",
".",
"old_csv_dump",
"(",
"brig",
")",
"elsif",
"brig",
".",
"is_a?",
"(",
"String",
")",
"\"#{... | complete file path | [
"complete",
"file",
"path"
] | 3fb0bde9a49b3894bde45d2668fc258eebd61049 | https://github.com/pboling/csv_pirate/blob/3fb0bde9a49b3894bde45d2668fc258eebd61049/lib/csv_pirate/the_capn.rb#L277-L285 | train |
pboling/csv_pirate | lib/csv_pirate/the_capn.rb | CsvPirate.TheCapn.unfurl | def unfurl
wibbly = self.waggoner == '' ? '' : Regexp.escape(self.waggoner)
timey = self.sand_glass == '' ? '' : '\.\d+'
wimey = self.gibbet == '' ? '' : Regexp.escape(self.gibbet)
Regexp.new("#{wibbly}#{timey}#{wimey}")
end | ruby | def unfurl
wibbly = self.waggoner == '' ? '' : Regexp.escape(self.waggoner)
timey = self.sand_glass == '' ? '' : '\.\d+'
wimey = self.gibbet == '' ? '' : Regexp.escape(self.gibbet)
Regexp.new("#{wibbly}#{timey}#{wimey}")
end | [
"def",
"unfurl",
"wibbly",
"=",
"self",
".",
"waggoner",
"==",
"''",
"?",
"''",
":",
"Regexp",
".",
"escape",
"(",
"self",
".",
"waggoner",
")",
"timey",
"=",
"self",
".",
"sand_glass",
"==",
"''",
"?",
"''",
":",
"'\\.\\d+'",
"wimey",
"=",
"self",
... | Regex for matching dumped CSVs | [
"Regex",
"for",
"matching",
"dumped",
"CSVs"
] | 3fb0bde9a49b3894bde45d2668fc258eebd61049 | https://github.com/pboling/csv_pirate/blob/3fb0bde9a49b3894bde45d2668fc258eebd61049/lib/csv_pirate/the_capn.rb#L432-L437 | train |
pboling/csv_pirate | lib/csv_pirate/the_capn.rb | CsvPirate.TheCapn.binnacle | def binnacle(join_value, humanize = true)
self.booty.map do |compass|
string = compass.is_a?(Hash) ?
self.run_through(compass, join_value) :
compass.is_a?(String) ?
compass :
compass.is_a?(Symbol) ?
compass.to_s :
compass.to_s
... | ruby | def binnacle(join_value, humanize = true)
self.booty.map do |compass|
string = compass.is_a?(Hash) ?
self.run_through(compass, join_value) :
compass.is_a?(String) ?
compass :
compass.is_a?(Symbol) ?
compass.to_s :
compass.to_s
... | [
"def",
"binnacle",
"(",
"join_value",
",",
"humanize",
"=",
"true",
")",
"self",
".",
"booty",
".",
"map",
"do",
"|",
"compass",
"|",
"string",
"=",
"compass",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"self",
".",
"run_through",
"(",
"compass",
",",
"joi... | returns an array of strings for CSV header based on booty | [
"returns",
"an",
"array",
"of",
"strings",
"for",
"CSV",
"header",
"based",
"on",
"booty"
] | 3fb0bde9a49b3894bde45d2668fc258eebd61049 | https://github.com/pboling/csv_pirate/blob/3fb0bde9a49b3894bde45d2668fc258eebd61049/lib/csv_pirate/the_capn.rb#L457-L468 | train |
pboling/csv_pirate | lib/csv_pirate/the_capn.rb | CsvPirate.TheCapn.boatswain | def boatswain
return self.swabbie unless self.swabbie.nil?
highval = 0
self.axe.each do |flotsam|
counter = self.filibuster(flotsam)
highval = ((highval <=> counter) == 1) ? highval : counter
end
".#{highval + 1}"
end | ruby | def boatswain
return self.swabbie unless self.swabbie.nil?
highval = 0
self.axe.each do |flotsam|
counter = self.filibuster(flotsam)
highval = ((highval <=> counter) == 1) ? highval : counter
end
".#{highval + 1}"
end | [
"def",
"boatswain",
"return",
"self",
".",
"swabbie",
"unless",
"self",
".",
"swabbie",
".",
"nil?",
"highval",
"=",
"0",
"self",
".",
"axe",
".",
"each",
"do",
"|",
"flotsam",
"|",
"counter",
"=",
"self",
".",
"filibuster",
"(",
"flotsam",
")",
"highv... | File increment for next CSV to dump | [
"File",
"increment",
"for",
"next",
"CSV",
"to",
"dump"
] | 3fb0bde9a49b3894bde45d2668fc258eebd61049 | https://github.com/pboling/csv_pirate/blob/3fb0bde9a49b3894bde45d2668fc258eebd61049/lib/csv_pirate/the_capn.rb#L517-L525 | train |
scrapper/perobs | lib/perobs/FlatFileBlobHeader.rb | PEROBS.FlatFileBlobHeader.write | def write
begin
buf = [ @flags, @length, @id, @crc].pack(FORMAT)
crc = Zlib.crc32(buf, 0)
@file.seek(@addr)
@file.write(buf + [ crc ].pack('L'))
rescue IOError => e
PEROBS.log.fatal "Cannot write blob header into flat file DB: " +
e.message
end
end | ruby | def write
begin
buf = [ @flags, @length, @id, @crc].pack(FORMAT)
crc = Zlib.crc32(buf, 0)
@file.seek(@addr)
@file.write(buf + [ crc ].pack('L'))
rescue IOError => e
PEROBS.log.fatal "Cannot write blob header into flat file DB: " +
e.message
end
end | [
"def",
"write",
"begin",
"buf",
"=",
"[",
"@flags",
",",
"@length",
",",
"@id",
",",
"@crc",
"]",
".",
"pack",
"(",
"FORMAT",
")",
"crc",
"=",
"Zlib",
".",
"crc32",
"(",
"buf",
",",
"0",
")",
"@file",
".",
"seek",
"(",
"@addr",
")",
"@file",
".... | Write the header to a given File. | [
"Write",
"the",
"header",
"to",
"a",
"given",
"File",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/FlatFileBlobHeader.rb#L182-L192 | train |
jeffnyman/tapestry | lib/tapestry/extensions/dom_observer.rb | Watir.Element.dom_updated? | def dom_updated?(delay: 1.1)
element_call do
begin
driver.manage.timeouts.script_timeout = delay + 1
driver.execute_async_script(DOM_OBSERVER, wd, delay)
rescue Selenium::WebDriver::Error::StaleElementReferenceError
# This situation can occur when the DOM changes betw... | ruby | def dom_updated?(delay: 1.1)
element_call do
begin
driver.manage.timeouts.script_timeout = delay + 1
driver.execute_async_script(DOM_OBSERVER, wd, delay)
rescue Selenium::WebDriver::Error::StaleElementReferenceError
# This situation can occur when the DOM changes betw... | [
"def",
"dom_updated?",
"(",
"delay",
":",
"1.1",
")",
"element_call",
"do",
"begin",
"driver",
".",
"manage",
".",
"timeouts",
".",
"script_timeout",
"=",
"delay",
"+",
"1",
"driver",
".",
"execute_async_script",
"(",
"DOM_OBSERVER",
",",
"wd",
",",
"delay",... | This method makes a call to `execute_async_script` which means that the
DOM observer script must explicitly signal that it is finished by
invoking a callback. In this case, the callback is nothing more than
a delay. The delay is being used to allow the DOM to be updated before
script actions continue.
The method ... | [
"This",
"method",
"makes",
"a",
"call",
"to",
"execute_async_script",
"which",
"means",
"that",
"the",
"DOM",
"observer",
"script",
"must",
"explicitly",
"signal",
"that",
"it",
"is",
"finished",
"by",
"invoking",
"a",
"callback",
".",
"In",
"this",
"case",
... | da28652dd6de71e415cd2c01afd89f641938a05b | https://github.com/jeffnyman/tapestry/blob/da28652dd6de71e415cd2c01afd89f641938a05b/lib/tapestry/extensions/dom_observer.rb#L46-L73 | train |
scrapper/perobs | lib/perobs/DataBase.rb | PEROBS.DataBase.serialize | def serialize(obj)
begin
case @serializer
when :marshal
Marshal.dump(obj)
when :json
obj.to_json
when :yaml
YAML.dump(obj)
end
rescue => e
PEROBS.log.fatal "Cannot serialize object as #{@serializer}: " +
e.message
... | ruby | def serialize(obj)
begin
case @serializer
when :marshal
Marshal.dump(obj)
when :json
obj.to_json
when :yaml
YAML.dump(obj)
end
rescue => e
PEROBS.log.fatal "Cannot serialize object as #{@serializer}: " +
e.message
... | [
"def",
"serialize",
"(",
"obj",
")",
"begin",
"case",
"@serializer",
"when",
":marshal",
"Marshal",
".",
"dump",
"(",
"obj",
")",
"when",
":json",
"obj",
".",
"to_json",
"when",
":yaml",
"YAML",
".",
"dump",
"(",
"obj",
")",
"end",
"rescue",
"=>",
"e",... | Serialize the given object using the object serializer.
@param obj [ObjectBase] Object to serialize
@return [String] Serialized version | [
"Serialize",
"the",
"given",
"object",
"using",
"the",
"object",
"serializer",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DataBase.rb#L64-L78 | train |
scrapper/perobs | lib/perobs/DataBase.rb | PEROBS.DataBase.deserialize | def deserialize(raw)
begin
case @serializer
when :marshal
Marshal.load(raw)
when :json
JSON.parse(raw, :create_additions => true)
when :yaml
YAML.load(raw)
end
rescue => e
PEROBS.log.fatal "Cannot de-serialize object with #{@seria... | ruby | def deserialize(raw)
begin
case @serializer
when :marshal
Marshal.load(raw)
when :json
JSON.parse(raw, :create_additions => true)
when :yaml
YAML.load(raw)
end
rescue => e
PEROBS.log.fatal "Cannot de-serialize object with #{@seria... | [
"def",
"deserialize",
"(",
"raw",
")",
"begin",
"case",
"@serializer",
"when",
":marshal",
"Marshal",
".",
"load",
"(",
"raw",
")",
"when",
":json",
"JSON",
".",
"parse",
"(",
"raw",
",",
":create_additions",
"=>",
"true",
")",
"when",
":yaml",
"YAML",
"... | De-serialize the given String into a Ruby object.
@param raw [String]
@return [Hash] Deserialized version | [
"De",
"-",
"serialize",
"the",
"given",
"String",
"into",
"a",
"Ruby",
"object",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DataBase.rb#L83-L97 | train |
scrapper/perobs | lib/perobs/DataBase.rb | PEROBS.DataBase.check_option | def check_option(name)
value = instance_variable_get('@' + name)
if @config.include?(name)
# The database already existed and has a setting for this config
# option. If it does not match the instance variable, adjust the
# instance variable accordingly.
unless @config[name] ... | ruby | def check_option(name)
value = instance_variable_get('@' + name)
if @config.include?(name)
# The database already existed and has a setting for this config
# option. If it does not match the instance variable, adjust the
# instance variable accordingly.
unless @config[name] ... | [
"def",
"check_option",
"(",
"name",
")",
"value",
"=",
"instance_variable_get",
"(",
"'@'",
"+",
"name",
")",
"if",
"@config",
".",
"include?",
"(",
"name",
")",
"unless",
"@config",
"[",
"name",
"]",
"==",
"value",
"instance_variable_set",
"(",
"'@'",
"+"... | Check a config option and adjust it if needed.
@param name [String] Name of the config option. | [
"Check",
"a",
"config",
"option",
"and",
"adjust",
"it",
"if",
"needed",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DataBase.rb#L101-L116 | train |
scrapper/perobs | lib/perobs/DataBase.rb | PEROBS.DataBase.ensure_dir_exists | def ensure_dir_exists(dir)
unless Dir.exist?(dir)
begin
Dir.mkdir(dir)
rescue IOError => e
PEROBS.log.fatal "Cannote create DB directory '#{dir}': #{e.message}"
end
end
end | ruby | def ensure_dir_exists(dir)
unless Dir.exist?(dir)
begin
Dir.mkdir(dir)
rescue IOError => e
PEROBS.log.fatal "Cannote create DB directory '#{dir}': #{e.message}"
end
end
end | [
"def",
"ensure_dir_exists",
"(",
"dir",
")",
"unless",
"Dir",
".",
"exist?",
"(",
"dir",
")",
"begin",
"Dir",
".",
"mkdir",
"(",
"dir",
")",
"rescue",
"IOError",
"=>",
"e",
"PEROBS",
".",
"log",
".",
"fatal",
"\"Cannote create DB directory '#{dir}': #{e.messag... | Ensure that we have a directory to store the DB items. | [
"Ensure",
"that",
"we",
"have",
"a",
"directory",
"to",
"store",
"the",
"DB",
"items",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DataBase.rb#L121-L129 | train |
xinminlabs/synvert-core | lib/synvert/core/rewriter/gem_spec.rb | Synvert::Core.Rewriter::GemSpec.match? | def match?
gemfile_lock_path = File.join(Configuration.instance.get(:path), 'Gemfile.lock')
if File.exists? gemfile_lock_path
parser = Bundler::LockfileParser.new(File.read(gemfile_lock_path))
if spec = parser.specs.find { |spec| spec.name == @name }
Gem::Version.new(spec.version).... | ruby | def match?
gemfile_lock_path = File.join(Configuration.instance.get(:path), 'Gemfile.lock')
if File.exists? gemfile_lock_path
parser = Bundler::LockfileParser.new(File.read(gemfile_lock_path))
if spec = parser.specs.find { |spec| spec.name == @name }
Gem::Version.new(spec.version).... | [
"def",
"match?",
"gemfile_lock_path",
"=",
"File",
".",
"join",
"(",
"Configuration",
".",
"instance",
".",
"get",
"(",
":path",
")",
",",
"'Gemfile.lock'",
")",
"if",
"File",
".",
"exists?",
"gemfile_lock_path",
"parser",
"=",
"Bundler",
"::",
"LockfileParser... | Initialize a gem_spec.
@param name [String] gem name
@param comparator [Hash] comparator to gem version, e.g. {eq: '2.0.0'},
comparator key can be eq, lt, gt, lte, gte or ne.
Check if the specified gem version in Gemfile.lock matches gem_spec comparator.
@return [Boolean] true if matches, otherwise false.
@ra... | [
"Initialize",
"a",
"gem_spec",
"."
] | a490bfd30eaec81002d10f8fb61b49138708e46c | https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/gem_spec.rb#L28-L40 | train |
sethvargo/community-zero | lib/community_zero/endpoints/cookbook_versions_version_endpoint.rb | CommunityZero.CookbookVersionsVersionEndpoint.response_hash_for | def response_hash_for(cookbook)
{
'cookbook' => url_for(cookbook),
'average_rating' => cookbook.average_rating,
'version' => cookbook.version,
'license' => cookbook.license,
'file' => "http://s3.amazonaws.com/#{c... | ruby | def response_hash_for(cookbook)
{
'cookbook' => url_for(cookbook),
'average_rating' => cookbook.average_rating,
'version' => cookbook.version,
'license' => cookbook.license,
'file' => "http://s3.amazonaws.com/#{c... | [
"def",
"response_hash_for",
"(",
"cookbook",
")",
"{",
"'cookbook'",
"=>",
"url_for",
"(",
"cookbook",
")",
",",
"'average_rating'",
"=>",
"cookbook",
".",
"average_rating",
",",
"'version'",
"=>",
"cookbook",
".",
"version",
",",
"'license'",
"=>",
"cookbook",
... | The response hash for this cookbook.
@param [CommunityZero::Cookbook] cookbook
the cookbook to generate a hash for | [
"The",
"response",
"hash",
"for",
"this",
"cookbook",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/endpoints/cookbook_versions_version_endpoint.rb#L45-L56 | train |
notonthehighstreet/chicago | lib/chicago/query.rb | Chicago.Query.order | def order(*ordering)
@order = ordering.map do |c|
if c.kind_of?(String)
{:column => c, :ascending => true}
else
c.symbolize_keys!
end
end
self
end | ruby | def order(*ordering)
@order = ordering.map do |c|
if c.kind_of?(String)
{:column => c, :ascending => true}
else
c.symbolize_keys!
end
end
self
end | [
"def",
"order",
"(",
"*",
"ordering",
")",
"@order",
"=",
"ordering",
".",
"map",
"do",
"|",
"c",
"|",
"if",
"c",
".",
"kind_of?",
"(",
"String",
")",
"{",
":column",
"=>",
"c",
",",
":ascending",
"=>",
"true",
"}",
"else",
"c",
".",
"symbolize_key... | Order the results by the specified columns.
@param ordering an array of hashes, of the form {:column =>
"name", :ascending => true}
@api public | [
"Order",
"the",
"results",
"by",
"the",
"specified",
"columns",
"."
] | 428e94f8089d2f36fdcff2e27ea2af572b816def | https://github.com/notonthehighstreet/chicago/blob/428e94f8089d2f36fdcff2e27ea2af572b816def/lib/chicago/query.rb#L79-L88 | train |
scrapper/perobs | lib/perobs/StackFile.rb | PEROBS.StackFile.close | def close
begin
@f.flush
@f.flock(File::LOCK_UN)
@f.close
rescue IOError => e
PEROBS.log.fatal "Cannot close stack file #{@file_name}: #{e.message}"
end
end | ruby | def close
begin
@f.flush
@f.flock(File::LOCK_UN)
@f.close
rescue IOError => e
PEROBS.log.fatal "Cannot close stack file #{@file_name}: #{e.message}"
end
end | [
"def",
"close",
"begin",
"@f",
".",
"flush",
"@f",
".",
"flock",
"(",
"File",
"::",
"LOCK_UN",
")",
"@f",
".",
"close",
"rescue",
"IOError",
"=>",
"e",
"PEROBS",
".",
"log",
".",
"fatal",
"\"Cannot close stack file #{@file_name}: #{e.message}\"",
"end",
"end"
... | Close the stack file. This method must be called before the program is
terminated to avoid data loss. | [
"Close",
"the",
"stack",
"file",
".",
"This",
"method",
"must",
"be",
"called",
"before",
"the",
"program",
"is",
"terminated",
"to",
"avoid",
"data",
"loss",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/StackFile.rb#L64-L72 | train |
scrapper/perobs | lib/perobs/StackFile.rb | PEROBS.StackFile.push | def push(bytes)
if bytes.length != @entry_bytes
PEROBS.log.fatal "All stack entries must be #{@entry_bytes} " +
"long. This entry is #{bytes.length} bytes long."
end
begin
@f.seek(0, IO::SEEK_END)
@f.write(bytes)
rescue => e
PEROBS.log.fatal "Cannot push... | ruby | def push(bytes)
if bytes.length != @entry_bytes
PEROBS.log.fatal "All stack entries must be #{@entry_bytes} " +
"long. This entry is #{bytes.length} bytes long."
end
begin
@f.seek(0, IO::SEEK_END)
@f.write(bytes)
rescue => e
PEROBS.log.fatal "Cannot push... | [
"def",
"push",
"(",
"bytes",
")",
"if",
"bytes",
".",
"length",
"!=",
"@entry_bytes",
"PEROBS",
".",
"log",
".",
"fatal",
"\"All stack entries must be #{@entry_bytes} \"",
"+",
"\"long. This entry is #{bytes.length} bytes long.\"",
"end",
"begin",
"@f",
".",
"seek",
"... | Push the given bytes onto the stack file.
@param bytes [String] Bytes to write. | [
"Push",
"the",
"given",
"bytes",
"onto",
"the",
"stack",
"file",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/StackFile.rb#L85-L96 | train |
scrapper/perobs | lib/perobs/StackFile.rb | PEROBS.StackFile.pop | def pop
begin
return nil if @f.size == 0
@f.seek(-@entry_bytes, IO::SEEK_END)
bytes = @f.read(@entry_bytes)
@f.truncate(@f.size - @entry_bytes)
@f.flush
rescue => e
PEROBS.log.fatal "Cannot pop from stack file #{@file_name}: " +
e.message
end
... | ruby | def pop
begin
return nil if @f.size == 0
@f.seek(-@entry_bytes, IO::SEEK_END)
bytes = @f.read(@entry_bytes)
@f.truncate(@f.size - @entry_bytes)
@f.flush
rescue => e
PEROBS.log.fatal "Cannot pop from stack file #{@file_name}: " +
e.message
end
... | [
"def",
"pop",
"begin",
"return",
"nil",
"if",
"@f",
".",
"size",
"==",
"0",
"@f",
".",
"seek",
"(",
"-",
"@entry_bytes",
",",
"IO",
"::",
"SEEK_END",
")",
"bytes",
"=",
"@f",
".",
"read",
"(",
"@entry_bytes",
")",
"@f",
".",
"truncate",
"(",
"@f",
... | Pop the last entry from the stack file.
@return [String or nil] Popped entry or nil if stack is already empty. | [
"Pop",
"the",
"last",
"entry",
"from",
"the",
"stack",
"file",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/StackFile.rb#L100-L114 | train |
tagoh/ruby-bugzilla | lib/bugzilla/bug.rb | Bugzilla.Bug.get_comments | def get_comments(bugs)
params = {}
if bugs.kind_of?(Array) then
params['ids'] = bugs
elsif bugs.kind_of?(Integer) ||
bugs.kind_of?(String) then
params['ids'] = [bugs]
else
raise ArgumentError, sprintf("Unknown type of arguments: %s", bugs.class)
end
... | ruby | def get_comments(bugs)
params = {}
if bugs.kind_of?(Array) then
params['ids'] = bugs
elsif bugs.kind_of?(Integer) ||
bugs.kind_of?(String) then
params['ids'] = [bugs]
else
raise ArgumentError, sprintf("Unknown type of arguments: %s", bugs.class)
end
... | [
"def",
"get_comments",
"(",
"bugs",
")",
"params",
"=",
"{",
"}",
"if",
"bugs",
".",
"kind_of?",
"(",
"Array",
")",
"then",
"params",
"[",
"'ids'",
"]",
"=",
"bugs",
"elsif",
"bugs",
".",
"kind_of?",
"(",
"Integer",
")",
"||",
"bugs",
".",
"kind_of?"... | def get_bugs
=begin rdoc
==== Bugzilla::Bug#get_comments(bugs)
=end | [
"def",
"get_bugs",
"=",
"begin",
"rdoc"
] | 5aabec1b045473bcd6e6ac7427b68adb3e3b4886 | https://github.com/tagoh/ruby-bugzilla/blob/5aabec1b045473bcd6e6ac7427b68adb3e3b4886/lib/bugzilla/bug.rb#L107-L123 | train |
jeffnyman/tapestry | lib/tapestry/ready.rb | Tapestry.Ready.when_ready | def when_ready(simple_check = false, &_block)
already_marked_ready = ready
unless simple_check
no_ready_check_possible unless block_given?
end
self.ready = ready?
not_ready_validation(ready_error || 'NO REASON PROVIDED') unless ready
yield self if block_given?
ensure
... | ruby | def when_ready(simple_check = false, &_block)
already_marked_ready = ready
unless simple_check
no_ready_check_possible unless block_given?
end
self.ready = ready?
not_ready_validation(ready_error || 'NO REASON PROVIDED') unless ready
yield self if block_given?
ensure
... | [
"def",
"when_ready",
"(",
"simple_check",
"=",
"false",
",",
"&",
"_block",
")",
"already_marked_ready",
"=",
"ready",
"unless",
"simple_check",
"no_ready_check_possible",
"unless",
"block_given?",
"end",
"self",
".",
"ready",
"=",
"ready?",
"not_ready_validation",
... | The `when_ready` method is called on an instance of an interface. This
executes the provided validation block after the page has been loaded.
The Ready object instance is yielded into the block.
Calls to the `ready?` method use a poor-man's cache approach. The idea
here being that when a page has confirmed that it... | [
"The",
"when_ready",
"method",
"is",
"called",
"on",
"an",
"instance",
"of",
"an",
"interface",
".",
"This",
"executes",
"the",
"provided",
"validation",
"block",
"after",
"the",
"page",
"has",
"been",
"loaded",
".",
"The",
"Ready",
"object",
"instance",
"is... | da28652dd6de71e415cd2c01afd89f641938a05b | https://github.com/jeffnyman/tapestry/blob/da28652dd6de71e415cd2c01afd89f641938a05b/lib/tapestry/ready.rb#L55-L68 | train |
jeffnyman/tapestry | lib/tapestry/ready.rb | Tapestry.Ready.ready_validations_pass? | def ready_validations_pass?
self.class.ready_validations.all? do |validation|
passed, message = instance_eval(&validation)
self.ready_error = message if message && !passed
passed
end
end | ruby | def ready_validations_pass?
self.class.ready_validations.all? do |validation|
passed, message = instance_eval(&validation)
self.ready_error = message if message && !passed
passed
end
end | [
"def",
"ready_validations_pass?",
"self",
".",
"class",
".",
"ready_validations",
".",
"all?",
"do",
"|",
"validation",
"|",
"passed",
",",
"message",
"=",
"instance_eval",
"(",
"&",
"validation",
")",
"self",
".",
"ready_error",
"=",
"message",
"if",
"message... | This method checks if the ready validations that have been specified
have passed. If any ready validation fails, no matter if others have
succeeded, this method immediately returns false. | [
"This",
"method",
"checks",
"if",
"the",
"ready",
"validations",
"that",
"have",
"been",
"specified",
"have",
"passed",
".",
"If",
"any",
"ready",
"validation",
"fails",
"no",
"matter",
"if",
"others",
"have",
"succeeded",
"this",
"method",
"immediately",
"ret... | da28652dd6de71e415cd2c01afd89f641938a05b | https://github.com/jeffnyman/tapestry/blob/da28652dd6de71e415cd2c01afd89f641938a05b/lib/tapestry/ready.rb#L92-L98 | train |
xinminlabs/synvert-core | lib/synvert/core/rewriter/condition/unless_exist_condition.rb | Synvert::Core.Rewriter::UnlessExistCondition.match? | def match?
match = false
@instance.current_node.recursive_children do |child_node|
match = match || (child_node && child_node.match?(@rules))
end
!match
end | ruby | def match?
match = false
@instance.current_node.recursive_children do |child_node|
match = match || (child_node && child_node.match?(@rules))
end
!match
end | [
"def",
"match?",
"match",
"=",
"false",
"@instance",
".",
"current_node",
".",
"recursive_children",
"do",
"|",
"child_node",
"|",
"match",
"=",
"match",
"||",
"(",
"child_node",
"&&",
"child_node",
".",
"match?",
"(",
"@rules",
")",
")",
"end",
"!",
"matc... | check if none of child node matches the rules. | [
"check",
"if",
"none",
"of",
"child",
"node",
"matches",
"the",
"rules",
"."
] | a490bfd30eaec81002d10f8fb61b49138708e46c | https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/condition/unless_exist_condition.rb#L7-L13 | train |
pupeno/random_unique_id | lib/random_unique_id.rb | RandomUniqueId.ClassMethods.add_rid_related_validations | def add_rid_related_validations(options)
validates(options[:field], presence: true)
validates(options[:field], uniqueness: true) if options[:random_generation_method] != :uuid # If we're generating UUIDs, don't check for uniqueness
end | ruby | def add_rid_related_validations(options)
validates(options[:field], presence: true)
validates(options[:field], uniqueness: true) if options[:random_generation_method] != :uuid # If we're generating UUIDs, don't check for uniqueness
end | [
"def",
"add_rid_related_validations",
"(",
"options",
")",
"validates",
"(",
"options",
"[",
":field",
"]",
",",
"presence",
":",
"true",
")",
"validates",
"(",
"options",
"[",
":field",
"]",
",",
"uniqueness",
":",
"true",
")",
"if",
"options",
"[",
":ran... | Add the rid related validations to the model.
@param options [Hash] same as in RandomUniqueID.config | [
"Add",
"the",
"rid",
"related",
"validations",
"to",
"the",
"model",
"."
] | bab61f23a17a3f6ba9f7bc255805d4f9d34b8bfc | https://github.com/pupeno/random_unique_id/blob/bab61f23a17a3f6ba9f7bc255805d4f9d34b8bfc/lib/random_unique_id.rb#L118-L121 | train |
pupeno/random_unique_id | lib/random_unique_id.rb | RandomUniqueId.ClassMethods.define_rid_accessors | def define_rid_accessors(related_class, relationship_name)
define_method("#{relationship_name}_rid") do
self.send(relationship_name).try(random_unique_id_options[:field])
end
define_method("#{relationship_name}_rid=") do |rid|
record = related_class.find_by_rid(rid)
self.send(... | ruby | def define_rid_accessors(related_class, relationship_name)
define_method("#{relationship_name}_rid") do
self.send(relationship_name).try(random_unique_id_options[:field])
end
define_method("#{relationship_name}_rid=") do |rid|
record = related_class.find_by_rid(rid)
self.send(... | [
"def",
"define_rid_accessors",
"(",
"related_class",
",",
"relationship_name",
")",
"define_method",
"(",
"\"#{relationship_name}_rid\"",
")",
"do",
"self",
".",
"send",
"(",
"relationship_name",
")",
".",
"try",
"(",
"random_unique_id_options",
"[",
":field",
"]",
... | Defines the setter and getter for the RID of a relationship.
@param related_class [Class] class in which the RID methods are going to be defined.
@param relationship_name [String] name of the relationship for which the RID methods are going to be defined.
@see RandomUniqueId::ClassMethods.belongs_to | [
"Defines",
"the",
"setter",
"and",
"getter",
"for",
"the",
"RID",
"of",
"a",
"relationship",
"."
] | bab61f23a17a3f6ba9f7bc255805d4f9d34b8bfc | https://github.com/pupeno/random_unique_id/blob/bab61f23a17a3f6ba9f7bc255805d4f9d34b8bfc/lib/random_unique_id.rb#L128-L138 | train |
code-and-effect/effective_pages | app/models/effective/menu.rb | Effective.Menu.build | def build(&block)
raise 'build must be called with a block' if !block_given?
root = menu_items.build(title: 'Home', url: '/', lft: 1, rgt: 2)
root.parent = true
instance_exec(&block) # A call to dropdown or item
root.rgt = menu_items.map(&:rgt).max
self
end | ruby | def build(&block)
raise 'build must be called with a block' if !block_given?
root = menu_items.build(title: 'Home', url: '/', lft: 1, rgt: 2)
root.parent = true
instance_exec(&block) # A call to dropdown or item
root.rgt = menu_items.map(&:rgt).max
self
end | [
"def",
"build",
"(",
"&",
"block",
")",
"raise",
"'build must be called with a block'",
"if",
"!",
"block_given?",
"root",
"=",
"menu_items",
".",
"build",
"(",
"title",
":",
"'Home'",
",",
"url",
":",
"'/'",
",",
"lft",
":",
"1",
",",
"rgt",
":",
"2",
... | This is the entry point to the DSL method for creating menu items | [
"This",
"is",
"the",
"entry",
"point",
"to",
"the",
"DSL",
"method",
"for",
"creating",
"menu",
"items"
] | ff00e2d76055985ab65f570747bc9a5f2748f817 | https://github.com/code-and-effect/effective_pages/blob/ff00e2d76055985ab65f570747bc9a5f2748f817/app/models/effective/menu.rb#L58-L66 | train |
scrapper/perobs | lib/perobs/BTreeNode.rb | PEROBS.BTreeNode.search_key_index | def search_key_index(key)
# Handle special case for empty keys list.
return 0 if @keys.empty?
# Keys are unique and always sorted. Use a binary search to find the
# index that fits the given key.
li = pi = 0
ui = @keys.size - 1
while li <= ui
# The pivot element is alw... | ruby | def search_key_index(key)
# Handle special case for empty keys list.
return 0 if @keys.empty?
# Keys are unique and always sorted. Use a binary search to find the
# index that fits the given key.
li = pi = 0
ui = @keys.size - 1
while li <= ui
# The pivot element is alw... | [
"def",
"search_key_index",
"(",
"key",
")",
"return",
"0",
"if",
"@keys",
".",
"empty?",
"li",
"=",
"pi",
"=",
"0",
"ui",
"=",
"@keys",
".",
"size",
"-",
"1",
"while",
"li",
"<=",
"ui",
"pi",
"=",
"li",
"+",
"(",
"ui",
"-",
"li",
")",
"/",
"2... | Search the keys of the node that fits the given key. The result is
either the index of an exact match or the index of the position where
the given key would have to be inserted.
@param key [Integer] key to search for
@return [Integer] Index of the matching key or the insert position. | [
"Search",
"the",
"keys",
"of",
"the",
"node",
"that",
"fits",
"the",
"given",
"key",
".",
"The",
"result",
"is",
"either",
"the",
"index",
"of",
"an",
"exact",
"match",
"or",
"the",
"index",
"of",
"the",
"position",
"where",
"the",
"given",
"key",
"wou... | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BTreeNode.rb#L563-L594 | train |
astro/ruby-sasl | lib/sasl/digest_md5.rb | SASL.DigestMD5.response_value | def response_value(nonce, nc, cnonce, qop, a2_prefix='AUTHENTICATE')
a1_h = h("#{preferences.username}:#{preferences.realm}:#{preferences.password}")
a1 = "#{a1_h}:#{nonce}:#{cnonce}"
if preferences.authzid
a1 += ":#{preferences.authzid}"
end
if qop && (qop.downcase == 'auth-int' |... | ruby | def response_value(nonce, nc, cnonce, qop, a2_prefix='AUTHENTICATE')
a1_h = h("#{preferences.username}:#{preferences.realm}:#{preferences.password}")
a1 = "#{a1_h}:#{nonce}:#{cnonce}"
if preferences.authzid
a1 += ":#{preferences.authzid}"
end
if qop && (qop.downcase == 'auth-int' |... | [
"def",
"response_value",
"(",
"nonce",
",",
"nc",
",",
"cnonce",
",",
"qop",
",",
"a2_prefix",
"=",
"'AUTHENTICATE'",
")",
"a1_h",
"=",
"h",
"(",
"\"#{preferences.username}:#{preferences.realm}:#{preferences.password}\"",
")",
"a1",
"=",
"\"#{a1_h}:#{nonce}:#{cnonce}\""... | Calculate the value for the response field | [
"Calculate",
"the",
"value",
"for",
"the",
"response",
"field"
] | e54d8950c9cfb6a51066fcbbe3ada9f0121aa7f4 | https://github.com/astro/ruby-sasl/blob/e54d8950c9cfb6a51066fcbbe3ada9f0121aa7f4/lib/sasl/digest_md5.rb#L139-L151 | train |
regru/reg_api2-ruby | lib/reg_api2/request_contract.rb | RegApi2.RequestContract.to_hash | def to_hash arr
return {} if arr.nil?
return arr if arr.kind_of?(Hash)
arr = [ arr.to_sym ] unless arr.kind_of?(Array)
ret = {}
arr.each { |key| ret[key.to_sym] = {} }
ret
end | ruby | def to_hash arr
return {} if arr.nil?
return arr if arr.kind_of?(Hash)
arr = [ arr.to_sym ] unless arr.kind_of?(Array)
ret = {}
arr.each { |key| ret[key.to_sym] = {} }
ret
end | [
"def",
"to_hash",
"arr",
"return",
"{",
"}",
"if",
"arr",
".",
"nil?",
"return",
"arr",
"if",
"arr",
".",
"kind_of?",
"(",
"Hash",
")",
"arr",
"=",
"[",
"arr",
".",
"to_sym",
"]",
"unless",
"arr",
".",
"kind_of?",
"(",
"Array",
")",
"ret",
"=",
"... | Normalizes `required` and `optional` fields to the form of Hash with options.
@param [NilClass,Hash,Array, etc.] arr Something to normalize. | [
"Normalizes",
"required",
"and",
"optional",
"fields",
"to",
"the",
"form",
"of",
"Hash",
"with",
"options",
"."
] | 82fadffc9da6534761003b8a33edb77ab617df70 | https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L21-L28 | train |
regru/reg_api2-ruby | lib/reg_api2/request_contract.rb | RegApi2.RequestContract.fields_to_validate | def fields_to_validate
required_fields = to_hash opts[:required]
optional_fields = to_hash opts[:optional]
required_fields.keys.each { |key| required_fields[key][:required] = true }
optional_fields.merge(required_fields)
end | ruby | def fields_to_validate
required_fields = to_hash opts[:required]
optional_fields = to_hash opts[:optional]
required_fields.keys.each { |key| required_fields[key][:required] = true }
optional_fields.merge(required_fields)
end | [
"def",
"fields_to_validate",
"required_fields",
"=",
"to_hash",
"opts",
"[",
":required",
"]",
"optional_fields",
"=",
"to_hash",
"opts",
"[",
":optional",
"]",
"required_fields",
".",
"keys",
".",
"each",
"{",
"|",
"key",
"|",
"required_fields",
"[",
"key",
"... | Gets fields to validate
@return [Hash] Fields to validate. | [
"Gets",
"fields",
"to",
"validate"
] | 82fadffc9da6534761003b8a33edb77ab617df70 | https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L32-L37 | train |
regru/reg_api2-ruby | lib/reg_api2/request_contract.rb | RegApi2.RequestContract.validate_ipaddr | def validate_ipaddr key, value, opts
if opts[:ipaddr] == true && value.kind_of?(String)
value = IPAddr.new(value)
end
value.to_s
end | ruby | def validate_ipaddr key, value, opts
if opts[:ipaddr] == true && value.kind_of?(String)
value = IPAddr.new(value)
end
value.to_s
end | [
"def",
"validate_ipaddr",
"key",
",",
"value",
",",
"opts",
"if",
"opts",
"[",
":ipaddr",
"]",
"==",
"true",
"&&",
"value",
".",
"kind_of?",
"(",
"String",
")",
"value",
"=",
"IPAddr",
".",
"new",
"(",
"value",
")",
"end",
"value",
".",
"to_s",
"end"... | Validates specified `value` with `ipaddr` field.
@param [Object] key Value to validate.
@param [Object] value Value to validate.
@param [Hash] opts opts with optional ipaddr field.
@return [String] Updated `value` | [
"Validates",
"specified",
"value",
"with",
"ipaddr",
"field",
"."
] | 82fadffc9da6534761003b8a33edb77ab617df70 | https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L73-L78 | train |
regru/reg_api2-ruby | lib/reg_api2/request_contract.rb | RegApi2.RequestContract.validate_presence_of_required_fields | def validate_presence_of_required_fields form, fields
absent_fields = []
fields.each_pair do |key, opts|
next unless opts[:required]
if !form.has_key?(key) || form[key].nil?
absent_fields << key
end
end
unless absent_fields.empty?
raise RegApi2::Contrac... | ruby | def validate_presence_of_required_fields form, fields
absent_fields = []
fields.each_pair do |key, opts|
next unless opts[:required]
if !form.has_key?(key) || form[key].nil?
absent_fields << key
end
end
unless absent_fields.empty?
raise RegApi2::Contrac... | [
"def",
"validate_presence_of_required_fields",
"form",
",",
"fields",
"absent_fields",
"=",
"[",
"]",
"fields",
".",
"each_pair",
"do",
"|",
"key",
",",
"opts",
"|",
"next",
"unless",
"opts",
"[",
":required",
"]",
"if",
"!",
"form",
".",
"has_key?",
"(",
... | Validates specified `form` for presence of all required fields.
@param [Hash] form Form to validate.
@param [Hash] fields Fields to test.
return void
@raise ContractError | [
"Validates",
"specified",
"form",
"for",
"presence",
"of",
"all",
"required",
"fields",
"."
] | 82fadffc9da6534761003b8a33edb77ab617df70 | https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L85-L100 | train |
regru/reg_api2-ruby | lib/reg_api2/request_contract.rb | RegApi2.RequestContract.validate | def validate(form)
fields = fields_to_validate
return form if fields.empty?
validate_presence_of_required_fields form, fields
fields.each_pair do |key, opts|
next if !form.has_key?(key) || form[key].nil?
form[key] = validate_re key, form[key], opts
form[key] = valida... | ruby | def validate(form)
fields = fields_to_validate
return form if fields.empty?
validate_presence_of_required_fields form, fields
fields.each_pair do |key, opts|
next if !form.has_key?(key) || form[key].nil?
form[key] = validate_re key, form[key], opts
form[key] = valida... | [
"def",
"validate",
"(",
"form",
")",
"fields",
"=",
"fields_to_validate",
"return",
"form",
"if",
"fields",
".",
"empty?",
"validate_presence_of_required_fields",
"form",
",",
"fields",
"fields",
".",
"each_pair",
"do",
"|",
"key",
",",
"opts",
"|",
"next",
"i... | Validates specified `form` with `required` and `optional` fields.
@param [Hash] form Form to validate.
@return [Hash] Updated form.
@raise ContractError | [
"Validates",
"specified",
"form",
"with",
"required",
"and",
"optional",
"fields",
"."
] | 82fadffc9da6534761003b8a33edb77ab617df70 | https://github.com/regru/reg_api2-ruby/blob/82fadffc9da6534761003b8a33edb77ab617df70/lib/reg_api2/request_contract.rb#L106-L121 | train |
scrapper/perobs | lib/perobs/BigTreeNode.rb | PEROBS.BigTreeNode.has_key? | def has_key?(key)
node = self
while node do
# Find index of the entry that best fits the key.
i = node.search_key_index(key)
if node.is_leaf?
# This is a leaf node. Check if there is an exact match for the
# given key and return the corresponding value or nil.
... | ruby | def has_key?(key)
node = self
while node do
# Find index of the entry that best fits the key.
i = node.search_key_index(key)
if node.is_leaf?
# This is a leaf node. Check if there is an exact match for the
# given key and return the corresponding value or nil.
... | [
"def",
"has_key?",
"(",
"key",
")",
"node",
"=",
"self",
"while",
"node",
"do",
"i",
"=",
"node",
".",
"search_key_index",
"(",
"key",
")",
"if",
"node",
".",
"is_leaf?",
"return",
"node",
".",
"keys",
"[",
"i",
"]",
"==",
"key",
"end",
"node",
"="... | Return if given key is stored in the node.
@param key [Integer] key to search for
@return [Boolean] True if key was found, false otherwise | [
"Return",
"if",
"given",
"key",
"is",
"stored",
"in",
"the",
"node",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigTreeNode.rb#L169-L187 | train |
scrapper/perobs | lib/perobs/BigTreeNode.rb | PEROBS.BigTreeNode.remove_element | def remove_element(index)
# Delete the key at the specified index.
unless (key = @keys.delete_at(index))
PEROBS.log.fatal "Could not remove element #{index} from BigTreeNode " +
"@#{@_id}"
end
update_branch_key(key) if index == 0
# Delete the corresponding value.
r... | ruby | def remove_element(index)
# Delete the key at the specified index.
unless (key = @keys.delete_at(index))
PEROBS.log.fatal "Could not remove element #{index} from BigTreeNode " +
"@#{@_id}"
end
update_branch_key(key) if index == 0
# Delete the corresponding value.
r... | [
"def",
"remove_element",
"(",
"index",
")",
"unless",
"(",
"key",
"=",
"@keys",
".",
"delete_at",
"(",
"index",
")",
")",
"PEROBS",
".",
"log",
".",
"fatal",
"\"Could not remove element #{index} from BigTreeNode \"",
"+",
"\"@#{@_id}\"",
"end",
"update_branch_key",
... | Remove the element from a leaf node at the given index.
@param index [Integer] The index of the entry to be removed
@return [Object] The removed value | [
"Remove",
"the",
"element",
"from",
"a",
"leaf",
"node",
"at",
"the",
"given",
"index",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigTreeNode.rb#L518-L543 | train |
scrapper/perobs | lib/perobs/BigTreeNode.rb | PEROBS.BigTreeNode.remove_child | def remove_child(node)
unless (index = search_node_index(node))
PEROBS.log.fatal "Cannot remove child #{node._id} from node #{@_id}"
end
if index == 0
# Removing the first child is a bit more complicated as the
# corresponding branch key is in a parent node.
key = @key... | ruby | def remove_child(node)
unless (index = search_node_index(node))
PEROBS.log.fatal "Cannot remove child #{node._id} from node #{@_id}"
end
if index == 0
# Removing the first child is a bit more complicated as the
# corresponding branch key is in a parent node.
key = @key... | [
"def",
"remove_child",
"(",
"node",
")",
"unless",
"(",
"index",
"=",
"search_node_index",
"(",
"node",
")",
")",
"PEROBS",
".",
"log",
".",
"fatal",
"\"Cannot remove child #{node._id} from node #{@_id}\"",
"end",
"if",
"index",
"==",
"0",
"key",
"=",
"@keys",
... | Remove the specified node from this branch node.
@param node [BigTreeNode] The child to remove | [
"Remove",
"the",
"specified",
"node",
"from",
"this",
"branch",
"node",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigTreeNode.rb#L547-L591 | train |
scrapper/perobs | lib/perobs/BigTreeNode.rb | PEROBS.BigTreeNode.statistics | def statistics(stats)
traverse do |node, position, stack|
if position == 0
if node.is_leaf?
stats.leaf_nodes += 1
depth = stack.size + 1
if stats.min_depth.nil? || stats.min_depth < depth
stats.min_depth = depth
end
if sta... | ruby | def statistics(stats)
traverse do |node, position, stack|
if position == 0
if node.is_leaf?
stats.leaf_nodes += 1
depth = stack.size + 1
if stats.min_depth.nil? || stats.min_depth < depth
stats.min_depth = depth
end
if sta... | [
"def",
"statistics",
"(",
"stats",
")",
"traverse",
"do",
"|",
"node",
",",
"position",
",",
"stack",
"|",
"if",
"position",
"==",
"0",
"if",
"node",
".",
"is_leaf?",
"stats",
".",
"leaf_nodes",
"+=",
"1",
"depth",
"=",
"stack",
".",
"size",
"+",
"1"... | Gather some statistics about the node and all sub nodes.
@param stats [Stats] Data structure that stores the gathered data | [
"Gather",
"some",
"statistics",
"about",
"the",
"node",
"and",
"all",
"sub",
"nodes",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BigTreeNode.rb#L702-L719 | train |
scrapper/perobs | lib/perobs/BTreeDB.rb | PEROBS.BTreeDB.include? | def include?(id)
!(blob = find_blob(id)).nil? && !blob.find(id).nil?
end | ruby | def include?(id)
!(blob = find_blob(id)).nil? && !blob.find(id).nil?
end | [
"def",
"include?",
"(",
"id",
")",
"!",
"(",
"blob",
"=",
"find_blob",
"(",
"id",
")",
")",
".",
"nil?",
"&&",
"!",
"blob",
".",
"find",
"(",
"id",
")",
".",
"nil?",
"end"
] | Return true if the object with given ID exists
@param id [Integer] | [
"Return",
"true",
"if",
"the",
"object",
"with",
"given",
"ID",
"exists"
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BTreeDB.rb#L107-L109 | train |
scrapper/perobs | lib/perobs/BTreeDB.rb | PEROBS.BTreeDB.get_object | def get_object(id)
return nil unless (blob = find_blob(id)) && (obj = blob.read_object(id))
deserialize(obj)
end | ruby | def get_object(id)
return nil unless (blob = find_blob(id)) && (obj = blob.read_object(id))
deserialize(obj)
end | [
"def",
"get_object",
"(",
"id",
")",
"return",
"nil",
"unless",
"(",
"blob",
"=",
"find_blob",
"(",
"id",
")",
")",
"&&",
"(",
"obj",
"=",
"blob",
".",
"read_object",
"(",
"id",
")",
")",
"deserialize",
"(",
"obj",
")",
"end"
] | Load the given object from the filesystem.
@param id [Integer] object ID
@return [Hash] Object as defined by PEROBS::ObjectBase or nil if ID does
not exist | [
"Load",
"the",
"given",
"object",
"from",
"the",
"filesystem",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BTreeDB.rb#L149-L152 | train |
scrapper/perobs | lib/perobs/BTreeDB.rb | PEROBS.BTreeDB.is_marked? | def is_marked?(id, ignore_errors = false)
(blob = find_blob(id)) && blob.is_marked?(id, ignore_errors)
end | ruby | def is_marked?(id, ignore_errors = false)
(blob = find_blob(id)) && blob.is_marked?(id, ignore_errors)
end | [
"def",
"is_marked?",
"(",
"id",
",",
"ignore_errors",
"=",
"false",
")",
"(",
"blob",
"=",
"find_blob",
"(",
"id",
")",
")",
"&&",
"blob",
".",
"is_marked?",
"(",
"id",
",",
"ignore_errors",
")",
"end"
] | Check if the object is marked.
@param id [Integer] ID of the object to check
@param ignore_errors [Boolean] If set to true no errors will be raised
for non-existing objects. | [
"Check",
"if",
"the",
"object",
"is",
"marked",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/BTreeDB.rb#L178-L180 | train |
dalehamel/cloudshaper | lib/cloudshaper/command.rb | Cloudshaper.Command.env | def env
vars = {}
@stack.variables.each { |k, v| vars["TF_VAR_#{k}"] = v }
SECRETS.each do |_provider, secrets|
if secrets.is_a?(Hash)
secrets.each do |k, v|
vars[k.to_s] = v
end
end
end
vars
end | ruby | def env
vars = {}
@stack.variables.each { |k, v| vars["TF_VAR_#{k}"] = v }
SECRETS.each do |_provider, secrets|
if secrets.is_a?(Hash)
secrets.each do |k, v|
vars[k.to_s] = v
end
end
end
vars
end | [
"def",
"env",
"vars",
"=",
"{",
"}",
"@stack",
".",
"variables",
".",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"vars",
"[",
"\"TF_VAR_#{k}\"",
"]",
"=",
"v",
"}",
"SECRETS",
".",
"each",
"do",
"|",
"_provider",
",",
"secrets",
"|",
"if",
"secrets",
... | fixme - make these shell safe | [
"fixme",
"-",
"make",
"these",
"shell",
"safe"
] | bcfeb18fd9853f782b7aa81ebe3f84d69e17e5b4 | https://github.com/dalehamel/cloudshaper/blob/bcfeb18fd9853f782b7aa81ebe3f84d69e17e5b4/lib/cloudshaper/command.rb#L14-L25 | train |
sethvargo/community-zero | lib/community_zero/store.rb | CommunityZero.Store.search | def search(query)
regex = Regexp.new(query, 'i')
_cookbooks.collect do |_, v|
v[v.keys.first] if regex.match(v[v.keys.first].name)
end.compact
end | ruby | def search(query)
regex = Regexp.new(query, 'i')
_cookbooks.collect do |_, v|
v[v.keys.first] if regex.match(v[v.keys.first].name)
end.compact
end | [
"def",
"search",
"(",
"query",
")",
"regex",
"=",
"Regexp",
".",
"new",
"(",
"query",
",",
"'i'",
")",
"_cookbooks",
".",
"collect",
"do",
"|",
"_",
",",
"v",
"|",
"v",
"[",
"v",
".",
"keys",
".",
"first",
"]",
"if",
"regex",
".",
"match",
"(",... | Query the installed cookbooks, returning those who's name matches the
given query.
@param [String] query
the query parameter
@return [Array<CommunityZero::Cookbook>]
the list of cookbooks that match the given query | [
"Query",
"the",
"installed",
"cookbooks",
"returning",
"those",
"who",
"s",
"name",
"matches",
"the",
"given",
"query",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L51-L56 | train |
sethvargo/community-zero | lib/community_zero/store.rb | CommunityZero.Store.add | def add(cookbook)
cookbook = cookbook.dup
cookbook.created_at = Time.now
cookbook.updated_at = Time.now
entry = _cookbooks[cookbook.name] ||= {}
entry[cookbook.version] = cookbook
end | ruby | def add(cookbook)
cookbook = cookbook.dup
cookbook.created_at = Time.now
cookbook.updated_at = Time.now
entry = _cookbooks[cookbook.name] ||= {}
entry[cookbook.version] = cookbook
end | [
"def",
"add",
"(",
"cookbook",
")",
"cookbook",
"=",
"cookbook",
".",
"dup",
"cookbook",
".",
"created_at",
"=",
"Time",
".",
"now",
"cookbook",
".",
"updated_at",
"=",
"Time",
".",
"now",
"entry",
"=",
"_cookbooks",
"[",
"cookbook",
".",
"name",
"]",
... | Add the given cookbook to the cookbook store. This method's
implementation prohibits duplicate cookbooks from entering the store.
@param [CommunityZero::Cookbook] cookbook
the cookbook to add | [
"Add",
"the",
"given",
"cookbook",
"to",
"the",
"cookbook",
"store",
".",
"This",
"method",
"s",
"implementation",
"prohibits",
"duplicate",
"cookbooks",
"from",
"entering",
"the",
"store",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L68-L75 | train |
sethvargo/community-zero | lib/community_zero/store.rb | CommunityZero.Store.remove | def remove(cookbook)
return unless has_cookbook?(cookbook.name, cookbook.version)
_cookbooks[cookbook.name].delete(cookbook.version)
end | ruby | def remove(cookbook)
return unless has_cookbook?(cookbook.name, cookbook.version)
_cookbooks[cookbook.name].delete(cookbook.version)
end | [
"def",
"remove",
"(",
"cookbook",
")",
"return",
"unless",
"has_cookbook?",
"(",
"cookbook",
".",
"name",
",",
"cookbook",
".",
"version",
")",
"_cookbooks",
"[",
"cookbook",
".",
"name",
"]",
".",
"delete",
"(",
"cookbook",
".",
"version",
")",
"end"
] | Remove the cookbook from the store.
@param [CommunityZero::Cookbook] cookbook
the cookbook to remove | [
"Remove",
"the",
"cookbook",
"from",
"the",
"store",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L82-L85 | train |
sethvargo/community-zero | lib/community_zero/store.rb | CommunityZero.Store.find | def find(name, version = nil)
possibles = _cookbooks[name]
return nil if possibles.nil?
version ||= possibles.keys.sort.last
possibles[version]
end | ruby | def find(name, version = nil)
possibles = _cookbooks[name]
return nil if possibles.nil?
version ||= possibles.keys.sort.last
possibles[version]
end | [
"def",
"find",
"(",
"name",
",",
"version",
"=",
"nil",
")",
"possibles",
"=",
"_cookbooks",
"[",
"name",
"]",
"return",
"nil",
"if",
"possibles",
".",
"nil?",
"version",
"||=",
"possibles",
".",
"keys",
".",
"sort",
".",
"last",
"possibles",
"[",
"ver... | Determine if the cookbook store contains a cookbook. If the version
attribute is nil, this method will return the latest cookbook version by
that name that exists. If the version is specified, this method will only
return that specific version, or nil if that cookbook at that version
exists.
@param [String] name
... | [
"Determine",
"if",
"the",
"cookbook",
"store",
"contains",
"a",
"cookbook",
".",
"If",
"the",
"version",
"attribute",
"is",
"nil",
"this",
"method",
"will",
"return",
"the",
"latest",
"cookbook",
"version",
"by",
"that",
"name",
"that",
"exists",
".",
"If",
... | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L107-L113 | train |
sethvargo/community-zero | lib/community_zero/store.rb | CommunityZero.Store.versions | def versions(name)
name = name.respond_to?(:name) ? name.name : name
(_cookbooks[name] && _cookbooks[name].keys.sort) || []
end | ruby | def versions(name)
name = name.respond_to?(:name) ? name.name : name
(_cookbooks[name] && _cookbooks[name].keys.sort) || []
end | [
"def",
"versions",
"(",
"name",
")",
"name",
"=",
"name",
".",
"respond_to?",
"(",
":name",
")",
"?",
"name",
".",
"name",
":",
"name",
"(",
"_cookbooks",
"[",
"name",
"]",
"&&",
"_cookbooks",
"[",
"name",
"]",
".",
"keys",
".",
"sort",
")",
"||",
... | Return a list of all versions for the given cookbook.
@param [String, CommunityZero::Cookbook] name
the cookbook or name of the cookbook to get versions for | [
"Return",
"a",
"list",
"of",
"all",
"versions",
"for",
"the",
"given",
"cookbook",
"."
] | 08a22c47c865deb6a5f931cb4d9f747a2b9d3459 | https://github.com/sethvargo/community-zero/blob/08a22c47c865deb6a5f931cb4d9f747a2b9d3459/lib/community_zero/store.rb#L119-L122 | train |
scrapper/perobs | lib/perobs/Hash.rb | PEROBS.Hash._referenced_object_ids | def _referenced_object_ids
@data.each_value.select { |v| v && v.respond_to?(:is_poxreference?) }.
map { |o| o.id }
end | ruby | def _referenced_object_ids
@data.each_value.select { |v| v && v.respond_to?(:is_poxreference?) }.
map { |o| o.id }
end | [
"def",
"_referenced_object_ids",
"@data",
".",
"each_value",
".",
"select",
"{",
"|",
"v",
"|",
"v",
"&&",
"v",
".",
"respond_to?",
"(",
":is_poxreference?",
")",
"}",
".",
"map",
"{",
"|",
"o",
"|",
"o",
".",
"id",
"}",
"end"
] | Return a list of all object IDs of all persistend objects that this Hash
is referencing.
@return [Array of Integer] IDs of referenced objects | [
"Return",
"a",
"list",
"of",
"all",
"object",
"IDs",
"of",
"all",
"persistend",
"objects",
"that",
"this",
"Hash",
"is",
"referencing",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Hash.rb#L141-L144 | train |
scrapper/perobs | lib/perobs/Hash.rb | PEROBS.Hash._delete_reference_to_id | def _delete_reference_to_id(id)
@data.delete_if do |k, v|
v && v.respond_to?(:is_poxreference?) && v.id == id
end
@store.cache.cache_write(self)
end | ruby | def _delete_reference_to_id(id)
@data.delete_if do |k, v|
v && v.respond_to?(:is_poxreference?) && v.id == id
end
@store.cache.cache_write(self)
end | [
"def",
"_delete_reference_to_id",
"(",
"id",
")",
"@data",
".",
"delete_if",
"do",
"|",
"k",
",",
"v",
"|",
"v",
"&&",
"v",
".",
"respond_to?",
"(",
":is_poxreference?",
")",
"&&",
"v",
".",
"id",
"==",
"id",
"end",
"@store",
".",
"cache",
".",
"cach... | This method should only be used during store repair operations. It will
delete all referenced to the given object ID.
@param id [Integer] targeted object ID | [
"This",
"method",
"should",
"only",
"be",
"used",
"during",
"store",
"repair",
"operations",
".",
"It",
"will",
"delete",
"all",
"referenced",
"to",
"the",
"given",
"object",
"ID",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/Hash.rb#L149-L154 | train |
scrapper/perobs | lib/perobs/IDListPageRecord.rb | PEROBS.IDListPageRecord.split | def split
# Determine the new max_id for the old page.
max_id = @min_id + (@max_id - @min_id) / 2
# Create a new page that stores the upper half of the ID range. Remove
# all IDs from this page that now belong into the new page and transfer
# them.
new_page_record = IDListPageRecord.... | ruby | def split
# Determine the new max_id for the old page.
max_id = @min_id + (@max_id - @min_id) / 2
# Create a new page that stores the upper half of the ID range. Remove
# all IDs from this page that now belong into the new page and transfer
# them.
new_page_record = IDListPageRecord.... | [
"def",
"split",
"max_id",
"=",
"@min_id",
"+",
"(",
"@max_id",
"-",
"@min_id",
")",
"/",
"2",
"new_page_record",
"=",
"IDListPageRecord",
".",
"new",
"(",
"@page_file",
",",
"max_id",
"+",
"1",
",",
"@max_id",
",",
"page",
".",
"delete",
"(",
"max_id",
... | Split the current page. This split is done by splitting the ID range in
half. This page will keep the first half, the newly created page will
get the second half. This may not actually yield an empty page as all
values could remain with one of the pages. In this case further splits
need to be issued by the caller.
... | [
"Split",
"the",
"current",
"page",
".",
"This",
"split",
"is",
"done",
"by",
"splitting",
"the",
"ID",
"range",
"in",
"half",
".",
"This",
"page",
"will",
"keep",
"the",
"first",
"half",
"the",
"newly",
"created",
"page",
"will",
"get",
"the",
"second",
... | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/IDListPageRecord.rb#L84-L96 | train |
notonthehighstreet/chicago | lib/chicago/schema/builders/shrunken_dimension_builder.rb | Chicago::Schema::Builders.ShrunkenDimensionBuilder.columns | def columns(*names)
columns = @base.columns.select {|c| names.include?(c.name) }
check_columns_subset_of_base_dimension names, columns
@options[:columns] = columns
end | ruby | def columns(*names)
columns = @base.columns.select {|c| names.include?(c.name) }
check_columns_subset_of_base_dimension names, columns
@options[:columns] = columns
end | [
"def",
"columns",
"(",
"*",
"names",
")",
"columns",
"=",
"@base",
".",
"columns",
".",
"select",
"{",
"|",
"c",
"|",
"names",
".",
"include?",
"(",
"c",
".",
"name",
")",
"}",
"check_columns_subset_of_base_dimension",
"names",
",",
"columns",
"@options",
... | Defines which columns of the base dimension are present in the
shrunken dimension.
Takes an array of the column names as symbols.
The columns must be a subset of the base dimension's columns;
additional names will raise a Chicago::MissingDefinitionError. | [
"Defines",
"which",
"columns",
"of",
"the",
"base",
"dimension",
"are",
"present",
"in",
"the",
"shrunken",
"dimension",
"."
] | 428e94f8089d2f36fdcff2e27ea2af572b816def | https://github.com/notonthehighstreet/chicago/blob/428e94f8089d2f36fdcff2e27ea2af572b816def/lib/chicago/schema/builders/shrunken_dimension_builder.rb#L29-L33 | train |
xinminlabs/synvert-core | lib/synvert/core/rewriter/action/insert_action.rb | Synvert::Core.Rewriter::InsertAction.insert_position | def insert_position(node)
case node.type
when :block
node.children[1].children.empty? ? node.children[0].loc.expression.end_pos + 3 : node.children[1].loc.expression.end_pos
when :class
node.children[1] ? node.children[1].loc.expression.end_pos : node.children[0].loc.expression.end_pos... | ruby | def insert_position(node)
case node.type
when :block
node.children[1].children.empty? ? node.children[0].loc.expression.end_pos + 3 : node.children[1].loc.expression.end_pos
when :class
node.children[1] ? node.children[1].loc.expression.end_pos : node.children[0].loc.expression.end_pos... | [
"def",
"insert_position",
"(",
"node",
")",
"case",
"node",
".",
"type",
"when",
":block",
"node",
".",
"children",
"[",
"1",
"]",
".",
"children",
".",
"empty?",
"?",
"node",
".",
"children",
"[",
"0",
"]",
".",
"loc",
".",
"expression",
".",
"end_p... | Insert position.
@return [Integer] insert position. | [
"Insert",
"position",
"."
] | a490bfd30eaec81002d10f8fb61b49138708e46c | https://github.com/xinminlabs/synvert-core/blob/a490bfd30eaec81002d10f8fb61b49138708e46c/lib/synvert/core/rewriter/action/insert_action.rb#L25-L34 | train |
jeffnyman/tapestry | lib/tapestry/element.rb | Tapestry.Element.accessor_aspects | def accessor_aspects(element, *signature)
identifier = signature.shift
locator_args = {}
qualifier_args = {}
gather_aspects(identifier, element, locator_args, qualifier_args)
[locator_args, qualifier_args]
end | ruby | def accessor_aspects(element, *signature)
identifier = signature.shift
locator_args = {}
qualifier_args = {}
gather_aspects(identifier, element, locator_args, qualifier_args)
[locator_args, qualifier_args]
end | [
"def",
"accessor_aspects",
"(",
"element",
",",
"*",
"signature",
")",
"identifier",
"=",
"signature",
".",
"shift",
"locator_args",
"=",
"{",
"}",
"qualifier_args",
"=",
"{",
"}",
"gather_aspects",
"(",
"identifier",
",",
"element",
",",
"locator_args",
",",
... | This method provides the means to get the aspects of an accessor
signature. The "aspects" refer to the locator information and any
qualifier information that was provided along with the locator.
This is important because the qualifier is not used to locate an
element but rather to put conditions on how the state of... | [
"This",
"method",
"provides",
"the",
"means",
"to",
"get",
"the",
"aspects",
"of",
"an",
"accessor",
"signature",
".",
"The",
"aspects",
"refer",
"to",
"the",
"locator",
"information",
"and",
"any",
"qualifier",
"information",
"that",
"was",
"provided",
"along... | da28652dd6de71e415cd2c01afd89f641938a05b | https://github.com/jeffnyman/tapestry/blob/da28652dd6de71e415cd2c01afd89f641938a05b/lib/tapestry/element.rb#L78-L84 | train |
scrapper/perobs | lib/perobs/DynamoDB.rb | PEROBS.DynamoDB.delete_database | def delete_database
dynamodb = Aws::DynamoDB::Client.new
dynamodb.delete_table(:table_name => @table_name)
dynamodb.wait_until(:table_not_exists, table_name: @table_name)
end | ruby | def delete_database
dynamodb = Aws::DynamoDB::Client.new
dynamodb.delete_table(:table_name => @table_name)
dynamodb.wait_until(:table_not_exists, table_name: @table_name)
end | [
"def",
"delete_database",
"dynamodb",
"=",
"Aws",
"::",
"DynamoDB",
"::",
"Client",
".",
"new",
"dynamodb",
".",
"delete_table",
"(",
":table_name",
"=>",
"@table_name",
")",
"dynamodb",
".",
"wait_until",
"(",
":table_not_exists",
",",
"table_name",
":",
"@tabl... | Create a new DynamoDB object.
@param db_name [String] name of the DB directory
@param options [Hash] options to customize the behavior. Currently only
the following options are supported:
:serializer : Can be :json and :yaml
:aws_id : AWS credentials ID
:aws_key : AWS c... | [
"Create",
"a",
"new",
"DynamoDB",
"object",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DynamoDB.rb#L93-L97 | train |
scrapper/perobs | lib/perobs/DynamoDB.rb | PEROBS.DynamoDB.delete_unmarked_objects | def delete_unmarked_objects
deleted_objects_count = 0
each_item do |id|
unless dynamo_is_marked?(id)
dynamo_delete_item(id)
deleted_objects_count += 1
@item_counter -= 1
end
end
dynamo_put_item('item_counter', @item_counter.to_s)
deleted_objec... | ruby | def delete_unmarked_objects
deleted_objects_count = 0
each_item do |id|
unless dynamo_is_marked?(id)
dynamo_delete_item(id)
deleted_objects_count += 1
@item_counter -= 1
end
end
dynamo_put_item('item_counter', @item_counter.to_s)
deleted_objec... | [
"def",
"delete_unmarked_objects",
"deleted_objects_count",
"=",
"0",
"each_item",
"do",
"|",
"id",
"|",
"unless",
"dynamo_is_marked?",
"(",
"id",
")",
"dynamo_delete_item",
"(",
"id",
")",
"deleted_objects_count",
"+=",
"1",
"@item_counter",
"-=",
"1",
"end",
"end... | Permanently delete all objects that have not been marked. Those are
orphaned and are no longer referenced by any actively used object.
@return [Integer] Count of the deleted objects. | [
"Permanently",
"delete",
"all",
"objects",
"that",
"have",
"not",
"been",
"marked",
".",
"Those",
"are",
"orphaned",
"and",
"are",
"no",
"longer",
"referenced",
"by",
"any",
"actively",
"used",
"object",
"."
] | 1c9327656912cf96683849f92d260546af856adf | https://github.com/scrapper/perobs/blob/1c9327656912cf96683849f92d260546af856adf/lib/perobs/DynamoDB.rb#L161-L173 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.