id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
12,000 | randym/axlsx | lib/axlsx/util/serialized_attributes.rb | Axlsx.SerializedAttributes.serialized_attributes | def serialized_attributes(str = '', additional_attributes = {})
attributes = declared_attributes.merge! additional_attributes
attributes.each do |key, value|
str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.camel(Axlsx.booleanize(value), false)}\" "
end
str
end | ruby | def serialized_attributes(str = '', additional_attributes = {})
attributes = declared_attributes.merge! additional_attributes
attributes.each do |key, value|
str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.camel(Axlsx.booleanize(value), false)}\" "
end
str
end | [
"def",
"serialized_attributes",
"(",
"str",
"=",
"''",
",",
"additional_attributes",
"=",
"{",
"}",
")",
"attributes",
"=",
"declared_attributes",
".",
"merge!",
"additional_attributes",
"attributes",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"str",
"<... | serializes the instance values of the defining object based on the
list of serializable attributes.
@param [String] str The string instance to append this
serialization to.
@param [Hash] additional_attributes An option key value hash for
defining values that are not serializable attributes list. | [
"serializes",
"the",
"instance",
"values",
"of",
"the",
"defining",
"object",
"based",
"on",
"the",
"list",
"of",
"serializable",
"attributes",
"."
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/serialized_attributes.rb#L52-L58 |
12,001 | randym/axlsx | lib/axlsx/util/serialized_attributes.rb | Axlsx.SerializedAttributes.declared_attributes | def declared_attributes
instance_values.select do |key, value|
value != nil && self.class.xml_attributes.include?(key.to_sym)
end
end | ruby | def declared_attributes
instance_values.select do |key, value|
value != nil && self.class.xml_attributes.include?(key.to_sym)
end
end | [
"def",
"declared_attributes",
"instance_values",
".",
"select",
"do",
"|",
"key",
",",
"value",
"|",
"value",
"!=",
"nil",
"&&",
"self",
".",
"class",
".",
"xml_attributes",
".",
"include?",
"(",
"key",
".",
"to_sym",
")",
"end",
"end"
] | A hash of instance variables that have been declared with
seraialized_attributes and are not nil.
This requires ruby 1.9.3 or higher | [
"A",
"hash",
"of",
"instance",
"variables",
"that",
"have",
"been",
"declared",
"with",
"seraialized_attributes",
"and",
"are",
"not",
"nil",
".",
"This",
"requires",
"ruby",
"1",
".",
"9",
".",
"3",
"or",
"higher"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/serialized_attributes.rb#L63-L67 |
12,002 | randym/axlsx | lib/axlsx/util/serialized_attributes.rb | Axlsx.SerializedAttributes.serialized_element_attributes | def serialized_element_attributes(str='', additional_attributes=[], &block)
attrs = self.class.xml_element_attributes + additional_attributes
values = instance_values
attrs.each do |attribute_name|
value = values[attribute_name.to_s]
next if value.nil?
value = yield value if bl... | ruby | def serialized_element_attributes(str='', additional_attributes=[], &block)
attrs = self.class.xml_element_attributes + additional_attributes
values = instance_values
attrs.each do |attribute_name|
value = values[attribute_name.to_s]
next if value.nil?
value = yield value if bl... | [
"def",
"serialized_element_attributes",
"(",
"str",
"=",
"''",
",",
"additional_attributes",
"=",
"[",
"]",
",",
"&",
"block",
")",
"attrs",
"=",
"self",
".",
"class",
".",
"xml_element_attributes",
"+",
"additional_attributes",
"values",
"=",
"instance_values",
... | serialized instance values at text nodes on a camelized element of the
attribute name. You may pass in a block for evaluation against non nil
values. We use an array for element attributes becuase misordering will
break the xml and 1.8.7 does not support ordered hashes.
@param [String] str The string instance to wh... | [
"serialized",
"instance",
"values",
"at",
"text",
"nodes",
"on",
"a",
"camelized",
"element",
"of",
"the",
"attribute",
"name",
".",
"You",
"may",
"pass",
"in",
"a",
"block",
"for",
"evaluation",
"against",
"non",
"nil",
"values",
".",
"We",
"use",
"an",
... | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/util/serialized_attributes.rb#L76-L87 |
12,003 | randym/axlsx | lib/axlsx/drawing/d_lbls.rb | Axlsx.DLbls.to_xml_string | def to_xml_string(str = '')
validate_attributes_for_chart_type
str << '<c:dLbls>'
%w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key|
next unless instance_values.keys.include?(key) && instance_values[key] != nil
... | ruby | def to_xml_string(str = '')
validate_attributes_for_chart_type
str << '<c:dLbls>'
%w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key|
next unless instance_values.keys.include?(key) && instance_values[key] != nil
... | [
"def",
"to_xml_string",
"(",
"str",
"=",
"''",
")",
"validate_attributes_for_chart_type",
"str",
"<<",
"'<c:dLbls>'",
"%w(",
"d_lbl_pos",
"show_legend_key",
"show_val",
"show_cat_name",
"show_ser_name",
"show_percent",
"show_bubble_size",
"show_leader_lines",
")",
".",
"e... | serializes the data labels
@return [String] | [
"serializes",
"the",
"data",
"labels"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/d_lbls.rb#L71-L79 |
12,004 | randym/axlsx | lib/axlsx/drawing/line_chart.rb | Axlsx.LineChart.node_name | def node_name
path = self.class.to_s
if i = path.rindex('::')
path = path[(i+2)..-1]
end
path[0] = path[0].chr.downcase
path
end | ruby | def node_name
path = self.class.to_s
if i = path.rindex('::')
path = path[(i+2)..-1]
end
path[0] = path[0].chr.downcase
path
end | [
"def",
"node_name",
"path",
"=",
"self",
".",
"class",
".",
"to_s",
"if",
"i",
"=",
"path",
".",
"rindex",
"(",
"'::'",
")",
"path",
"=",
"path",
"[",
"(",
"i",
"+",
"2",
")",
"..",
"-",
"1",
"]",
"end",
"path",
"[",
"0",
"]",
"=",
"path",
... | The node name to use in serialization. As LineChart is used as the
base class for Liine3DChart we need to be sure to serialize the
chart based on the actual class type and not a fixed node name.
@return [String] | [
"The",
"node",
"name",
"to",
"use",
"in",
"serialization",
".",
"As",
"LineChart",
"is",
"used",
"as",
"the",
"base",
"class",
"for",
"Liine3DChart",
"we",
"need",
"to",
"be",
"sure",
"to",
"serialize",
"the",
"chart",
"based",
"on",
"the",
"actual",
"cl... | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/line_chart.rb#L66-L73 |
12,005 | randym/axlsx | lib/axlsx/doc_props/app.rb | Axlsx.App.to_xml_string | def to_xml_string(str = '')
str << '<?xml version="1.0" encoding="UTF-8"?>'
str << ('<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">')
instance_values.each do |key, value|
node_name = Axlsx.camel(key)
str << "<#{node_name}>#{value}</#{node_name}>"
end
s... | ruby | def to_xml_string(str = '')
str << '<?xml version="1.0" encoding="UTF-8"?>'
str << ('<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">')
instance_values.each do |key, value|
node_name = Axlsx.camel(key)
str << "<#{node_name}>#{value}</#{node_name}>"
end
s... | [
"def",
"to_xml_string",
"(",
"str",
"=",
"''",
")",
"str",
"<<",
"'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'",
"str",
"<<",
"(",
"'<Properties xmlns=\"'",
"<<",
"APP_NS",
"<<",
"'\" xmlns:vt=\"'",
"<<",
"APP_NS_VT",
"<<",
"'\">'",
")",
"instance_values",
".",
"eac... | Serialize the app.xml document
@return [String] | [
"Serialize",
"the",
"app",
".",
"xml",
"document"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/doc_props/app.rb#L223-L231 |
12,006 | randym/axlsx | lib/axlsx/workbook/worksheet/cell.rb | Axlsx.Cell.merge | def merge(target)
start, stop = if target.is_a?(String)
[self.r, target]
elsif(target.is_a?(Cell))
Axlsx.sort_cells([self, target]).map { |c| c.r }
end
self.row.worksheet.merge_cells "#{start}:#{stop}" unless stop.nil?
e... | ruby | def merge(target)
start, stop = if target.is_a?(String)
[self.r, target]
elsif(target.is_a?(Cell))
Axlsx.sort_cells([self, target]).map { |c| c.r }
end
self.row.worksheet.merge_cells "#{start}:#{stop}" unless stop.nil?
e... | [
"def",
"merge",
"(",
"target",
")",
"start",
",",
"stop",
"=",
"if",
"target",
".",
"is_a?",
"(",
"String",
")",
"[",
"self",
".",
"r",
",",
"target",
"]",
"elsif",
"(",
"target",
".",
"is_a?",
"(",
"Cell",
")",
")",
"Axlsx",
".",
"sort_cells",
"... | Merges all the cells in a range created between this cell and the cell or string name for a cell provided
@see worksheet.merge_cells
@param [Cell, String] target The last cell, or str ref for the cell in the merge range | [
"Merges",
"all",
"the",
"cells",
"in",
"a",
"range",
"created",
"between",
"this",
"cell",
"and",
"the",
"cell",
"or",
"string",
"name",
"for",
"a",
"cell",
"provided"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/cell.rb#L308-L315 |
12,007 | randym/axlsx | lib/axlsx/workbook/worksheet/cell.rb | Axlsx.Cell.autowidth | def autowidth
return if is_formula? || value.nil?
if contains_rich_text?
string_width('', font_size) + value.autowidth
elsif styles.cellXfs[style].alignment && styles.cellXfs[style].alignment.wrap_text
max_width = 0
value.to_s.split(/\r?\n/).each do |line|
width = str... | ruby | def autowidth
return if is_formula? || value.nil?
if contains_rich_text?
string_width('', font_size) + value.autowidth
elsif styles.cellXfs[style].alignment && styles.cellXfs[style].alignment.wrap_text
max_width = 0
value.to_s.split(/\r?\n/).each do |line|
width = str... | [
"def",
"autowidth",
"return",
"if",
"is_formula?",
"||",
"value",
".",
"nil?",
"if",
"contains_rich_text?",
"string_width",
"(",
"''",
",",
"font_size",
")",
"+",
"value",
".",
"autowidth",
"elsif",
"styles",
".",
"cellXfs",
"[",
"style",
"]",
".",
"alignmen... | Attempts to determine the correct width for this cell's content
@return [Float] | [
"Attempts",
"to",
"determine",
"the",
"correct",
"width",
"for",
"this",
"cell",
"s",
"content"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/cell.rb#L354-L368 |
12,008 | randym/axlsx | lib/axlsx/workbook/worksheet/cell.rb | Axlsx.Cell.cell_type_from_value | def cell_type_from_value(v)
if v.is_a?(Date)
:date
elsif v.is_a?(Time)
:time
elsif v.is_a?(TrueClass) || v.is_a?(FalseClass)
:boolean
elsif v.to_s =~ Axlsx::NUMERIC_REGEX
:integer
elsif v.to_s =~ Axlsx::FLOAT_REGEX
:float
elsif v.to_s =~ Axlsx:... | ruby | def cell_type_from_value(v)
if v.is_a?(Date)
:date
elsif v.is_a?(Time)
:time
elsif v.is_a?(TrueClass) || v.is_a?(FalseClass)
:boolean
elsif v.to_s =~ Axlsx::NUMERIC_REGEX
:integer
elsif v.to_s =~ Axlsx::FLOAT_REGEX
:float
elsif v.to_s =~ Axlsx:... | [
"def",
"cell_type_from_value",
"(",
"v",
")",
"if",
"v",
".",
"is_a?",
"(",
"Date",
")",
":date",
"elsif",
"v",
".",
"is_a?",
"(",
"Time",
")",
":time",
"elsif",
"v",
".",
"is_a?",
"(",
"TrueClass",
")",
"||",
"v",
".",
"is_a?",
"(",
"FalseClass",
... | Determines the cell type based on the cell value.
@note This is only used when a cell is created but no :type option is specified, the following rules apply:
1. If the value is an instance of Date, the type is set to :date
2. If the value is an instance of Time, the type is set to :time
3. If the value is an ... | [
"Determines",
"the",
"cell",
"type",
"based",
"on",
"the",
"cell",
"value",
"."
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/cell.rb#L426-L444 |
12,009 | randym/axlsx | lib/axlsx/workbook/worksheet/cell.rb | Axlsx.Cell.cast_value | def cast_value(v)
return v if v.is_a?(RichText) || v.nil?
case type
when :date
self.style = STYLE_DATE if self.style == 0
v
when :time
self.style = STYLE_DATE if self.style == 0
if !v.is_a?(Time) && v.respond_to?(:to_time)
v.to_time
else
... | ruby | def cast_value(v)
return v if v.is_a?(RichText) || v.nil?
case type
when :date
self.style = STYLE_DATE if self.style == 0
v
when :time
self.style = STYLE_DATE if self.style == 0
if !v.is_a?(Time) && v.respond_to?(:to_time)
v.to_time
else
... | [
"def",
"cast_value",
"(",
"v",
")",
"return",
"v",
"if",
"v",
".",
"is_a?",
"(",
"RichText",
")",
"||",
"v",
".",
"nil?",
"case",
"type",
"when",
":date",
"self",
".",
"style",
"=",
"STYLE_DATE",
"if",
"self",
".",
"style",
"==",
"0",
"v",
"when",
... | Cast the value into this cells data type.
@note
About Time - Time in OOXML is *different* from what you might expect. The history as to why is interesting, but you can safely assume that if you are generating docs on a mac, you will want to specify Workbook.1904 as true when using time typed values.
@see Axlsx#dat... | [
"Cast",
"the",
"value",
"into",
"this",
"cells",
"data",
"type",
"."
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/cell.rb#L450-L475 |
12,010 | randym/axlsx | lib/axlsx/workbook/worksheet/auto_filter/filters.rb | Axlsx.Filters.apply | def apply(cell)
return false unless cell
filter_items.each do |filter|
return false if cell.value == filter.val
end
true
end | ruby | def apply(cell)
return false unless cell
filter_items.each do |filter|
return false if cell.value == filter.val
end
true
end | [
"def",
"apply",
"(",
"cell",
")",
"return",
"false",
"unless",
"cell",
"filter_items",
".",
"each",
"do",
"|",
"filter",
"|",
"return",
"false",
"if",
"cell",
".",
"value",
"==",
"filter",
".",
"val",
"end",
"true",
"end"
] | Tells us if the row of the cell provided should be filterd as it
does not meet any of the specified filter_items or
date_group_items restrictions.
@param [Cell] cell The cell to test against items
TODO implement this for date filters as well! | [
"Tells",
"us",
"if",
"the",
"row",
"of",
"the",
"cell",
"provided",
"should",
"be",
"filterd",
"as",
"it",
"does",
"not",
"meet",
"any",
"of",
"the",
"specified",
"filter_items",
"or",
"date_group_items",
"restrictions",
"."
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/auto_filter/filters.rb#L43-L49 |
12,011 | randym/axlsx | lib/axlsx/workbook/worksheet/auto_filter/filters.rb | Axlsx.Filters.to_xml_string | def to_xml_string(str = '')
str << "<filters #{serialized_attributes}>"
filter_items.each { |filter| filter.to_xml_string(str) }
date_group_items.each { |date_group_item| date_group_item.to_xml_string(str) }
str << '</filters>'
end | ruby | def to_xml_string(str = '')
str << "<filters #{serialized_attributes}>"
filter_items.each { |filter| filter.to_xml_string(str) }
date_group_items.each { |date_group_item| date_group_item.to_xml_string(str) }
str << '</filters>'
end | [
"def",
"to_xml_string",
"(",
"str",
"=",
"''",
")",
"str",
"<<",
"\"<filters #{serialized_attributes}>\"",
"filter_items",
".",
"each",
"{",
"|",
"filter",
"|",
"filter",
".",
"to_xml_string",
"(",
"str",
")",
"}",
"date_group_items",
".",
"each",
"{",
"|",
... | Serialize the object to xml | [
"Serialize",
"the",
"object",
"to",
"xml"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/auto_filter/filters.rb#L77-L82 |
12,012 | randym/axlsx | lib/axlsx/workbook/worksheet/auto_filter/filters.rb | Axlsx.Filters.date_group_items= | def date_group_items=(options)
options.each do |date_group|
raise ArgumentError, "date_group_items should be an array of hashes specifying the options for each date_group_item" unless date_group.is_a?(Hash)
date_group_items << DateGroupItem.new(date_group)
end
end | ruby | def date_group_items=(options)
options.each do |date_group|
raise ArgumentError, "date_group_items should be an array of hashes specifying the options for each date_group_item" unless date_group.is_a?(Hash)
date_group_items << DateGroupItem.new(date_group)
end
end | [
"def",
"date_group_items",
"=",
"(",
"options",
")",
"options",
".",
"each",
"do",
"|",
"date_group",
"|",
"raise",
"ArgumentError",
",",
"\"date_group_items should be an array of hashes specifying the options for each date_group_item\"",
"unless",
"date_group",
".",
"is_a?",... | Date group items are date group filter items where you specify the
date_group and a value for that option as part of the auto_filter
@note This can be specified, but will not be applied to the date
values in your workbook at this time. | [
"Date",
"group",
"items",
"are",
"date",
"group",
"filter",
"items",
"where",
"you",
"specify",
"the",
"date_group",
"and",
"a",
"value",
"for",
"that",
"option",
"as",
"part",
"of",
"the",
"auto_filter"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/auto_filter/filters.rb#L98-L103 |
12,013 | randym/axlsx | lib/axlsx/workbook/worksheet/sheet_protection.rb | Axlsx.SheetProtection.create_password_hash | def create_password_hash(password)
encoded_password = encode_password(password)
password_as_hex = [encoded_password].pack("v")
password_as_string = password_as_hex.unpack("H*").first.upcase
password_as_string[2..3] + password_as_string[0..1]
end | ruby | def create_password_hash(password)
encoded_password = encode_password(password)
password_as_hex = [encoded_password].pack("v")
password_as_string = password_as_hex.unpack("H*").first.upcase
password_as_string[2..3] + password_as_string[0..1]
end | [
"def",
"create_password_hash",
"(",
"password",
")",
"encoded_password",
"=",
"encode_password",
"(",
"password",
")",
"password_as_hex",
"=",
"[",
"encoded_password",
"]",
".",
"pack",
"(",
"\"v\"",
")",
"password_as_string",
"=",
"password_as_hex",
".",
"unpack",
... | Creates a password hash for a given password
@return [String] | [
"Creates",
"a",
"password",
"hash",
"for",
"a",
"given",
"password"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/sheet_protection.rb#L85-L92 |
12,014 | randym/axlsx | lib/axlsx/drawing/num_data.rb | Axlsx.NumData.data= | def data=(values=[])
@tag_name = values.first.is_a?(Cell) ? :numCache : :numLit
values.each do |value|
value = value.is_formula? ? 0 : value.value if value.is_a?(Cell)
@pt << NumVal.new(:v => value)
end
end | ruby | def data=(values=[])
@tag_name = values.first.is_a?(Cell) ? :numCache : :numLit
values.each do |value|
value = value.is_formula? ? 0 : value.value if value.is_a?(Cell)
@pt << NumVal.new(:v => value)
end
end | [
"def",
"data",
"=",
"(",
"values",
"=",
"[",
"]",
")",
"@tag_name",
"=",
"values",
".",
"first",
".",
"is_a?",
"(",
"Cell",
")",
"?",
":numCache",
":",
":numLit",
"values",
".",
"each",
"do",
"|",
"value",
"|",
"value",
"=",
"value",
".",
"is_formu... | Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types.
@param [Array] values An array of cells or values. | [
"Creates",
"the",
"val",
"objects",
"for",
"this",
"data",
"set",
".",
"I",
"am",
"not",
"overly",
"confident",
"this",
"is",
"going",
"to",
"play",
"nicely",
"with",
"time",
"and",
"data",
"types",
"."
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/drawing/num_data.rb#L25-L31 |
12,015 | randym/axlsx | lib/axlsx/workbook/worksheet/table.rb | Axlsx.Table.name= | def name=(v)
DataTypeValidator.validate :table_name, [String], v
if v.is_a?(String)
@name = v
end
end | ruby | def name=(v)
DataTypeValidator.validate :table_name, [String], v
if v.is_a?(String)
@name = v
end
end | [
"def",
"name",
"=",
"(",
"v",
")",
"DataTypeValidator",
".",
"validate",
":table_name",
",",
"[",
"String",
"]",
",",
"v",
"if",
"v",
".",
"is_a?",
"(",
"String",
")",
"@name",
"=",
"v",
"end",
"end"
] | The name of the Table.
@param [String, Cell] v
@return [Title] | [
"The",
"name",
"of",
"the",
"Table",
"."
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/table.rb#L60-L65 |
12,016 | randym/axlsx | lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb | Axlsx.ConditionalFormattingRule.to_xml_string | def to_xml_string(str = '')
str << '<cfRule '
serialized_attributes str
str << '>'
str << ('<formula>' << [*self.formula].join('</formula><formula>') << '</formula>') if @formula
@color_scale.to_xml_string(str) if @color_scale && @type == :colorScale
@data_bar.to_xml_string(str) if @... | ruby | def to_xml_string(str = '')
str << '<cfRule '
serialized_attributes str
str << '>'
str << ('<formula>' << [*self.formula].join('</formula><formula>') << '</formula>') if @formula
@color_scale.to_xml_string(str) if @color_scale && @type == :colorScale
@data_bar.to_xml_string(str) if @... | [
"def",
"to_xml_string",
"(",
"str",
"=",
"''",
")",
"str",
"<<",
"'<cfRule '",
"serialized_attributes",
"str",
"str",
"<<",
"'>'",
"str",
"<<",
"(",
"'<formula>'",
"<<",
"[",
"self",
".",
"formula",
"]",
".",
"join",
"(",
"'</formula><formula>'",
")",
"<<"... | Serializes the conditional formatting rule
@param [String] str
@return [String] | [
"Serializes",
"the",
"conditional",
"formatting",
"rule"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb#L209-L218 |
12,017 | randym/axlsx | lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb | Axlsx.WorksheetHyperlink.ref= | def ref=(cell_reference)
cell_reference = cell_reference.r if cell_reference.is_a?(Cell)
Axlsx::validate_string cell_reference
@ref = cell_reference
end | ruby | def ref=(cell_reference)
cell_reference = cell_reference.r if cell_reference.is_a?(Cell)
Axlsx::validate_string cell_reference
@ref = cell_reference
end | [
"def",
"ref",
"=",
"(",
"cell_reference",
")",
"cell_reference",
"=",
"cell_reference",
".",
"r",
"if",
"cell_reference",
".",
"is_a?",
"(",
"Cell",
")",
"Axlsx",
"::",
"validate_string",
"cell_reference",
"@ref",
"=",
"cell_reference",
"end"
] | Sets the cell location of this hyperlink in the worksheet
@param [String|Cell] cell_reference The string reference or cell that defines where this hyperlink shows in the worksheet. | [
"Sets",
"the",
"cell",
"location",
"of",
"this",
"hyperlink",
"in",
"the",
"worksheet"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb#L42-L46 |
12,018 | randym/axlsx | lib/axlsx/doc_props/core.rb | Axlsx.Core.to_xml_string | def to_xml_string(str = '')
str << '<?xml version="1.0" encoding="UTF-8"?>'
str << ('<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ')
str << ('xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ')
str << ('xmlns:xsi="' << CORE_NS_XSI ... | ruby | def to_xml_string(str = '')
str << '<?xml version="1.0" encoding="UTF-8"?>'
str << ('<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ')
str << ('xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ')
str << ('xmlns:xsi="' << CORE_NS_XSI ... | [
"def",
"to_xml_string",
"(",
"str",
"=",
"''",
")",
"str",
"<<",
"'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'",
"str",
"<<",
"(",
"'<cp:coreProperties xmlns:cp=\"'",
"<<",
"CORE_NS",
"<<",
"'\" xmlns:dc=\"'",
"<<",
"CORE_NS_DC",
"<<",
"'\" '",
")",
"str",
"<<",
"("... | serializes the core.xml document
@return [String] | [
"serializes",
"the",
"core",
".",
"xml",
"document"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/doc_props/core.rb#L26-L35 |
12,019 | randym/axlsx | lib/axlsx/workbook/worksheet/merged_cells.rb | Axlsx.MergedCells.add | def add(cells)
self << if cells.is_a?(String)
cells
elsif cells.is_a?(Array)
Axlsx::cell_range(cells, false)
elsif cells.is_a?(Row)
Axlsx::cell_range(cells, false)
end
end | ruby | def add(cells)
self << if cells.is_a?(String)
cells
elsif cells.is_a?(Array)
Axlsx::cell_range(cells, false)
elsif cells.is_a?(Row)
Axlsx::cell_range(cells, false)
end
end | [
"def",
"add",
"(",
"cells",
")",
"self",
"<<",
"if",
"cells",
".",
"is_a?",
"(",
"String",
")",
"cells",
"elsif",
"cells",
".",
"is_a?",
"(",
"Array",
")",
"Axlsx",
"::",
"cell_range",
"(",
"cells",
",",
"false",
")",
"elsif",
"cells",
".",
"is_a?",
... | creates a new MergedCells object
@param [Worksheet] worksheet
adds cells to the merged cells collection
@param [Array||String] cells The cells to add to the merged cells
collection. This can be an array of actual cells or a string style
range like 'A1:C1' | [
"creates",
"a",
"new",
"MergedCells",
"object"
] | c593a08b2a929dac7aa8dc418b55e26b4c49dc34 | https://github.com/randym/axlsx/blob/c593a08b2a929dac7aa8dc418b55e26b4c49dc34/lib/axlsx/workbook/worksheet/merged_cells.rb#L17-L25 |
12,020 | alexreisner/geocoder | lib/geocoder/lookups/ban_data_gouv_fr.rb | Geocoder::Lookup.BanDataGouvFr.search_geocode_ban_fr_params | def search_geocode_ban_fr_params(query)
params = {
q: query.sanitized_text
}
unless (limit = query.options[:limit]).nil? || !limit_param_is_valid?(limit)
params[:limit] = limit.to_i
end
unless (autocomplete = query.options[:autocomplete]).nil? || !autocomplete_param_is_vali... | ruby | def search_geocode_ban_fr_params(query)
params = {
q: query.sanitized_text
}
unless (limit = query.options[:limit]).nil? || !limit_param_is_valid?(limit)
params[:limit] = limit.to_i
end
unless (autocomplete = query.options[:autocomplete]).nil? || !autocomplete_param_is_vali... | [
"def",
"search_geocode_ban_fr_params",
"(",
"query",
")",
"params",
"=",
"{",
"q",
":",
"query",
".",
"sanitized_text",
"}",
"unless",
"(",
"limit",
"=",
"query",
".",
"options",
"[",
":limit",
"]",
")",
".",
"nil?",
"||",
"!",
"limit_param_is_valid?",
"("... | SEARCH GEOCODING PARAMS
:q => required, full text search param)
:limit => force limit number of results returned by raw API
(default = 5) note : only first result is taken
in account in geocoder
:autocomplete => pass 0 to disable autoc... | [
"SEARCH",
"GEOCODING",
"PARAMS"
] | e087dc2759264ee6f307b926bb2de4ec2406859e | https://github.com/alexreisner/geocoder/blob/e087dc2759264ee6f307b926bb2de4ec2406859e/lib/geocoder/lookups/ban_data_gouv_fr.rb#L70-L90 |
12,021 | alexreisner/geocoder | lib/geocoder/lookups/ban_data_gouv_fr.rb | Geocoder::Lookup.BanDataGouvFr.reverse_geocode_ban_fr_params | def reverse_geocode_ban_fr_params(query)
lat_lon = query.coordinates
params = {
lat: lat_lon.first,
lon: lat_lon.last
}
unless (type = query.options[:type]).nil? || !type_param_is_valid?(type)
params[:type] = type.downcase
end
params
end | ruby | def reverse_geocode_ban_fr_params(query)
lat_lon = query.coordinates
params = {
lat: lat_lon.first,
lon: lat_lon.last
}
unless (type = query.options[:type]).nil? || !type_param_is_valid?(type)
params[:type] = type.downcase
end
params
end | [
"def",
"reverse_geocode_ban_fr_params",
"(",
"query",
")",
"lat_lon",
"=",
"query",
".",
"coordinates",
"params",
"=",
"{",
"lat",
":",
"lat_lon",
".",
"first",
",",
"lon",
":",
"lat_lon",
".",
"last",
"}",
"unless",
"(",
"type",
"=",
"query",
".",
"opti... | REVERSE GEOCODING PARAMS
:lat => required
:lon => required
:type => force returned results type
(check results for a list of accepted types) | [
"REVERSE",
"GEOCODING",
"PARAMS"
] | e087dc2759264ee6f307b926bb2de4ec2406859e | https://github.com/alexreisner/geocoder/blob/e087dc2759264ee6f307b926bb2de4ec2406859e/lib/geocoder/lookups/ban_data_gouv_fr.rb#L101-L111 |
12,022 | alexreisner/geocoder | lib/geocoder/lookup.rb | Geocoder.Lookup.classify_name | def classify_name(filename)
filename.to_s.split("_").map{ |i| i[0...1].upcase + i[1..-1] }.join
end | ruby | def classify_name(filename)
filename.to_s.split("_").map{ |i| i[0...1].upcase + i[1..-1] }.join
end | [
"def",
"classify_name",
"(",
"filename",
")",
"filename",
".",
"to_s",
".",
"split",
"(",
"\"_\"",
")",
".",
"map",
"{",
"|",
"i",
"|",
"i",
"[",
"0",
"...",
"1",
"]",
".",
"upcase",
"+",
"i",
"[",
"1",
"..",
"-",
"1",
"]",
"}",
".",
"join",
... | Convert an "underscore" version of a name into a "class" version. | [
"Convert",
"an",
"underscore",
"version",
"of",
"a",
"name",
"into",
"a",
"class",
"version",
"."
] | e087dc2759264ee6f307b926bb2de4ec2406859e | https://github.com/alexreisner/geocoder/blob/e087dc2759264ee6f307b926bb2de4ec2406859e/lib/geocoder/lookup.rb#L114-L116 |
12,023 | alexreisner/geocoder | lib/geocoder/lookups/maxmind.rb | Geocoder::Lookup.Maxmind.configured_service! | def configured_service!
if s = configuration[:service] and services.keys.include?(s)
return s
else
raise(
Geocoder::ConfigurationError,
"When using MaxMind you MUST specify a service name: " +
"Geocoder.configure(:maxmind => {:service => ...}), " +
"wh... | ruby | def configured_service!
if s = configuration[:service] and services.keys.include?(s)
return s
else
raise(
Geocoder::ConfigurationError,
"When using MaxMind you MUST specify a service name: " +
"Geocoder.configure(:maxmind => {:service => ...}), " +
"wh... | [
"def",
"configured_service!",
"if",
"s",
"=",
"configuration",
"[",
":service",
"]",
"and",
"services",
".",
"keys",
".",
"include?",
"(",
"s",
")",
"return",
"s",
"else",
"raise",
"(",
"Geocoder",
"::",
"ConfigurationError",
",",
"\"When using MaxMind you MUST ... | Return the name of the configured service, or raise an exception. | [
"Return",
"the",
"name",
"of",
"the",
"configured",
"service",
"or",
"raise",
"an",
"exception",
"."
] | e087dc2759264ee6f307b926bb2de4ec2406859e | https://github.com/alexreisner/geocoder/blob/e087dc2759264ee6f307b926bb2de4ec2406859e/lib/geocoder/lookups/maxmind.rb#L21-L32 |
12,024 | alexreisner/geocoder | lib/geocoder/cache.rb | Geocoder.Cache.[] | def [](url)
interpret case
when store.respond_to?(:[])
store[key_for(url)]
when store.respond_to?(:get)
store.get key_for(url)
when store.respond_to?(:read)
store.read key_for(url)
end
end | ruby | def [](url)
interpret case
when store.respond_to?(:[])
store[key_for(url)]
when store.respond_to?(:get)
store.get key_for(url)
when store.respond_to?(:read)
store.read key_for(url)
end
end | [
"def",
"[]",
"(",
"url",
")",
"interpret",
"case",
"when",
"store",
".",
"respond_to?",
"(",
":[]",
")",
"store",
"[",
"key_for",
"(",
"url",
")",
"]",
"when",
"store",
".",
"respond_to?",
"(",
":get",
")",
"store",
".",
"get",
"key_for",
"(",
"url",... | Read from the Cache. | [
"Read",
"from",
"the",
"Cache",
"."
] | e087dc2759264ee6f307b926bb2de4ec2406859e | https://github.com/alexreisner/geocoder/blob/e087dc2759264ee6f307b926bb2de4ec2406859e/lib/geocoder/cache.rb#L12-L21 |
12,025 | alexreisner/geocoder | lib/geocoder/cache.rb | Geocoder.Cache.[]= | def []=(url, value)
case
when store.respond_to?(:[]=)
store[key_for(url)] = value
when store.respond_to?(:set)
store.set key_for(url), value
when store.respond_to?(:write)
store.write key_for(url), value
end
end | ruby | def []=(url, value)
case
when store.respond_to?(:[]=)
store[key_for(url)] = value
when store.respond_to?(:set)
store.set key_for(url), value
when store.respond_to?(:write)
store.write key_for(url), value
end
end | [
"def",
"[]=",
"(",
"url",
",",
"value",
")",
"case",
"when",
"store",
".",
"respond_to?",
"(",
":[]=",
")",
"store",
"[",
"key_for",
"(",
"url",
")",
"]",
"=",
"value",
"when",
"store",
".",
"respond_to?",
"(",
":set",
")",
"store",
".",
"set",
"ke... | Write to the Cache. | [
"Write",
"to",
"the",
"Cache",
"."
] | e087dc2759264ee6f307b926bb2de4ec2406859e | https://github.com/alexreisner/geocoder/blob/e087dc2759264ee6f307b926bb2de4ec2406859e/lib/geocoder/cache.rb#L26-L35 |
12,026 | plataformatec/simple_form | lib/simple_form/form_builder.rb | SimpleForm.FormBuilder.full_error | def full_error(attribute_name, options = {})
options = options.dup
options[:error_prefix] ||= if object.class.respond_to?(:human_attribute_name)
object.class.human_attribute_name(attribute_name.to_s)
else
attribute_name.to_s.humanize
end
error(attribute_name, options)
... | ruby | def full_error(attribute_name, options = {})
options = options.dup
options[:error_prefix] ||= if object.class.respond_to?(:human_attribute_name)
object.class.human_attribute_name(attribute_name.to_s)
else
attribute_name.to_s.humanize
end
error(attribute_name, options)
... | [
"def",
"full_error",
"(",
"attribute_name",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"options",
".",
"dup",
"options",
"[",
":error_prefix",
"]",
"||=",
"if",
"object",
".",
"class",
".",
"respond_to?",
"(",
":human_attribute_name",
")",
"object",... | Return the error but also considering its name. This is used
when errors for a hidden field need to be shown.
== Examples
f.full_error :token #=> <span class="error">Token is invalid</span> | [
"Return",
"the",
"error",
"but",
"also",
"considering",
"its",
"name",
".",
"This",
"is",
"used",
"when",
"errors",
"for",
"a",
"hidden",
"field",
"need",
"to",
"be",
"shown",
"."
] | 4dd9261ebb392e46a9beeefe8d83081e7c6e56b5 | https://github.com/plataformatec/simple_form/blob/4dd9261ebb392e46a9beeefe8d83081e7c6e56b5/lib/simple_form/form_builder.rb#L272-L282 |
12,027 | plataformatec/simple_form | lib/simple_form/form_builder.rb | SimpleForm.FormBuilder.lookup_model_names | def lookup_model_names #:nodoc:
@lookup_model_names ||= begin
child_index = options[:child_index]
names = object_name.to_s.scan(/(?!\d)\w+/).flatten
names.delete(child_index) if child_index
names.each { |name| name.gsub!('_attributes', '') }
names.freeze
end
end | ruby | def lookup_model_names #:nodoc:
@lookup_model_names ||= begin
child_index = options[:child_index]
names = object_name.to_s.scan(/(?!\d)\w+/).flatten
names.delete(child_index) if child_index
names.each { |name| name.gsub!('_attributes', '') }
names.freeze
end
end | [
"def",
"lookup_model_names",
"#:nodoc:",
"@lookup_model_names",
"||=",
"begin",
"child_index",
"=",
"options",
"[",
":child_index",
"]",
"names",
"=",
"object_name",
".",
"to_s",
".",
"scan",
"(",
"/",
"\\d",
"\\w",
"/",
")",
".",
"flatten",
"names",
".",
"d... | Extract the model names from the object_name mess, ignoring numeric and
explicit child indexes.
Example:
route[blocks_attributes][0][blocks_learning_object_attributes][1][foo_attributes]
["route", "blocks", "blocks_learning_object", "foo"] | [
"Extract",
"the",
"model",
"names",
"from",
"the",
"object_name",
"mess",
"ignoring",
"numeric",
"and",
"explicit",
"child",
"indexes",
"."
] | 4dd9261ebb392e46a9beeefe8d83081e7c6e56b5 | https://github.com/plataformatec/simple_form/blob/4dd9261ebb392e46a9beeefe8d83081e7c6e56b5/lib/simple_form/form_builder.rb#L462-L470 |
12,028 | plataformatec/simple_form | lib/simple_form/form_builder.rb | SimpleForm.FormBuilder.lookup_action | def lookup_action #:nodoc:
@lookup_action ||= begin
action = template.controller && template.controller.action_name
return unless action
action = action.to_s
ACTIONS[action] || action
end
end | ruby | def lookup_action #:nodoc:
@lookup_action ||= begin
action = template.controller && template.controller.action_name
return unless action
action = action.to_s
ACTIONS[action] || action
end
end | [
"def",
"lookup_action",
"#:nodoc:",
"@lookup_action",
"||=",
"begin",
"action",
"=",
"template",
".",
"controller",
"&&",
"template",
".",
"controller",
".",
"action_name",
"return",
"unless",
"action",
"action",
"=",
"action",
".",
"to_s",
"ACTIONS",
"[",
"acti... | The action to be used in lookup. | [
"The",
"action",
"to",
"be",
"used",
"in",
"lookup",
"."
] | 4dd9261ebb392e46a9beeefe8d83081e7c6e56b5 | https://github.com/plataformatec/simple_form/blob/4dd9261ebb392e46a9beeefe8d83081e7c6e56b5/lib/simple_form/form_builder.rb#L473-L480 |
12,029 | plataformatec/simple_form | lib/simple_form/form_builder.rb | SimpleForm.FormBuilder.find_input | def find_input(attribute_name, options = {}, &block)
column = find_attribute_column(attribute_name)
input_type = default_input_type(attribute_name, column, options)
if block_given?
SimpleForm::Inputs::BlockInput.new(self, attribute_name, column, input_type, options, &block)
else
... | ruby | def find_input(attribute_name, options = {}, &block)
column = find_attribute_column(attribute_name)
input_type = default_input_type(attribute_name, column, options)
if block_given?
SimpleForm::Inputs::BlockInput.new(self, attribute_name, column, input_type, options, &block)
else
... | [
"def",
"find_input",
"(",
"attribute_name",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"column",
"=",
"find_attribute_column",
"(",
"attribute_name",
")",
"input_type",
"=",
"default_input_type",
"(",
"attribute_name",
",",
"column",
",",
"options",
... | Find an input based on the attribute name. | [
"Find",
"an",
"input",
"based",
"on",
"the",
"attribute",
"name",
"."
] | 4dd9261ebb392e46a9beeefe8d83081e7c6e56b5 | https://github.com/plataformatec/simple_form/blob/4dd9261ebb392e46a9beeefe8d83081e7c6e56b5/lib/simple_form/form_builder.rb#L530-L539 |
12,030 | david942j/one_gadget | lib/one_gadget/helper.rb | OneGadget.Helper.valid_elf_file? | def valid_elf_file?(path)
# A light-weight way to check if is a valid ELF file
# Checks at least one phdr should present.
File.open(path) { |f| ELFTools::ELFFile.new(f).each_segments.first }
true
rescue ELFTools::ELFError
false
end | ruby | def valid_elf_file?(path)
# A light-weight way to check if is a valid ELF file
# Checks at least one phdr should present.
File.open(path) { |f| ELFTools::ELFFile.new(f).each_segments.first }
true
rescue ELFTools::ELFError
false
end | [
"def",
"valid_elf_file?",
"(",
"path",
")",
"# A light-weight way to check if is a valid ELF file",
"# Checks at least one phdr should present.",
"File",
".",
"open",
"(",
"path",
")",
"{",
"|",
"f",
"|",
"ELFTools",
"::",
"ELFFile",
".",
"new",
"(",
"f",
")",
".",
... | Checks if the file of given path is a valid ELF file.
@param [String] path Path to target file.
@return [Boolean] If the file is an ELF or not.
@example
Helper.valid_elf_file?('/etc/passwd')
#=> false
Helper.valid_elf_file?('/lib64/ld-linux-x86-64.so.2')
#=> true | [
"Checks",
"if",
"the",
"file",
"of",
"given",
"path",
"is",
"a",
"valid",
"ELF",
"file",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/helper.rb#L60-L67 |
12,031 | david942j/one_gadget | lib/one_gadget/helper.rb | OneGadget.Helper.build_id_of | def build_id_of(path)
File.open(path) { |f| ELFTools::ELFFile.new(f).build_id }
end | ruby | def build_id_of(path)
File.open(path) { |f| ELFTools::ELFFile.new(f).build_id }
end | [
"def",
"build_id_of",
"(",
"path",
")",
"File",
".",
"open",
"(",
"path",
")",
"{",
"|",
"f",
"|",
"ELFTools",
"::",
"ELFFile",
".",
"new",
"(",
"f",
")",
".",
"build_id",
"}",
"end"
] | Get the Build ID of target ELF.
@param [String] path Absolute file path.
@return [String] Target build id.
@example
Helper.build_id_of('/lib/x86_64-linux-gnu/libc-2.23.so')
#=> '60131540dadc6796cab33388349e6e4e68692053' | [
"Get",
"the",
"Build",
"ID",
"of",
"target",
"ELF",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/helper.rb#L88-L90 |
12,032 | david942j/one_gadget | lib/one_gadget/helper.rb | OneGadget.Helper.colorize | def colorize(str, sev: :normal_s)
return str unless color_enabled?
cc = COLOR_CODE
color = cc.key?(sev) ? cc[sev] : ''
"#{color}#{str.sub(cc[:esc_m], color)}#{cc[:esc_m]}"
end | ruby | def colorize(str, sev: :normal_s)
return str unless color_enabled?
cc = COLOR_CODE
color = cc.key?(sev) ? cc[sev] : ''
"#{color}#{str.sub(cc[:esc_m], color)}#{cc[:esc_m]}"
end | [
"def",
"colorize",
"(",
"str",
",",
"sev",
":",
":normal_s",
")",
"return",
"str",
"unless",
"color_enabled?",
"cc",
"=",
"COLOR_CODE",
"color",
"=",
"cc",
".",
"key?",
"(",
"sev",
")",
"?",
"cc",
"[",
"sev",
"]",
":",
"''",
"\"#{color}#{str.sub(cc[:esc_... | Wrap string with color codes for pretty inspect.
@param [String] str Contents to colorize.
@param [Symbol] sev Specify which kind of color to use, valid symbols are defined in {.COLOR_CODE}.
@return [String] String wrapped with color codes. | [
"Wrap",
"string",
"with",
"color",
"codes",
"for",
"pretty",
"inspect",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/helper.rb#L122-L128 |
12,033 | david942j/one_gadget | lib/one_gadget/helper.rb | OneGadget.Helper.url_request | def url_request(url)
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = ::OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
raise ArgumentError, "Fail to get response of #... | ruby | def url_request(url)
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = ::OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
raise ArgumentError, "Fail to get response of #... | [
"def",
"url_request",
"(",
"url",
")",
"uri",
"=",
"URI",
".",
"parse",
"(",
"url",
")",
"http",
"=",
"Net",
"::",
"HTTP",
".",
"new",
"(",
"uri",
".",
"host",
",",
"uri",
".",
"port",
")",
"http",
".",
"use_ssl",
"=",
"true",
"http",
".",
"ver... | Get request.
@param [String] url The url.
@return [String]
The request response body.
If the response is +302 Found+, returns the location in header. | [
"Get",
"request",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/helper.rb#L173-L188 |
12,034 | david942j/one_gadget | lib/one_gadget/helper.rb | OneGadget.Helper.architecture | def architecture(file)
return :invalid unless File.exist?(file)
f = File.open(file)
str = ELFTools::ELFFile.new(f).machine
{
'Advanced Micro Devices X86-64' => :amd64,
'Intel 80386' => :i386,
'ARM' => :arm,
'AArch64' => :aarch64,
'MIPS R3000' => :mips
... | ruby | def architecture(file)
return :invalid unless File.exist?(file)
f = File.open(file)
str = ELFTools::ELFFile.new(f).machine
{
'Advanced Micro Devices X86-64' => :amd64,
'Intel 80386' => :i386,
'ARM' => :arm,
'AArch64' => :aarch64,
'MIPS R3000' => :mips
... | [
"def",
"architecture",
"(",
"file",
")",
"return",
":invalid",
"unless",
"File",
".",
"exist?",
"(",
"file",
")",
"f",
"=",
"File",
".",
"open",
"(",
"file",
")",
"str",
"=",
"ELFTools",
"::",
"ELFFile",
".",
"new",
"(",
"f",
")",
".",
"machine",
"... | Fetch the ELF archiecture of +file+.
@param [String] file The target ELF filename.
@return [Symbol]
Currently supports amd64, i386, arm, aarch64, and mips.
@example
Helper.architecture('/bin/cat')
#=> :amd64 | [
"Fetch",
"the",
"ELF",
"archiecture",
"of",
"+",
"file",
"+",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/helper.rb#L197-L213 |
12,035 | david942j/one_gadget | lib/one_gadget/helper.rb | OneGadget.Helper.find_objdump | def find_objdump(arch)
[
which('objdump'),
which(arch_specific_objdump(arch))
].find { |bin| objdump_arch_supported?(bin, arch) }
end | ruby | def find_objdump(arch)
[
which('objdump'),
which(arch_specific_objdump(arch))
].find { |bin| objdump_arch_supported?(bin, arch) }
end | [
"def",
"find_objdump",
"(",
"arch",
")",
"[",
"which",
"(",
"'objdump'",
")",
",",
"which",
"(",
"arch_specific_objdump",
"(",
"arch",
")",
")",
"]",
".",
"find",
"{",
"|",
"bin",
"|",
"objdump_arch_supported?",
"(",
"bin",
",",
"arch",
")",
"}",
"end"... | Find objdump that supports architecture +arch+.
@param [String] arch
@return [String?]
@example
Helper.find_objdump(:amd64)
#=> '/usr/bin/objdump'
Helper.find_objdump(:aarch64)
#=> '/usr/bin/aarch64-linux-gnu-objdump' | [
"Find",
"objdump",
"that",
"supports",
"architecture",
"+",
"arch",
"+",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/helper.rb#L278-L283 |
12,036 | david942j/one_gadget | lib/one_gadget/abi.rb | OneGadget.ABI.stack_register? | def stack_register?(reg)
%w[esp ebp rsp rbp sp x29].include?(reg)
end | ruby | def stack_register?(reg)
%w[esp ebp rsp rbp sp x29].include?(reg)
end | [
"def",
"stack_register?",
"(",
"reg",
")",
"%w[",
"esp",
"ebp",
"rsp",
"rbp",
"sp",
"x29",
"]",
".",
"include?",
"(",
"reg",
")",
"end"
] | Checks if the register is a stack-related pointer.
@param [String] reg
Register's name.
@return [Boolean] | [
"Checks",
"if",
"the",
"register",
"is",
"a",
"stack",
"-",
"related",
"pointer",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/abi.rb#L47-L49 |
12,037 | david942j/one_gadget | lib/one_gadget/logger.rb | OneGadget.Logger.ask_update | def ask_update(msg: '')
name = 'one_gadget'
cmd = OneGadget::Helper.colorize("gem update #{name} && gem cleanup #{name}")
OneGadget::Logger.info(msg + "\n" + "Update with: $ #{cmd}" + "\n")
end | ruby | def ask_update(msg: '')
name = 'one_gadget'
cmd = OneGadget::Helper.colorize("gem update #{name} && gem cleanup #{name}")
OneGadget::Logger.info(msg + "\n" + "Update with: $ #{cmd}" + "\n")
end | [
"def",
"ask_update",
"(",
"msg",
":",
"''",
")",
"name",
"=",
"'one_gadget'",
"cmd",
"=",
"OneGadget",
"::",
"Helper",
".",
"colorize",
"(",
"\"gem update #{name} && gem cleanup #{name}\"",
")",
"OneGadget",
"::",
"Logger",
".",
"info",
"(",
"msg",
"+",
"\"\\n... | Show the message of ask user to update gem.
@return [void] | [
"Show",
"the",
"message",
"of",
"ask",
"user",
"to",
"update",
"gem",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/logger.rb#L40-L44 |
12,038 | david942j/one_gadget | lib/one_gadget/cli.rb | OneGadget.CLI.work | def work(argv)
@options = DEFAULT_OPTIONS.dup
parser.parse!(argv)
return show("OneGadget Version #{OneGadget::VERSION}") if @options[:version]
return info_build_id(@options[:info]) if @options[:info]
libc_file = argv.pop
build_id = @options[:build_id]
level = @options[:level]
... | ruby | def work(argv)
@options = DEFAULT_OPTIONS.dup
parser.parse!(argv)
return show("OneGadget Version #{OneGadget::VERSION}") if @options[:version]
return info_build_id(@options[:info]) if @options[:info]
libc_file = argv.pop
build_id = @options[:build_id]
level = @options[:level]
... | [
"def",
"work",
"(",
"argv",
")",
"@options",
"=",
"DEFAULT_OPTIONS",
".",
"dup",
"parser",
".",
"parse!",
"(",
"argv",
")",
"return",
"show",
"(",
"\"OneGadget Version #{OneGadget::VERSION}\"",
")",
"if",
"@options",
"[",
":version",
"]",
"return",
"info_build_i... | Main method of CLI.
@param [Array<String>] argv
Command line arguments.
@return [Boolean]
Whether the command execute successfully.
@example
CLI.work(%w[--help])
# usage message
#=> true
CLI.work(%w[--version])
# version message
#=> true
@example
CLI.work([])
# usage message
#=> fal... | [
"Main",
"method",
"of",
"CLI",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/cli.rb#L39-L57 |
12,039 | david942j/one_gadget | lib/one_gadget/cli.rb | OneGadget.CLI.handle_gadgets | def handle_gadgets(gadgets, libc_file)
return false if gadgets.empty? # error occurs when fetching gadgets
return handle_script(gadgets, @options[:script]) if @options[:script]
return handle_near(libc_file, gadgets, @options[:near]) if @options[:near]
display_gadgets(gadgets, @options[:raw])
... | ruby | def handle_gadgets(gadgets, libc_file)
return false if gadgets.empty? # error occurs when fetching gadgets
return handle_script(gadgets, @options[:script]) if @options[:script]
return handle_near(libc_file, gadgets, @options[:near]) if @options[:near]
display_gadgets(gadgets, @options[:raw])
... | [
"def",
"handle_gadgets",
"(",
"gadgets",
",",
"libc_file",
")",
"return",
"false",
"if",
"gadgets",
".",
"empty?",
"# error occurs when fetching gadgets",
"return",
"handle_script",
"(",
"gadgets",
",",
"@options",
"[",
":script",
"]",
")",
"if",
"@options",
"[",
... | Decides how to display fetched gadgets according to options.
@param [Array<OneGadget::Gadget::Gadget>] gadgets
@param [String] libc_file
@return [Boolean] | [
"Decides",
"how",
"to",
"display",
"fetched",
"gadgets",
"according",
"to",
"options",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/cli.rb#L63-L69 |
12,040 | david942j/one_gadget | lib/one_gadget/cli.rb | OneGadget.CLI.info_build_id | def info_build_id(id)
result = OneGadget::Gadget.builds_info(id)
return false if result.nil? # invalid form or BuildID not found
OneGadget::Logger.info("Information of #{id}:\n#{result.join("\n")}")
true
end | ruby | def info_build_id(id)
result = OneGadget::Gadget.builds_info(id)
return false if result.nil? # invalid form or BuildID not found
OneGadget::Logger.info("Information of #{id}:\n#{result.join("\n")}")
true
end | [
"def",
"info_build_id",
"(",
"id",
")",
"result",
"=",
"OneGadget",
"::",
"Gadget",
".",
"builds_info",
"(",
"id",
")",
"return",
"false",
"if",
"result",
".",
"nil?",
"# invalid form or BuildID not found",
"OneGadget",
"::",
"Logger",
".",
"info",
"(",
"\"Inf... | Displays libc information given BuildID.
@param [String] id
@return [Boolean]
+false+ is returned if no information found.
@example
CLI.info_build_id('b417c')
# [OneGadget] Information of b417c:
# spec/data/libc-2.27-b417c0ba7cc5cf06d1d1bed6652cedb9253c60d0.so
# Advanced Mi... | [
"Displays",
"libc",
"information",
"given",
"BuildID",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/cli.rb#L92-L98 |
12,041 | david942j/one_gadget | lib/one_gadget/cli.rb | OneGadget.CLI.parser | def parser
@parser ||= OptionParser.new do |opts|
opts.banner = USAGE
opts.on('-b', '--build-id BuildID', 'BuildID[sha1] of libc.') do |b|
@options[:build_id] = b
end
opts.on('-f', '--[no-]force-file', 'Force search gadgets in file instead of build id first.') do |f|
... | ruby | def parser
@parser ||= OptionParser.new do |opts|
opts.banner = USAGE
opts.on('-b', '--build-id BuildID', 'BuildID[sha1] of libc.') do |b|
@options[:build_id] = b
end
opts.on('-f', '--[no-]force-file', 'Force search gadgets in file instead of build id first.') do |f|
... | [
"def",
"parser",
"@parser",
"||=",
"OptionParser",
".",
"new",
"do",
"|",
"opts",
"|",
"opts",
".",
"banner",
"=",
"USAGE",
"opts",
".",
"on",
"(",
"'-b'",
",",
"'--build-id BuildID'",
",",
"'BuildID[sha1] of libc.'",
")",
"do",
"|",
"b",
"|",
"@options",
... | The option parser.
@return [OptionParser] | [
"The",
"option",
"parser",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/cli.rb#L102-L143 |
12,042 | david942j/one_gadget | lib/one_gadget/cli.rb | OneGadget.CLI.display_gadgets | def display_gadgets(gadgets, raw)
if raw
show(gadgets.map(&:offset).join(' '))
else
show(gadgets.map(&:inspect).join("\n"))
end
end | ruby | def display_gadgets(gadgets, raw)
if raw
show(gadgets.map(&:offset).join(' '))
else
show(gadgets.map(&:inspect).join("\n"))
end
end | [
"def",
"display_gadgets",
"(",
"gadgets",
",",
"raw",
")",
"if",
"raw",
"show",
"(",
"gadgets",
".",
"map",
"(",
":offset",
")",
".",
"join",
"(",
"' '",
")",
")",
"else",
"show",
"(",
"gadgets",
".",
"map",
"(",
":inspect",
")",
".",
"join",
"(",
... | Writes gadgets to stdout.
@param [Array<OneGadget::Gadget::Gadget>] gadgets
@param [Boolean] raw
In raw mode, only the offset of gadgets are printed.
@return [true] | [
"Writes",
"gadgets",
"to",
"stdout",
"."
] | ff6ef04541e83441bfe3c2664a6febd1640f4263 | https://github.com/david942j/one_gadget/blob/ff6ef04541e83441bfe3c2664a6febd1640f4263/lib/one_gadget/cli.rb#L177-L183 |
12,043 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.logger | def logger(logger, level = :info, format = :apache)
default_options[:logger] = logger
default_options[:log_level] = level
default_options[:log_format] = format
end | ruby | def logger(logger, level = :info, format = :apache)
default_options[:logger] = logger
default_options[:log_level] = level
default_options[:log_format] = format
end | [
"def",
"logger",
"(",
"logger",
",",
"level",
"=",
":info",
",",
"format",
"=",
":apache",
")",
"default_options",
"[",
":logger",
"]",
"=",
"logger",
"default_options",
"[",
":log_level",
"]",
"=",
"level",
"default_options",
"[",
":log_format",
"]",
"=",
... | Turns on logging
class Foo
include HTTParty
logger Logger.new('http_logger'), :info, :apache
end | [
"Turns",
"on",
"logging"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L73-L77 |
12,044 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.http_proxy | def http_proxy(addr = nil, port = nil, user = nil, pass = nil)
default_options[:http_proxyaddr] = addr
default_options[:http_proxyport] = port
default_options[:http_proxyuser] = user
default_options[:http_proxypass] = pass
end | ruby | def http_proxy(addr = nil, port = nil, user = nil, pass = nil)
default_options[:http_proxyaddr] = addr
default_options[:http_proxyport] = port
default_options[:http_proxyuser] = user
default_options[:http_proxypass] = pass
end | [
"def",
"http_proxy",
"(",
"addr",
"=",
"nil",
",",
"port",
"=",
"nil",
",",
"user",
"=",
"nil",
",",
"pass",
"=",
"nil",
")",
"default_options",
"[",
":http_proxyaddr",
"]",
"=",
"addr",
"default_options",
"[",
":http_proxyport",
"]",
"=",
"port",
"defau... | Allows setting http proxy information to be used
class Foo
include HTTParty
http_proxy 'http://foo.com', 80, 'user', 'pass'
end | [
"Allows",
"setting",
"http",
"proxy",
"information",
"to",
"be",
"used"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L95-L100 |
12,045 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.default_params | def default_params(h = {})
raise ArgumentError, 'Default params must be an object which responds to #to_hash' unless h.respond_to?(:to_hash)
default_options[:default_params] ||= {}
default_options[:default_params].merge!(h)
end | ruby | def default_params(h = {})
raise ArgumentError, 'Default params must be an object which responds to #to_hash' unless h.respond_to?(:to_hash)
default_options[:default_params] ||= {}
default_options[:default_params].merge!(h)
end | [
"def",
"default_params",
"(",
"h",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'Default params must be an object which responds to #to_hash'",
"unless",
"h",
".",
"respond_to?",
"(",
":to_hash",
")",
"default_options",
"[",
":default_params",
"]",
"||=",
"{",
... | Allows setting default parameters to be appended to each request.
Great for api keys and such.
class Foo
include HTTParty
default_params api_key: 'secret', another: 'foo'
end | [
"Allows",
"setting",
"default",
"parameters",
"to",
"be",
"appended",
"to",
"each",
"request",
".",
"Great",
"for",
"api",
"keys",
"and",
"such",
"."
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L163-L167 |
12,046 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.headers | def headers(h = nil)
if h
raise ArgumentError, 'Headers must be an object which responds to #to_hash' unless h.respond_to?(:to_hash)
default_options[:headers] ||= {}
default_options[:headers].merge!(h.to_hash)
else
default_options[:headers] || {}
end
end | ruby | def headers(h = nil)
if h
raise ArgumentError, 'Headers must be an object which responds to #to_hash' unless h.respond_to?(:to_hash)
default_options[:headers] ||= {}
default_options[:headers].merge!(h.to_hash)
else
default_options[:headers] || {}
end
end | [
"def",
"headers",
"(",
"h",
"=",
"nil",
")",
"if",
"h",
"raise",
"ArgumentError",
",",
"'Headers must be an object which responds to #to_hash'",
"unless",
"h",
".",
"respond_to?",
"(",
":to_hash",
")",
"default_options",
"[",
":headers",
"]",
"||=",
"{",
"}",
"d... | Allows setting HTTP headers to be used for each request.
class Foo
include HTTParty
headers 'Accept' => 'text/html'
end | [
"Allows",
"setting",
"HTTP",
"headers",
"to",
"be",
"used",
"for",
"each",
"request",
"."
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L233-L241 |
12,047 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.connection_adapter | def connection_adapter(custom_adapter = nil, options = nil)
if custom_adapter.nil?
default_options[:connection_adapter]
else
default_options[:connection_adapter] = custom_adapter
default_options[:connection_adapter_options] = options
end
end | ruby | def connection_adapter(custom_adapter = nil, options = nil)
if custom_adapter.nil?
default_options[:connection_adapter]
else
default_options[:connection_adapter] = custom_adapter
default_options[:connection_adapter_options] = options
end
end | [
"def",
"connection_adapter",
"(",
"custom_adapter",
"=",
"nil",
",",
"options",
"=",
"nil",
")",
"if",
"custom_adapter",
".",
"nil?",
"default_options",
"[",
":connection_adapter",
"]",
"else",
"default_options",
"[",
":connection_adapter",
"]",
"=",
"custom_adapter... | Allows setting a custom connection_adapter for the http connections
@example
class Foo
include HTTParty
connection_adapter Proc.new {|uri, options| ... }
end
@example provide optional configuration for your connection_adapter
class Foo
include HTTParty
connection_adapter Proc.new {|uri,... | [
"Allows",
"setting",
"a",
"custom",
"connection_adapter",
"for",
"the",
"http",
"connections"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L485-L492 |
12,048 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.get | def get(path, options = {}, &block)
perform_request Net::HTTP::Get, path, options, &block
end | ruby | def get(path, options = {}, &block)
perform_request Net::HTTP::Get, path, options, &block
end | [
"def",
"get",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Get",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Allows making a get request to a url.
class Foo
include HTTParty
end
# Simple get with full url
Foo.get('http://foo.com/resource.json')
# Simple get with full url and query parameters
# ie: http://foo.com/resource.json?limit=10
Foo.get('http://foo.com/resource.json', query: {limit: 10}) | [
"Allows",
"making",
"a",
"get",
"request",
"to",
"a",
"url",
"."
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L506-L508 |
12,049 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.post | def post(path, options = {}, &block)
perform_request Net::HTTP::Post, path, options, &block
end | ruby | def post(path, options = {}, &block)
perform_request Net::HTTP::Post, path, options, &block
end | [
"def",
"post",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Post",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Allows making a post request to a url.
class Foo
include HTTParty
end
# Simple post with full url and setting the body
Foo.post('http://foo.com/resources', body: {bar: 'baz'})
# Simple post with full url using :query option,
# which appends the parameters to the URI.
Foo.post('http://foo.co... | [
"Allows",
"making",
"a",
"post",
"request",
"to",
"a",
"url",
"."
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L522-L524 |
12,050 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.patch | def patch(path, options = {}, &block)
perform_request Net::HTTP::Patch, path, options, &block
end | ruby | def patch(path, options = {}, &block)
perform_request Net::HTTP::Patch, path, options, &block
end | [
"def",
"patch",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Patch",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Perform a PATCH request to a path | [
"Perform",
"a",
"PATCH",
"request",
"to",
"a",
"path"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L527-L529 |
12,051 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.put | def put(path, options = {}, &block)
perform_request Net::HTTP::Put, path, options, &block
end | ruby | def put(path, options = {}, &block)
perform_request Net::HTTP::Put, path, options, &block
end | [
"def",
"put",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Put",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Perform a PUT request to a path | [
"Perform",
"a",
"PUT",
"request",
"to",
"a",
"path"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L532-L534 |
12,052 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.delete | def delete(path, options = {}, &block)
perform_request Net::HTTP::Delete, path, options, &block
end | ruby | def delete(path, options = {}, &block)
perform_request Net::HTTP::Delete, path, options, &block
end | [
"def",
"delete",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Delete",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Perform a DELETE request to a path | [
"Perform",
"a",
"DELETE",
"request",
"to",
"a",
"path"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L537-L539 |
12,053 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.move | def move(path, options = {}, &block)
perform_request Net::HTTP::Move, path, options, &block
end | ruby | def move(path, options = {}, &block)
perform_request Net::HTTP::Move, path, options, &block
end | [
"def",
"move",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Move",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Perform a MOVE request to a path | [
"Perform",
"a",
"MOVE",
"request",
"to",
"a",
"path"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L542-L544 |
12,054 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.copy | def copy(path, options = {}, &block)
perform_request Net::HTTP::Copy, path, options, &block
end | ruby | def copy(path, options = {}, &block)
perform_request Net::HTTP::Copy, path, options, &block
end | [
"def",
"copy",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Copy",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Perform a COPY request to a path | [
"Perform",
"a",
"COPY",
"request",
"to",
"a",
"path"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L547-L549 |
12,055 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.head | def head(path, options = {}, &block)
ensure_method_maintained_across_redirects options
perform_request Net::HTTP::Head, path, options, &block
end | ruby | def head(path, options = {}, &block)
ensure_method_maintained_across_redirects options
perform_request Net::HTTP::Head, path, options, &block
end | [
"def",
"head",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"ensure_method_maintained_across_redirects",
"options",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Head",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Perform a HEAD request to a path | [
"Perform",
"a",
"HEAD",
"request",
"to",
"a",
"path"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L552-L555 |
12,056 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.options | def options(path, options = {}, &block)
perform_request Net::HTTP::Options, path, options, &block
end | ruby | def options(path, options = {}, &block)
perform_request Net::HTTP::Options, path, options, &block
end | [
"def",
"options",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Options",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Perform an OPTIONS request to a path | [
"Perform",
"an",
"OPTIONS",
"request",
"to",
"a",
"path"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L558-L560 |
12,057 | jnunemaker/httparty | lib/httparty.rb | HTTParty.ClassMethods.mkcol | def mkcol(path, options = {}, &block)
perform_request Net::HTTP::Mkcol, path, options, &block
end | ruby | def mkcol(path, options = {}, &block)
perform_request Net::HTTP::Mkcol, path, options, &block
end | [
"def",
"mkcol",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"perform_request",
"Net",
"::",
"HTTP",
"::",
"Mkcol",
",",
"path",
",",
"options",
",",
"block",
"end"
] | Perform a MKCOL request to a path | [
"Perform",
"a",
"MKCOL",
"request",
"to",
"a",
"path"
] | b4099defba01231d2faaaa2660476f867e096bfb | https://github.com/jnunemaker/httparty/blob/b4099defba01231d2faaaa2660476f867e096bfb/lib/httparty.rb#L563-L565 |
12,058 | sferik/twitter | lib/twitter/utils.rb | Twitter.Utils.flat_pmap | def flat_pmap(enumerable)
return to_enum(:flat_pmap, enumerable) unless block_given?
pmap(enumerable, &Proc.new).flatten(1)
end | ruby | def flat_pmap(enumerable)
return to_enum(:flat_pmap, enumerable) unless block_given?
pmap(enumerable, &Proc.new).flatten(1)
end | [
"def",
"flat_pmap",
"(",
"enumerable",
")",
"return",
"to_enum",
"(",
":flat_pmap",
",",
"enumerable",
")",
"unless",
"block_given?",
"pmap",
"(",
"enumerable",
",",
"Proc",
".",
"new",
")",
".",
"flatten",
"(",
"1",
")",
"end"
] | Returns a new array with the concatenated results of running block once for every element in enumerable.
If no block is given, an enumerator is returned instead.
@param enumerable [Enumerable]
@return [Array, Enumerator] | [
"Returns",
"a",
"new",
"array",
"with",
"the",
"concatenated",
"results",
"of",
"running",
"block",
"once",
"for",
"every",
"element",
"in",
"enumerable",
".",
"If",
"no",
"block",
"is",
"given",
"an",
"enumerator",
"is",
"returned",
"instead",
"."
] | 844818cad07ce490ccb9d8542ebb6b4fc7a61cb4 | https://github.com/sferik/twitter/blob/844818cad07ce490ccb9d8542ebb6b4fc7a61cb4/lib/twitter/utils.rb#L10-L13 |
12,059 | sferik/twitter | lib/twitter/utils.rb | Twitter.Utils.pmap | def pmap(enumerable)
return to_enum(:pmap, enumerable) unless block_given?
if enumerable.count == 1
enumerable.collect { |object| yield(object) }
else
enumerable.collect { |object| Thread.new { yield(object) } }.collect(&:value)
end
end | ruby | def pmap(enumerable)
return to_enum(:pmap, enumerable) unless block_given?
if enumerable.count == 1
enumerable.collect { |object| yield(object) }
else
enumerable.collect { |object| Thread.new { yield(object) } }.collect(&:value)
end
end | [
"def",
"pmap",
"(",
"enumerable",
")",
"return",
"to_enum",
"(",
":pmap",
",",
"enumerable",
")",
"unless",
"block_given?",
"if",
"enumerable",
".",
"count",
"==",
"1",
"enumerable",
".",
"collect",
"{",
"|",
"object",
"|",
"yield",
"(",
"object",
")",
"... | Returns a new array with the results of running block once for every element in enumerable.
If no block is given, an enumerator is returned instead.
@param enumerable [Enumerable]
@return [Array, Enumerator] | [
"Returns",
"a",
"new",
"array",
"with",
"the",
"results",
"of",
"running",
"block",
"once",
"for",
"every",
"element",
"in",
"enumerable",
".",
"If",
"no",
"block",
"is",
"given",
"an",
"enumerator",
"is",
"returned",
"instead",
"."
] | 844818cad07ce490ccb9d8542ebb6b4fc7a61cb4 | https://github.com/sferik/twitter/blob/844818cad07ce490ccb9d8542ebb6b4fc7a61cb4/lib/twitter/utils.rb#L20-L27 |
12,060 | sferik/twitter | lib/twitter/search_results.rb | Twitter.SearchResults.query_string_to_hash | def query_string_to_hash(query_string)
query = CGI.parse(URI.parse(query_string).query)
Hash[query.collect { |key, value| [key.to_sym, value.first] }]
end | ruby | def query_string_to_hash(query_string)
query = CGI.parse(URI.parse(query_string).query)
Hash[query.collect { |key, value| [key.to_sym, value.first] }]
end | [
"def",
"query_string_to_hash",
"(",
"query_string",
")",
"query",
"=",
"CGI",
".",
"parse",
"(",
"URI",
".",
"parse",
"(",
"query_string",
")",
".",
"query",
")",
"Hash",
"[",
"query",
".",
"collect",
"{",
"|",
"key",
",",
"value",
"|",
"[",
"key",
"... | Converts query string to a hash
@param query_string [String] The query string of a URL.
@return [Hash] The query string converted to a hash (with symbol keys).
@example Convert query string to a hash
query_string_to_hash("foo=bar&baz=qux") #=> {:foo=>"bar", :baz=>"qux"} | [
"Converts",
"query",
"string",
"to",
"a",
"hash"
] | 844818cad07ce490ccb9d8542ebb6b4fc7a61cb4 | https://github.com/sferik/twitter/blob/844818cad07ce490ccb9d8542ebb6b4fc7a61cb4/lib/twitter/search_results.rb#L72-L75 |
12,061 | sferik/twitter | lib/twitter/creatable.rb | Twitter.Creatable.created_at | def created_at
time = @attrs[:created_at]
return if time.nil?
time = Time.parse(time) unless time.is_a?(Time)
time.utc
end | ruby | def created_at
time = @attrs[:created_at]
return if time.nil?
time = Time.parse(time) unless time.is_a?(Time)
time.utc
end | [
"def",
"created_at",
"time",
"=",
"@attrs",
"[",
":created_at",
"]",
"return",
"if",
"time",
".",
"nil?",
"time",
"=",
"Time",
".",
"parse",
"(",
"time",
")",
"unless",
"time",
".",
"is_a?",
"(",
"Time",
")",
"time",
".",
"utc",
"end"
] | Time when the object was created on Twitter
@return [Time] | [
"Time",
"when",
"the",
"object",
"was",
"created",
"on",
"Twitter"
] | 844818cad07ce490ccb9d8542ebb6b4fc7a61cb4 | https://github.com/sferik/twitter/blob/844818cad07ce490ccb9d8542ebb6b4fc7a61cb4/lib/twitter/creatable.rb#L11-L16 |
12,062 | doorkeeper-gem/doorkeeper | lib/doorkeeper/models/access_token_mixin.rb | Doorkeeper.AccessTokenMixin.as_json | def as_json(_options = {})
{
resource_owner_id: resource_owner_id,
scope: scopes,
expires_in: expires_in_seconds,
application: { uid: application.try(:uid) },
created_at: created_at.to_i,
}
end | ruby | def as_json(_options = {})
{
resource_owner_id: resource_owner_id,
scope: scopes,
expires_in: expires_in_seconds,
application: { uid: application.try(:uid) },
created_at: created_at.to_i,
}
end | [
"def",
"as_json",
"(",
"_options",
"=",
"{",
"}",
")",
"{",
"resource_owner_id",
":",
"resource_owner_id",
",",
"scope",
":",
"scopes",
",",
"expires_in",
":",
"expires_in_seconds",
",",
"application",
":",
"{",
"uid",
":",
"application",
".",
"try",
"(",
... | JSON representation of the Access Token instance.
@return [Hash] hash with token data | [
"JSON",
"representation",
"of",
"the",
"Access",
"Token",
"instance",
"."
] | f1be81891c3d54a42928c1b9e03c5d6833b8af87 | https://github.com/doorkeeper-gem/doorkeeper/blob/f1be81891c3d54a42928c1b9e03c5d6833b8af87/lib/doorkeeper/models/access_token_mixin.rb#L205-L213 |
12,063 | doorkeeper-gem/doorkeeper | lib/doorkeeper/models/application_mixin.rb | Doorkeeper.ApplicationMixin.secret_matches? | def secret_matches?(input)
# return false if either is nil, since secure_compare depends on strings
# but Application secrets MAY be nil depending on confidentiality.
return false if input.nil? || secret.nil?
# When matching the secret by comparer function, all is well.
return true if sec... | ruby | def secret_matches?(input)
# return false if either is nil, since secure_compare depends on strings
# but Application secrets MAY be nil depending on confidentiality.
return false if input.nil? || secret.nil?
# When matching the secret by comparer function, all is well.
return true if sec... | [
"def",
"secret_matches?",
"(",
"input",
")",
"# return false if either is nil, since secure_compare depends on strings",
"# but Application secrets MAY be nil depending on confidentiality.",
"return",
"false",
"if",
"input",
".",
"nil?",
"||",
"secret",
".",
"nil?",
"# When matchin... | Check whether the given plain text secret matches our stored secret
@param input [#to_s] Plain secret provided by user
(any object that responds to `#to_s`)
@return [true] Whether the given secret matches the stored secret
of this application. | [
"Check",
"whether",
"the",
"given",
"plain",
"text",
"secret",
"matches",
"our",
"stored",
"secret"
] | f1be81891c3d54a42928c1b9e03c5d6833b8af87 | https://github.com/doorkeeper-gem/doorkeeper/blob/f1be81891c3d54a42928c1b9e03c5d6833b8af87/lib/doorkeeper/models/application_mixin.rb#L78-L93 |
12,064 | doorkeeper-gem/doorkeeper | lib/doorkeeper/config.rb | Doorkeeper.Config.validate_reuse_access_token_value | def validate_reuse_access_token_value
strategy = token_secret_strategy
return if !reuse_access_token || strategy.allows_restoring_secrets?
::Rails.logger.warn(
"You have configured both reuse_access_token " \
"AND strategy strategy '#{strategy}' that cannot restore tokens. " \
... | ruby | def validate_reuse_access_token_value
strategy = token_secret_strategy
return if !reuse_access_token || strategy.allows_restoring_secrets?
::Rails.logger.warn(
"You have configured both reuse_access_token " \
"AND strategy strategy '#{strategy}' that cannot restore tokens. " \
... | [
"def",
"validate_reuse_access_token_value",
"strategy",
"=",
"token_secret_strategy",
"return",
"if",
"!",
"reuse_access_token",
"||",
"strategy",
".",
"allows_restoring_secrets?",
"::",
"Rails",
".",
"logger",
".",
"warn",
"(",
"\"You have configured both reuse_access_token ... | Determine whether +reuse_access_token+ and a non-restorable
+token_secret_strategy+ have both been activated.
In that case, disable reuse_access_token value and warn the user. | [
"Determine",
"whether",
"+",
"reuse_access_token",
"+",
"and",
"a",
"non",
"-",
"restorable",
"+",
"token_secret_strategy",
"+",
"have",
"both",
"been",
"activated",
"."
] | f1be81891c3d54a42928c1b9e03c5d6833b8af87 | https://github.com/doorkeeper-gem/doorkeeper/blob/f1be81891c3d54a42928c1b9e03c5d6833b8af87/lib/doorkeeper/config.rb#L460-L470 |
12,065 | mikel/mail | lib/mail/network/delivery_methods/smtp.rb | Mail.SMTP.ssl_context | def ssl_context
openssl_verify_mode = settings[:openssl_verify_mode]
if openssl_verify_mode.kind_of?(String)
openssl_verify_mode = OpenSSL::SSL.const_get("VERIFY_#{openssl_verify_mode.upcase}")
end
context = Net::SMTP.default_ssl_context
context.verify_mode = openssl_... | ruby | def ssl_context
openssl_verify_mode = settings[:openssl_verify_mode]
if openssl_verify_mode.kind_of?(String)
openssl_verify_mode = OpenSSL::SSL.const_get("VERIFY_#{openssl_verify_mode.upcase}")
end
context = Net::SMTP.default_ssl_context
context.verify_mode = openssl_... | [
"def",
"ssl_context",
"openssl_verify_mode",
"=",
"settings",
"[",
":openssl_verify_mode",
"]",
"if",
"openssl_verify_mode",
".",
"kind_of?",
"(",
"String",
")",
"openssl_verify_mode",
"=",
"OpenSSL",
"::",
"SSL",
".",
"const_get",
"(",
"\"VERIFY_#{openssl_verify_mode.u... | Allow SSL context to be configured via settings, for Ruby >= 1.9
Just returns openssl verify mode for Ruby 1.8.x | [
"Allow",
"SSL",
"context",
"to",
"be",
"configured",
"via",
"settings",
"for",
"Ruby",
">",
"=",
"1",
".",
"9",
"Just",
"returns",
"openssl",
"verify",
"mode",
"for",
"Ruby",
"1",
".",
"8",
".",
"x"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/network/delivery_methods/smtp.rb#L135-L147 |
12,066 | mikel/mail | lib/mail/attachments_list.rb | Mail.AttachmentsList.[] | def [](index_value)
if index_value.is_a?(Integer)
self.fetch(index_value)
else
self.select { |a| a.filename == index_value }.first
end
end | ruby | def [](index_value)
if index_value.is_a?(Integer)
self.fetch(index_value)
else
self.select { |a| a.filename == index_value }.first
end
end | [
"def",
"[]",
"(",
"index_value",
")",
"if",
"index_value",
".",
"is_a?",
"(",
"Integer",
")",
"self",
".",
"fetch",
"(",
"index_value",
")",
"else",
"self",
".",
"select",
"{",
"|",
"a",
"|",
"a",
".",
"filename",
"==",
"index_value",
"}",
".",
"firs... | Returns the attachment by filename or at index.
mail.attachments['test.png'] = File.read('test.png')
mail.attachments['test.jpg'] = File.read('test.jpg')
mail.attachments['test.png'].filename #=> 'test.png'
mail.attachments[1].filename #=> 'test.jpg' | [
"Returns",
"the",
"attachment",
"by",
"filename",
"or",
"at",
"index",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/attachments_list.rb#L32-L38 |
12,067 | mikel/mail | lib/mail/network/retriever_methods/pop3.rb | Mail.POP3.find | def find(options = nil, &block)
options = validate_options(options)
start do |pop3|
mails = pop3.mails
pop3.reset # Clears all "deleted" marks. This prevents non-explicit/accidental deletions due to server settings.
mails.sort! { |m1, m2| m2.number <=> m1.number } if options[:... | ruby | def find(options = nil, &block)
options = validate_options(options)
start do |pop3|
mails = pop3.mails
pop3.reset # Clears all "deleted" marks. This prevents non-explicit/accidental deletions due to server settings.
mails.sort! { |m1, m2| m2.number <=> m1.number } if options[:... | [
"def",
"find",
"(",
"options",
"=",
"nil",
",",
"&",
"block",
")",
"options",
"=",
"validate_options",
"(",
"options",
")",
"start",
"do",
"|",
"pop3",
"|",
"mails",
"=",
"pop3",
".",
"mails",
"pop3",
".",
"reset",
"# Clears all \"deleted\" marks. This preve... | Find emails in a POP3 mailbox. Without any options, the 5 last received emails are returned.
Possible options:
what: last or first emails. The default is :first.
order: order of emails returned. Possible values are :asc or :desc. Default value is :asc.
count: number of emails to retrieve. The default value ... | [
"Find",
"emails",
"in",
"a",
"POP3",
"mailbox",
".",
"Without",
"any",
"options",
"the",
"5",
"last",
"received",
"emails",
"are",
"returned",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/network/retriever_methods/pop3.rb#L60-L91 |
12,068 | mikel/mail | lib/mail/network/retriever_methods/pop3.rb | Mail.POP3.delete_all | def delete_all
start do |pop3|
unless pop3.mails.empty?
pop3.delete_all
pop3.finish
end
end
end | ruby | def delete_all
start do |pop3|
unless pop3.mails.empty?
pop3.delete_all
pop3.finish
end
end
end | [
"def",
"delete_all",
"start",
"do",
"|",
"pop3",
"|",
"unless",
"pop3",
".",
"mails",
".",
"empty?",
"pop3",
".",
"delete_all",
"pop3",
".",
"finish",
"end",
"end",
"end"
] | Delete all emails from a POP3 server | [
"Delete",
"all",
"emails",
"from",
"a",
"POP3",
"server"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/network/retriever_methods/pop3.rb#L94-L101 |
12,069 | mikel/mail | lib/mail/fields/common_address_field.rb | Mail.CommonAddressField.addresses | def addresses
list = element.addresses.map { |a| a.address }
Mail::AddressContainer.new(self, list)
end | ruby | def addresses
list = element.addresses.map { |a| a.address }
Mail::AddressContainer.new(self, list)
end | [
"def",
"addresses",
"list",
"=",
"element",
".",
"addresses",
".",
"map",
"{",
"|",
"a",
"|",
"a",
".",
"address",
"}",
"Mail",
"::",
"AddressContainer",
".",
"new",
"(",
"self",
",",
"list",
")",
"end"
] | Returns the address string of all the addresses in the address list | [
"Returns",
"the",
"address",
"string",
"of",
"all",
"the",
"addresses",
"in",
"the",
"address",
"list"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/fields/common_address_field.rb#L46-L49 |
12,070 | mikel/mail | lib/mail/fields/common_address_field.rb | Mail.CommonAddressField.formatted | def formatted
list = element.addresses.map { |a| a.format }
Mail::AddressContainer.new(self, list)
end | ruby | def formatted
list = element.addresses.map { |a| a.format }
Mail::AddressContainer.new(self, list)
end | [
"def",
"formatted",
"list",
"=",
"element",
".",
"addresses",
".",
"map",
"{",
"|",
"a",
"|",
"a",
".",
"format",
"}",
"Mail",
"::",
"AddressContainer",
".",
"new",
"(",
"self",
",",
"list",
")",
"end"
] | Returns the formatted string of all the addresses in the address list | [
"Returns",
"the",
"formatted",
"string",
"of",
"all",
"the",
"addresses",
"in",
"the",
"address",
"list"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/fields/common_address_field.rb#L52-L55 |
12,071 | mikel/mail | lib/mail/fields/common_address_field.rb | Mail.CommonAddressField.display_names | def display_names
list = element.addresses.map { |a| a.display_name }
Mail::AddressContainer.new(self, list)
end | ruby | def display_names
list = element.addresses.map { |a| a.display_name }
Mail::AddressContainer.new(self, list)
end | [
"def",
"display_names",
"list",
"=",
"element",
".",
"addresses",
".",
"map",
"{",
"|",
"a",
"|",
"a",
".",
"display_name",
"}",
"Mail",
"::",
"AddressContainer",
".",
"new",
"(",
"self",
",",
"list",
")",
"end"
] | Returns the display name of all the addresses in the address list | [
"Returns",
"the",
"display",
"name",
"of",
"all",
"the",
"addresses",
"in",
"the",
"address",
"list"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/fields/common_address_field.rb#L58-L61 |
12,072 | mikel/mail | lib/mail/fields/common_address_field.rb | Mail.CommonAddressField.decoded_group_addresses | def decoded_group_addresses
groups.map { |k,v| v.map { |a| a.decoded } }.flatten
end | ruby | def decoded_group_addresses
groups.map { |k,v| v.map { |a| a.decoded } }.flatten
end | [
"def",
"decoded_group_addresses",
"groups",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"v",
".",
"map",
"{",
"|",
"a",
"|",
"a",
".",
"decoded",
"}",
"}",
".",
"flatten",
"end"
] | Returns a list of decoded group addresses | [
"Returns",
"a",
"list",
"of",
"decoded",
"group",
"addresses"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/fields/common_address_field.rb#L80-L82 |
12,073 | mikel/mail | lib/mail/fields/common_address_field.rb | Mail.CommonAddressField.encoded_group_addresses | def encoded_group_addresses
groups.map { |k,v| v.map { |a| a.encoded } }.flatten
end | ruby | def encoded_group_addresses
groups.map { |k,v| v.map { |a| a.encoded } }.flatten
end | [
"def",
"encoded_group_addresses",
"groups",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"v",
".",
"map",
"{",
"|",
"a",
"|",
"a",
".",
"encoded",
"}",
"}",
".",
"flatten",
"end"
] | Returns a list of encoded group addresses | [
"Returns",
"a",
"list",
"of",
"encoded",
"group",
"addresses"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/fields/common_address_field.rb#L85-L87 |
12,074 | mikel/mail | lib/mail/network/delivery_methods/smtp_connection.rb | Mail.SMTPConnection.deliver! | def deliver!(mail)
envelope = Mail::SmtpEnvelope.new(mail)
response = smtp.sendmail(dot_stuff(envelope.message), envelope.from, envelope.to)
settings[:return_response] ? response : self
end | ruby | def deliver!(mail)
envelope = Mail::SmtpEnvelope.new(mail)
response = smtp.sendmail(dot_stuff(envelope.message), envelope.from, envelope.to)
settings[:return_response] ? response : self
end | [
"def",
"deliver!",
"(",
"mail",
")",
"envelope",
"=",
"Mail",
"::",
"SmtpEnvelope",
".",
"new",
"(",
"mail",
")",
"response",
"=",
"smtp",
".",
"sendmail",
"(",
"dot_stuff",
"(",
"envelope",
".",
"message",
")",
",",
"envelope",
".",
"from",
",",
"enve... | Send the message via SMTP.
The from and to attributes are optional. If not set, they are retrieve from the Message. | [
"Send",
"the",
"message",
"via",
"SMTP",
".",
"The",
"from",
"and",
"to",
"attributes",
"are",
"optional",
".",
"If",
"not",
"set",
"they",
"are",
"retrieve",
"from",
"the",
"Message",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/network/delivery_methods/smtp_connection.rb#L51-L55 |
12,075 | mikel/mail | lib/mail/fields/content_type_field.rb | Mail.ContentTypeField.sanitize | def sanitize(val)
# TODO: check if there are cases where whitespace is not a separator
val = val.
gsub(/\s*=\s*/,'='). # remove whitespaces around equal sign
gsub(/[; ]+/, '; '). #use '; ' as a separator (or EOL)
gsub(/;\s*$/,'') #remove trailing to keep examples below
if val ... | ruby | def sanitize(val)
# TODO: check if there are cases where whitespace is not a separator
val = val.
gsub(/\s*=\s*/,'='). # remove whitespaces around equal sign
gsub(/[; ]+/, '; '). #use '; ' as a separator (or EOL)
gsub(/;\s*$/,'') #remove trailing to keep examples below
if val ... | [
"def",
"sanitize",
"(",
"val",
")",
"# TODO: check if there are cases where whitespace is not a separator",
"val",
"=",
"val",
".",
"gsub",
"(",
"/",
"\\s",
"\\s",
"/",
",",
"'='",
")",
".",
"# remove whitespaces around equal sign",
"gsub",
"(",
"/",
"/",
",",
"';... | Various special cases from random emails found that I am not going to change
the parser for | [
"Various",
"special",
"cases",
"from",
"random",
"emails",
"found",
"that",
"I",
"am",
"not",
"going",
"to",
"change",
"the",
"parser",
"for"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/fields/content_type_field.rb#L119-L161 |
12,076 | mikel/mail | lib/mail/utilities.rb | Mail.Utilities.quote_phrase | def quote_phrase( str )
if str.respond_to?(:force_encoding)
original_encoding = str.encoding
ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT')
if Constants::PHRASE_UNSAFE === ascii_str
dquote(ascii_str).force_encoding(original_encoding)
else
str
end
... | ruby | def quote_phrase( str )
if str.respond_to?(:force_encoding)
original_encoding = str.encoding
ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT')
if Constants::PHRASE_UNSAFE === ascii_str
dquote(ascii_str).force_encoding(original_encoding)
else
str
end
... | [
"def",
"quote_phrase",
"(",
"str",
")",
"if",
"str",
".",
"respond_to?",
"(",
":force_encoding",
")",
"original_encoding",
"=",
"str",
".",
"encoding",
"ascii_str",
"=",
"str",
".",
"to_s",
".",
"dup",
".",
"force_encoding",
"(",
"'ASCII-8BIT'",
")",
"if",
... | If the string supplied has PHRASE unsafe characters in it, will return the string quoted
in double quotes, otherwise returns the string unmodified | [
"If",
"the",
"string",
"supplied",
"has",
"PHRASE",
"unsafe",
"characters",
"in",
"it",
"will",
"return",
"the",
"string",
"quoted",
"in",
"double",
"quotes",
"otherwise",
"returns",
"the",
"string",
"unmodified"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/utilities.rb#L23-L35 |
12,077 | mikel/mail | lib/mail/utilities.rb | Mail.Utilities.quote_token | def quote_token( str )
if str.respond_to?(:force_encoding)
original_encoding = str.encoding
ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT')
if token_safe?( ascii_str )
str
else
dquote(ascii_str).force_encoding(original_encoding)
end
else
... | ruby | def quote_token( str )
if str.respond_to?(:force_encoding)
original_encoding = str.encoding
ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT')
if token_safe?( ascii_str )
str
else
dquote(ascii_str).force_encoding(original_encoding)
end
else
... | [
"def",
"quote_token",
"(",
"str",
")",
"if",
"str",
".",
"respond_to?",
"(",
":force_encoding",
")",
"original_encoding",
"=",
"str",
".",
"encoding",
"ascii_str",
"=",
"str",
".",
"to_s",
".",
"dup",
".",
"force_encoding",
"(",
"'ASCII-8BIT'",
")",
"if",
... | If the string supplied has TOKEN unsafe characters in it, will return the string quoted
in double quotes, otherwise returns the string unmodified | [
"If",
"the",
"string",
"supplied",
"has",
"TOKEN",
"unsafe",
"characters",
"in",
"it",
"will",
"return",
"the",
"string",
"quoted",
"in",
"double",
"quotes",
"otherwise",
"returns",
"the",
"string",
"unmodified"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/utilities.rb#L44-L56 |
12,078 | mikel/mail | lib/mail/utilities.rb | Mail.Utilities.capitalize_field | def capitalize_field( str )
str.to_s.split("-").map { |v| v.capitalize }.join("-")
end | ruby | def capitalize_field( str )
str.to_s.split("-").map { |v| v.capitalize }.join("-")
end | [
"def",
"capitalize_field",
"(",
"str",
")",
"str",
".",
"to_s",
".",
"split",
"(",
"\"-\"",
")",
".",
"map",
"{",
"|",
"v",
"|",
"v",
".",
"capitalize",
"}",
".",
"join",
"(",
"\"-\"",
")",
"end"
] | Capitalizes a string that is joined by hyphens correctly.
Example:
string = 'resent-from-field'
capitalize_field( string ) #=> 'Resent-From-Field' | [
"Capitalizes",
"a",
"string",
"that",
"is",
"joined",
"by",
"hyphens",
"correctly",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/utilities.rb#L188-L190 |
12,079 | mikel/mail | lib/mail/utilities.rb | Mail.Utilities.constantize | def constantize( str )
str.to_s.split(/[-_]/).map { |v| v.capitalize }.to_s
end | ruby | def constantize( str )
str.to_s.split(/[-_]/).map { |v| v.capitalize }.to_s
end | [
"def",
"constantize",
"(",
"str",
")",
"str",
".",
"to_s",
".",
"split",
"(",
"/",
"/",
")",
".",
"map",
"{",
"|",
"v",
"|",
"v",
".",
"capitalize",
"}",
".",
"to_s",
"end"
] | Takes an underscored word and turns it into a class name
Example:
constantize("hello") #=> "Hello"
constantize("hello-there") #=> "HelloThere"
constantize("hello-there-mate") #=> "HelloThereMate" | [
"Takes",
"an",
"underscored",
"word",
"and",
"turns",
"it",
"into",
"a",
"class",
"name"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/utilities.rb#L199-L201 |
12,080 | mikel/mail | lib/mail/utilities.rb | Mail.Utilities.blank? | def blank?(value)
if value.kind_of?(NilClass)
true
elsif value.kind_of?(String)
value !~ /\S/
else
value.respond_to?(:empty?) ? value.empty? : !value
end
end | ruby | def blank?(value)
if value.kind_of?(NilClass)
true
elsif value.kind_of?(String)
value !~ /\S/
else
value.respond_to?(:empty?) ? value.empty? : !value
end
end | [
"def",
"blank?",
"(",
"value",
")",
"if",
"value",
".",
"kind_of?",
"(",
"NilClass",
")",
"true",
"elsif",
"value",
".",
"kind_of?",
"(",
"String",
")",
"value",
"!~",
"/",
"\\S",
"/",
"else",
"value",
".",
"respond_to?",
"(",
":empty?",
")",
"?",
"v... | Returns true if the object is considered blank.
A blank includes things like '', ' ', nil,
and arrays and hashes that have nothing in them.
This logic is mostly shared with ActiveSupport's blank? | [
"Returns",
"true",
"if",
"the",
"object",
"is",
"considered",
"blank",
".",
"A",
"blank",
"includes",
"things",
"like",
"nil",
"and",
"arrays",
"and",
"hashes",
"that",
"have",
"nothing",
"in",
"them",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/utilities.rb#L315-L323 |
12,081 | mikel/mail | lib/mail/network/retriever_methods/imap.rb | Mail.IMAP.find | def find(options=nil, &block)
options = validate_options(options)
start do |imap|
options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])
uids = imap.uid_search(options[:keys], options[:search_charset])
uids.reverse! if options[:what].to_sym == :last
... | ruby | def find(options=nil, &block)
options = validate_options(options)
start do |imap|
options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])
uids = imap.uid_search(options[:keys], options[:search_charset])
uids.reverse! if options[:what].to_sym == :last
... | [
"def",
"find",
"(",
"options",
"=",
"nil",
",",
"&",
"block",
")",
"options",
"=",
"validate_options",
"(",
"options",
")",
"start",
"do",
"|",
"imap",
"|",
"options",
"[",
":read_only",
"]",
"?",
"imap",
".",
"examine",
"(",
"options",
"[",
":mailbox"... | Find emails in a IMAP mailbox. Without any options, the 10 last received emails are returned.
Possible options:
mailbox: mailbox to search the email(s) in. The default is 'INBOX'.
what: last or first emails. The default is :first.
order: order of emails returned. Possible values are :asc or :desc. Defau... | [
"Find",
"emails",
"in",
"a",
"IMAP",
"mailbox",
".",
"Without",
"any",
"options",
"the",
"10",
"last",
"received",
"emails",
"are",
"returned",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/network/retriever_methods/imap.rb#L73-L116 |
12,082 | mikel/mail | lib/mail/network/retriever_methods/imap.rb | Mail.IMAP.delete_all | def delete_all(mailbox='INBOX')
mailbox ||= 'INBOX'
mailbox = Net::IMAP.encode_utf7(mailbox)
start do |imap|
imap.select(mailbox)
imap.uid_search(['ALL']).each do |uid|
imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED])
end
imap.expunge
end
end | ruby | def delete_all(mailbox='INBOX')
mailbox ||= 'INBOX'
mailbox = Net::IMAP.encode_utf7(mailbox)
start do |imap|
imap.select(mailbox)
imap.uid_search(['ALL']).each do |uid|
imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED])
end
imap.expunge
end
end | [
"def",
"delete_all",
"(",
"mailbox",
"=",
"'INBOX'",
")",
"mailbox",
"||=",
"'INBOX'",
"mailbox",
"=",
"Net",
"::",
"IMAP",
".",
"encode_utf7",
"(",
"mailbox",
")",
"start",
"do",
"|",
"imap",
"|",
"imap",
".",
"select",
"(",
"mailbox",
")",
"imap",
".... | Delete all emails from a IMAP mailbox | [
"Delete",
"all",
"emails",
"from",
"a",
"IMAP",
"mailbox"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/network/retriever_methods/imap.rb#L119-L130 |
12,083 | mikel/mail | lib/mail/network/retriever_methods/imap.rb | Mail.IMAP.start | def start(config=Mail::Configuration.instance, &block)
raise ArgumentError.new("Mail::Retrievable#imap_start takes a block") unless block_given?
if settings[:enable_starttls] && settings[:enable_ssl]
raise ArgumentError, ":enable_starttls and :enable_ssl are mutually exclusive. Set :enable_ss... | ruby | def start(config=Mail::Configuration.instance, &block)
raise ArgumentError.new("Mail::Retrievable#imap_start takes a block") unless block_given?
if settings[:enable_starttls] && settings[:enable_ssl]
raise ArgumentError, ":enable_starttls and :enable_ssl are mutually exclusive. Set :enable_ss... | [
"def",
"start",
"(",
"config",
"=",
"Mail",
"::",
"Configuration",
".",
"instance",
",",
"&",
"block",
")",
"raise",
"ArgumentError",
".",
"new",
"(",
"\"Mail::Retrievable#imap_start takes a block\"",
")",
"unless",
"block_given?",
"if",
"settings",
"[",
":enable_... | Start an IMAP session and ensures that it will be closed in any case. | [
"Start",
"an",
"IMAP",
"session",
"and",
"ensures",
"that",
"it",
"will",
"be",
"closed",
"in",
"any",
"case",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/network/retriever_methods/imap.rb#L160-L184 |
12,084 | mikel/mail | lib/mail/header.rb | Mail.Header.fields= | def fields=(unfolded_fields)
@fields = Mail::FieldList.new
if unfolded_fields.size > self.class.maximum_amount
Kernel.warn "WARNING: More than #{self.class.maximum_amount} header fields; only using the first #{self.class.maximum_amount} and ignoring the rest"
unfolded_fields = unfolded_fiel... | ruby | def fields=(unfolded_fields)
@fields = Mail::FieldList.new
if unfolded_fields.size > self.class.maximum_amount
Kernel.warn "WARNING: More than #{self.class.maximum_amount} header fields; only using the first #{self.class.maximum_amount} and ignoring the rest"
unfolded_fields = unfolded_fiel... | [
"def",
"fields",
"=",
"(",
"unfolded_fields",
")",
"@fields",
"=",
"Mail",
"::",
"FieldList",
".",
"new",
"if",
"unfolded_fields",
".",
"size",
">",
"self",
".",
"class",
".",
"maximum_amount",
"Kernel",
".",
"warn",
"\"WARNING: More than #{self.class.maximum_amou... | 3.6. Field definitions
It is important to note that the header fields are not guaranteed to
be in a particular order. They may appear in any order, and they
have been known to be reordered occasionally when transported over
the Internet. However, for the purposes of this standard, header
fields SHOULD... | [
"3",
".",
"6",
".",
"Field",
"definitions"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/header.rb#L90-L103 |
12,085 | mikel/mail | lib/mail/header.rb | Mail.Header.[]= | def []=(name, value)
name = name.to_s
if name.include?(Constants::COLON)
raise ArgumentError, "Header names may not contain a colon: #{name.inspect}"
end
name = Utilities.dasherize(name)
# Assign nil to delete the field
if value.nil?
fields.delete_field name
e... | ruby | def []=(name, value)
name = name.to_s
if name.include?(Constants::COLON)
raise ArgumentError, "Header names may not contain a colon: #{name.inspect}"
end
name = Utilities.dasherize(name)
# Assign nil to delete the field
if value.nil?
fields.delete_field name
e... | [
"def",
"[]=",
"(",
"name",
",",
"value",
")",
"name",
"=",
"name",
".",
"to_s",
"if",
"name",
".",
"include?",
"(",
"Constants",
"::",
"COLON",
")",
"raise",
"ArgumentError",
",",
"\"Header names may not contain a colon: #{name.inspect}\"",
"end",
"name",
"=",
... | Sets the FIRST matching field in the header to passed value, or deletes
the FIRST field matched from the header if passed nil
Example:
h = Header.new
h.fields = ['To: mikel@me.com', 'X-Mail-SPAM: 15', 'X-Mail-SPAM: 20']
h['To'] = 'bob@you.com'
h['To'] #=> 'bob@you.com'
h['X-Mail-SPAM'] = '10000'
h['X... | [
"Sets",
"the",
"FIRST",
"matching",
"field",
"in",
"the",
"header",
"to",
"passed",
"value",
"or",
"deletes",
"the",
"FIRST",
"field",
"matched",
"from",
"the",
"header",
"if",
"passed",
"nil"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/header.rb#L147-L167 |
12,086 | mikel/mail | lib/mail/message.rb | Mail.Message.default | def default( sym, val = nil )
if val
header[sym] = val
elsif field = header[sym]
field.default
end
end | ruby | def default( sym, val = nil )
if val
header[sym] = val
elsif field = header[sym]
field.default
end
end | [
"def",
"default",
"(",
"sym",
",",
"val",
"=",
"nil",
")",
"if",
"val",
"header",
"[",
"sym",
"]",
"=",
"val",
"elsif",
"field",
"=",
"header",
"[",
"sym",
"]",
"field",
".",
"default",
"end",
"end"
] | Returns the default value of the field requested as a symbol.
Each header field has a :default method which returns the most common use case for
that field, for example, the date field types will return a DateTime object when
sent :default, the subject, or unstructured fields will return a decoded string of
their ... | [
"Returns",
"the",
"default",
"value",
"of",
"the",
"field",
"requested",
"as",
"a",
"symbol",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1204-L1210 |
12,087 | mikel/mail | lib/mail/message.rb | Mail.Message.[]= | def []=(name, value)
if name.to_s == 'body'
self.body = value
elsif name.to_s =~ /content[-_]type/i
header[name] = value
elsif name.to_s == 'charset'
self.charset = value
else
header[name] = value
end
end | ruby | def []=(name, value)
if name.to_s == 'body'
self.body = value
elsif name.to_s =~ /content[-_]type/i
header[name] = value
elsif name.to_s == 'charset'
self.charset = value
else
header[name] = value
end
end | [
"def",
"[]=",
"(",
"name",
",",
"value",
")",
"if",
"name",
".",
"to_s",
"==",
"'body'",
"self",
".",
"body",
"=",
"value",
"elsif",
"name",
".",
"to_s",
"=~",
"/",
"/i",
"header",
"[",
"name",
"]",
"=",
"value",
"elsif",
"name",
".",
"to_s",
"==... | Allows you to add an arbitrary header
Example:
mail['foo'] = '1234'
mail['foo'].to_s #=> '1234' | [
"Allows",
"you",
"to",
"add",
"an",
"arbitrary",
"header"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1316-L1326 |
12,088 | mikel/mail | lib/mail/message.rb | Mail.Message.method_missing | def method_missing(name, *args, &block)
#:nodoc:
# Only take the structured fields, as we could take _anything_ really
# as it could become an optional field... "but therin lies the dark side"
field_name = Utilities.underscoreize(name).chomp("=")
if Mail::Field::KNOWN_FIELDS.include?(field... | ruby | def method_missing(name, *args, &block)
#:nodoc:
# Only take the structured fields, as we could take _anything_ really
# as it could become an optional field... "but therin lies the dark side"
field_name = Utilities.underscoreize(name).chomp("=")
if Mail::Field::KNOWN_FIELDS.include?(field... | [
"def",
"method_missing",
"(",
"name",
",",
"*",
"args",
",",
"&",
"block",
")",
"#:nodoc:",
"# Only take the structured fields, as we could take _anything_ really",
"# as it could become an optional field... \"but therin lies the dark side\"",
"field_name",
"=",
"Utilities",
".",
... | Method Missing in this implementation allows you to set any of the
standard fields directly as you would the "to", "subject" etc.
Those fields used most often (to, subject et al) are given their
own method for ease of documentation and also to avoid the hook
call to method missing.
This will only catch the known... | [
"Method",
"Missing",
"in",
"this",
"implementation",
"allows",
"you",
"to",
"set",
"any",
"of",
"the",
"standard",
"fields",
"directly",
"as",
"you",
"would",
"the",
"to",
"subject",
"etc",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1377-L1392 |
12,089 | mikel/mail | lib/mail/message.rb | Mail.Message.add_charset | def add_charset
if !body.empty?
# Only give a warning if this isn't an attachment, has non US-ASCII and the user
# has not specified an encoding explicitly.
if @defaulted_charset && !body.raw_source.ascii_only? && !self.attachment?
warning = "Non US-ASCII detected and no charset ... | ruby | def add_charset
if !body.empty?
# Only give a warning if this isn't an attachment, has non US-ASCII and the user
# has not specified an encoding explicitly.
if @defaulted_charset && !body.raw_source.ascii_only? && !self.attachment?
warning = "Non US-ASCII detected and no charset ... | [
"def",
"add_charset",
"if",
"!",
"body",
".",
"empty?",
"# Only give a warning if this isn't an attachment, has non US-ASCII and the user",
"# has not specified an encoding explicitly.",
"if",
"@defaulted_charset",
"&&",
"!",
"body",
".",
"raw_source",
".",
"ascii_only?",
"&&",
... | Adds a content type and charset if the body is US-ASCII
Otherwise raises a warning | [
"Adds",
"a",
"content",
"type",
"and",
"charset",
"if",
"the",
"body",
"is",
"US",
"-",
"ASCII"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1472-L1482 |
12,090 | mikel/mail | lib/mail/message.rb | Mail.Message.add_part | def add_part(part)
if !body.multipart? && !Utilities.blank?(self.body.decoded)
@text_part = Mail::Part.new('Content-Type: text/plain;')
@text_part.body = body.decoded
self.body << @text_part
add_multipart_alternate_header
end
add_boundary
self.body << part
end | ruby | def add_part(part)
if !body.multipart? && !Utilities.blank?(self.body.decoded)
@text_part = Mail::Part.new('Content-Type: text/plain;')
@text_part.body = body.decoded
self.body << @text_part
add_multipart_alternate_header
end
add_boundary
self.body << part
end | [
"def",
"add_part",
"(",
"part",
")",
"if",
"!",
"body",
".",
"multipart?",
"&&",
"!",
"Utilities",
".",
"blank?",
"(",
"self",
".",
"body",
".",
"decoded",
")",
"@text_part",
"=",
"Mail",
"::",
"Part",
".",
"new",
"(",
"'Content-Type: text/plain;'",
")",... | Adds a part to the parts list or creates the part list | [
"Adds",
"a",
"part",
"to",
"the",
"parts",
"list",
"or",
"creates",
"the",
"part",
"list"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1699-L1708 |
12,091 | mikel/mail | lib/mail/message.rb | Mail.Message.part | def part(params = {})
new_part = Part.new(params)
yield new_part if block_given?
add_part(new_part)
end | ruby | def part(params = {})
new_part = Part.new(params)
yield new_part if block_given?
add_part(new_part)
end | [
"def",
"part",
"(",
"params",
"=",
"{",
"}",
")",
"new_part",
"=",
"Part",
".",
"new",
"(",
"params",
")",
"yield",
"new_part",
"if",
"block_given?",
"add_part",
"(",
"new_part",
")",
"end"
] | Allows you to add a part in block form to an existing mail message object
Example:
mail = Mail.new do
part :content_type => "multipart/alternative", :content_disposition => "inline" do |p|
p.part :content_type => "text/plain", :body => "test text\nline #2"
p.part :content_type => "text/html", :body... | [
"Allows",
"you",
"to",
"add",
"a",
"part",
"in",
"block",
"form",
"to",
"an",
"existing",
"mail",
"message",
"object"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1720-L1724 |
12,092 | mikel/mail | lib/mail/message.rb | Mail.Message.add_file | def add_file(values)
convert_to_multipart unless self.multipart? || Utilities.blank?(self.body.decoded)
add_multipart_mixed_header
if values.is_a?(String)
basename = File.basename(values)
filedata = File.open(values, 'rb') { |f| f.read }
else
basename = values[:filename]
... | ruby | def add_file(values)
convert_to_multipart unless self.multipart? || Utilities.blank?(self.body.decoded)
add_multipart_mixed_header
if values.is_a?(String)
basename = File.basename(values)
filedata = File.open(values, 'rb') { |f| f.read }
else
basename = values[:filename]
... | [
"def",
"add_file",
"(",
"values",
")",
"convert_to_multipart",
"unless",
"self",
".",
"multipart?",
"||",
"Utilities",
".",
"blank?",
"(",
"self",
".",
"body",
".",
"decoded",
")",
"add_multipart_mixed_header",
"if",
"values",
".",
"is_a?",
"(",
"String",
")",... | Adds a file to the message. You have two options with this method, you can
just pass in the absolute path to the file you want and Mail will read the file,
get the filename from the path you pass in and guess the MIME media type, or you
can pass in the filename as a string, and pass in the file content as a blob.
... | [
"Adds",
"a",
"file",
"to",
"the",
"message",
".",
"You",
"have",
"two",
"options",
"with",
"this",
"method",
"you",
"can",
"just",
"pass",
"in",
"the",
"absolute",
"path",
"to",
"the",
"file",
"you",
"want",
"and",
"Mail",
"will",
"read",
"the",
"file"... | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1755-L1766 |
12,093 | mikel/mail | lib/mail/message.rb | Mail.Message.ready_to_send! | def ready_to_send!
identify_and_set_transfer_encoding
parts.each do |part|
part.transport_encoding = transport_encoding
part.ready_to_send!
end
add_required_fields
end | ruby | def ready_to_send!
identify_and_set_transfer_encoding
parts.each do |part|
part.transport_encoding = transport_encoding
part.ready_to_send!
end
add_required_fields
end | [
"def",
"ready_to_send!",
"identify_and_set_transfer_encoding",
"parts",
".",
"each",
"do",
"|",
"part",
"|",
"part",
".",
"transport_encoding",
"=",
"transport_encoding",
"part",
".",
"ready_to_send!",
"end",
"add_required_fields",
"end"
] | Encodes the message, calls encode on all its parts, gets an email message
ready to send | [
"Encodes",
"the",
"message",
"calls",
"encode",
"on",
"all",
"its",
"parts",
"gets",
"an",
"email",
"message",
"ready",
"to",
"send"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1789-L1796 |
12,094 | mikel/mail | lib/mail/message.rb | Mail.Message.encoded | def encoded
ready_to_send!
buffer = header.encoded
buffer << "\r\n"
buffer << body.encoded(content_transfer_encoding)
buffer
end | ruby | def encoded
ready_to_send!
buffer = header.encoded
buffer << "\r\n"
buffer << body.encoded(content_transfer_encoding)
buffer
end | [
"def",
"encoded",
"ready_to_send!",
"buffer",
"=",
"header",
".",
"encoded",
"buffer",
"<<",
"\"\\r\\n\"",
"buffer",
"<<",
"body",
".",
"encoded",
"(",
"content_transfer_encoding",
")",
"buffer",
"end"
] | Outputs an encoded string representation of the mail message including
all headers, attachments, etc. This is an encoded email in US-ASCII,
so it is able to be directly sent to an email server. | [
"Outputs",
"an",
"encoded",
"string",
"representation",
"of",
"the",
"mail",
"message",
"including",
"all",
"headers",
"attachments",
"etc",
".",
"This",
"is",
"an",
"encoded",
"email",
"in",
"US",
"-",
"ASCII",
"so",
"it",
"is",
"able",
"to",
"be",
"direc... | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1801-L1807 |
12,095 | mikel/mail | lib/mail/message.rb | Mail.Message.body_lazy | def body_lazy(value)
process_body_raw if @body_raw && value
case
when value == nil || value.length<=0
@body = Mail::Body.new('')
@body_raw = nil
add_encoding_to_body
when @body && @body.multipart?
self.text_part = value
else
@body_raw = value
e... | ruby | def body_lazy(value)
process_body_raw if @body_raw && value
case
when value == nil || value.length<=0
@body = Mail::Body.new('')
@body_raw = nil
add_encoding_to_body
when @body && @body.multipart?
self.text_part = value
else
@body_raw = value
e... | [
"def",
"body_lazy",
"(",
"value",
")",
"process_body_raw",
"if",
"@body_raw",
"&&",
"value",
"case",
"when",
"value",
"==",
"nil",
"||",
"value",
".",
"length",
"<=",
"0",
"@body",
"=",
"Mail",
"::",
"Body",
".",
"new",
"(",
"''",
")",
"@body_raw",
"="... | see comments to body=. We take data and process it lazily | [
"see",
"comments",
"to",
"body",
"=",
".",
"We",
"take",
"data",
"and",
"process",
"it",
"lazily"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/message.rb#L1988-L2000 |
12,096 | mikel/mail | lib/mail/elements/address.rb | Mail.Address.comments | def comments
parse unless @parsed
comments = get_comments
if comments.nil? || comments.none?
nil
else
comments.map { |c| c.squeeze(Constants::SPACE) }
end
end | ruby | def comments
parse unless @parsed
comments = get_comments
if comments.nil? || comments.none?
nil
else
comments.map { |c| c.squeeze(Constants::SPACE) }
end
end | [
"def",
"comments",
"parse",
"unless",
"@parsed",
"comments",
"=",
"get_comments",
"if",
"comments",
".",
"nil?",
"||",
"comments",
".",
"none?",
"nil",
"else",
"comments",
".",
"map",
"{",
"|",
"c",
"|",
"c",
".",
"squeeze",
"(",
"Constants",
"::",
"SPAC... | Returns an array of comments that are in the email, or nil if there
are no comments
a = Address.new('Mikel Lindsaar (My email address) <mikel@test.lindsaar.net>')
a.comments #=> ['My email address']
b = Address.new('Mikel Lindsaar <mikel@test.lindsaar.net>')
b.comments #=> nil | [
"Returns",
"an",
"array",
"of",
"comments",
"that",
"are",
"in",
"the",
"email",
"or",
"nil",
"if",
"there",
"are",
"no",
"comments"
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/elements/address.rb#L132-L140 |
12,097 | mikel/mail | lib/mail/network/retriever_methods/base.rb | Mail.Retriever.all | def all(options = nil, &block)
options = options ? Hash[options] : {}
options[:count] = :all
find(options, &block)
end | ruby | def all(options = nil, &block)
options = options ? Hash[options] : {}
options[:count] = :all
find(options, &block)
end | [
"def",
"all",
"(",
"options",
"=",
"nil",
",",
"&",
"block",
")",
"options",
"=",
"options",
"?",
"Hash",
"[",
"options",
"]",
":",
"{",
"}",
"options",
"[",
":count",
"]",
"=",
":all",
"find",
"(",
"options",
",",
"block",
")",
"end"
] | Get all emails.
Possible options:
order: order of emails returned. Possible values are :asc or :desc. Default value is :asc. | [
"Get",
"all",
"emails",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/network/retriever_methods/base.rb#L39-L43 |
12,098 | mikel/mail | lib/mail/network/retriever_methods/base.rb | Mail.Retriever.find_and_delete | def find_and_delete(options = nil, &block)
options = options ? Hash[options] : {}
options[:delete_after_find] ||= true
find(options, &block)
end | ruby | def find_and_delete(options = nil, &block)
options = options ? Hash[options] : {}
options[:delete_after_find] ||= true
find(options, &block)
end | [
"def",
"find_and_delete",
"(",
"options",
"=",
"nil",
",",
"&",
"block",
")",
"options",
"=",
"options",
"?",
"Hash",
"[",
"options",
"]",
":",
"{",
"}",
"options",
"[",
":delete_after_find",
"]",
"||=",
"true",
"find",
"(",
"options",
",",
"block",
")... | Find emails in the mailbox, and then deletes them. Without any options, the
five last received emails are returned.
Possible options:
what: last or first emails. The default is :first.
order: order of emails returned. Possible values are :asc or :desc. Default value is :asc.
count: number of emails to retr... | [
"Find",
"emails",
"in",
"the",
"mailbox",
"and",
"then",
"deletes",
"them",
".",
"Without",
"any",
"options",
"the",
"five",
"last",
"received",
"emails",
"are",
"returned",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/network/retriever_methods/base.rb#L56-L60 |
12,099 | mikel/mail | lib/mail/field_list.rb | Mail.FieldList.insert_field | def insert_field(field)
lo, hi = 0, size
while lo < hi
mid = (lo + hi).div(2)
if field < self[mid]
hi = mid
else
lo = mid + 1
end
end
insert lo, field
end | ruby | def insert_field(field)
lo, hi = 0, size
while lo < hi
mid = (lo + hi).div(2)
if field < self[mid]
hi = mid
else
lo = mid + 1
end
end
insert lo, field
end | [
"def",
"insert_field",
"(",
"field",
")",
"lo",
",",
"hi",
"=",
"0",
",",
"size",
"while",
"lo",
"<",
"hi",
"mid",
"=",
"(",
"lo",
"+",
"hi",
")",
".",
"div",
"(",
"2",
")",
"if",
"field",
"<",
"self",
"[",
"mid",
"]",
"hi",
"=",
"mid",
"el... | Insert the field in sorted order.
Heavily based on bisect.insort from Python, which is:
Copyright (C) 2001-2013 Python Software Foundation.
Licensed under <http://docs.python.org/license.html>
From <http://hg.python.org/cpython/file/2.7/Lib/bisect.py> | [
"Insert",
"the",
"field",
"in",
"sorted",
"order",
"."
] | fb53fb369eb2bf0494ac70675970c90cdcc3f495 | https://github.com/mikel/mail/blob/fb53fb369eb2bf0494ac70675970c90cdcc3f495/lib/mail/field_list.rb#L53-L65 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.