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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.position_object | def position_object(col_start, row_start, x1, y1, width, height) #:nodoc:
# col_start; # Col containing upper left corner of object
# x1; # Distance to left side of object
# row_start; # Row containing top left corner of object
# y1; # Distance to top of object
# col_end; # ... | ruby | def position_object(col_start, row_start, x1, y1, width, height) #:nodoc:
# col_start; # Col containing upper left corner of object
# x1; # Distance to left side of object
# row_start; # Row containing top left corner of object
# y1; # Distance to top of object
# col_end; # ... | [
"def",
"position_object",
"(",
"col_start",
",",
"row_start",
",",
"x1",
",",
"y1",
",",
"width",
",",
"height",
")",
"x1",
",",
"col_start",
"=",
"adjust_col_position",
"(",
"x1",
",",
"col_start",
")",
"y1",
",",
"row_start",
"=",
"adjust_row_position",
... | Calculate the vertices that define the position of a graphical object within
the worksheet.
+------------+------------+
| A | B |
+-----+------------+------------+
| |(x1,y1) | |
| 1 |(A1)._______|______ |
| | | | |
|... | [
"Calculate",
"the",
"vertices",
"that",
"define",
"the",
"position",
"of",
"a",
"graphical",
"object",
"within",
"the",
"worksheet",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L4410-L4471 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_mso_sp_container | def store_mso_sp_container(length) #:nodoc:
type = 0xF004
version = 15
instance = 0
data = ''
add_mso_generic(type, version, instance, data, length)
end | ruby | def store_mso_sp_container(length) #:nodoc:
type = 0xF004
version = 15
instance = 0
data = ''
add_mso_generic(type, version, instance, data, length)
end | [
"def",
"store_mso_sp_container",
"(",
"length",
")",
"type",
"=",
"0xF004",
"version",
"=",
"15",
"instance",
"=",
"0",
"data",
"=",
"''",
"add_mso_generic",
"(",
"type",
",",
"version",
",",
"instance",
",",
"data",
",",
"length",
")",
"end"
] | Write the Escher SpContainer record that is part of MSODRAWING. | [
"Write",
"the",
"Escher",
"SpContainer",
"record",
"that",
"is",
"part",
"of",
"MSODRAWING",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L4489-L4496 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_mso_sp | def store_mso_sp(instance, spid, options) #:nodoc:
type = 0xF00A
version = 2
data = ''
length = 8
data = [spid, options].pack('VV')
add_mso_generic(type, version, instance, data, length)
end | ruby | def store_mso_sp(instance, spid, options) #:nodoc:
type = 0xF00A
version = 2
data = ''
length = 8
data = [spid, options].pack('VV')
add_mso_generic(type, version, instance, data, length)
end | [
"def",
"store_mso_sp",
"(",
"instance",
",",
"spid",
",",
"options",
")",
"type",
"=",
"0xF00A",
"version",
"=",
"2",
"data",
"=",
"''",
"length",
"=",
"8",
"data",
"=",
"[",
"spid",
",",
"options",
"]",
".",
"pack",
"(",
"'VV'",
")",
"add_mso_generi... | Write the Escher Sp record that is part of MSODRAWING. | [
"Write",
"the",
"Escher",
"Sp",
"record",
"that",
"is",
"part",
"of",
"MSODRAWING",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L4501-L4509 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_mso_client_data | def store_mso_client_data #:nodoc:
type = 0xF011
version = 0
instance = 0
data = ''
length = 0
add_mso_generic(type, version, instance, data, length)
end | ruby | def store_mso_client_data #:nodoc:
type = 0xF011
version = 0
instance = 0
data = ''
length = 0
add_mso_generic(type, version, instance, data, length)
end | [
"def",
"store_mso_client_data",
"type",
"=",
"0xF011",
"version",
"=",
"0",
"instance",
"=",
"0",
"data",
"=",
"''",
"length",
"=",
"0",
"add_mso_generic",
"(",
"type",
",",
"version",
",",
"instance",
",",
"data",
",",
"length",
")",
"end"
] | Write the Escher ClientData record that is part of MSODRAWING. | [
"Write",
"the",
"Escher",
"ClientData",
"record",
"that",
"is",
"part",
"of",
"MSODRAWING",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L4561-L4569 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.boundsheet | def boundsheet #:nodoc:
hidden = self.hidden? ? 1 : 0
encoding = self.is_name_utf16be? ? 1 : 0
record = 0x0085 # Record identifier
length = 0x08 + @name.bytesize # Number of bytes to follow
cch = @name.bytesize # Length of sheet name
# Charact... | ruby | def boundsheet #:nodoc:
hidden = self.hidden? ? 1 : 0
encoding = self.is_name_utf16be? ? 1 : 0
record = 0x0085 # Record identifier
length = 0x08 + @name.bytesize # Number of bytes to follow
cch = @name.bytesize # Length of sheet name
# Charact... | [
"def",
"boundsheet",
"hidden",
"=",
"self",
".",
"hidden?",
"?",
"1",
":",
"0",
"encoding",
"=",
"self",
".",
"is_name_utf16be?",
"?",
"1",
":",
"0",
"record",
"=",
"0x0085",
"length",
"=",
"0x08",
"+",
"@name",
".",
"bytesize",
"cch",
"=",
"@name",
... | Excel BIFF BOUNDSHEET record.
sheetname # Worksheet name
offset # Location of worksheet BOF
type # Worksheet type
hidden # Worksheet hidden flag
encoding # Sheet name encoding | [
"Excel",
"BIFF",
"BOUNDSHEET",
"record",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L4584-L4605 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.parse_filter_expression | def parse_filter_expression(expression, tokens) #:nodoc:
# The number of tokens will be either 3 (for 1 expression)
# or 7 (for 2 expressions).
#
if (tokens.size == 7)
conditional = tokens[3]
if conditional =~ /^(and|&&)$/
conditional = 0
elsif conditional =~ /^(or|\|\|)$/
... | ruby | def parse_filter_expression(expression, tokens) #:nodoc:
# The number of tokens will be either 3 (for 1 expression)
# or 7 (for 2 expressions).
#
if (tokens.size == 7)
conditional = tokens[3]
if conditional =~ /^(and|&&)$/
conditional = 0
elsif conditional =~ /^(or|\|\|)$/
... | [
"def",
"parse_filter_expression",
"(",
"expression",
",",
"tokens",
")",
"if",
"(",
"tokens",
".",
"size",
"==",
"7",
")",
"conditional",
"=",
"tokens",
"[",
"3",
"]",
"if",
"conditional",
"=~",
"/",
"/",
"conditional",
"=",
"0",
"elsif",
"conditional",
... | Converts the tokens of a possibly conditional expression into 1 or 2
sub expressions for further parsing.
Examples:
('x', '==', 2000) -> exp1
('x', '>', 2000, 'and', 'x', '<', 5000) -> exp1 and exp2 | [
"Converts",
"the",
"tokens",
"of",
"a",
"possibly",
"conditional",
"expression",
"into",
"1",
"or",
"2",
"sub",
"expressions",
"for",
"further",
"parsing",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L4775-L4795 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.xf_record_index | def xf_record_index(row, col, xf=nil) #:nodoc:
if xf.respond_to?(:xf_index)
xf.xf_index
elsif @row_formats.has_key?(row)
@row_formats[row].xf_index
elsif @col_formats.has_key?(col)
@col_formats[col].xf_index
else
0x0F
end
end | ruby | def xf_record_index(row, col, xf=nil) #:nodoc:
if xf.respond_to?(:xf_index)
xf.xf_index
elsif @row_formats.has_key?(row)
@row_formats[row].xf_index
elsif @col_formats.has_key?(col)
@col_formats[col].xf_index
else
0x0F
end
end | [
"def",
"xf_record_index",
"(",
"row",
",",
"col",
",",
"xf",
"=",
"nil",
")",
"if",
"xf",
".",
"respond_to?",
"(",
":xf_index",
")",
"xf",
".",
"xf_index",
"elsif",
"@row_formats",
".",
"has_key?",
"(",
"row",
")",
"@row_formats",
"[",
"row",
"]",
".",... | Returns an index to the XF record in the workbook.
Note: this is a function, not a method. | [
"Returns",
"an",
"index",
"to",
"the",
"XF",
"record",
"in",
"the",
"workbook",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L4918-L4928 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.encode_password | def encode_password(password)
i = 0
chars = password.split(//)
count = chars.size
chars.collect! do |char|
i += 1
char = char.ord << i
low_15 = char & 0x7fff
high_15 = char & 0x7fff << 15
high_15 = high_15 >> 15
char = low_15 | high_15
end
encode... | ruby | def encode_password(password)
i = 0
chars = password.split(//)
count = chars.size
chars.collect! do |char|
i += 1
char = char.ord << i
low_15 = char & 0x7fff
high_15 = char & 0x7fff << 15
high_15 = high_15 >> 15
char = low_15 | high_15
end
encode... | [
"def",
"encode_password",
"(",
"password",
")",
"i",
"=",
"0",
"chars",
"=",
"password",
".",
"split",
"(",
"/",
"/",
")",
"count",
"=",
"chars",
".",
"size",
"chars",
".",
"collect!",
"do",
"|",
"char",
"|",
"i",
"+=",
"1",
"char",
"=",
"char",
... | Based on the algorithm provided by Daniel Rentz of OpenOffice. | [
"Based",
"on",
"the",
"algorithm",
"provided",
"by",
"Daniel",
"Rentz",
"of",
"OpenOffice",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5005-L5023 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.get_formula_string | def get_formula_string(string) #:nodoc:
ruby_19 { string = convert_to_ascii_if_ascii(string) }
record = 0x0207 # Record identifier
length = 0x00 # Bytes to follow
# string # Formula string.
strlen = string.bytesize # Length of the formula string (... | ruby | def get_formula_string(string) #:nodoc:
ruby_19 { string = convert_to_ascii_if_ascii(string) }
record = 0x0207 # Record identifier
length = 0x00 # Bytes to follow
# string # Formula string.
strlen = string.bytesize # Length of the formula string (... | [
"def",
"get_formula_string",
"(",
"string",
")",
"ruby_19",
"{",
"string",
"=",
"convert_to_ascii_if_ascii",
"(",
"string",
")",
"}",
"record",
"=",
"0x0207",
"length",
"=",
"0x00",
"strlen",
"=",
"string",
".",
"bytesize",
"encoding",
"=",
"0",
"if",
"is_ut... | Pack the string value when a formula evaluates to a string. The value cannot
be calculated by the module and thus must be supplied by the user. | [
"Pack",
"the",
"string",
"value",
"when",
"a",
"formula",
"evaluates",
"to",
"a",
"string",
".",
"The",
"value",
"cannot",
"be",
"calculated",
"by",
"the",
"module",
"and",
"thus",
"must",
"be",
"supplied",
"by",
"the",
"user",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5077-L5098 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_dimensions | def store_dimensions #:nodoc:
record = 0x0200 # Record identifier
length = 0x000E # Number of bytes to follow
reserved = 0x0000 # Reserved by Excel
@dimension.increment_row_max
@dimension.increment_col_max
header = [record, length].pack("vv")
fields = [@dim... | ruby | def store_dimensions #:nodoc:
record = 0x0200 # Record identifier
length = 0x000E # Number of bytes to follow
reserved = 0x0000 # Reserved by Excel
@dimension.increment_row_max
@dimension.increment_col_max
header = [record, length].pack("vv")
fields = [@dim... | [
"def",
"store_dimensions",
"record",
"=",
"0x0200",
"length",
"=",
"0x000E",
"reserved",
"=",
"0x0000",
"@dimension",
".",
"increment_row_max",
"@dimension",
".",
"increment_col_max",
"header",
"=",
"[",
"record",
",",
"length",
"]",
".",
"pack",
"(",
"\"vv\"",
... | Writes Excel DIMENSIONS to define the area in which there is cell data.
Notes:
Excel stores the max row/col as row/col +1.
Max and min values of 0 are used to indicate that no cell data.
We set the undef member data to 0 since it is used by store_table().
Inserting images or charts doesn't change the DIME... | [
"Writes",
"Excel",
"DIMENSIONS",
"to",
"define",
"the",
"area",
"in",
"which",
"there",
"is",
"cell",
"data",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5508-L5521 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_window2 | def store_window2 #:nodoc:
record = 0x023E # Record identifier
length = 0x0012 # Number of bytes to follow
grbit = 0x00B6 # Option flags
rwTop = @first_row # Top visible row
colLeft = @first_col # Leftmost visible column
rgbHdr ... | ruby | def store_window2 #:nodoc:
record = 0x023E # Record identifier
length = 0x0012 # Number of bytes to follow
grbit = 0x00B6 # Option flags
rwTop = @first_row # Top visible row
colLeft = @first_col # Leftmost visible column
rgbHdr ... | [
"def",
"store_window2",
"record",
"=",
"0x023E",
"length",
"=",
"0x0012",
"grbit",
"=",
"0x00B6",
"rwTop",
"=",
"@first_row",
"colLeft",
"=",
"@first_col",
"rgbHdr",
"=",
"0x00000040",
"wScaleSLV",
"=",
"0x0000",
"wScaleNormal",
"=",
"0x0000",
"reserved",
"=",
... | Write BIFF record Window2. | [
"Write",
"BIFF",
"record",
"Window2",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5526-L5571 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_tab_color | def store_tab_color #:nodoc:
color = @tab_color
return if color == 0
record = 0x0862 # Record identifier
length = 0x0014 # Number of bytes to follow
zero = 0x0000
unknown = 0x0014
store_simple(record, length, record, zero, zero, zero, zero,
zero, unkno... | ruby | def store_tab_color #:nodoc:
color = @tab_color
return if color == 0
record = 0x0862 # Record identifier
length = 0x0014 # Number of bytes to follow
zero = 0x0000
unknown = 0x0014
store_simple(record, length, record, zero, zero, zero, zero,
zero, unkno... | [
"def",
"store_tab_color",
"color",
"=",
"@tab_color",
"return",
"if",
"color",
"==",
"0",
"record",
"=",
"0x0862",
"length",
"=",
"0x0014",
"zero",
"=",
"0x0000",
"unknown",
"=",
"0x0014",
"store_simple",
"(",
"record",
",",
"length",
",",
"record",
",",
"... | Write the Tab Color BIFF record. | [
"Write",
"the",
"Tab",
"Color",
"BIFF",
"record",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5585-L5598 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_defrow | def store_defrow #:nodoc:
record = 0x0225 # Record identifier
length = 0x0004 # Number of bytes to follow
grbit = 0x0000 # Options.
height = 0x00FF # Default row height
header = [record, length].pack("vv")
data = [grbit, height].pack("vv")
prepend(header,... | ruby | def store_defrow #:nodoc:
record = 0x0225 # Record identifier
length = 0x0004 # Number of bytes to follow
grbit = 0x0000 # Options.
height = 0x00FF # Default row height
header = [record, length].pack("vv")
data = [grbit, height].pack("vv")
prepend(header,... | [
"def",
"store_defrow",
"record",
"=",
"0x0225",
"length",
"=",
"0x0004",
"grbit",
"=",
"0x0000",
"height",
"=",
"0x00FF",
"header",
"=",
"[",
"record",
",",
"length",
"]",
".",
"pack",
"(",
"\"vv\"",
")",
"data",
"=",
"[",
"grbit",
",",
"height",
"]",
... | Write BIFF record DEFROWHEIGHT. | [
"Write",
"BIFF",
"record",
"DEFROWHEIGHT",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5603-L5614 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_defcol | def store_defcol #:nodoc:
record = 0x0055 # Record identifier
length = 0x0002 # Number of bytes to follow
colwidth = 0x0008 # Default column width
header = [record, length].pack("vv")
data = [colwidth].pack("v")
prepend(header, data)
end | ruby | def store_defcol #:nodoc:
record = 0x0055 # Record identifier
length = 0x0002 # Number of bytes to follow
colwidth = 0x0008 # Default column width
header = [record, length].pack("vv")
data = [colwidth].pack("v")
prepend(header, data)
end | [
"def",
"store_defcol",
"record",
"=",
"0x0055",
"length",
"=",
"0x0002",
"colwidth",
"=",
"0x0008",
"header",
"=",
"[",
"record",
",",
"length",
"]",
".",
"pack",
"(",
"\"vv\"",
")",
"data",
"=",
"[",
"colwidth",
"]",
".",
"pack",
"(",
"\"v\"",
")",
... | Write BIFF record DEFCOLWIDTH. | [
"Write",
"BIFF",
"record",
"DEFCOLWIDTH",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5619-L5628 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_autofilterinfo | def store_autofilterinfo #:nodoc:
# Only write the record if the worksheet contains an autofilter.
return '' if @filter_area.count == 0
record = 0x009D # Record identifier
length = 0x0002 # Number of bytes to follow
num_filters = @filter_area.count
header = [record, lengt... | ruby | def store_autofilterinfo #:nodoc:
# Only write the record if the worksheet contains an autofilter.
return '' if @filter_area.count == 0
record = 0x009D # Record identifier
length = 0x0002 # Number of bytes to follow
num_filters = @filter_area.count
header = [record, lengt... | [
"def",
"store_autofilterinfo",
"return",
"''",
"if",
"@filter_area",
".",
"count",
"==",
"0",
"record",
"=",
"0x009D",
"length",
"=",
"0x0002",
"num_filters",
"=",
"@filter_area",
".",
"count",
"header",
"=",
"[",
"record",
",",
"length",
"]",
".",
"pack",
... | Write BIFF record AUTOFILTERINFO. | [
"Write",
"BIFF",
"record",
"AUTOFILTERINFO",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5653-L5665 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_selection | def store_selection(first_row=0, first_col=0, last_row = nil, last_col =nil) #:nodoc:
record = 0x001D # Record identifier
length = 0x000F # Number of bytes to follow
pane_position = @active_pane # Pane position
row_active = first_row # Active ro... | ruby | def store_selection(first_row=0, first_col=0, last_row = nil, last_col =nil) #:nodoc:
record = 0x001D # Record identifier
length = 0x000F # Number of bytes to follow
pane_position = @active_pane # Pane position
row_active = first_row # Active ro... | [
"def",
"store_selection",
"(",
"first_row",
"=",
"0",
",",
"first_col",
"=",
"0",
",",
"last_row",
"=",
"nil",
",",
"last_col",
"=",
"nil",
")",
"record",
"=",
"0x001D",
"length",
"=",
"0x000F",
"pane_position",
"=",
"@active_pane",
"row_active",
"=",
"fir... | Write BIFF record SELECTION. | [
"Write",
"BIFF",
"record",
"SELECTION",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5670-L5694 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_externcount | def store_externcount(count) #:nodoc:
record = 0x0016 # Record identifier
length = 0x0002 # Number of bytes to follow
cxals = count # Number of external references
header = [record, length].pack('vv')
data = [cxals].pack('v')
prepend(header, data)
end | ruby | def store_externcount(count) #:nodoc:
record = 0x0016 # Record identifier
length = 0x0002 # Number of bytes to follow
cxals = count # Number of external references
header = [record, length].pack('vv')
data = [cxals].pack('v')
prepend(header, data)
end | [
"def",
"store_externcount",
"(",
"count",
")",
"record",
"=",
"0x0016",
"length",
"=",
"0x0002",
"cxals",
"=",
"count",
"header",
"=",
"[",
"record",
",",
"length",
"]",
".",
"pack",
"(",
"'vv'",
")",
"data",
"=",
"[",
"cxals",
"]",
".",
"pack",
"(",... | Write BIFF record EXTERNCOUNT to indicate the number of external sheet
references in a worksheet.
Excel only stores references to external sheets that are used in formulas.
For simplicity we store references to all the sheets in the workbook
regardless of whether they are used or not. This reduces the overall
com... | [
"Write",
"BIFF",
"record",
"EXTERNCOUNT",
"to",
"indicate",
"the",
"number",
"of",
"external",
"sheet",
"references",
"in",
"a",
"worksheet",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5706-L5716 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_setup | def store_setup #:nodoc:
record = 0x00A1 # Record identifier
length = 0x0022 # Number of bytes to follow
iPaperSize = @paper_size # Paper size
iScale = @print_scale # Print scaling factor
iPageStart = @page_start # Starting page numb... | ruby | def store_setup #:nodoc:
record = 0x00A1 # Record identifier
length = 0x0022 # Number of bytes to follow
iPaperSize = @paper_size # Paper size
iScale = @print_scale # Print scaling factor
iPageStart = @page_start # Starting page numb... | [
"def",
"store_setup",
"record",
"=",
"0x00A1",
"length",
"=",
"0x0022",
"iPaperSize",
"=",
"@paper_size",
"iScale",
"=",
"@print_scale",
"iPageStart",
"=",
"@page_start",
"iFitWidth",
"=",
"@fit_width",
"iFitHeight",
"=",
"@fit_height",
"grbit",
"=",
"0x00",
"iRes... | Store the page setup SETUP BIFF record. | [
"Store",
"the",
"page",
"setup",
"SETUP",
"BIFF",
"record",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L5807-L5859 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_gridset | def store_gridset #:nodoc:
record = 0x0082 # Record identifier
length = 0x0002 # Bytes to follow
fGridSet = @print_gridlines == 0 ? 1 : 0 # Boolean flag
header = [record, length].pack("vv")
data = [fGridSet].pack("v")
pr... | ruby | def store_gridset #:nodoc:
record = 0x0082 # Record identifier
length = 0x0002 # Bytes to follow
fGridSet = @print_gridlines == 0 ? 1 : 0 # Boolean flag
header = [record, length].pack("vv")
data = [fGridSet].pack("v")
pr... | [
"def",
"store_gridset",
"record",
"=",
"0x0082",
"length",
"=",
"0x0002",
"fGridSet",
"=",
"@print_gridlines",
"==",
"0",
"?",
"1",
":",
"0",
"header",
"=",
"[",
"record",
",",
"length",
"]",
".",
"pack",
"(",
"\"vv\"",
")",
"data",
"=",
"[",
"fGridSet... | Write the GRIDSET BIFF record. Must be used in conjunction with the
PRINTGRIDLINES record. | [
"Write",
"the",
"GRIDSET",
"BIFF",
"record",
".",
"Must",
"be",
"used",
"in",
"conjunction",
"with",
"the",
"PRINTGRIDLINES",
"record",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6032-L6042 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_wsbool | def store_wsbool #:nodoc:
record = 0x0081 # Record identifier
length = 0x0002 # Bytes to follow
grbit = 0x0000 # Option flags
# Set the option flags
grbit |= 0x0001 # Auto page breaks visible
grbit |= 0x0020 if @outline.style != 0 # Auto outline s... | ruby | def store_wsbool #:nodoc:
record = 0x0081 # Record identifier
length = 0x0002 # Bytes to follow
grbit = 0x0000 # Option flags
# Set the option flags
grbit |= 0x0001 # Auto page breaks visible
grbit |= 0x0020 if @outline.style != 0 # Auto outline s... | [
"def",
"store_wsbool",
"record",
"=",
"0x0081",
"length",
"=",
"0x0002",
"grbit",
"=",
"0x0000",
"grbit",
"|=",
"0x0001",
"grbit",
"|=",
"0x0020",
"if",
"@outline",
".",
"style",
"!=",
"0",
"grbit",
"|=",
"0x0040",
"if",
"@outline",
".",
"below",
"!=",
"... | Write the WSBOOL BIFF record, mainly for fit-to-page. Used in conjunction
with the SETUP record. | [
"Write",
"the",
"WSBOOL",
"BIFF",
"record",
"mainly",
"for",
"fit",
"-",
"to",
"-",
"page",
".",
"Used",
"in",
"conjunction",
"with",
"the",
"SETUP",
"record",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6083-L6101 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_password | def store_password #:nodoc:
# Exit unless sheet protection and password have been specified
return unless protect? && @password
record = 0x0013 # Record identifier
length = 0x0002 # Bytes to follow
wPassword = @password # Encoded password
... | ruby | def store_password #:nodoc:
# Exit unless sheet protection and password have been specified
return unless protect? && @password
record = 0x0013 # Record identifier
length = 0x0002 # Bytes to follow
wPassword = @password # Encoded password
... | [
"def",
"store_password",
"return",
"unless",
"protect?",
"&&",
"@password",
"record",
"=",
"0x0013",
"length",
"=",
"0x0002",
"wPassword",
"=",
"@password",
"header",
"=",
"[",
"record",
",",
"length",
"]",
".",
"pack",
"(",
"\"vv\"",
")",
"data",
"=",
"["... | Write the worksheet PASSWORD record. | [
"Write",
"the",
"worksheet",
"PASSWORD",
"record",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6175-L6188 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_table | def store_table #:nodoc:
return unless compatibility?
# Offset from the DBCELL record back to the first ROW of the 32 row block.
row_offset = 0
# Track rows that have cell data or modified by set_row().
written_rows = []
# Write the ROW records with updated max/min col fields.
#
(0... | ruby | def store_table #:nodoc:
return unless compatibility?
# Offset from the DBCELL record back to the first ROW of the 32 row block.
row_offset = 0
# Track rows that have cell data or modified by set_row().
written_rows = []
# Write the ROW records with updated max/min col fields.
#
(0... | [
"def",
"store_table",
"return",
"unless",
"compatibility?",
"row_offset",
"=",
"0",
"written_rows",
"=",
"[",
"]",
"(",
"0",
"..",
"@dimension",
".",
"row_max",
"-",
"1",
")",
".",
"each",
"do",
"|",
"row",
"|",
"next",
"unless",
"@table",
"[",
"row",
... | Note about compatibility mode.
Excel doesn't require every possible Biff record to be present in a file.
In particular if the indexing records INDEX, ROW and DBCELL aren't present
it just ignores the fact and reads the cells anyway. This is also true of
the EXTSST record. Gnumeric and OOo also take this approach. ... | [
"Note",
"about",
"compatibility",
"mode",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6219-L6297 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.size_col | def size_col(col) #:nodoc:
# Look up the cell value to see if it has been changed
if @col_sizes[col]
width = @col_sizes[col]
# The relationship is different for user units less than 1.
if width < 1
(width *12).to_i
else
(width *7 +5 ).to_i
end
else
64
... | ruby | def size_col(col) #:nodoc:
# Look up the cell value to see if it has been changed
if @col_sizes[col]
width = @col_sizes[col]
# The relationship is different for user units less than 1.
if width < 1
(width *12).to_i
else
(width *7 +5 ).to_i
end
else
64
... | [
"def",
"size_col",
"(",
"col",
")",
"if",
"@col_sizes",
"[",
"col",
"]",
"width",
"=",
"@col_sizes",
"[",
"col",
"]",
"if",
"width",
"<",
"1",
"(",
"width",
"*",
"12",
")",
".",
"to_i",
"else",
"(",
"width",
"*",
"7",
"+",
"5",
")",
".",
"to_i"... | Convert the width of a cell from user's units to pixels. Excel rounds the
column width to the nearest pixel. If the width hasn't been set by the user
we use the default value. If the column is hidden we use a value of zero. | [
"Convert",
"the",
"width",
"of",
"a",
"cell",
"from",
"user",
"s",
"units",
"to",
"pixels",
".",
"Excel",
"rounds",
"the",
"column",
"width",
"to",
"the",
"nearest",
"pixel",
".",
"If",
"the",
"width",
"hasn",
"t",
"been",
"set",
"by",
"the",
"user",
... | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6364-L6378 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_autofilter | def store_autofilter(index, operator_1, token_1, #:nodoc:
join = nil, operator_2 = nil, token_2 = nil)
record = 0x009E
length = 0x0000
top10_active = 0
top10_direction = 0
top10_percent = 0
top10_value = 101
grbit = join |... | ruby | def store_autofilter(index, operator_1, token_1, #:nodoc:
join = nil, operator_2 = nil, token_2 = nil)
record = 0x009E
length = 0x0000
top10_active = 0
top10_direction = 0
top10_percent = 0
top10_value = 101
grbit = join |... | [
"def",
"store_autofilter",
"(",
"index",
",",
"operator_1",
",",
"token_1",
",",
"join",
"=",
"nil",
",",
"operator_2",
"=",
"nil",
",",
"token_2",
"=",
"nil",
")",
"record",
"=",
"0x009E",
"length",
"=",
"0x0000",
"top10_active",
"=",
"0",
"top10_directio... | Function to write worksheet AUTOFILTER records. These contain 2 Biff Doper
structures to represent the 2 possible filter conditions. | [
"Function",
"to",
"write",
"worksheet",
"AUTOFILTER",
"records",
".",
"These",
"contain",
"2",
"Biff",
"Doper",
"structures",
"to",
"represent",
"the",
"2",
"possible",
"filter",
"conditions",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6444-L6520 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.pack_doper | def pack_doper(operator, token) #:nodoc:
doper = ''
string = ''
# Return default doper for non-defined filters.
unless operator
return pack_unused_doper, string
end
if token.to_s =~ /^blanks|nonblanks$/i
doper = pack_blanks_doper(operator, token)
elsif operator ==... | ruby | def pack_doper(operator, token) #:nodoc:
doper = ''
string = ''
# Return default doper for non-defined filters.
unless operator
return pack_unused_doper, string
end
if token.to_s =~ /^blanks|nonblanks$/i
doper = pack_blanks_doper(operator, token)
elsif operator ==... | [
"def",
"pack_doper",
"(",
"operator",
",",
"token",
")",
"doper",
"=",
"''",
"string",
"=",
"''",
"unless",
"operator",
"return",
"pack_unused_doper",
",",
"string",
"end",
"if",
"token",
".",
"to_s",
"=~",
"/",
"/i",
"doper",
"=",
"pack_blanks_doper",
"("... | Create a Biff Doper structure that represents a filter expression. Depending
on the type of the token we pack an Empty, String or Number doper. | [
"Create",
"a",
"Biff",
"Doper",
"structure",
"that",
"represents",
"a",
"filter",
"expression",
".",
"Depending",
"on",
"the",
"type",
"of",
"the",
"token",
"we",
"pack",
"an",
"Empty",
"String",
"or",
"Number",
"doper",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6526-L6562 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.pack_number_doper | def pack_number_doper(operator, number) #:nodoc:
number = [number].pack('d')
number.reverse! if @byte_order
[0x04, operator].pack('CC') + number
end | ruby | def pack_number_doper(operator, number) #:nodoc:
number = [number].pack('d')
number.reverse! if @byte_order
[0x04, operator].pack('CC') + number
end | [
"def",
"pack_number_doper",
"(",
"operator",
",",
"number",
")",
"number",
"=",
"[",
"number",
"]",
".",
"pack",
"(",
"'d'",
")",
"number",
".",
"reverse!",
"if",
"@byte_order",
"[",
"0x04",
",",
"operator",
"]",
".",
"pack",
"(",
"'CC'",
")",
"+",
"... | Pack an IEEE double number Doper structure. | [
"Pack",
"an",
"IEEE",
"double",
"number",
"Doper",
"structure",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6604-L6609 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_images | def store_images #:nodoc:
# Skip this if there aren't any images.
return if @images.array.empty?
spid = @object_ids.spid
@images.array.each_index do |i|
@images.array[i].store_image_record(i, @images.array.size, charts_size, @filter_area.count, comments_size, spid)
store_obj_image(i + 1)... | ruby | def store_images #:nodoc:
# Skip this if there aren't any images.
return if @images.array.empty?
spid = @object_ids.spid
@images.array.each_index do |i|
@images.array[i].store_image_record(i, @images.array.size, charts_size, @filter_area.count, comments_size, spid)
store_obj_image(i + 1)... | [
"def",
"store_images",
"return",
"if",
"@images",
".",
"array",
".",
"empty?",
"spid",
"=",
"@object_ids",
".",
"spid",
"@images",
".",
"array",
".",
"each_index",
"do",
"|",
"i",
"|",
"@images",
".",
"array",
"[",
"i",
"]",
".",
"store_image_record",
"(... | Store the collections of records that make up images. | [
"Store",
"the",
"collections",
"of",
"records",
"that",
"make",
"up",
"images",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6614-L6626 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_charts | def store_charts #:nodoc:
# Skip this if there aren't any charts.
return if charts_size == 0
record = 0x00EC # Record identifier
charts = @charts.array
charts.each_index do |i|
data = ''
if i == 0 && images_size == 0
dg_length = 192 + 120 * (charts_size - 1) + 9... | ruby | def store_charts #:nodoc:
# Skip this if there aren't any charts.
return if charts_size == 0
record = 0x00EC # Record identifier
charts = @charts.array
charts.each_index do |i|
data = ''
if i == 0 && images_size == 0
dg_length = 192 + 120 * (charts_size - 1) + 9... | [
"def",
"store_charts",
"return",
"if",
"charts_size",
"==",
"0",
"record",
"=",
"0x00EC",
"charts",
"=",
"@charts",
".",
"array",
"charts",
".",
"each_index",
"do",
"|",
"i",
"|",
"data",
"=",
"''",
"if",
"i",
"==",
"0",
"&&",
"images_size",
"==",
"0",... | Store the collections of records that make up charts. | [
"Store",
"the",
"collections",
"of",
"records",
"that",
"make",
"up",
"charts",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6639-L6674 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_comments | def store_comments #:nodoc:
return if @comments.array.empty?
spid = @object_ids.spid
num_comments = comments_size
# Number of objects written so far.
num_objects = images_size + @filter_area.count + charts_size
@comments.array.each_index { |i| spid = @comments.array[i].store_comment_... | ruby | def store_comments #:nodoc:
return if @comments.array.empty?
spid = @object_ids.spid
num_comments = comments_size
# Number of objects written so far.
num_objects = images_size + @filter_area.count + charts_size
@comments.array.each_index { |i| spid = @comments.array[i].store_comment_... | [
"def",
"store_comments",
"return",
"if",
"@comments",
".",
"array",
".",
"empty?",
"spid",
"=",
"@object_ids",
".",
"spid",
"num_comments",
"=",
"comments_size",
"num_objects",
"=",
"images_size",
"+",
"@filter_area",
".",
"count",
"+",
"charts_size",
"@comments",... | Store the collections of records that make up cell comments.
NOTE: We write the comment objects last since that makes it a little easier
to write the NOTE records directly after the MSODRAWIING records. | [
"Store",
"the",
"collections",
"of",
"records",
"that",
"make",
"up",
"cell",
"comments",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6728-L6741 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_mso_dg_container | def store_mso_dg_container(length) #:nodoc:
type = 0xF002
version = 15
instance = 0
data = ''
add_mso_generic(type, version, instance, data, length)
end | ruby | def store_mso_dg_container(length) #:nodoc:
type = 0xF002
version = 15
instance = 0
data = ''
add_mso_generic(type, version, instance, data, length)
end | [
"def",
"store_mso_dg_container",
"(",
"length",
")",
"type",
"=",
"0xF002",
"version",
"=",
"15",
"instance",
"=",
"0",
"data",
"=",
"''",
"add_mso_generic",
"(",
"type",
",",
"version",
",",
"instance",
",",
"data",
",",
"length",
")",
"end"
] | Write the Escher DgContainer record that is part of MSODRAWING. | [
"Write",
"the",
"Escher",
"DgContainer",
"record",
"that",
"is",
"part",
"of",
"MSODRAWING",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6746-L6752 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_mso_dg | def store_mso_dg #:nodoc:
type = 0xF008
version = 0
length = 8
data = [@object_ids.num_shapes, @object_ids.max_spid].pack("VV")
add_mso_generic(type, version, @object_ids.drawings_saved, data, length)
end | ruby | def store_mso_dg #:nodoc:
type = 0xF008
version = 0
length = 8
data = [@object_ids.num_shapes, @object_ids.max_spid].pack("VV")
add_mso_generic(type, version, @object_ids.drawings_saved, data, length)
end | [
"def",
"store_mso_dg",
"type",
"=",
"0xF008",
"version",
"=",
"0",
"length",
"=",
"8",
"data",
"=",
"[",
"@object_ids",
".",
"num_shapes",
",",
"@object_ids",
".",
"max_spid",
"]",
".",
"pack",
"(",
"\"VV\"",
")",
"add_mso_generic",
"(",
"type",
",",
"ve... | Write the Escher Dg record that is part of MSODRAWING. | [
"Write",
"the",
"Escher",
"Dg",
"record",
"that",
"is",
"part",
"of",
"MSODRAWING",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6757-L6764 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_mso_spgr_container | def store_mso_spgr_container(length) #:nodoc:
type = 0xF003
version = 15
instance = 0
data = ''
add_mso_generic(type, version, instance, data, length)
end | ruby | def store_mso_spgr_container(length) #:nodoc:
type = 0xF003
version = 15
instance = 0
data = ''
add_mso_generic(type, version, instance, data, length)
end | [
"def",
"store_mso_spgr_container",
"(",
"length",
")",
"type",
"=",
"0xF003",
"version",
"=",
"15",
"instance",
"=",
"0",
"data",
"=",
"''",
"add_mso_generic",
"(",
"type",
",",
"version",
",",
"instance",
",",
"data",
",",
"length",
")",
"end"
] | Write the Escher SpgrContainer record that is part of MSODRAWING. | [
"Write",
"the",
"Escher",
"SpgrContainer",
"record",
"that",
"is",
"part",
"of",
"MSODRAWING",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6769-L6776 | train |
cxn03651/writeexcel | lib/writeexcel/worksheet.rb | Writeexcel.Worksheet.store_mso_spgr | def store_mso_spgr #:nodoc:
type = 0xF009
version = 1
instance = 0
data = [0, 0, 0, 0].pack("VVVV")
length = 16
add_mso_generic(type, version, instance, data, length)
end | ruby | def store_mso_spgr #:nodoc:
type = 0xF009
version = 1
instance = 0
data = [0, 0, 0, 0].pack("VVVV")
length = 16
add_mso_generic(type, version, instance, data, length)
end | [
"def",
"store_mso_spgr",
"type",
"=",
"0xF009",
"version",
"=",
"1",
"instance",
"=",
"0",
"data",
"=",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
"]",
".",
"pack",
"(",
"\"VVVV\"",
")",
"length",
"=",
"16",
"add_mso_generic",
"(",
"type",
",",
"versi... | Write the Escher Spgr record that is part of MSODRAWING. | [
"Write",
"the",
"Escher",
"Spgr",
"record",
"that",
"is",
"part",
"of",
"MSODRAWING",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L6781-L6789 | train |
cxn03651/writeexcel | lib/writeexcel/format.rb | Writeexcel.Format.get_font | def get_font # :nodoc:
# my $record; # Record identifier
# my $length; # Record length
# my $dyHeight; # Height of font (1/20 of a point)
# my $grbit; # Font attributes
# my $icv; # Index to color palette
# my $bls; # Bold style
# my $sss; ... | ruby | def get_font # :nodoc:
# my $record; # Record identifier
# my $length; # Record length
# my $dyHeight; # Height of font (1/20 of a point)
# my $grbit; # Font attributes
# my $icv; # Index to color palette
# my $bls; # Bold style
# my $sss; ... | [
"def",
"get_font",
"dyHeight",
"=",
"@size",
"*",
"20",
"icv",
"=",
"@color",
"bls",
"=",
"@bold",
"sss",
"=",
"@font_script",
"uls",
"=",
"@underline",
"bFamily",
"=",
"@font_family",
"bCharSet",
"=",
"@font_charset",
"rgch",
"=",
"@font",
"encoding",
"=",
... | Generate an Excel BIFF FONT record. | [
"Generate",
"an",
"Excel",
"BIFF",
"FONT",
"record",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/format.rb#L336-L399 | train |
cxn03651/writeexcel | lib/writeexcel/format.rb | Writeexcel.Format.set_border | def set_border(style)
set_bottom(style)
set_top(style)
set_left(style)
set_right(style)
end | ruby | def set_border(style)
set_bottom(style)
set_top(style)
set_left(style)
set_right(style)
end | [
"def",
"set_border",
"(",
"style",
")",
"set_bottom",
"(",
"style",
")",
"set_top",
"(",
"style",
")",
"set_left",
"(",
"style",
")",
"set_right",
"(",
"style",
")",
"end"
] | Set cells borders to the same style
Also applies to: set_bottom()
set_top()
set_left()
set_right()
Default state: Border is off
Default action: Set border type 1
Valid args: 0-13, See below.
A cell bor... | [
"Set",
"cells",
"borders",
"to",
"the",
"same",
"style"
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/format.rb#L1106-L1111 | train |
cxn03651/writeexcel | lib/writeexcel/format.rb | Writeexcel.Format.set_border_color | def set_border_color(color)
set_bottom_color(color)
set_top_color(color)
set_left_color(color)
set_right_color(color)
end | ruby | def set_border_color(color)
set_bottom_color(color)
set_top_color(color)
set_left_color(color)
set_right_color(color)
end | [
"def",
"set_border_color",
"(",
"color",
")",
"set_bottom_color",
"(",
"color",
")",
"set_top_color",
"(",
"color",
")",
"set_left_color",
"(",
"color",
")",
"set_right_color",
"(",
"color",
")",
"end"
] | Set cells border to the same color
Also applies to: set_bottom_color()
set_top_color()
set_left_color()
set_right_color()
Default state: Color is off
Default action: Undefined
Valid args: See set_color()... | [
"Set",
"cells",
"border",
"to",
"the",
"same",
"color"
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/format.rb#L1163-L1168 | train |
cxn03651/writeexcel | lib/writeexcel/format.rb | Writeexcel.Format.method_missing | def method_missing(name, *args) # :nodoc:
# -- original perl comment --
# There are two types of set methods: set_property() and
# set_property_color(). When a method is AUTOLOADED we store a new anonymous
# sub in the appropriate slot in the symbol table. The speeds up subsequent
# calls to the sa... | ruby | def method_missing(name, *args) # :nodoc:
# -- original perl comment --
# There are two types of set methods: set_property() and
# set_property_color(). When a method is AUTOLOADED we store a new anonymous
# sub in the appropriate slot in the symbol table. The speeds up subsequent
# calls to the sa... | [
"def",
"method_missing",
"(",
"name",
",",
"*",
"args",
")",
"method",
"=",
"\"#{name}\"",
"method",
"=~",
"/",
"\\w",
"/",
"or",
"raise",
"\"Unknown method: #{method}\\n\"",
"attribute",
"=",
"\"@#{$1}\"",
"if",
"method",
"=~",
"/",
"\\w",
"/",
"value",
"="... | Dynamically create set methods that aren't already defined. | [
"Dynamically",
"create",
"set",
"methods",
"that",
"aren",
"t",
"already",
"defined",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/format.rb#L1543-L1571 | train |
cxn03651/writeexcel | lib/writeexcel/image.rb | Writeexcel.Image.process_jpg | def process_jpg(data)
@type = 5 # Excel Blip type (MSOBLIPTYPE).
offset = 2
data_length = data.bytesize
# Search through the image data to find the 0xFFC0 marker. The height and
# width are contained in the data for that sub element.
while offset < data_length
marker ... | ruby | def process_jpg(data)
@type = 5 # Excel Blip type (MSOBLIPTYPE).
offset = 2
data_length = data.bytesize
# Search through the image data to find the 0xFFC0 marker. The height and
# width are contained in the data for that sub element.
while offset < data_length
marker ... | [
"def",
"process_jpg",
"(",
"data",
")",
"@type",
"=",
"5",
"offset",
"=",
"2",
"data_length",
"=",
"data",
".",
"bytesize",
"while",
"offset",
"<",
"data_length",
"marker",
"=",
"data",
"[",
"offset",
",",
"2",
"]",
".",
"unpack",
"(",
"\"n\"",
")",
... | Extract width and height information from a JPEG file. | [
"Extract",
"width",
"and",
"height",
"information",
"from",
"a",
"JPEG",
"file",
"."
] | d0345067c21b14a7141ba66b6752be8f4be379de | https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/image.rb#L119-L146 | train |
burtlo/yard-cucumber | lib/yard/code_objects/step_transformer.rb | YARD::CodeObjects.StepTransformerObject.value | def value
unless @processed
@processed = true
until (nested = constants_from_value).empty?
nested.each {|n| @value.gsub!(value_regex(n),find_value_for_constant(n)) }
end
end
@value
end | ruby | def value
unless @processed
@processed = true
until (nested = constants_from_value).empty?
nested.each {|n| @value.gsub!(value_regex(n),find_value_for_constant(n)) }
end
end
@value
end | [
"def",
"value",
"unless",
"@processed",
"@processed",
"=",
"true",
"until",
"(",
"nested",
"=",
"constants_from_value",
")",
".",
"empty?",
"nested",
".",
"each",
"{",
"|",
"n",
"|",
"@value",
".",
"gsub!",
"(",
"value_regex",
"(",
"n",
")",
",",
"find_v... | When requesting a step tranformer object value, process it, if it hasn't
alredy been processed, replacing any constants that may be lurking within
the value.
Processing it means looking for any escaped characters that happen to be
CONSTANTS that could be matched and then replaced. This is done recursively
as CONS... | [
"When",
"requesting",
"a",
"step",
"tranformer",
"object",
"value",
"process",
"it",
"if",
"it",
"hasn",
"t",
"alredy",
"been",
"processed",
"replacing",
"any",
"constants",
"that",
"may",
"be",
"lurking",
"within",
"the",
"value",
"."
] | 177e5ad17aa4973660ce646b398118a6408d8913 | https://github.com/burtlo/yard-cucumber/blob/177e5ad17aa4973660ce646b398118a6408d8913/lib/yard/code_objects/step_transformer.rb#L31-L40 | train |
burtlo/yard-cucumber | lib/yard/code_objects/step_transformer.rb | YARD::CodeObjects.StepTransformerObject.constants_from_value | def constants_from_value(data=@value)
data.scan(escape_pattern).flatten.collect { |value| value.strip }
end | ruby | def constants_from_value(data=@value)
data.scan(escape_pattern).flatten.collect { |value| value.strip }
end | [
"def",
"constants_from_value",
"(",
"data",
"=",
"@value",
")",
"data",
".",
"scan",
"(",
"escape_pattern",
")",
".",
"flatten",
".",
"collect",
"{",
"|",
"value",
"|",
"value",
".",
"strip",
"}",
"end"
] | Look through the specified data for the escape pattern and return an array
of those constants found. This defaults to the @value within step transformer
as it is used internally, however, it can be called externally if it's
needed somewhere. | [
"Look",
"through",
"the",
"specified",
"data",
"for",
"the",
"escape",
"pattern",
"and",
"return",
"an",
"array",
"of",
"those",
"constants",
"found",
".",
"This",
"defaults",
"to",
"the"
] | 177e5ad17aa4973660ce646b398118a6408d8913 | https://github.com/burtlo/yard-cucumber/blob/177e5ad17aa4973660ce646b398118a6408d8913/lib/yard/code_objects/step_transformer.rb#L68-L70 | train |
burtlo/yard-cucumber | lib/yard/code_objects/step_transformer.rb | YARD::CodeObjects.StepTransformerObject.find_value_for_constant | def find_value_for_constant(name)
constant = YARD::Registry.all(:constant).find{|c| c.name == name.to_sym }
log.warn "StepTransformer#find_value_for_constant : Could not find the CONSTANT [#{name}] using the string value." unless constant
constant ? strip_regex_from(constant.value) : name
end | ruby | def find_value_for_constant(name)
constant = YARD::Registry.all(:constant).find{|c| c.name == name.to_sym }
log.warn "StepTransformer#find_value_for_constant : Could not find the CONSTANT [#{name}] using the string value." unless constant
constant ? strip_regex_from(constant.value) : name
end | [
"def",
"find_value_for_constant",
"(",
"name",
")",
"constant",
"=",
"YARD",
"::",
"Registry",
".",
"all",
"(",
":constant",
")",
".",
"find",
"{",
"|",
"c",
"|",
"c",
".",
"name",
"==",
"name",
".",
"to_sym",
"}",
"log",
".",
"warn",
"\"StepTransforme... | Looking through all the constants in the registry and returning the value
with the regex items replaced from the constnat if present | [
"Looking",
"through",
"all",
"the",
"constants",
"in",
"the",
"registry",
"and",
"returning",
"the",
"value",
"with",
"the",
"regex",
"items",
"replaced",
"from",
"the",
"constnat",
"if",
"present"
] | 177e5ad17aa4973660ce646b398118a6408d8913 | https://github.com/burtlo/yard-cucumber/blob/177e5ad17aa4973660ce646b398118a6408d8913/lib/yard/code_objects/step_transformer.rb#L78-L82 | train |
burtlo/yard-cucumber | lib/yard/parser/cucumber/feature.rb | YARD::Parser::Cucumber.FeatureParser.parse | def parse
begin
@parser.parse(@source)
@feature = @builder.ast
return nil if @feature.nil? # Nothing matched
# The parser used the following keywords when parsing the feature
# @feature.language = @parser.i18n_language.get_code_keywords.map {|word| word }
... | ruby | def parse
begin
@parser.parse(@source)
@feature = @builder.ast
return nil if @feature.nil? # Nothing matched
# The parser used the following keywords when parsing the feature
# @feature.language = @parser.i18n_language.get_code_keywords.map {|word| word }
... | [
"def",
"parse",
"begin",
"@parser",
".",
"parse",
"(",
"@source",
")",
"@feature",
"=",
"@builder",
".",
"ast",
"return",
"nil",
"if",
"@feature",
".",
"nil?",
"rescue",
"Gherkin",
"::",
"ParserError",
"=>",
"e",
"e",
".",
"message",
".",
"insert",
"(",
... | Each found feature found is creates a new FeatureParser
This logic was copied from the logic found in Cucumber to create the builder
and then set up the formatter and parser. The difference is really the
custom Cucumber::Parser::CityBuilder that is being used to parse the elements
of the feature into YARD::CodeObj... | [
"Each",
"found",
"feature",
"found",
"is",
"creates",
"a",
"new",
"FeatureParser"
] | 177e5ad17aa4973660ce646b398118a6408d8913 | https://github.com/burtlo/yard-cucumber/blob/177e5ad17aa4973660ce646b398118a6408d8913/lib/yard/parser/cucumber/feature.rb#L35-L50 | train |
hidroh/cucumber-api | lib/cucumber-api/response.rb | CucumberApi.Response.has | def has json_path, json=nil
if json.nil?
json = JSON.parse body
end
not JsonPath.new(json_path).on(json).empty?
end | ruby | def has json_path, json=nil
if json.nil?
json = JSON.parse body
end
not JsonPath.new(json_path).on(json).empty?
end | [
"def",
"has",
"json_path",
",",
"json",
"=",
"nil",
"if",
"json",
".",
"nil?",
"json",
"=",
"JSON",
".",
"parse",
"body",
"end",
"not",
"JsonPath",
".",
"new",
"(",
"json_path",
")",
".",
"on",
"(",
"json",
")",
".",
"empty?",
"end"
] | Check if given JSON path exists
@param json_path [String] a valid JSON path expression
@param json [String] optional JSON from which to check JSON path, default to response body
@return [true, false] true if JSON path is valid and exists, false otherwise | [
"Check",
"if",
"given",
"JSON",
"path",
"exists"
] | 8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11 | https://github.com/hidroh/cucumber-api/blob/8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11/lib/cucumber-api/response.rb#L22-L27 | train |
hidroh/cucumber-api | lib/cucumber-api/response.rb | CucumberApi.Response.get | def get json_path, json=nil
if json.nil?
json = JSON.parse body
end
results = JsonPath.new(json_path).on(json)
if results.empty?
raise %/Expected json path '#{json_path}' not found\n#{to_json_s}/
end
results.first
end | ruby | def get json_path, json=nil
if json.nil?
json = JSON.parse body
end
results = JsonPath.new(json_path).on(json)
if results.empty?
raise %/Expected json path '#{json_path}' not found\n#{to_json_s}/
end
results.first
end | [
"def",
"get",
"json_path",
",",
"json",
"=",
"nil",
"if",
"json",
".",
"nil?",
"json",
"=",
"JSON",
".",
"parse",
"body",
"end",
"results",
"=",
"JsonPath",
".",
"new",
"(",
"json_path",
")",
".",
"on",
"(",
"json",
")",
"if",
"results",
".",
"empt... | Retrieve value of the first JSON element with given JSON path
@param json_path [String] a valid JSON path expression
@param json [String] optional JSON from which to apply JSON path, default to response body
@return [Object] value of first retrieved JSON element in form of Ruby object
@raise [Exception] if JSON pat... | [
"Retrieve",
"value",
"of",
"the",
"first",
"JSON",
"element",
"with",
"given",
"JSON",
"path"
] | 8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11 | https://github.com/hidroh/cucumber-api/blob/8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11/lib/cucumber-api/response.rb#L34-L43 | train |
hidroh/cucumber-api | lib/cucumber-api/response.rb | CucumberApi.Response.get_as_type | def get_as_type json_path, type, json=nil
value = get json_path, json
case type
when 'numeric'
valid = value.is_a? Numeric
when 'array'
valid = value.is_a? Array
when 'string'
valid = value.is_a? String
when 'boolean'
valid = !!value ==... | ruby | def get_as_type json_path, type, json=nil
value = get json_path, json
case type
when 'numeric'
valid = value.is_a? Numeric
when 'array'
valid = value.is_a? Array
when 'string'
valid = value.is_a? String
when 'boolean'
valid = !!value ==... | [
"def",
"get_as_type",
"json_path",
",",
"type",
",",
"json",
"=",
"nil",
"value",
"=",
"get",
"json_path",
",",
"json",
"case",
"type",
"when",
"'numeric'",
"valid",
"=",
"value",
".",
"is_a?",
"Numeric",
"when",
"'array'",
"valid",
"=",
"value",
".",
"i... | Retrieve value of the first JSON element with given JSON path as given type
@param json_path [String] a valid JSON path expression
@param type [String] required type, possible values are 'numeric', 'array', 'string', 'boolean', 'numeric_string'
or 'object'
@param json [String] optional JSON from which to apply JSON... | [
"Retrieve",
"value",
"of",
"the",
"first",
"JSON",
"element",
"with",
"given",
"JSON",
"path",
"as",
"given",
"type"
] | 8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11 | https://github.com/hidroh/cucumber-api/blob/8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11/lib/cucumber-api/response.rb#L53-L76 | train |
hidroh/cucumber-api | lib/cucumber-api/response.rb | CucumberApi.Response.get_as_type_or_null | def get_as_type_or_null json_path, type, json=nil
value = get json_path, json
value.nil? ? value : get_as_type(json_path, type, json)
end | ruby | def get_as_type_or_null json_path, type, json=nil
value = get json_path, json
value.nil? ? value : get_as_type(json_path, type, json)
end | [
"def",
"get_as_type_or_null",
"json_path",
",",
"type",
",",
"json",
"=",
"nil",
"value",
"=",
"get",
"json_path",
",",
"json",
"value",
".",
"nil?",
"?",
"value",
":",
"get_as_type",
"(",
"json_path",
",",
"type",
",",
"json",
")",
"end"
] | Retrieve value of the first JSON element with given JSON path as given type, with nil value allowed
@param json_path [String] a valid JSON path expression
@param type [String] required type, possible values are 'numeric', 'array', 'string', 'boolean', 'numeric_string'
or 'object'
@param json [String] optional JSON ... | [
"Retrieve",
"value",
"of",
"the",
"first",
"JSON",
"element",
"with",
"given",
"JSON",
"path",
"as",
"given",
"type",
"with",
"nil",
"value",
"allowed"
] | 8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11 | https://github.com/hidroh/cucumber-api/blob/8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11/lib/cucumber-api/response.rb#L86-L89 | train |
hidroh/cucumber-api | lib/cucumber-api/response.rb | CucumberApi.Response.get_as_type_and_check_value | def get_as_type_and_check_value json_path, type, value, json=nil
v = get_as_type json_path, type, json
if value != v.to_s
raise %/Expect '#{json_path}' to be '#{value}' but was '#{v}'\n#{to_json_s}/
end
end | ruby | def get_as_type_and_check_value json_path, type, value, json=nil
v = get_as_type json_path, type, json
if value != v.to_s
raise %/Expect '#{json_path}' to be '#{value}' but was '#{v}'\n#{to_json_s}/
end
end | [
"def",
"get_as_type_and_check_value",
"json_path",
",",
"type",
",",
"value",
",",
"json",
"=",
"nil",
"v",
"=",
"get_as_type",
"json_path",
",",
"type",
",",
"json",
"if",
"value",
"!=",
"v",
".",
"to_s",
"raise",
"%/Expect '#{json_path}' to be '#{value}' but was... | Retrieve value of the first JSON element with given JSON path as given type, and check for a given value
@param json_path [String] a valid JSON path expression
@param type [String] required type, possible values are 'numeric', 'string', 'boolean', or 'numeric_string'
@param value [String] value to check for
@param ... | [
"Retrieve",
"value",
"of",
"the",
"first",
"JSON",
"element",
"with",
"given",
"JSON",
"path",
"as",
"given",
"type",
"and",
"check",
"for",
"a",
"given",
"value"
] | 8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11 | https://github.com/hidroh/cucumber-api/blob/8d101d166b5eb0dd2f9f6eee5019e062bc3d4f11/lib/cucumber-api/response.rb#L99-L104 | train |
square/rails-auth | lib/rails/auth/helpers.rb | Rails.Auth.authorized! | def authorized!(rack_env, allowed_by)
Env.new(rack_env).tap do |env|
env.authorize(allowed_by)
end.to_rack
end | ruby | def authorized!(rack_env, allowed_by)
Env.new(rack_env).tap do |env|
env.authorize(allowed_by)
end.to_rack
end | [
"def",
"authorized!",
"(",
"rack_env",
",",
"allowed_by",
")",
"Env",
".",
"new",
"(",
"rack_env",
")",
".",
"tap",
"do",
"|",
"env",
"|",
"env",
".",
"authorize",
"(",
"allowed_by",
")",
"end",
".",
"to_rack",
"end"
] | Mark a request as externally authorized. Causes ACL checks to be skipped.
@param [Hash] :rack_env Rack environment
@param [String] :allowed_by what allowed the request | [
"Mark",
"a",
"request",
"as",
"externally",
"authorized",
".",
"Causes",
"ACL",
"checks",
"to",
"be",
"skipped",
"."
] | 7cac4119c043f7de923f67255d1789ea70aeba5d | https://github.com/square/rails-auth/blob/7cac4119c043f7de923f67255d1789ea70aeba5d/lib/rails/auth/helpers.rb#L11-L15 | train |
square/rails-auth | lib/rails/auth/helpers.rb | Rails.Auth.set_allowed_by | def set_allowed_by(rack_env, allowed_by)
Env.new(rack_env).tap do |env|
env.allowed_by = allowed_by
end.to_rack
end | ruby | def set_allowed_by(rack_env, allowed_by)
Env.new(rack_env).tap do |env|
env.allowed_by = allowed_by
end.to_rack
end | [
"def",
"set_allowed_by",
"(",
"rack_env",
",",
"allowed_by",
")",
"Env",
".",
"new",
"(",
"rack_env",
")",
".",
"tap",
"do",
"|",
"env",
"|",
"env",
".",
"allowed_by",
"=",
"allowed_by",
"end",
".",
"to_rack",
"end"
] | Mark what authorized the request in the Rack environment
@param [Hash] :rack_env Rack environment
@param [String] :allowed_by what allowed this request | [
"Mark",
"what",
"authorized",
"the",
"request",
"in",
"the",
"Rack",
"environment"
] | 7cac4119c043f7de923f67255d1789ea70aeba5d | https://github.com/square/rails-auth/blob/7cac4119c043f7de923f67255d1789ea70aeba5d/lib/rails/auth/helpers.rb#L29-L33 | train |
square/rails-auth | lib/rails/auth/helpers.rb | Rails.Auth.add_credential | def add_credential(rack_env, type, credential)
Env.new(rack_env).tap do |env|
env.credentials[type] = credential
end.to_rack
end | ruby | def add_credential(rack_env, type, credential)
Env.new(rack_env).tap do |env|
env.credentials[type] = credential
end.to_rack
end | [
"def",
"add_credential",
"(",
"rack_env",
",",
"type",
",",
"credential",
")",
"Env",
".",
"new",
"(",
"rack_env",
")",
".",
"tap",
"do",
"|",
"env",
"|",
"env",
".",
"credentials",
"[",
"type",
"]",
"=",
"credential",
"end",
".",
"to_rack",
"end"
] | Add a credential to the Rack environment
@param [Hash] :rack_env Rack environment
@param [String] :type credential type to add to the environment
@param [Object] :credential object to add to the environment | [
"Add",
"a",
"credential",
"to",
"the",
"Rack",
"environment"
] | 7cac4119c043f7de923f67255d1789ea70aeba5d | https://github.com/square/rails-auth/blob/7cac4119c043f7de923f67255d1789ea70aeba5d/lib/rails/auth/helpers.rb#L58-L62 | train |
cristibalan/braid | lib/braid/config.rb | Braid.Config.write_db | def write_db
new_db = {}
@db.keys.sort.each do |key|
new_db[key] = {}
Braid::Mirror::ATTRIBUTES.each do |k|
new_db[key][k] = @db[key][k] if @db[key].has_key?(k)
end
end
new_data = {
'config_version' => CURRENT_CONFIG_VERSION,
'mirrors' => new_db
... | ruby | def write_db
new_db = {}
@db.keys.sort.each do |key|
new_db[key] = {}
Braid::Mirror::ATTRIBUTES.each do |k|
new_db[key][k] = @db[key][k] if @db[key].has_key?(k)
end
end
new_data = {
'config_version' => CURRENT_CONFIG_VERSION,
'mirrors' => new_db
... | [
"def",
"write_db",
"new_db",
"=",
"{",
"}",
"@db",
".",
"keys",
".",
"sort",
".",
"each",
"do",
"|",
"key",
"|",
"new_db",
"[",
"key",
"]",
"=",
"{",
"}",
"Braid",
"::",
"Mirror",
"::",
"ATTRIBUTES",
".",
"each",
"do",
"|",
"k",
"|",
"new_db",
... | Public for upgrade-config command only. | [
"Public",
"for",
"upgrade",
"-",
"config",
"command",
"only",
"."
] | d5eba17bb2905e75227e36858709b0a49b988b9e | https://github.com/cristibalan/braid/blob/d5eba17bb2905e75227e36858709b0a49b988b9e/lib/braid/config.rb#L194-L210 | train |
michaelherold/benchmark-memory | lib/benchmark/memory.rb | Benchmark.Memory.memory | def memory(quiet: false)
raise ConfigurationError unless block_given?
job = Job.new(quiet: quiet)
yield job
job.run
job.run_comparison
job.full_report
end | ruby | def memory(quiet: false)
raise ConfigurationError unless block_given?
job = Job.new(quiet: quiet)
yield job
job.run
job.run_comparison
job.full_report
end | [
"def",
"memory",
"(",
"quiet",
":",
"false",
")",
"raise",
"ConfigurationError",
"unless",
"block_given?",
"job",
"=",
"Job",
".",
"new",
"(",
"quiet",
":",
"quiet",
")",
"yield",
"job",
"job",
".",
"run",
"job",
".",
"run_comparison",
"job",
".",
"full_... | Measure memory usage in report blocks.
@param quiet [Boolean] A flag to toggle benchmark output.
@return [Report] | [
"Measure",
"memory",
"usage",
"in",
"report",
"blocks",
"."
] | cd91f5ba81e20cbcea583f305a5b9b9d77cecdd3 | https://github.com/michaelherold/benchmark-memory/blob/cd91f5ba81e20cbcea583f305a5b9b9d77cecdd3/lib/benchmark/memory.rb#L15-L25 | train |
ryanb/populator | lib/populator/factory.rb | Populator.Factory.populate | def populate(amount, options = {}, &block)
self.class.remember_depth do
build_records(Populator.interpret_value(amount), options[:per_query] || DEFAULT_RECORDS_PER_QUERY, &block)
end
end | ruby | def populate(amount, options = {}, &block)
self.class.remember_depth do
build_records(Populator.interpret_value(amount), options[:per_query] || DEFAULT_RECORDS_PER_QUERY, &block)
end
end | [
"def",
"populate",
"(",
"amount",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"self",
".",
"class",
".",
"remember_depth",
"do",
"build_records",
"(",
"Populator",
".",
"interpret_value",
"(",
"amount",
")",
",",
"options",
"[",
":per_query",
... | Use for_model instead of instatiating a record directly.
Entry method for building records. Delegates to build_records after remember_depth. | [
"Use",
"for_model",
"instead",
"of",
"instatiating",
"a",
"record",
"directly",
".",
"Entry",
"method",
"for",
"building",
"records",
".",
"Delegates",
"to",
"build_records",
"after",
"remember_depth",
"."
] | cd1373d8c0a89709a892db9abb2517a87646ed41 | https://github.com/ryanb/populator/blob/cd1373d8c0a89709a892db9abb2517a87646ed41/lib/populator/factory.rb#L41-L45 | train |
ryanb/populator | lib/populator/factory.rb | Populator.Factory.save_records | def save_records
unless @records.empty?
@model_class.connection.populate(@model_class.quoted_table_name, columns_sql, rows_sql_arr, "#{@model_class.name} Populate")
@last_id_in_database = @records.last.id
@records.clear
end
end | ruby | def save_records
unless @records.empty?
@model_class.connection.populate(@model_class.quoted_table_name, columns_sql, rows_sql_arr, "#{@model_class.name} Populate")
@last_id_in_database = @records.last.id
@records.clear
end
end | [
"def",
"save_records",
"unless",
"@records",
".",
"empty?",
"@model_class",
".",
"connection",
".",
"populate",
"(",
"@model_class",
".",
"quoted_table_name",
",",
"columns_sql",
",",
"rows_sql_arr",
",",
"\"#{@model_class.name} Populate\"",
")",
"@last_id_in_database",
... | Saves the records to the database by calling populate on the current database adapter. | [
"Saves",
"the",
"records",
"to",
"the",
"database",
"by",
"calling",
"populate",
"on",
"the",
"current",
"database",
"adapter",
"."
] | cd1373d8c0a89709a892db9abb2517a87646ed41 | https://github.com/ryanb/populator/blob/cd1373d8c0a89709a892db9abb2517a87646ed41/lib/populator/factory.rb#L60-L66 | train |
ryanb/populator | lib/populator/model_additions.rb | Populator.ModelAdditions.populate | def populate(amount, options = {}, &block)
Factory.for_model(self).populate(amount, options, &block)
end | ruby | def populate(amount, options = {}, &block)
Factory.for_model(self).populate(amount, options, &block)
end | [
"def",
"populate",
"(",
"amount",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"Factory",
".",
"for_model",
"(",
"self",
")",
".",
"populate",
"(",
"amount",
",",
"options",
",",
"&",
"block",
")",
"end"
] | Call populate on any ActiveRecord model to fill it with data.
Pass the number of records you want to create, and a block to
set the attributes. You can nest calls to handle associations
and use ranges or arrays to randomize the values.
Person.populate(3000) do |person|
person.name = "John Doe"
person.g... | [
"Call",
"populate",
"on",
"any",
"ActiveRecord",
"model",
"to",
"fill",
"it",
"with",
"data",
".",
"Pass",
"the",
"number",
"of",
"records",
"you",
"want",
"to",
"create",
"and",
"a",
"block",
"to",
"set",
"the",
"attributes",
".",
"You",
"can",
"nest",
... | cd1373d8c0a89709a892db9abb2517a87646ed41 | https://github.com/ryanb/populator/blob/cd1373d8c0a89709a892db9abb2517a87646ed41/lib/populator/model_additions.rb#L24-L26 | train |
ryanb/populator | lib/populator/random.rb | Populator.Random.value_in_range | def value_in_range(range)
case range.first
when Integer then number_in_range(range)
when Time then time_in_range(range)
when Date then date_in_range(range)
else range.to_a[rand(range.to_a.size)]
end
end | ruby | def value_in_range(range)
case range.first
when Integer then number_in_range(range)
when Time then time_in_range(range)
when Date then date_in_range(range)
else range.to_a[rand(range.to_a.size)]
end
end | [
"def",
"value_in_range",
"(",
"range",
")",
"case",
"range",
".",
"first",
"when",
"Integer",
"then",
"number_in_range",
"(",
"range",
")",
"when",
"Time",
"then",
"time_in_range",
"(",
"range",
")",
"when",
"Date",
"then",
"date_in_range",
"(",
"range",
")"... | Pick a random value out of a given range. | [
"Pick",
"a",
"random",
"value",
"out",
"of",
"a",
"given",
"range",
"."
] | cd1373d8c0a89709a892db9abb2517a87646ed41 | https://github.com/ryanb/populator/blob/cd1373d8c0a89709a892db9abb2517a87646ed41/lib/populator/random.rb#L8-L15 | train |
sophsec/ruby-nmap | lib/nmap/program.rb | Nmap.Program.scan | def scan(options={},exec_options={},&block)
run_task(Task.new(options,&block),exec_options)
end | ruby | def scan(options={},exec_options={},&block)
run_task(Task.new(options,&block),exec_options)
end | [
"def",
"scan",
"(",
"options",
"=",
"{",
"}",
",",
"exec_options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"run_task",
"(",
"Task",
".",
"new",
"(",
"options",
",",
"&",
"block",
")",
",",
"exec_options",
")",
"end"
] | Performs a scan.
@param [Hash{Symbol => Object}] options
Additional options for nmap.
@param [Hash{Symbol => Object}] exec_options
Additional exec-options.
@yield [task]
If a block is given, it will be passed a task object
used to specify options for nmap.
@yieldparam [Task] task
The nmap task ob... | [
"Performs",
"a",
"scan",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/program.rb#L86-L88 | train |
sophsec/ruby-nmap | lib/nmap/program.rb | Nmap.Program.sudo_scan | def sudo_scan(options={},exec_options={},&block)
sudo_task(Task.new(options,&block),exec_options)
end | ruby | def sudo_scan(options={},exec_options={},&block)
sudo_task(Task.new(options,&block),exec_options)
end | [
"def",
"sudo_scan",
"(",
"options",
"=",
"{",
"}",
",",
"exec_options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"sudo_task",
"(",
"Task",
".",
"new",
"(",
"options",
",",
"&",
"block",
")",
",",
"exec_options",
")",
"end"
] | Performs a scan and runs `nmap` under `sudo`.
@see #scan
@since 0.8.0 | [
"Performs",
"a",
"scan",
"and",
"runs",
"nmap",
"under",
"sudo",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/program.rb#L97-L99 | train |
sophsec/ruby-nmap | lib/nmap/xml.rb | Nmap.XML.scanner | def scanner
@scanner ||= Scanner.new(
@doc.root['scanner'],
@doc.root['version'],
@doc.root['args'],
Time.at(@doc.root['start'].to_i)
)
end | ruby | def scanner
@scanner ||= Scanner.new(
@doc.root['scanner'],
@doc.root['version'],
@doc.root['args'],
Time.at(@doc.root['start'].to_i)
)
end | [
"def",
"scanner",
"@scanner",
"||=",
"Scanner",
".",
"new",
"(",
"@doc",
".",
"root",
"[",
"'scanner'",
"]",
",",
"@doc",
".",
"root",
"[",
"'version'",
"]",
",",
"@doc",
".",
"root",
"[",
"'args'",
"]",
",",
"Time",
".",
"at",
"(",
"@doc",
".",
... | Parses the scanner information.
@return [Scanner]
The scanner that was used and generated the scan file. | [
"Parses",
"the",
"scanner",
"information",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/xml.rb#L99-L106 | train |
sophsec/ruby-nmap | lib/nmap/xml.rb | Nmap.XML.scan_info | def scan_info
@doc.xpath('/nmaprun/scaninfo').map do |scaninfo|
Scan.new(
scaninfo['type'].to_sym,
scaninfo['protocol'].to_sym,
scaninfo['services'].split(',').map { |ports|
if ports.include?('-')
Range.new(*(ports.split('-',2)))
else
... | ruby | def scan_info
@doc.xpath('/nmaprun/scaninfo').map do |scaninfo|
Scan.new(
scaninfo['type'].to_sym,
scaninfo['protocol'].to_sym,
scaninfo['services'].split(',').map { |ports|
if ports.include?('-')
Range.new(*(ports.split('-',2)))
else
... | [
"def",
"scan_info",
"@doc",
".",
"xpath",
"(",
"'/nmaprun/scaninfo'",
")",
".",
"map",
"do",
"|",
"scaninfo",
"|",
"Scan",
".",
"new",
"(",
"scaninfo",
"[",
"'type'",
"]",
".",
"to_sym",
",",
"scaninfo",
"[",
"'protocol'",
"]",
".",
"to_sym",
",",
"sca... | Parses the scan information.
@return [Array<Scan>]
The scan information. | [
"Parses",
"the",
"scan",
"information",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/xml.rb#L124-L138 | train |
sophsec/ruby-nmap | lib/nmap/xml.rb | Nmap.XML.each_run_stat | def each_run_stat
return enum_for(__method__) unless block_given?
@doc.xpath('/nmaprun/runstats/finished').each do |run_stat|
yield RunStat.new(
Time.at(run_stat['time'].to_i),
run_stat['elapsed'],
run_stat['summary'],
run_stat['exit']
)
end
... | ruby | def each_run_stat
return enum_for(__method__) unless block_given?
@doc.xpath('/nmaprun/runstats/finished').each do |run_stat|
yield RunStat.new(
Time.at(run_stat['time'].to_i),
run_stat['elapsed'],
run_stat['summary'],
run_stat['exit']
)
end
... | [
"def",
"each_run_stat",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"@doc",
".",
"xpath",
"(",
"'/nmaprun/runstats/finished'",
")",
".",
"each",
"do",
"|",
"run_stat",
"|",
"yield",
"RunStat",
".",
"new",
"(",
"Time",
".",
"at",
"... | Parses the essential runstats information.
@yield [run_stat]
The given block will be passed each runstat.
@yieldparam [RunStat] run_stat
A runstat.
@return [Enumerator]
If no block is given, an enumerator will be returned.
@since 0.7.0 | [
"Parses",
"the",
"essential",
"runstats",
"information",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/xml.rb#L154-L167 | train |
sophsec/ruby-nmap | lib/nmap/xml.rb | Nmap.XML.each_task | def each_task
return enum_for(__method__) unless block_given?
@doc.xpath('/nmaprun/taskbegin').each do |task_begin|
task_end = task_begin.xpath('following-sibling::taskend').first
yield ScanTask.new(
task_begin['task'],
Time.at(task_begin['time'].to_i),
Time.a... | ruby | def each_task
return enum_for(__method__) unless block_given?
@doc.xpath('/nmaprun/taskbegin').each do |task_begin|
task_end = task_begin.xpath('following-sibling::taskend').first
yield ScanTask.new(
task_begin['task'],
Time.at(task_begin['time'].to_i),
Time.a... | [
"def",
"each_task",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"@doc",
".",
"xpath",
"(",
"'/nmaprun/taskbegin'",
")",
".",
"each",
"do",
"|",
"task_begin",
"|",
"task_end",
"=",
"task_begin",
".",
"xpath",
"(",
"'following-sibling::... | Parses the tasks of the scan.
@yield [task]
The given block will be passed each scan task.
@yieldparam [ScanTask] task
A task from the scan.
@return [Enumerator]
If no block is given, an enumerator will be returned.
@since 0.7.0 | [
"Parses",
"the",
"tasks",
"of",
"the",
"scan",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/xml.rb#L215-L230 | train |
sophsec/ruby-nmap | lib/nmap/xml.rb | Nmap.XML.each_up_host | def each_up_host
return enum_for(__method__) unless block_given?
@doc.xpath("/nmaprun/host[status[@state='up']]").each do |host|
yield Host.new(host)
end
return self
end | ruby | def each_up_host
return enum_for(__method__) unless block_given?
@doc.xpath("/nmaprun/host[status[@state='up']]").each do |host|
yield Host.new(host)
end
return self
end | [
"def",
"each_up_host",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"@doc",
".",
"xpath",
"(",
"\"/nmaprun/host[status[@state='up']]\"",
")",
".",
"each",
"do",
"|",
"host",
"|",
"yield",
"Host",
".",
"new",
"(",
"host",
")",
"end",
... | Parses the hosts that were found to be up during the scan.
@yield [host]
Each host will be passed to a given block.
@yieldparam [Host] host
A host in the scan.
@return [XML, Enumerator]
The XML parser. If no block was given, an enumerator object will
be returned. | [
"Parses",
"the",
"hosts",
"that",
"were",
"found",
"to",
"be",
"up",
"during",
"the",
"scan",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/xml.rb#L381-L389 | train |
sophsec/ruby-nmap | lib/nmap/host.rb | Nmap.Host.each_address | def each_address
return enum_for(__method__) unless block_given?
@node.xpath("address[@addr]").each do |addr|
address = Address.new(
addr['addrtype'].to_sym,
addr['addr'],
addr['vendor']
)
yield address
end
return self
end | ruby | def each_address
return enum_for(__method__) unless block_given?
@node.xpath("address[@addr]").each do |addr|
address = Address.new(
addr['addrtype'].to_sym,
addr['addr'],
addr['vendor']
)
yield address
end
return self
end | [
"def",
"each_address",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"@node",
".",
"xpath",
"(",
"\"address[@addr]\"",
")",
".",
"each",
"do",
"|",
"addr",
"|",
"address",
"=",
"Address",
".",
"new",
"(",
"addr",
"[",
"'addrtype'",
... | Parses each address of the host.
@yield [addr]
Each parsed address will be pass to a given block.
@yieldparam [Address] addr
A address of the host.
@return [Host, Enumerator]
The host.
If no block was given, an enumerator will be returned. | [
"Parses",
"each",
"address",
"of",
"the",
"host",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/host.rb#L90-L104 | train |
sophsec/ruby-nmap | lib/nmap/host.rb | Nmap.Host.each_hostname | def each_hostname
return enum_for(__method__) unless block_given?
@node.xpath("hostnames/hostname[@name]").each do |host|
yield Hostname.new(host['type'],host['name'])
end
return self
end | ruby | def each_hostname
return enum_for(__method__) unless block_given?
@node.xpath("hostnames/hostname[@name]").each do |host|
yield Hostname.new(host['type'],host['name'])
end
return self
end | [
"def",
"each_hostname",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"@node",
".",
"xpath",
"(",
"\"hostnames/hostname[@name]\"",
")",
".",
"each",
"do",
"|",
"host",
"|",
"yield",
"Hostname",
".",
"new",
"(",
"host",
"[",
"'type'",
... | Parses the hostnames of the host.
@yield [host]
Each parsed hostname will be passed to the given block.
@yieldparam [Hostname] host
A hostname of the host.
@return [Host, Enumerator]
The host.
If no block was given, an enumerator will be returned. | [
"Parses",
"the",
"hostnames",
"of",
"the",
"host",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/host.rb#L199-L207 | train |
sophsec/ruby-nmap | lib/nmap/host.rb | Nmap.Host.uptime | def uptime
@uptime ||= if (uptime = @node.at_xpath('uptime'))
Uptime.new(
uptime['seconds'].to_i,
Time.parse(uptime['lastboot'])
)
end
yield @uptime if (@uptime && block_given?)
return @uptime
en... | ruby | def uptime
@uptime ||= if (uptime = @node.at_xpath('uptime'))
Uptime.new(
uptime['seconds'].to_i,
Time.parse(uptime['lastboot'])
)
end
yield @uptime if (@uptime && block_given?)
return @uptime
en... | [
"def",
"uptime",
"@uptime",
"||=",
"if",
"(",
"uptime",
"=",
"@node",
".",
"at_xpath",
"(",
"'uptime'",
")",
")",
"Uptime",
".",
"new",
"(",
"uptime",
"[",
"'seconds'",
"]",
".",
"to_i",
",",
"Time",
".",
"parse",
"(",
"uptime",
"[",
"'lastboot'",
"]... | Parses the Uptime analysis of the host.
@yield [uptime]
If a block is given, it will be passed the resulting object
@yieldparam [Uptime]
Uptime value.
@return [Uptime]
The parsed object.
@since 0.7.0 | [
"Parses",
"the",
"Uptime",
"analysis",
"of",
"the",
"host",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/host.rb#L265-L275 | train |
sophsec/ruby-nmap | lib/nmap/host.rb | Nmap.Host.each_tcp_port | def each_tcp_port
return enum_for(__method__) unless block_given?
@node.xpath("ports/port[@protocol='tcp']").each do |port|
yield Port.new(port)
end
return self
end | ruby | def each_tcp_port
return enum_for(__method__) unless block_given?
@node.xpath("ports/port[@protocol='tcp']").each do |port|
yield Port.new(port)
end
return self
end | [
"def",
"each_tcp_port",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"@node",
".",
"xpath",
"(",
"\"ports/port[@protocol='tcp']\"",
")",
".",
"each",
"do",
"|",
"port",
"|",
"yield",
"Port",
".",
"new",
"(",
"port",
")",
"end",
"re... | Parses the TCP ports of the host.
@yield [port]
Each TCP port of the host.
@yieldparam [Port] port
An TCP scanned port of the host.
@return [Host, Enumerator]
The host.
If no block was given, an enumerator will be returned. | [
"Parses",
"the",
"TCP",
"ports",
"of",
"the",
"host",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/host.rb#L446-L454 | train |
sophsec/ruby-nmap | lib/nmap/scripts.rb | Nmap.Scripts.script_data | def script_data
unless @script_data
@script_data = {}
traverse = lambda do |node|
case node.name
when 'script', 'table'
unless node.xpath('*[@key]').empty?
hash = {}
node.elements.each do |element|
hash[element['key']] =... | ruby | def script_data
unless @script_data
@script_data = {}
traverse = lambda do |node|
case node.name
when 'script', 'table'
unless node.xpath('*[@key]').empty?
hash = {}
node.elements.each do |element|
hash[element['key']] =... | [
"def",
"script_data",
"unless",
"@script_data",
"@script_data",
"=",
"{",
"}",
"traverse",
"=",
"lambda",
"do",
"|",
"node",
"|",
"case",
"node",
".",
"name",
"when",
"'script'",
",",
"'table'",
"unless",
"node",
".",
"xpath",
"(",
"'*[@key]'",
")",
".",
... | The structured output of the NSE scripts.
@return [Hash{String => Hash{String => Array<String>}}]
The NSE script names and their structured output.
@since 0.9.0 | [
"The",
"structured",
"output",
"of",
"the",
"NSE",
"scripts",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/scripts.rb#L31-L68 | train |
sophsec/ruby-nmap | lib/nmap/traceroute.rb | Nmap.Traceroute.each | def each
return enum_for(__method__) unless block_given?
@node.xpath('hop').each do |hop|
yield Hop.new(hop['ipaddr'],hop['host'],hop['ttl'],hop['rtt'])
end
return self
end | ruby | def each
return enum_for(__method__) unless block_given?
@node.xpath('hop').each do |hop|
yield Hop.new(hop['ipaddr'],hop['host'],hop['ttl'],hop['rtt'])
end
return self
end | [
"def",
"each",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"@node",
".",
"xpath",
"(",
"'hop'",
")",
".",
"each",
"do",
"|",
"hop",
"|",
"yield",
"Hop",
".",
"new",
"(",
"hop",
"[",
"'ipaddr'",
"]",
",",
"hop",
"[",
"'host... | Parses the traceroute information for the host.
@yield [hop]
Each hop to the host.
@yieldparam [Hop] hop
A hop to the host.
@return [Traceroute, Enumerator]
The traceroute.
If no block was given, an enumerator will be returned. | [
"Parses",
"the",
"traceroute",
"information",
"for",
"the",
"host",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/traceroute.rb#L60-L68 | train |
sophsec/ruby-nmap | lib/nmap/os.rb | Nmap.OS.each_class | def each_class
return enum_for(__method__) unless block_given?
@node.xpath("osmatch/osclass").each do |osclass|
yield OSClass.new(osclass)
end
return self
end | ruby | def each_class
return enum_for(__method__) unless block_given?
@node.xpath("osmatch/osclass").each do |osclass|
yield OSClass.new(osclass)
end
return self
end | [
"def",
"each_class",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"@node",
".",
"xpath",
"(",
"\"osmatch/osclass\"",
")",
".",
"each",
"do",
"|",
"osclass",
"|",
"yield",
"OSClass",
".",
"new",
"(",
"osclass",
")",
"end",
"return",... | Creates a new OS object.
@param [Nokogiri::XML::Node] node
The node that contains the OS guessing information.
Parses the OS class information.
@yield [class]
Passes each OS class to the given block.
@yieldparam [OSClass] class
The OS class information.
@return [OS, Enumerator]
The OS information... | [
"Creates",
"a",
"new",
"OS",
"object",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/os.rb#L35-L43 | train |
sophsec/ruby-nmap | lib/nmap/os.rb | Nmap.OS.each_match | def each_match
return enum_for(__method__) unless block_given?
@node.xpath("osmatch").map do |osclass|
os_match = OSMatch.new(
osclass['name'],
osclass['accuracy'].to_i
)
yield os_match
end
return self
end | ruby | def each_match
return enum_for(__method__) unless block_given?
@node.xpath("osmatch").map do |osclass|
os_match = OSMatch.new(
osclass['name'],
osclass['accuracy'].to_i
)
yield os_match
end
return self
end | [
"def",
"each_match",
"return",
"enum_for",
"(",
"__method__",
")",
"unless",
"block_given?",
"@node",
".",
"xpath",
"(",
"\"osmatch\"",
")",
".",
"map",
"do",
"|",
"osclass",
"|",
"os_match",
"=",
"OSMatch",
".",
"new",
"(",
"osclass",
"[",
"'name'",
"]",
... | Parses the OS match information.
@yield [match]
Passes each OS match to the given block.
@yieldparam [OSMatch] class
The OS match information.
@return [OS, Enumerator]
The OS information. If no block was given, an enumerator object
will be returned. | [
"Parses",
"the",
"OS",
"match",
"information",
"."
] | f6060a7b2238872357622572145add88fc2ba412 | https://github.com/sophsec/ruby-nmap/blob/f6060a7b2238872357622572145add88fc2ba412/lib/nmap/os.rb#L68-L81 | train |
veger/ruby-bbcode | lib/ruby-bbcode/bbtree.rb | RubyBBCode.BBTree.retrogress_bbtree | def retrogress_bbtree
if @tags_list[-1].definition[:self_closable]
# It is possible that the next (self_closable) tag is on the next line
# Remove newline of current tag and parent tag as they are (probably) not intented as an actual newline here but as tag separator
@tags_list[-1][:nodes]... | ruby | def retrogress_bbtree
if @tags_list[-1].definition[:self_closable]
# It is possible that the next (self_closable) tag is on the next line
# Remove newline of current tag and parent tag as they are (probably) not intented as an actual newline here but as tag separator
@tags_list[-1][:nodes]... | [
"def",
"retrogress_bbtree",
"if",
"@tags_list",
"[",
"-",
"1",
"]",
".",
"definition",
"[",
":self_closable",
"]",
"@tags_list",
"[",
"-",
"1",
"]",
"[",
":nodes",
"]",
"[",
"0",
"]",
"[",
":text",
"]",
".",
"chomp!",
"unless",
"@tags_list",
"[",
"-",
... | Step down the bbtree a notch because we've reached a closing tag | [
"Step",
"down",
"the",
"bbtree",
"a",
"notch",
"because",
"we",
"ve",
"reached",
"a",
"closing",
"tag"
] | 0b9ea504060f3e5b1ae9c3e5d9586a5672ec5fc7 | https://github.com/veger/ruby-bbcode/blob/0b9ea504060f3e5b1ae9c3e5d9586a5672ec5fc7/lib/ruby-bbcode/bbtree.rb#L48-L64 | train |
veger/ruby-bbcode | lib/ruby-bbcode/tag_sifter.rb | RubyBBCode.TagSifter.get_formatted_between | def get_formatted_between
between = @ti[:text]
# perform special formatting for cenrtain tags
between = match_url_id(between, @bbtree.current_node.definition[:url_matches]) if @bbtree.current_node.definition[:url_matches]
return between
end | ruby | def get_formatted_between
between = @ti[:text]
# perform special formatting for cenrtain tags
between = match_url_id(between, @bbtree.current_node.definition[:url_matches]) if @bbtree.current_node.definition[:url_matches]
return between
end | [
"def",
"get_formatted_between",
"between",
"=",
"@ti",
"[",
":text",
"]",
"between",
"=",
"match_url_id",
"(",
"between",
",",
"@bbtree",
".",
"current_node",
".",
"definition",
"[",
":url_matches",
"]",
")",
"if",
"@bbtree",
".",
"current_node",
".",
"definit... | Get 'between tag' for tag | [
"Get",
"between",
"tag",
"for",
"tag"
] | 0b9ea504060f3e5b1ae9c3e5d9586a5672ec5fc7 | https://github.com/veger/ruby-bbcode/blob/0b9ea504060f3e5b1ae9c3e5d9586a5672ec5fc7/lib/ruby-bbcode/tag_sifter.rb#L139-L144 | train |
xeger/docker-compose | lib/docker/compose/session.rb | Docker::Compose.Session.up | def up(*services,
abort_on_container_exit: false,
detached: false, timeout: 10, build: false,
exit_code_from: nil,
no_build: false, no_deps: false, no_start: false)
o = opts(
abort_on_container_exit: [abort_on_container_exit, false],
d: [de... | ruby | def up(*services,
abort_on_container_exit: false,
detached: false, timeout: 10, build: false,
exit_code_from: nil,
no_build: false, no_deps: false, no_start: false)
o = opts(
abort_on_container_exit: [abort_on_container_exit, false],
d: [de... | [
"def",
"up",
"(",
"*",
"services",
",",
"abort_on_container_exit",
":",
"false",
",",
"detached",
":",
"false",
",",
"timeout",
":",
"10",
",",
"build",
":",
"false",
",",
"exit_code_from",
":",
"nil",
",",
"no_build",
":",
"false",
",",
"no_deps",
":",
... | Idempotently up the given services in the project.
@param [Array] services list of String service names to run
@param [Boolean] detached if true, to start services in the background;
otherwise, monitor logs in the foreground and shutdown on Ctrl+C
@param [Integer] timeout how long to wait for each service to star... | [
"Idempotently",
"up",
"the",
"given",
"services",
"in",
"the",
"project",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/session.rb#L83-L100 | train |
xeger/docker-compose | lib/docker/compose/session.rb | Docker::Compose.Session.scale | def scale(container_count, timeout: 10)
args = container_count.map {|service, count| "#{service}=#{count}"}
o = opts(timeout: [timeout, 10])
run!('scale', o, *args)
end | ruby | def scale(container_count, timeout: 10)
args = container_count.map {|service, count| "#{service}=#{count}"}
o = opts(timeout: [timeout, 10])
run!('scale', o, *args)
end | [
"def",
"scale",
"(",
"container_count",
",",
"timeout",
":",
"10",
")",
"args",
"=",
"container_count",
".",
"map",
"{",
"|",
"service",
",",
"count",
"|",
"\"#{service}=#{count}\"",
"}",
"o",
"=",
"opts",
"(",
"timeout",
":",
"[",
"timeout",
",",
"10",
... | Idempotently scales the number of containers for given services in the project.
@param [Hash] container_count per service, e.g. {web: 2, worker: 3}
@param [Integer] timeout how long to wait for each service to scale | [
"Idempotently",
"scales",
"the",
"number",
"of",
"containers",
"for",
"given",
"services",
"in",
"the",
"project",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/session.rb#L105-L109 | train |
xeger/docker-compose | lib/docker/compose/session.rb | Docker::Compose.Session.run | def run(service, *cmd, detached: false, no_deps: false, volumes: [], env: [], rm: false, no_tty: false, user: nil, service_ports: false)
o = opts(d: [detached, false], no_deps: [no_deps, false], rm: [rm, false], T: [no_tty, false], u: [user, nil], service_ports: [service_ports, false])
env_params = env.map ... | ruby | def run(service, *cmd, detached: false, no_deps: false, volumes: [], env: [], rm: false, no_tty: false, user: nil, service_ports: false)
o = opts(d: [detached, false], no_deps: [no_deps, false], rm: [rm, false], T: [no_tty, false], u: [user, nil], service_ports: [service_ports, false])
env_params = env.map ... | [
"def",
"run",
"(",
"service",
",",
"*",
"cmd",
",",
"detached",
":",
"false",
",",
"no_deps",
":",
"false",
",",
"volumes",
":",
"[",
"]",
",",
"env",
":",
"[",
"]",
",",
"rm",
":",
"false",
",",
"no_tty",
":",
"false",
",",
"user",
":",
"nil",... | Idempotently run an arbitrary command with a service container.
@param [String] service name to run
@param [String] cmd command statement to run
@param [Boolean] detached if true, to start services in the background;
otherwise, monitor logs in the foreground and shutdown on Ctrl+C
@param [Boolean] no_deps if tru... | [
"Idempotently",
"run",
"an",
"arbitrary",
"command",
"with",
"a",
"service",
"container",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/session.rb#L140-L145 | train |
xeger/docker-compose | lib/docker/compose/session.rb | Docker::Compose.Session.stop | def stop(*services, timeout: 10)
o = opts(timeout: [timeout, 10])
run!('stop', o, services)
end | ruby | def stop(*services, timeout: 10)
o = opts(timeout: [timeout, 10])
run!('stop', o, services)
end | [
"def",
"stop",
"(",
"*",
"services",
",",
"timeout",
":",
"10",
")",
"o",
"=",
"opts",
"(",
"timeout",
":",
"[",
"timeout",
",",
"10",
"]",
")",
"run!",
"(",
"'stop'",
",",
"o",
",",
"services",
")",
"end"
] | Stop running services.
@param [Array] services list of String service names to stop
@param [Integer] timeout how long to wait for each service to stop
@raise [Error] if command fails | [
"Stop",
"running",
"services",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/session.rb#L168-L171 | train |
xeger/docker-compose | lib/docker/compose/session.rb | Docker::Compose.Session.kill | def kill(*services, signal: 'KILL')
o = opts(signal: [signal, 'KILL'])
run!('kill', o, services)
end | ruby | def kill(*services, signal: 'KILL')
o = opts(signal: [signal, 'KILL'])
run!('kill', o, services)
end | [
"def",
"kill",
"(",
"*",
"services",
",",
"signal",
":",
"'KILL'",
")",
"o",
"=",
"opts",
"(",
"signal",
":",
"[",
"signal",
",",
"'KILL'",
"]",
")",
"run!",
"(",
"'kill'",
",",
"o",
",",
"services",
")",
"end"
] | Forcibly stop running services.
@param [Array] services list of String service names to stop
@param [String] name of murderous signal to use, default is 'KILL'
@see Signal.list for a list of acceptable signal names | [
"Forcibly",
"stop",
"running",
"services",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/session.rb#L177-L180 | train |
xeger/docker-compose | lib/docker/compose/session.rb | Docker::Compose.Session.version | def version(short: false)
o = opts(short: [short, false])
result = run!('version', o, file: false, dir: false)
if short
result.strip
else
lines = result.split(/[\r\n]+/)
lines.inject({}) do |h, line|
kv = line.split(/: +/, 2)
h[kv.first] = kv.last
... | ruby | def version(short: false)
o = opts(short: [short, false])
result = run!('version', o, file: false, dir: false)
if short
result.strip
else
lines = result.split(/[\r\n]+/)
lines.inject({}) do |h, line|
kv = line.split(/: +/, 2)
h[kv.first] = kv.last
... | [
"def",
"version",
"(",
"short",
":",
"false",
")",
"o",
"=",
"opts",
"(",
"short",
":",
"[",
"short",
",",
"false",
"]",
")",
"result",
"=",
"run!",
"(",
"'version'",
",",
"o",
",",
"file",
":",
"false",
",",
"dir",
":",
"false",
")",
"if",
"sh... | Determine the installed version of docker-compose.
@param [Boolean] short whether to return terse version information
@return [String, Hash] if short==true, returns a version string;
otherwise, returns a Hash of component-name strings to version strings
@raise [Error] if command fails | [
"Determine",
"the",
"installed",
"version",
"of",
"docker",
"-",
"compose",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/session.rb#L220-L234 | train |
xeger/docker-compose | lib/docker/compose/session.rb | Docker::Compose.Session.run! | def run!(*args)
file_args = case @file
when 'docker-compose.yml'
[]
when Array
# backticks sugar can't handle array values; build a list of hashes
# IMPORTANT: preserve the order of the files so overrides work correctly
file_args = @file.map { |filepath| { :file => file... | ruby | def run!(*args)
file_args = case @file
when 'docker-compose.yml'
[]
when Array
# backticks sugar can't handle array values; build a list of hashes
# IMPORTANT: preserve the order of the files so overrides work correctly
file_args = @file.map { |filepath| { :file => file... | [
"def",
"run!",
"(",
"*",
"args",
")",
"file_args",
"=",
"case",
"@file",
"when",
"'docker-compose.yml'",
"[",
"]",
"when",
"Array",
"file_args",
"=",
"@file",
".",
"map",
"{",
"|",
"filepath",
"|",
"{",
":file",
"=>",
"filepath",
"}",
"}",
"else",
"[",... | Run a docker-compose command without validating that the CLI parameters
make sense. Prepend project and file options if suitable.
@see Docker::Compose::Shell#command
@param [Array] args command-line arguments in the format accepted by
Backticks::Runner#command
@return [String] output of the command
@raise [Er... | [
"Run",
"a",
"docker",
"-",
"compose",
"command",
"without",
"validating",
"that",
"the",
"CLI",
"parameters",
"make",
"sense",
".",
"Prepend",
"project",
"and",
"file",
"options",
"if",
"suitable",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/session.rb#L252-L272 | train |
xeger/docker-compose | lib/docker/compose/session.rb | Docker::Compose.Session.parse | def parse(str)
fields = []
nest = 0
field = ''
str.each_char do |ch|
got = false
if nest == 0
if ch == '('
nest += 1
end
else
if ch == '('
nest += 1
field << ch
elsif ch == ')'
nest -=... | ruby | def parse(str)
fields = []
nest = 0
field = ''
str.each_char do |ch|
got = false
if nest == 0
if ch == '('
nest += 1
end
else
if ch == '('
nest += 1
field << ch
elsif ch == ')'
nest -=... | [
"def",
"parse",
"(",
"str",
")",
"fields",
"=",
"[",
"]",
"nest",
"=",
"0",
"field",
"=",
"''",
"str",
".",
"each_char",
"do",
"|",
"ch",
"|",
"got",
"=",
"false",
"if",
"nest",
"==",
"0",
"if",
"ch",
"==",
"'('",
"nest",
"+=",
"1",
"end",
"e... | Parse a string that consists of a sequence of values enclosed within parentheses.
Ignore any bytes that are outside of parentheses. Values may include nested parentheses.
@param [String] str e.g. "(foo) ((bar)) ... (baz)"
@return [Array] e.g. ["foo", "bar", "baz"] | [
"Parse",
"a",
"string",
"that",
"consists",
"of",
"a",
"sequence",
"of",
"values",
"enclosed",
"within",
"parentheses",
".",
"Ignore",
"any",
"bytes",
"that",
"are",
"outside",
"of",
"parentheses",
".",
"Values",
"may",
"include",
"nested",
"parentheses",
"."
... | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/session.rb#L310-L343 | train |
xeger/docker-compose | lib/docker/compose/rake_tasks.rb | Docker::Compose.RakeTasks.export_env | def export_env(print:)
Docker::Compose::Mapper.map(host_env,
session: @session,
net_info: @net_info) do |k, v|
ENV[k] = serialize_for_env(v)
print_env(k, ENV[k]) if print
end
extra_host_env.each do |k, v|
ENV[... | ruby | def export_env(print:)
Docker::Compose::Mapper.map(host_env,
session: @session,
net_info: @net_info) do |k, v|
ENV[k] = serialize_for_env(v)
print_env(k, ENV[k]) if print
end
extra_host_env.each do |k, v|
ENV[... | [
"def",
"export_env",
"(",
"print",
":",
")",
"Docker",
"::",
"Compose",
"::",
"Mapper",
".",
"map",
"(",
"host_env",
",",
"session",
":",
"@session",
",",
"net_info",
":",
"@net_info",
")",
"do",
"|",
"k",
",",
"v",
"|",
"ENV",
"[",
"k",
"]",
"=",
... | Substitute and set environment variables that point to network ports
published by docker-compose services. Optionally also print bash export
statements so this information can be made available to a user's shell. | [
"Substitute",
"and",
"set",
"environment",
"variables",
"that",
"point",
"to",
"network",
"ports",
"published",
"by",
"docker",
"-",
"compose",
"services",
".",
"Optionally",
"also",
"print",
"bash",
"export",
"statements",
"so",
"this",
"information",
"can",
"b... | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/rake_tasks.rb#L111-L123 | train |
xeger/docker-compose | lib/docker/compose/rake_tasks.rb | Docker::Compose.RakeTasks.serialize_for_env | def serialize_for_env(v)
case v
when String
v
when NilClass
nil
when Array
JSON.dump(v)
else
fail ArgumentError, "Can't represent a #{v.class} in the environment"
end
end | ruby | def serialize_for_env(v)
case v
when String
v
when NilClass
nil
when Array
JSON.dump(v)
else
fail ArgumentError, "Can't represent a #{v.class} in the environment"
end
end | [
"def",
"serialize_for_env",
"(",
"v",
")",
"case",
"v",
"when",
"String",
"v",
"when",
"NilClass",
"nil",
"when",
"Array",
"JSON",
".",
"dump",
"(",
"v",
")",
"else",
"fail",
"ArgumentError",
",",
"\"Can't represent a #{v.class} in the environment\"",
"end",
"en... | Transform a Ruby value into a String that can be stored in the
environment. This accepts nil, String, or Array and returns nil, String
or JSON-serialized Array. | [
"Transform",
"a",
"Ruby",
"value",
"into",
"a",
"String",
"that",
"can",
"be",
"stored",
"in",
"the",
"environment",
".",
"This",
"accepts",
"nil",
"String",
"or",
"Array",
"and",
"returns",
"nil",
"String",
"or",
"JSON",
"-",
"serialized",
"Array",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/rake_tasks.rb#L129-L140 | train |
xeger/docker-compose | lib/docker/compose/rake_tasks.rb | Docker::Compose.RakeTasks.print_env | def print_env(k, v)
if v
puts @shell_printer.export(k, v)
else
puts @shell_printer.unset(k)
end
end | ruby | def print_env(k, v)
if v
puts @shell_printer.export(k, v)
else
puts @shell_printer.unset(k)
end
end | [
"def",
"print_env",
"(",
"k",
",",
"v",
")",
"if",
"v",
"puts",
"@shell_printer",
".",
"export",
"(",
"k",
",",
"v",
")",
"else",
"puts",
"@shell_printer",
".",
"unset",
"(",
"k",
")",
"end",
"end"
] | Print an export or unset statement suitable for user's shell | [
"Print",
"an",
"export",
"or",
"unset",
"statement",
"suitable",
"for",
"user",
"s",
"shell"
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/rake_tasks.rb#L144-L150 | train |
xeger/docker-compose | lib/docker/compose/net_info.rb | Docker::Compose.NetInfo.docker_routable_ip | def docker_routable_ip
case @docker_url.scheme
when 'tcp', 'http', 'https'
docker_dns = @docker_url.host
docker_port = @docker_url.port || 2376
else
# Cheap trick: for unix, file or other protocols, assume docker ports
# are proxied to localhost in addition to other int... | ruby | def docker_routable_ip
case @docker_url.scheme
when 'tcp', 'http', 'https'
docker_dns = @docker_url.host
docker_port = @docker_url.port || 2376
else
# Cheap trick: for unix, file or other protocols, assume docker ports
# are proxied to localhost in addition to other int... | [
"def",
"docker_routable_ip",
"case",
"@docker_url",
".",
"scheme",
"when",
"'tcp'",
",",
"'http'",
",",
"'https'",
"docker_dns",
"=",
"@docker_url",
".",
"host",
"docker_port",
"=",
"@docker_url",
".",
"port",
"||",
"2376",
"else",
"docker_dns",
"=",
"'localhost... | Figure out the likely IP address of the host pointed to by
self.docker_url.
@return [String] host-reachable IPv4 address of docker host | [
"Figure",
"out",
"the",
"likely",
"IP",
"address",
"of",
"the",
"host",
"pointed",
"to",
"by",
"self",
".",
"docker_url",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/net_info.rb#L70-L87 | train |
xeger/docker-compose | lib/docker/compose/mapper.rb | Docker::Compose.Mapper.map | def map(value)
if value.respond_to?(:map)
value.map { |e| map_scalar(e) }
else
map_scalar(value)
end
end | ruby | def map(value)
if value.respond_to?(:map)
value.map { |e| map_scalar(e) }
else
map_scalar(value)
end
end | [
"def",
"map",
"(",
"value",
")",
"if",
"value",
".",
"respond_to?",
"(",
":map",
")",
"value",
".",
"map",
"{",
"|",
"e",
"|",
"map_scalar",
"(",
"e",
")",
"}",
"else",
"map_scalar",
"(",
"value",
")",
"end",
"end"
] | Create an instance of Mapper
@param [Docker::Compose::Session] session
@param [NetInfo] net_info
Substitute service hostnames and ports that appear in a URL or a
host:port string. If either component of a host:port string is
surrounded by square brackets, "elide" that component, removing it
from the result but u... | [
"Create",
"an",
"instance",
"of",
"Mapper"
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/mapper.rb#L88-L94 | train |
xeger/docker-compose | lib/docker/compose/mapper.rb | Docker::Compose.Mapper.map_scalar | def map_scalar(value)
uri = begin
URI.parse(value)
rescue
nil
end
pair = value.split(':')
if uri && uri.scheme && uri.host
# absolute URI with scheme, authority, etc
uri.host, uri.port = host_and_port(uri.host, uri.port)
retu... | ruby | def map_scalar(value)
uri = begin
URI.parse(value)
rescue
nil
end
pair = value.split(':')
if uri && uri.scheme && uri.host
# absolute URI with scheme, authority, etc
uri.host, uri.port = host_and_port(uri.host, uri.port)
retu... | [
"def",
"map_scalar",
"(",
"value",
")",
"uri",
"=",
"begin",
"URI",
".",
"parse",
"(",
"value",
")",
"rescue",
"nil",
"end",
"pair",
"=",
"value",
".",
"split",
"(",
"':'",
")",
"if",
"uri",
"&&",
"uri",
".",
"scheme",
"&&",
"uri",
".",
"host",
"... | Map a single string, replacing service names with IPs and container ports
with the host ports that they have been mapped to.
@param [String] value
@return [String] | [
"Map",
"a",
"single",
"string",
"replacing",
"service",
"names",
"with",
"IPs",
"and",
"container",
"ports",
"with",
"the",
"host",
"ports",
"that",
"they",
"have",
"been",
"mapped",
"to",
"."
] | c1428491b686a33cbafdc26e609e6a863e2ec6fa | https://github.com/xeger/docker-compose/blob/c1428491b686a33cbafdc26e609e6a863e2ec6fa/lib/docker/compose/mapper.rb#L122-L156 | train |
sue445/rubicure | lib/rubicure/girl.rb | Rubicure.Girl.birthday? | def birthday?(date = Date.today)
return false unless have_birthday?
# NOTE: birthday is "mm/dd"
month, day = birthday.split("/")
birthday_date = Date.new(date.year, month.to_i, day.to_i)
birthday_date == date
end | ruby | def birthday?(date = Date.today)
return false unless have_birthday?
# NOTE: birthday is "mm/dd"
month, day = birthday.split("/")
birthday_date = Date.new(date.year, month.to_i, day.to_i)
birthday_date == date
end | [
"def",
"birthday?",
"(",
"date",
"=",
"Date",
".",
"today",
")",
"return",
"false",
"unless",
"have_birthday?",
"month",
",",
"day",
"=",
"birthday",
".",
"split",
"(",
"\"/\"",
")",
"birthday_date",
"=",
"Date",
".",
"new",
"(",
"date",
".",
"year",
"... | Whether `date` is her birthday
@param date [Date]
@return [Boolean]
@example
Cure.twinkle.birthday?(Date.parse("2015-9-12"))
#=> true | [
"Whether",
"date",
"is",
"her",
"birthday"
] | bdd5efc2127774a0620399e779b076d9f8f4aeab | https://github.com/sue445/rubicure/blob/bdd5efc2127774a0620399e779b076d9f8f4aeab/lib/rubicure/girl.rb#L131-L140 | train |
sue445/rubicure | lib/rubicure/core.rb | Rubicure.Core.all_stars | def all_stars(arg = Time.current)
extra_girls = []
# args is Time or Date
date = to_date(arg)
if date
last_all_stars_date = Rubicure::Movie.find(:stmm).started_date
if date > last_all_stars_date
date = last_all_stars_date
end
else
# args is movie... | ruby | def all_stars(arg = Time.current)
extra_girls = []
# args is Time or Date
date = to_date(arg)
if date
last_all_stars_date = Rubicure::Movie.find(:stmm).started_date
if date > last_all_stars_date
date = last_all_stars_date
end
else
# args is movie... | [
"def",
"all_stars",
"(",
"arg",
"=",
"Time",
".",
"current",
")",
"extra_girls",
"=",
"[",
"]",
"date",
"=",
"to_date",
"(",
"arg",
")",
"if",
"date",
"last_all_stars_date",
"=",
"Rubicure",
"::",
"Movie",
".",
"find",
"(",
":stmm",
")",
".",
"started_... | Get precure all stars
@param [Time,Date,String,Symbol] arg Time, Date or date like String (ex. "2013-12-16")
@return [Array<Rubicure::Girl>]
@example precure all stars
Precure.all_stars.count
Precure.all_stars.map(&:precure_name)
# returns current precure count and names
Precure.all_stars.include?(Cu... | [
"Get",
"precure",
"all",
"stars"
] | bdd5efc2127774a0620399e779b076d9f8f4aeab | https://github.com/sue445/rubicure/blob/bdd5efc2127774a0620399e779b076d9f8f4aeab/lib/rubicure/core.rb#L98-L120 | train |
sue445/rubicure | lib/rubicure/core.rb | Rubicure.Core.all_girls | def all_girls(arg = Time.current)
date = to_date(arg)
unless @all_girls
@all_girls = []
Rubicure::Girl.names.each do |girl_name|
@all_girls << Rubicure::Girl.find(girl_name)
end
@all_girls.uniq!(&:human_name)
end
@all_girls.select {|girl| girl.created... | ruby | def all_girls(arg = Time.current)
date = to_date(arg)
unless @all_girls
@all_girls = []
Rubicure::Girl.names.each do |girl_name|
@all_girls << Rubicure::Girl.find(girl_name)
end
@all_girls.uniq!(&:human_name)
end
@all_girls.select {|girl| girl.created... | [
"def",
"all_girls",
"(",
"arg",
"=",
"Time",
".",
"current",
")",
"date",
"=",
"to_date",
"(",
"arg",
")",
"unless",
"@all_girls",
"@all_girls",
"=",
"[",
"]",
"Rubicure",
"::",
"Girl",
".",
"names",
".",
"each",
"do",
"|",
"girl_name",
"|",
"@all_girl... | Get all precures
@param [Time,Date] arg Time, Date or date like String (ex. "2013-12-16")
@return [Array<Rubicure::Girl>] all precures
@example
Precure.all_girls.count
Precure.all_girls.map(&:precure_name)
# returns current precure count and names
Precure.all_girls("2013-10-26").count
#=> 33
P... | [
"Get",
"all",
"precures"
] | bdd5efc2127774a0620399e779b076d9f8f4aeab | https://github.com/sue445/rubicure/blob/bdd5efc2127774a0620399e779b076d9f8f4aeab/lib/rubicure/core.rb#L138-L151 | train |
sue445/rubicure | lib/rubicure/core.rb | Rubicure.Core.dream_stars | def dream_stars
return @dream_stars if @dream_stars
girls = Precure.go_princess.girls + Precure.maho_girls.girls + Precure.a_la_mode.girls
dream_stars_date = Rubicure::Movie.find(:dream_stars).started_date
@dream_stars = girls.select {|girl| girl.created_date && girl.created_date <= dream_star... | ruby | def dream_stars
return @dream_stars if @dream_stars
girls = Precure.go_princess.girls + Precure.maho_girls.girls + Precure.a_la_mode.girls
dream_stars_date = Rubicure::Movie.find(:dream_stars).started_date
@dream_stars = girls.select {|girl| girl.created_date && girl.created_date <= dream_star... | [
"def",
"dream_stars",
"return",
"@dream_stars",
"if",
"@dream_stars",
"girls",
"=",
"Precure",
".",
"go_princess",
".",
"girls",
"+",
"Precure",
".",
"maho_girls",
".",
"girls",
"+",
"Precure",
".",
"a_la_mode",
".",
"girls",
"dream_stars_date",
"=",
"Rubicure",... | Get precure dream stars
@return [Array<Rubicure::Girl>] precure dream stars
@example
Precure.dream_stars.count
#=> 12
Precure.dream_stars.map(&:precure_name)
#=> ["キュアフローラ", "キュアマーメイド", "キュアトゥインクル", "キュアスカーレット", "キュアミラクル", "キュアマジカル", "キュアフェリーチェ", "キュアホイップ", "キュアカスタード", "キュアジェラート", "キュアマカロン", "キュアショコラ"] | [
"Get",
"precure",
"dream",
"stars"
] | bdd5efc2127774a0620399e779b076d9f8f4aeab | https://github.com/sue445/rubicure/blob/bdd5efc2127774a0620399e779b076d9f8f4aeab/lib/rubicure/core.rb#L165-L174 | train |
sue445/rubicure | lib/rubicure/core.rb | Rubicure.Core.super_stars | def super_stars
return @super_stars if @super_stars
girls = Precure.maho_girls.girls + Precure.a_la_mode.girls + Precure.hugtto.girls
super_stars_date = Rubicure::Movie.find(:super_stars).started_date
@super_stars = girls.select {|girl| girl.created_date && girl.created_date <= super_stars_dat... | ruby | def super_stars
return @super_stars if @super_stars
girls = Precure.maho_girls.girls + Precure.a_la_mode.girls + Precure.hugtto.girls
super_stars_date = Rubicure::Movie.find(:super_stars).started_date
@super_stars = girls.select {|girl| girl.created_date && girl.created_date <= super_stars_dat... | [
"def",
"super_stars",
"return",
"@super_stars",
"if",
"@super_stars",
"girls",
"=",
"Precure",
".",
"maho_girls",
".",
"girls",
"+",
"Precure",
".",
"a_la_mode",
".",
"girls",
"+",
"Precure",
".",
"hugtto",
".",
"girls",
"super_stars_date",
"=",
"Rubicure",
":... | Get precure super stars
@return [Array<Rubicure::Girl>] precure super stars
@example
Precure.super_stars.count
#=> 12
Precure.super_stars.map(&:precure_name)
#=> ["キュアミラクル", "キュアマジカル", "キュアフェリーチェ", "キュアホイップ", "キュアカスタード", "キュアジェラート", "キュアマカロン", "キュアショコラ", "キュアパルフェ", "キュアエール", "キュアアンジュ", "キュアエトワール"] | [
"Get",
"precure",
"super",
"stars"
] | bdd5efc2127774a0620399e779b076d9f8f4aeab | https://github.com/sue445/rubicure/blob/bdd5efc2127774a0620399e779b076d9f8f4aeab/lib/rubicure/core.rb#L186-L195 | train |
pinnymz/migration_comments | lib/migration_comments/active_record/connection_adapters/postgresql_adapter.rb | MigrationComments::ActiveRecord::ConnectionAdapters.PostgreSQLAdapter.set_column_comment | def set_column_comment(table_name, column_name, comment_text)
execute comment_sql(CommentDefinition.new(table_name, column_name, comment_text))
end | ruby | def set_column_comment(table_name, column_name, comment_text)
execute comment_sql(CommentDefinition.new(table_name, column_name, comment_text))
end | [
"def",
"set_column_comment",
"(",
"table_name",
",",
"column_name",
",",
"comment_text",
")",
"execute",
"comment_sql",
"(",
"CommentDefinition",
".",
"new",
"(",
"table_name",
",",
"column_name",
",",
"comment_text",
")",
")",
"end"
] | Set a comment on a column | [
"Set",
"a",
"comment",
"on",
"a",
"column"
] | 2b62e5291deb982a5034052504fdf30cb20450bc | https://github.com/pinnymz/migration_comments/blob/2b62e5291deb982a5034052504fdf30cb20450bc/lib/migration_comments/active_record/connection_adapters/postgresql_adapter.rb#L18-L20 | train |
microformats/microformats-ruby | lib/microformats/format_parser.rb | Microformats.FormatParser.imply_dates | def imply_dates
return unless !@properties['end'].nil? && !@properties['start'].nil?
start_date = nil
@properties['start'].each do |start_val|
if start_val =~ /^(\d{4}-[01]\d-[0-3]\d)/
start_date = Regexp.last_match(1) if start_date.nil?
elsif start_val =~ /^(\d{4}-[0-3]\d\... | ruby | def imply_dates
return unless !@properties['end'].nil? && !@properties['start'].nil?
start_date = nil
@properties['start'].each do |start_val|
if start_val =~ /^(\d{4}-[01]\d-[0-3]\d)/
start_date = Regexp.last_match(1) if start_date.nil?
elsif start_val =~ /^(\d{4}-[0-3]\d\... | [
"def",
"imply_dates",
"return",
"unless",
"!",
"@properties",
"[",
"'end'",
"]",
".",
"nil?",
"&&",
"!",
"@properties",
"[",
"'start'",
"]",
".",
"nil?",
"start_date",
"=",
"nil",
"@properties",
"[",
"'start'",
"]",
".",
"each",
"do",
"|",
"start_val",
"... | imply date for dt-end if dt-start is defined with a date | [
"imply",
"date",
"for",
"dt",
"-",
"end",
"if",
"dt",
"-",
"start",
"is",
"defined",
"with",
"a",
"date"
] | d0841b2489ce7bf6fbae03d3e3aa1ecfbf56e98b | https://github.com/microformats/microformats-ruby/blob/d0841b2489ce7bf6fbae03d3e3aa1ecfbf56e98b/lib/microformats/format_parser.rb#L323-L347 | train |
justindomingue/markov_chains | lib/markov_chains/generator.rb | MarkovChains.Generator.get_sentences | def get_sentences(n)
sentences = []
n.times do
sentence = @dict.get_start_words
while nw = @dict.get(sentence[-@dict.order, @dict.order])
sentence << nw
end
sentences << (sentence[0...-1].join(" ").gsub(/\s([,;:])/, '\1') << sentence.last)
... | ruby | def get_sentences(n)
sentences = []
n.times do
sentence = @dict.get_start_words
while nw = @dict.get(sentence[-@dict.order, @dict.order])
sentence << nw
end
sentences << (sentence[0...-1].join(" ").gsub(/\s([,;:])/, '\1') << sentence.last)
... | [
"def",
"get_sentences",
"(",
"n",
")",
"sentences",
"=",
"[",
"]",
"n",
".",
"times",
"do",
"sentence",
"=",
"@dict",
".",
"get_start_words",
"while",
"nw",
"=",
"@dict",
".",
"get",
"(",
"sentence",
"[",
"-",
"@dict",
".",
"order",
",",
"@dict",
"."... | Initializes the generator
@example Create a new generator
MarkovChains::Generator.new(text)
@param Text source to generate sentences from
Returns a given number of randonly generated sentences
@example Get 5 sentences
get_sentences(5)
@param n [int] number of sentences to generate
@return Array conatai... | [
"Initializes",
"the",
"generator"
] | cc94beb2ad17bea13db6cb9dacaa5bf23e7274e8 | https://github.com/justindomingue/markov_chains/blob/cc94beb2ad17bea13db6cb9dacaa5bf23e7274e8/lib/markov_chains/generator.rb#L23-L37 | train |
codez/dry_crud | app/controllers/dry_crud/nestable.rb | DryCrud.Nestable.parents | def parents
@parents ||= Array(nesting).map do |p|
if p.is_a?(Class) && p < ActiveRecord::Base
parent_entry(p)
else
p
end
end
end | ruby | def parents
@parents ||= Array(nesting).map do |p|
if p.is_a?(Class) && p < ActiveRecord::Base
parent_entry(p)
else
p
end
end
end | [
"def",
"parents",
"@parents",
"||=",
"Array",
"(",
"nesting",
")",
".",
"map",
"do",
"|",
"p",
"|",
"if",
"p",
".",
"is_a?",
"(",
"Class",
")",
"&&",
"p",
"<",
"ActiveRecord",
"::",
"Base",
"parent_entry",
"(",
"p",
")",
"else",
"p",
"end",
"end",
... | Returns the parent entries of the current request, if any.
These are ActiveRecords or namespace symbols, corresponding
to the defined nesting attribute. | [
"Returns",
"the",
"parent",
"entries",
"of",
"the",
"current",
"request",
"if",
"any",
".",
"These",
"are",
"ActiveRecords",
"or",
"namespace",
"symbols",
"corresponding",
"to",
"the",
"defined",
"nesting",
"attribute",
"."
] | 2d034b25fe3fc2a096c602f59a29fe7be152b050 | https://github.com/codez/dry_crud/blob/2d034b25fe3fc2a096c602f59a29fe7be152b050/app/controllers/dry_crud/nestable.rb#L30-L38 | train |
nccgroup/BinProxy | lib/binproxy/proxy_message.rb | BinProxy.ProxyMessage.headers | def headers
super.merge({
size: @raw.length,
# HACK - this will prevent errors, but will mangle anything that isn't
# actually utf8. We should try to handle this upstream where we might
# know what the actual encoding is.
summary: @message.summary.force_encoding('UTF-8').sc... | ruby | def headers
super.merge({
size: @raw.length,
# HACK - this will prevent errors, but will mangle anything that isn't
# actually utf8. We should try to handle this upstream where we might
# know what the actual encoding is.
summary: @message.summary.force_encoding('UTF-8').sc... | [
"def",
"headers",
"super",
".",
"merge",
"(",
"{",
"size",
":",
"@raw",
".",
"length",
",",
"summary",
":",
"@message",
".",
"summary",
".",
"force_encoding",
"(",
"'UTF-8'",
")",
".",
"scrub",
",",
"message_class",
":",
"@message_class",
".",
"to_s",
",... | The next two methods are the last stop before JSON encoding, so all strings
in the returned hash must be UTF-8 compatible. | [
"The",
"next",
"two",
"methods",
"are",
"the",
"last",
"stop",
"before",
"JSON",
"encoding",
"so",
"all",
"strings",
"in",
"the",
"returned",
"hash",
"must",
"be",
"UTF",
"-",
"8",
"compatible",
"."
] | d02fce91a1bd5aa0bd4b99a6f60f65ddc9d33c27 | https://github.com/nccgroup/BinProxy/blob/d02fce91a1bd5aa0bd4b99a6f60f65ddc9d33c27/lib/binproxy/proxy_message.rb#L106-L115 | train |
nccgroup/BinProxy | lib/binproxy/parser.rb | BinProxy.Parser.parse | def parse(raw_buffer, peer)
start_pos = nil
loop do
break if raw_buffer.eof?
start_pos = raw_buffer.pos
log.debug "at #{start_pos} of #{raw_buffer.length} in buffer"
read_fn = lambda { message_class.new(src: peer.to_s, protocol_state: @protocol_state).read(raw_buffer) }
... | ruby | def parse(raw_buffer, peer)
start_pos = nil
loop do
break if raw_buffer.eof?
start_pos = raw_buffer.pos
log.debug "at #{start_pos} of #{raw_buffer.length} in buffer"
read_fn = lambda { message_class.new(src: peer.to_s, protocol_state: @protocol_state).read(raw_buffer) }
... | [
"def",
"parse",
"(",
"raw_buffer",
",",
"peer",
")",
"start_pos",
"=",
"nil",
"loop",
"do",
"break",
"if",
"raw_buffer",
".",
"eof?",
"start_pos",
"=",
"raw_buffer",
".",
"pos",
"log",
".",
"debug",
"\"at #{start_pos} of #{raw_buffer.length} in buffer\"",
"read_fn... | Try to parse one or more messages from the buffer, and yield them | [
"Try",
"to",
"parse",
"one",
"or",
"more",
"messages",
"from",
"the",
"buffer",
"and",
"yield",
"them"
] | d02fce91a1bd5aa0bd4b99a6f60f65ddc9d33c27 | https://github.com/nccgroup/BinProxy/blob/d02fce91a1bd5aa0bd4b99a6f60f65ddc9d33c27/lib/binproxy/parser.rb#L36-L74 | train |
nccgroup/BinProxy | lib/binproxy/connection.rb | BinProxy.Connection.connect | def connect(host=nil, port=nil, &cb)
host ||= opts[:upstream_host] || raise('no upstream host')
port ||= opts[:upstream_port] || raise('no upstream port')
cb ||= lambda { |conn| opts[:session_callback].call(self, conn) }
log.debug "Making upstream connection to #{host}:#{port}"
EM.connec... | ruby | def connect(host=nil, port=nil, &cb)
host ||= opts[:upstream_host] || raise('no upstream host')
port ||= opts[:upstream_port] || raise('no upstream port')
cb ||= lambda { |conn| opts[:session_callback].call(self, conn) }
log.debug "Making upstream connection to #{host}:#{port}"
EM.connec... | [
"def",
"connect",
"(",
"host",
"=",
"nil",
",",
"port",
"=",
"nil",
",",
"&",
"cb",
")",
"host",
"||=",
"opts",
"[",
":upstream_host",
"]",
"||",
"raise",
"(",
"'no upstream host'",
")",
"port",
"||=",
"opts",
"[",
":upstream_port",
"]",
"||",
"raise",... | Used by filters to initiate upstream connection in response to
inbound connection | [
"Used",
"by",
"filters",
"to",
"initiate",
"upstream",
"connection",
"in",
"response",
"to",
"inbound",
"connection"
] | d02fce91a1bd5aa0bd4b99a6f60f65ddc9d33c27 | https://github.com/nccgroup/BinProxy/blob/d02fce91a1bd5aa0bd4b99a6f60f65ddc9d33c27/lib/binproxy/connection.rb#L37-L43 | train |
nccgroup/BinProxy | lib/binproxy/connection.rb | BinProxy.Connection.send_message | def send_message(pm)
log.error "OOPS! message going the wrong way (to #{peer})" if pm.dest != peer
data = pm.to_binary_s
@filters.each do |f|
data = f.write data
return if data.nil? or data == ''
end
send_data(data)
end | ruby | def send_message(pm)
log.error "OOPS! message going the wrong way (to #{peer})" if pm.dest != peer
data = pm.to_binary_s
@filters.each do |f|
data = f.write data
return if data.nil? or data == ''
end
send_data(data)
end | [
"def",
"send_message",
"(",
"pm",
")",
"log",
".",
"error",
"\"OOPS! message going the wrong way (to #{peer})\"",
"if",
"pm",
".",
"dest",
"!=",
"peer",
"data",
"=",
"pm",
".",
"to_binary_s",
"@filters",
".",
"each",
"do",
"|",
"f",
"|",
"data",
"=",
"f",
... | called with a ProxyMessage | [
"called",
"with",
"a",
"ProxyMessage"
] | d02fce91a1bd5aa0bd4b99a6f60f65ddc9d33c27 | https://github.com/nccgroup/BinProxy/blob/d02fce91a1bd5aa0bd4b99a6f60f65ddc9d33c27/lib/binproxy/connection.rb#L84-L93 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.