repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.bold
def bold style = CharacterStyle.new style.bold = true if block_given? apply(style) {|node| yield node} else apply(style) end end
ruby
def bold style = CharacterStyle.new style.bold = true if block_given? apply(style) {|node| yield node} else apply(style) end end
[ "def", "bold", "style", "=", "CharacterStyle", ".", "new", "style", ".", "bold", "=", "true", "if", "block_given?", "apply", "(", "style", ")", "{", "|", "node", "|", "yield", "node", "}", "else", "apply", "(", "style", ")", "end", "end" ]
This method provides a short cut means of creating a bold command node. The method accepts a block that will be passed a single parameter which will be a reference to the bold node created. After the block is complete the bold node is appended to the end of the child nodes on the object that the method is call agai...
[ "This", "method", "provides", "a", "short", "cut", "means", "of", "creating", "a", "bold", "command", "node", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "a", "single", "parameter", "which", "will", "be", "a", "reference"...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L396-L404
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.italic
def italic style = CharacterStyle.new style.italic = true if block_given? apply(style) {|node| yield node} else apply(style) end end
ruby
def italic style = CharacterStyle.new style.italic = true if block_given? apply(style) {|node| yield node} else apply(style) end end
[ "def", "italic", "style", "=", "CharacterStyle", ".", "new", "style", ".", "italic", "=", "true", "if", "block_given?", "apply", "(", "style", ")", "{", "|", "node", "|", "yield", "node", "}", "else", "apply", "(", "style", ")", "end", "end" ]
This method provides a short cut means of creating an italic command node. The method accepts a block that will be passed a single parameter which will be a reference to the italic node created. After the block is complete the italic node is appended to the end of the child nodes on the object that the method is ca...
[ "This", "method", "provides", "a", "short", "cut", "means", "of", "creating", "an", "italic", "command", "node", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "a", "single", "parameter", "which", "will", "be", "a", "referen...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L411-L419
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.underline
def underline style = CharacterStyle.new style.underline = true if block_given? apply(style) {|node| yield node} else apply(style) end end
ruby
def underline style = CharacterStyle.new style.underline = true if block_given? apply(style) {|node| yield node} else apply(style) end end
[ "def", "underline", "style", "=", "CharacterStyle", ".", "new", "style", ".", "underline", "=", "true", "if", "block_given?", "apply", "(", "style", ")", "{", "|", "node", "|", "yield", "node", "}", "else", "apply", "(", "style", ")", "end", "end" ]
This method provides a short cut means of creating an underline command node. The method accepts a block that will be passed a single parameter which will be a reference to the underline node created. After the block is complete the underline node is appended to the end of the child nodes on the object that the met...
[ "This", "method", "provides", "a", "short", "cut", "means", "of", "creating", "an", "underline", "command", "node", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "a", "single", "parameter", "which", "will", "be", "a", "refe...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L426-L434
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.subscript
def subscript style = CharacterStyle.new style.subscript = true if block_given? apply(style) {|node| yield node} else apply(style) end end
ruby
def subscript style = CharacterStyle.new style.subscript = true if block_given? apply(style) {|node| yield node} else apply(style) end end
[ "def", "subscript", "style", "=", "CharacterStyle", ".", "new", "style", ".", "subscript", "=", "true", "if", "block_given?", "apply", "(", "style", ")", "{", "|", "node", "|", "yield", "node", "}", "else", "apply", "(", "style", ")", "end", "end" ]
This method provides a short cut means of creating a subscript command node. The method accepts a block that will be passed a single parameter which will be a reference to the subscript node created. After the block is complete the subscript node is appended to the end of the child nodes on the object that the meth...
[ "This", "method", "provides", "a", "short", "cut", "means", "of", "creating", "a", "subscript", "command", "node", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "a", "single", "parameter", "which", "will", "be", "a", "refer...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L441-L449
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.superscript
def superscript style = CharacterStyle.new style.superscript = true if block_given? apply(style) {|node| yield node} else apply(style) end end
ruby
def superscript style = CharacterStyle.new style.superscript = true if block_given? apply(style) {|node| yield node} else apply(style) end end
[ "def", "superscript", "style", "=", "CharacterStyle", ".", "new", "style", ".", "superscript", "=", "true", "if", "block_given?", "apply", "(", "style", ")", "{", "|", "node", "|", "yield", "node", "}", "else", "apply", "(", "style", ")", "end", "end" ]
This method provides a short cut means of creating a superscript command node. The method accepts a block that will be passed a single parameter which will be a reference to the superscript node created. After the block is complete the superscript node is appended to the end of the child nodes on the object that th...
[ "This", "method", "provides", "a", "short", "cut", "means", "of", "creating", "a", "superscript", "command", "node", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "a", "single", "parameter", "which", "will", "be", "a", "ref...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L456-L464
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.strike
def strike style = CharacterStyle.new style.strike = true if block_given? apply(style) {|node| yield node} else apply(style) end end
ruby
def strike style = CharacterStyle.new style.strike = true if block_given? apply(style) {|node| yield node} else apply(style) end end
[ "def", "strike", "style", "=", "CharacterStyle", ".", "new", "style", ".", "strike", "=", "true", "if", "block_given?", "apply", "(", "style", ")", "{", "|", "node", "|", "yield", "node", "}", "else", "apply", "(", "style", ")", "end", "end" ]
This method provides a short cut means of creating a strike command node. The method accepts a block that will be passed a single parameter which will be a reference to the strike node created. After the block is complete the strike node is appended to the end of the child nodes on the object that the method is cal...
[ "This", "method", "provides", "a", "short", "cut", "means", "of", "creating", "a", "strike", "command", "node", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "a", "single", "parameter", "which", "will", "be", "a", "referenc...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L471-L479
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.font
def font(font, size=nil) style = CharacterStyle.new style.font = font style.font_size = size root.fonts << font if block_given? apply(style) {|node| yield node} else apply(style) end end
ruby
def font(font, size=nil) style = CharacterStyle.new style.font = font style.font_size = size root.fonts << font if block_given? apply(style) {|node| yield node} else apply(style) end end
[ "def", "font", "(", "font", ",", "size", "=", "nil", ")", "style", "=", "CharacterStyle", ".", "new", "style", ".", "font", "=", "font", "style", ".", "font_size", "=", "size", "root", ".", "fonts", "<<", "font", "if", "block_given?", "apply", "(", "...
This method provides a short cut means of creating a font command node. The method accepts a block that will be passed a single parameter which will be a reference to the font node created. After the block is complete the font node is appended to the end of the child nodes on the object that the method is called ag...
[ "This", "method", "provides", "a", "short", "cut", "means", "of", "creating", "a", "font", "command", "node", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "a", "single", "parameter", "which", "will", "be", "a", "reference"...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L492-L502
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.foreground
def foreground(colour) style = CharacterStyle.new style.foreground = colour root.colours << colour if block_given? apply(style) {|node| yield node} else apply(style) end end
ruby
def foreground(colour) style = CharacterStyle.new style.foreground = colour root.colours << colour if block_given? apply(style) {|node| yield node} else apply(style) end end
[ "def", "foreground", "(", "colour", ")", "style", "=", "CharacterStyle", ".", "new", "style", ".", "foreground", "=", "colour", "root", ".", "colours", "<<", "colour", "if", "block_given?", "apply", "(", "style", ")", "{", "|", "node", "|", "yield", "nod...
This method provides a short cut means of creating a foreground colour command node. The method accepts a block that will be passed a single parameter which will be a reference to the foreground colour node created. After the block is complete the foreground colour node is appended to the end of the child nodes on ...
[ "This", "method", "provides", "a", "short", "cut", "means", "of", "creating", "a", "foreground", "colour", "command", "node", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "a", "single", "parameter", "which", "will", "be", ...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L513-L522
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.colour
def colour(fore, back) style = CharacterStyle.new style.foreground = fore style.background = back root.colours << fore root.colours << back if block_given? apply(style) {|node| yield node} else apply(style) end ...
ruby
def colour(fore, back) style = CharacterStyle.new style.foreground = fore style.background = back root.colours << fore root.colours << back if block_given? apply(style) {|node| yield node} else apply(style) end ...
[ "def", "colour", "(", "fore", ",", "back", ")", "style", "=", "CharacterStyle", ".", "new", "style", ".", "foreground", "=", "fore", "style", ".", "background", "=", "back", "root", ".", "colours", "<<", "fore", "root", ".", "colours", "<<", "back", "i...
This method provides a short cut menas of creating a colour node that deals with foreground and background colours. The method accepts a block that will be passed a single parameter which will be a reference to the colour node created. After the block is complete the colour node is append to the end of the child no...
[ "This", "method", "provides", "a", "short", "cut", "menas", "of", "creating", "a", "colour", "node", "that", "deals", "with", "foreground", "and", "background", "colours", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "a", ...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L554-L565
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.CommandNode.table
def table(rows, columns, *widths) node = TableNode.new(self, rows, columns, *widths) yield node if block_given? store(node) node end
ruby
def table(rows, columns, *widths) node = TableNode.new(self, rows, columns, *widths) yield node if block_given? store(node) node end
[ "def", "table", "(", "rows", ",", "columns", ",", "*", "widths", ")", "node", "=", "TableNode", ".", "new", "(", "self", ",", "rows", ",", "columns", ",", "*", "widths", ")", "yield", "node", "if", "block_given?", "store", "(", "node", ")", "node", ...
This method creates a new table node and returns it. The method accepts a block that will be passed the table as a parameter. The node is added to the node the method is called upon after the block is complete. ==== Parameters rows:: The number of rows that the table contains. columns:: The number of columns...
[ "This", "method", "creates", "a", "new", "table", "node", "and", "returns", "it", ".", "The", "method", "accepts", "a", "block", "that", "will", "be", "passed", "the", "table", "as", "a", "parameter", ".", "The", "node", "is", "added", "to", "the", "no...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L576-L581
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.ListLevelNode.list
def list(kind=@kind) node = ListLevelNode.new(self, @template, kind, @level.level+1) yield node self.store(node) end
ruby
def list(kind=@kind) node = ListLevelNode.new(self, @template, kind, @level.level+1) yield node self.store(node) end
[ "def", "list", "(", "kind", "=", "@kind", ")", "node", "=", "ListLevelNode", ".", "new", "(", "self", ",", "@template", ",", "kind", ",", "@level", ".", "level", "+", "1", ")", "yield", "node", "self", ".", "store", "(", "node", ")", "end" ]
Creates a new +ListLevelNode+ to implement nested lists
[ "Creates", "a", "new", "+", "ListLevelNode", "+", "to", "implement", "nested", "lists" ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L664-L668
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.TableNode.column_shading_colour
def column_shading_colour(index, colour) self.each do |row| cell = row[index] cell.shading_colour = colour if cell != nil end end
ruby
def column_shading_colour(index, colour) self.each do |row| cell = row[index] cell.shading_colour = colour if cell != nil end end
[ "def", "column_shading_colour", "(", "index", ",", "colour", ")", "self", ".", "each", "do", "|", "row", "|", "cell", "=", "row", "[", "index", "]", "cell", ".", "shading_colour", "=", "colour", "if", "cell", "!=", "nil", "end", "end" ]
This method assigns a shading colour to a specified column within a TableNode object. ==== Parameters index:: The offset from the first column of the column to have shading applied to it. colour:: A reference to a Colour object representing the shading colour to be used. Set to nil to clea...
[ "This", "method", "assigns", "a", "shading", "colour", "to", "a", "specified", "column", "within", "a", "TableNode", "object", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L776-L781
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.TableNode.shading_colour
def shading_colour(colour) if block_given? 0.upto(self.size - 1) do |x| row = self[x] 0.upto(row.size - 1) do |y| apply = yield row[y], x, y row[y].shading_colour = colour if apply end end end ...
ruby
def shading_colour(colour) if block_given? 0.upto(self.size - 1) do |x| row = self[x] 0.upto(row.size - 1) do |y| apply = yield row[y], x, y row[y].shading_colour = colour if apply end end end ...
[ "def", "shading_colour", "(", "colour", ")", "if", "block_given?", "0", ".", "upto", "(", "self", ".", "size", "-", "1", ")", "do", "|", "x", "|", "row", "=", "self", "[", "x", "]", "0", ".", "upto", "(", "row", ".", "size", "-", "1", ")", "d...
This method provides a means of assigning a shading colour to a selection of cells within a table. The method accepts a block that takes three parameters - a TableCellNode representing a cell within the table, an integer representing the x offset of the cell and an integer representing the y offset of the cell. If ...
[ "This", "method", "provides", "a", "means", "of", "assigning", "a", "shading", "colour", "to", "a", "selection", "of", "cells", "within", "a", "table", ".", "The", "method", "accepts", "a", "block", "that", "takes", "three", "parameters", "-", "a", "TableC...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L793-L803
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.TableRowNode.to_rtf
def to_rtf text = StringIO.new temp = StringIO.new offset = 0 text << "\\trowd\\tgraph#{parent.cell_margin}" self.each do |entry| widths = entry.border_widths colour = entry.shading_colour text << "\n" text << "\\clbrdrt\...
ruby
def to_rtf text = StringIO.new temp = StringIO.new offset = 0 text << "\\trowd\\tgraph#{parent.cell_margin}" self.each do |entry| widths = entry.border_widths colour = entry.shading_colour text << "\n" text << "\\clbrdrt\...
[ "def", "to_rtf", "text", "=", "StringIO", ".", "new", "temp", "=", "StringIO", ".", "new", "offset", "=", "0", "text", "<<", "\"\\\\trowd\\\\tgraph#{parent.cell_margin}\"", "self", ".", "each", "do", "|", "entry", "|", "widths", "=", "entry", ".", "border_wi...
This method overloads the store method inherited from the ContainerNode class to forbid addition of further nodes. ==== Parameters node:: A reference to the node to be added. def store(node) RTFError.fire("Table row nodes cannot have nodes added to.") end This method generates the RTF document text for a Table...
[ "This", "method", "overloads", "the", "store", "method", "inherited", "from", "the", "ContainerNode", "class", "to", "forbid", "addition", "of", "further", "nodes", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L902-L925
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.TableCellNode.border_width=
def border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[TOP] = @borders[RIGHT] = @borders[BOTTOM] = @borders[LEFT] = size.to_i else @borders = [nil, nil, nil, nil] end end
ruby
def border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[TOP] = @borders[RIGHT] = @borders[BOTTOM] = @borders[LEFT] = size.to_i else @borders = [nil, nil, nil, nil] end end
[ "def", "border_width", "=", "(", "width", ")", "size", "=", "width", ".", "nil?", "?", "0", ":", "width", "if", "size", ">", "0", "@borders", "[", "TOP", "]", "=", "@borders", "[", "RIGHT", "]", "=", "@borders", "[", "BOTTOM", "]", "=", "@borders",...
This method assigns a width, in twips, for the borders on all sides of the cell. Negative widths will be ignored and a width of zero will switch the border off. ==== Parameters width:: The setting for the width of the border.
[ "This", "method", "assigns", "a", "width", "in", "twips", "for", "the", "borders", "on", "all", "sides", "of", "the", "cell", ".", "Negative", "widths", "will", "be", "ignored", "and", "a", "width", "of", "zero", "will", "switch", "the", "border", "off",...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1005-L1012
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.TableCellNode.top_border_width=
def top_border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[TOP] = size.to_i else @borders[TOP] = nil end end
ruby
def top_border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[TOP] = size.to_i else @borders[TOP] = nil end end
[ "def", "top_border_width", "=", "(", "width", ")", "size", "=", "width", ".", "nil?", "?", "0", ":", "width", "if", "size", ">", "0", "@borders", "[", "TOP", "]", "=", "size", ".", "to_i", "else", "@borders", "[", "TOP", "]", "=", "nil", "end", "...
This method assigns a border width to the top side of a table cell. Negative values are ignored and a value of 0 switches the border off. ==== Parameters width:: The new border width setting.
[ "This", "method", "assigns", "a", "border", "width", "to", "the", "top", "side", "of", "a", "table", "cell", ".", "Negative", "values", "are", "ignored", "and", "a", "value", "of", "0", "switches", "the", "border", "off", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1019-L1026
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.TableCellNode.right_border_width=
def right_border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[RIGHT] = size.to_i else @borders[RIGHT] = nil end end
ruby
def right_border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[RIGHT] = size.to_i else @borders[RIGHT] = nil end end
[ "def", "right_border_width", "=", "(", "width", ")", "size", "=", "width", ".", "nil?", "?", "0", ":", "width", "if", "size", ">", "0", "@borders", "[", "RIGHT", "]", "=", "size", ".", "to_i", "else", "@borders", "[", "RIGHT", "]", "=", "nil", "end...
This method assigns a border width to the right side of a table cell. Negative values are ignored and a value of 0 switches the border off. ==== Parameters width:: The new border width setting.
[ "This", "method", "assigns", "a", "border", "width", "to", "the", "right", "side", "of", "a", "table", "cell", ".", "Negative", "values", "are", "ignored", "and", "a", "value", "of", "0", "switches", "the", "border", "off", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1033-L1040
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.TableCellNode.bottom_border_width=
def bottom_border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[BOTTOM] = size.to_i else @borders[BOTTOM] = nil end end
ruby
def bottom_border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[BOTTOM] = size.to_i else @borders[BOTTOM] = nil end end
[ "def", "bottom_border_width", "=", "(", "width", ")", "size", "=", "width", ".", "nil?", "?", "0", ":", "width", "if", "size", ">", "0", "@borders", "[", "BOTTOM", "]", "=", "size", ".", "to_i", "else", "@borders", "[", "BOTTOM", "]", "=", "nil", "...
This method assigns a border width to the bottom side of a table cell. Negative values are ignored and a value of 0 switches the border off. ==== Parameters width:: The new border width setting.
[ "This", "method", "assigns", "a", "border", "width", "to", "the", "bottom", "side", "of", "a", "table", "cell", ".", "Negative", "values", "are", "ignored", "and", "a", "value", "of", "0", "switches", "the", "border", "off", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1047-L1054
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.TableCellNode.left_border_width=
def left_border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[LEFT] = size.to_i else @borders[LEFT] = nil end end
ruby
def left_border_width=(width) size = width.nil? ? 0 : width if size > 0 @borders[LEFT] = size.to_i else @borders[LEFT] = nil end end
[ "def", "left_border_width", "=", "(", "width", ")", "size", "=", "width", ".", "nil?", "?", "0", ":", "width", "if", "size", ">", "0", "@borders", "[", "LEFT", "]", "=", "size", ".", "to_i", "else", "@borders", "[", "LEFT", "]", "=", "nil", "end", ...
This method assigns a border width to the left side of a table cell. Negative values are ignored and a value of 0 switches the border off. ==== Parameters width:: The new border width setting.
[ "This", "method", "assigns", "a", "border", "width", "to", "the", "left", "side", "of", "a", "table", "cell", ".", "Negative", "values", "are", "ignored", "and", "a", "value", "of", "0", "switches", "the", "border", "off", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1061-L1068
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.TableCellNode.border_widths
def border_widths widths = [] @borders.each {|entry| widths.push(entry.nil? ? 0 : entry)} widths end
ruby
def border_widths widths = [] @borders.each {|entry| widths.push(entry.nil? ? 0 : entry)} widths end
[ "def", "border_widths", "widths", "=", "[", "]", "@borders", ".", "each", "{", "|", "entry", "|", "widths", ".", "push", "(", "entry", ".", "nil?", "?", "0", ":", "entry", ")", "}", "widths", "end" ]
This method retrieves an array with the cell border width settings. The values are inserted in top, right, bottom, left order.
[ "This", "method", "retrieves", "an", "array", "with", "the", "cell", "border", "width", "settings", ".", "The", "values", "are", "inserted", "in", "top", "right", "bottom", "left", "order", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1083-L1087
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.ImageNode.get_file_type
def get_file_type type = nil read = [] open_file do |file| # Check if the file is a JPEG. read_source(file, read, 2) if read[0,2] == [255, 216] type = JPEG else # Check if it's a PNG. read_source(file, read...
ruby
def get_file_type type = nil read = [] open_file do |file| # Check if the file is a JPEG. read_source(file, read, 2) if read[0,2] == [255, 216] type = JPEG else # Check if it's a PNG. read_source(file, read...
[ "def", "get_file_type", "type", "=", "nil", "read", "=", "[", "]", "open_file", "do", "|", "file", "|", "read_source", "(", "file", ",", "read", ",", "2", ")", "if", "read", "[", "0", ",", "2", "]", "==", "[", "255", ",", "216", "]", "type", "=...
This method attempts to determine the image type associated with a file, returning nil if it fails to make the determination.
[ "This", "method", "attempts", "to", "determine", "the", "image", "type", "associated", "with", "a", "file", "returning", "nil", "if", "it", "fails", "to", "make", "the", "determination", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1345-L1371
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.ImageNode.to_rtf
def to_rtf text = StringIO.new count = 0 #text << '{\pard{\*\shppict{\pict' text << '{\*\shppict{\pict' text << "\\picscalex#{@x_scaling}" if @x_scaling != nil text << "\\picscaley#{@y_scaling}" if @y_scaling != nil text << "\\piccropl#{@left_crop}" if @left_c...
ruby
def to_rtf text = StringIO.new count = 0 #text << '{\pard{\*\shppict{\pict' text << '{\*\shppict{\pict' text << "\\picscalex#{@x_scaling}" if @x_scaling != nil text << "\\picscaley#{@y_scaling}" if @y_scaling != nil text << "\\piccropl#{@left_crop}" if @left_c...
[ "def", "to_rtf", "text", "=", "StringIO", ".", "new", "count", "=", "0", "text", "<<", "'{\\*\\shppict{\\pict'", "text", "<<", "\"\\\\picscalex#{@x_scaling}\"", "if", "@x_scaling", "!=", "nil", "text", "<<", "\"\\\\picscaley#{@y_scaling}\"", "if", "@y_scaling", "!="...
This method generates the RTF for an ImageNode object.
[ "This", "method", "generates", "the", "RTF", "for", "an", "ImageNode", "object", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1374-L1407
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.ImageNode.to_integer
def to_integer(array, signed=false) from = nil to = nil data = [] if array.size == 2 data.concat(get_endian == BIG_ENDIAN ? array.reverse : array) from = 'C2' to = signed ? 's' : 'S' else data.concat(get_endian == BIG_ENDI...
ruby
def to_integer(array, signed=false) from = nil to = nil data = [] if array.size == 2 data.concat(get_endian == BIG_ENDIAN ? array.reverse : array) from = 'C2' to = signed ? 's' : 'S' else data.concat(get_endian == BIG_ENDI...
[ "def", "to_integer", "(", "array", ",", "signed", "=", "false", ")", "from", "=", "nil", "to", "=", "nil", "data", "=", "[", "]", "if", "array", ".", "size", "==", "2", "data", ".", "concat", "(", "get_endian", "==", "BIG_ENDIAN", "?", "array", "."...
This method converts an array to an integer. The array must be either two or four bytes in length. ==== Parameters array:: A reference to the array containing the data to be converted. signed:: A boolean to indicate whether the value is signed. Defaults to false.
[ "This", "method", "converts", "an", "array", "to", "an", "integer", ".", "The", "array", "must", "be", "either", "two", "or", "four", "bytes", "in", "length", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1422-L1437
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.ImageNode.read_source
def read_source(file, read, size=nil) if block_given? done = false while !done and !file.eof? read << file.getbyte done = yield read[-1] end else if size != nil if size > 0 total = 0 ...
ruby
def read_source(file, read, size=nil) if block_given? done = false while !done and !file.eof? read << file.getbyte done = yield read[-1] end else if size != nil if size > 0 total = 0 ...
[ "def", "read_source", "(", "file", ",", "read", ",", "size", "=", "nil", ")", "if", "block_given?", "done", "=", "false", "while", "!", "done", "and", "!", "file", ".", "eof?", "read", "<<", "file", ".", "getbyte", "done", "=", "yield", "read", "[", ...
This method loads the data for an image from its source. The method accepts two call approaches. If called without a block then the method considers the size parameter it is passed. If called with a block the method executes until the block returns true. ==== Parameters size:: The maximum number of bytes to be r...
[ "This", "method", "loads", "the", "data", "for", "an", "image", "from", "its", "source", ".", "The", "method", "accepts", "two", "call", "approaches", ".", "If", "called", "without", "a", "block", "then", "the", "method", "considers", "the", "size", "param...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1448-L1469
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.ImageNode.get_dimensions
def get_dimensions dimensions = nil open_file do |file| file.pos = DIMENSIONS_OFFSET[@type] read = [] # Check the image type. if @type == JPEG # Read until we can't anymore or we've found what we're looking for. done = false ...
ruby
def get_dimensions dimensions = nil open_file do |file| file.pos = DIMENSIONS_OFFSET[@type] read = [] # Check the image type. if @type == JPEG # Read until we can't anymore or we've found what we're looking for. done = false ...
[ "def", "get_dimensions", "dimensions", "=", "nil", "open_file", "do", "|", "file", "|", "file", ".", "pos", "=", "DIMENSIONS_OFFSET", "[", "@type", "]", "read", "=", "[", "]", "if", "@type", "==", "JPEG", "done", "=", "false", "while", "!", "file", "."...
This method fetches details of the dimensions associated with an image.
[ "This", "method", "fetches", "details", "of", "the", "dimensions", "associated", "with", "an", "image", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1473-L1512
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.Document.header=
def header=(header) if header.type == HeaderNode::UNIVERSAL @headers[0] = header elsif header.type == HeaderNode::LEFT_PAGE @headers[1] = header elsif header.type == HeaderNode::RIGHT_PAGE @headers[2] = header elsif header.type == HeaderNode::FIRST...
ruby
def header=(header) if header.type == HeaderNode::UNIVERSAL @headers[0] = header elsif header.type == HeaderNode::LEFT_PAGE @headers[1] = header elsif header.type == HeaderNode::RIGHT_PAGE @headers[2] = header elsif header.type == HeaderNode::FIRST...
[ "def", "header", "=", "(", "header", ")", "if", "header", ".", "type", "==", "HeaderNode", "::", "UNIVERSAL", "@headers", "[", "0", "]", "=", "header", "elsif", "header", ".", "type", "==", "HeaderNode", "::", "LEFT_PAGE", "@headers", "[", "1", "]", "=...
This method assigns a new header to a document. A Document object can have up to four header - a default header, a header for left pages, a header for right pages and a header for the first page. The method checks the header type and stores it appropriately. ==== Parameters header:: A reference to the header obj...
[ "This", "method", "assigns", "a", "new", "header", "to", "a", "document", ".", "A", "Document", "object", "can", "have", "up", "to", "four", "header", "-", "a", "default", "header", "a", "header", "for", "left", "pages", "a", "header", "for", "right", ...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1719-L1729
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.Document.footer=
def footer=(footer) if footer.type == FooterNode::UNIVERSAL @footers[0] = footer elsif footer.type == FooterNode::LEFT_PAGE @footers[1] = footer elsif footer.type == FooterNode::RIGHT_PAGE @footers[2] = footer elsif footer.type == FooterNode::FIRST...
ruby
def footer=(footer) if footer.type == FooterNode::UNIVERSAL @footers[0] = footer elsif footer.type == FooterNode::LEFT_PAGE @footers[1] = footer elsif footer.type == FooterNode::RIGHT_PAGE @footers[2] = footer elsif footer.type == FooterNode::FIRST...
[ "def", "footer", "=", "(", "footer", ")", "if", "footer", ".", "type", "==", "FooterNode", "::", "UNIVERSAL", "@footers", "[", "0", "]", "=", "footer", "elsif", "footer", ".", "type", "==", "FooterNode", "::", "LEFT_PAGE", "@footers", "[", "1", "]", "=...
This method assigns a new footer to a document. A Document object can have up to four footers - a default footer, a footer for left pages, a footer for right pages and a footer for the first page. The method checks the footer type and stores it appropriately. ==== Parameters footer:: A reference to the footer ob...
[ "This", "method", "assigns", "a", "new", "footer", "to", "a", "document", ".", "A", "Document", "object", "can", "have", "up", "to", "four", "footers", "-", "a", "default", "footer", "a", "footer", "for", "left", "pages", "a", "footer", "for", "right", ...
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1739-L1749
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.Document.header
def header(type=HeaderNode::UNIVERSAL) index = 0 if type == HeaderNode::LEFT_PAGE index = 1 elsif type == HeaderNode::RIGHT_PAGE index = 2 elsif type == HeaderNode::FIRST_PAGE index = 3 end @headers[index] end
ruby
def header(type=HeaderNode::UNIVERSAL) index = 0 if type == HeaderNode::LEFT_PAGE index = 1 elsif type == HeaderNode::RIGHT_PAGE index = 2 elsif type == HeaderNode::FIRST_PAGE index = 3 end @headers[index] end
[ "def", "header", "(", "type", "=", "HeaderNode", "::", "UNIVERSAL", ")", "index", "=", "0", "if", "type", "==", "HeaderNode", "::", "LEFT_PAGE", "index", "=", "1", "elsif", "type", "==", "HeaderNode", "::", "RIGHT_PAGE", "index", "=", "2", "elsif", "type...
This method fetches a header from a Document object. ==== Parameters type:: One of the header types defined in the header class. Defaults to HeaderNode::UNIVERSAL.
[ "This", "method", "fetches", "a", "header", "from", "a", "Document", "object", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1756-L1766
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.Document.footer
def footer(type=FooterNode::UNIVERSAL) index = 0 if type == FooterNode::LEFT_PAGE index = 1 elsif type == FooterNode::RIGHT_PAGE index = 2 elsif type == FooterNode::FIRST_PAGE index = 3 end @footers[index] end
ruby
def footer(type=FooterNode::UNIVERSAL) index = 0 if type == FooterNode::LEFT_PAGE index = 1 elsif type == FooterNode::RIGHT_PAGE index = 2 elsif type == FooterNode::FIRST_PAGE index = 3 end @footers[index] end
[ "def", "footer", "(", "type", "=", "FooterNode", "::", "UNIVERSAL", ")", "index", "=", "0", "if", "type", "==", "FooterNode", "::", "LEFT_PAGE", "index", "=", "1", "elsif", "type", "==", "FooterNode", "::", "RIGHT_PAGE", "index", "=", "2", "elsif", "type...
This method fetches a footer from a Document object. ==== Parameters type:: One of the footer types defined in the footer class. Defaults to FooterNode::UNIVERSAL.
[ "This", "method", "fetches", "a", "footer", "from", "a", "Document", "object", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1773-L1783
valid
thechrisoshow/rtf
lib/rtf/node.rb
RTF.Document.to_rtf
def to_rtf text = StringIO.new text << "{#{prefix}\\#{@character_set.id2name}" text << "\\deff#{@default_font}" text << "\\deflang#{@language}" if !@language.nil? text << "\\plain\\fs24\\fet1" text << "\n#{@fonts.to_rtf}" text << "\n#{@colours.to_rtf}" if ...
ruby
def to_rtf text = StringIO.new text << "{#{prefix}\\#{@character_set.id2name}" text << "\\deff#{@default_font}" text << "\\deflang#{@language}" if !@language.nil? text << "\\plain\\fs24\\fet1" text << "\n#{@fonts.to_rtf}" text << "\n#{@colours.to_rtf}" if ...
[ "def", "to_rtf", "text", "=", "StringIO", ".", "new", "text", "<<", "\"{#{prefix}\\\\#{@character_set.id2name}\"", "text", "<<", "\"\\\\deff#{@default_font}\"", "text", "<<", "\"\\\\deflang#{@language}\"", "if", "!", "@language", ".", "nil?", "text", "<<", "\"\\\\plain\...
This method generates the RTF text for a Document object.
[ "This", "method", "generates", "the", "RTF", "text", "for", "a", "Document", "object", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/node.rb#L1831-L1863
valid
thechrisoshow/rtf
lib/rtf/colour.rb
RTF.ColourTable.add
def add(colour) if colour.instance_of?(Colour) @colours.push(colour) if @colours.index(colour).nil? end self end
ruby
def add(colour) if colour.instance_of?(Colour) @colours.push(colour) if @colours.index(colour).nil? end self end
[ "def", "add", "(", "colour", ")", "if", "colour", ".", "instance_of?", "(", "Colour", ")", "@colours", ".", "push", "(", "colour", ")", "if", "@colours", ".", "index", "(", "colour", ")", ".", "nil?", "end", "self", "end" ]
This method adds a new colour to a ColourTable object. If the colour already exists within the table or is not a Colour object then this method does nothing. ==== Parameters colour:: The colour to be added to the table.
[ "This", "method", "adds", "a", "new", "colour", "to", "a", "ColourTable", "object", ".", "If", "the", "colour", "already", "exists", "within", "the", "table", "or", "is", "not", "a", "Colour", "object", "then", "this", "method", "does", "nothing", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/colour.rb#L103-L108
valid
thechrisoshow/rtf
lib/rtf/colour.rb
RTF.ColourTable.to_s
def to_s(indent=0) prefix = indent > 0 ? ' ' * indent : '' text = StringIO.new text << "#{prefix}Colour Table (#{@colours.size} colours)" @colours.each {|colour| text << "\n#{prefix} #{colour}"} text.string end
ruby
def to_s(indent=0) prefix = indent > 0 ? ' ' * indent : '' text = StringIO.new text << "#{prefix}Colour Table (#{@colours.size} colours)" @colours.each {|colour| text << "\n#{prefix} #{colour}"} text.string end
[ "def", "to_s", "(", "indent", "=", "0", ")", "prefix", "=", "indent", ">", "0", "?", "' '", "*", "indent", ":", "''", "text", "=", "StringIO", ".", "new", "text", "<<", "\"#{prefix}Colour Table (#{@colours.size} colours)\"", "@colours", ".", "each", "{", "...
This method generates a textual description for a ColourTable object. ==== Parameters indent:: The number of spaces to prefix to the lines generated by the method. Defaults to zero.
[ "This", "method", "generates", "a", "textual", "description", "for", "a", "ColourTable", "object", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/colour.rb#L145-L153
valid
thechrisoshow/rtf
lib/rtf/information.rb
RTF.Information.created=
def created=(setting) if setting.instance_of?(Time) @created = setting else datetime = Date._parse(setting.to_s).values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday) if datetime == nil RTFError.fire("Invalid document creation date/time ...
ruby
def created=(setting) if setting.instance_of?(Time) @created = setting else datetime = Date._parse(setting.to_s).values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday) if datetime == nil RTFError.fire("Invalid document creation date/time ...
[ "def", "created", "=", "(", "setting", ")", "if", "setting", ".", "instance_of?", "(", "Time", ")", "@created", "=", "setting", "else", "datetime", "=", "Date", ".", "_parse", "(", "setting", ".", "to_s", ")", ".", "values_at", "(", ":year", ",", ":mon...
This is the constructor for the Information class. ==== Parameters title:: A string containing the document title information. Defaults to nil. author:: A string containing the document author information. Defaults to nil. company:: A string containing the company name informatio...
[ "This", "is", "the", "constructor", "for", "the", "Information", "class", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/information.rb#L54-L66
valid
thechrisoshow/rtf
lib/rtf/information.rb
RTF.Information.to_s
def to_s(indent=0) prefix = indent > 0 ? ' ' * indent : '' text = StringIO.new text << "#{prefix}Information" text << "\n#{prefix} Title: #{@title}" unless @title.nil? text << "\n#{prefix} Author: #{@author}" unless @author.nil? text << "\n#{...
ruby
def to_s(indent=0) prefix = indent > 0 ? ' ' * indent : '' text = StringIO.new text << "#{prefix}Information" text << "\n#{prefix} Title: #{@title}" unless @title.nil? text << "\n#{prefix} Author: #{@author}" unless @author.nil? text << "\n#{...
[ "def", "to_s", "(", "indent", "=", "0", ")", "prefix", "=", "indent", ">", "0", "?", "' '", "*", "indent", ":", "''", "text", "=", "StringIO", ".", "new", "text", "<<", "\"#{prefix}Information\"", "text", "<<", "\"\\n#{prefix} Title: #{@title}\"", "unle...
This method creates a textual description for an Information object. ==== Parameters indent:: The number of spaces to prefix to the lines generated by the method. Defaults to zero.
[ "This", "method", "creates", "a", "textual", "description", "for", "an", "Information", "object", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/information.rb#L73-L85
valid
thechrisoshow/rtf
lib/rtf/information.rb
RTF.Information.to_rtf
def to_rtf(indent=0) prefix = indent > 0 ? ' ' * indent : '' text = StringIO.new text << "#{prefix}{\\info" text << "\n#{prefix}{\\title #{@title}}" unless @title.nil? text << "\n#{prefix}{\\author #{@author}}" unless @author.nil? text << "\n#{pr...
ruby
def to_rtf(indent=0) prefix = indent > 0 ? ' ' * indent : '' text = StringIO.new text << "#{prefix}{\\info" text << "\n#{prefix}{\\title #{@title}}" unless @title.nil? text << "\n#{prefix}{\\author #{@author}}" unless @author.nil? text << "\n#{pr...
[ "def", "to_rtf", "(", "indent", "=", "0", ")", "prefix", "=", "indent", ">", "0", "?", "' '", "*", "indent", ":", "''", "text", "=", "StringIO", ".", "new", "text", "<<", "\"#{prefix}{\\\\info\"", "text", "<<", "\"\\n#{prefix}{\\\\title #{@title}}\"", "unles...
This method generates the RTF text for an Information object. ==== Parameters indent:: The number of spaces to prefix to the lines generated by the method. Defaults to zero.
[ "This", "method", "generates", "the", "RTF", "text", "for", "an", "Information", "object", "." ]
d6455933262a25628006101be802d7f7b2c3feb7
https://github.com/thechrisoshow/rtf/blob/d6455933262a25628006101be802d7f7b2c3feb7/lib/rtf/information.rb#L92-L109
valid
cotag/spider-gazelle
lib/spider-gazelle/signaller.rb
SpiderGazelle.Signaller.process_request
def process_request(data, client) validated = @validated.include?(client) parser = @validating[client.object_id] if validated parser.process data else result = parser.signal(data) case result when :validate...
ruby
def process_request(data, client) validated = @validated.include?(client) parser = @validating[client.object_id] if validated parser.process data else result = parser.signal(data) case result when :validate...
[ "def", "process_request", "(", "data", ",", "client", ")", "validated", "=", "@validated", ".", "include?", "(", "client", ")", "parser", "=", "@validating", "[", "client", ".", "object_id", "]", "if", "validated", "parser", ".", "process", "data", "else", ...
The server processes requests here
[ "The", "server", "processes", "requests", "here" ]
9eb8ffdf713f66e06579d1a9170618f457e1065c
https://github.com/cotag/spider-gazelle/blob/9eb8ffdf713f66e06579d1a9170618f457e1065c/lib/spider-gazelle/signaller.rb#L188-L214
valid
cotag/spider-gazelle
lib/spider-gazelle/reactor.rb
SpiderGazelle.Reactor.log
def log(error, context, trace = nil) msg = String.new if error.respond_to?(:backtrace) msg << "unhandled exception: #{error.message} (#{context})" backtrace = error.backtrace msg << "\n#{backtrace.join("\n")}" if backtrace msg << "\...
ruby
def log(error, context, trace = nil) msg = String.new if error.respond_to?(:backtrace) msg << "unhandled exception: #{error.message} (#{context})" backtrace = error.backtrace msg << "\n#{backtrace.join("\n")}" if backtrace msg << "\...
[ "def", "log", "(", "error", ",", "context", ",", "trace", "=", "nil", ")", "msg", "=", "String", ".", "new", "if", "error", ".", "respond_to?", "(", ":backtrace", ")", "msg", "<<", "\"unhandled exception: #{error.message} (#{context})\"", "backtrace", "=", "er...
This is an unhandled error on the Libuv Event loop
[ "This", "is", "an", "unhandled", "error", "on", "the", "Libuv", "Event", "loop" ]
9eb8ffdf713f66e06579d1a9170618f457e1065c
https://github.com/cotag/spider-gazelle/blob/9eb8ffdf713f66e06579d1a9170618f457e1065c/lib/spider-gazelle/reactor.rb#L54-L65
valid
cotag/spider-gazelle
lib/spider-gazelle/spider.rb
SpiderGazelle.Spider.ready
def ready load_promise = load_applications load_promise.then do # Check a shutdown request didn't occur as we were loading if @running @logger.verbose "All gazelles running" # This happends on the master thread so we don't ...
ruby
def ready load_promise = load_applications load_promise.then do # Check a shutdown request didn't occur as we were loading if @running @logger.verbose "All gazelles running" # This happends on the master thread so we don't ...
[ "def", "ready", "load_promise", "=", "load_applications", "load_promise", ".", "then", "do", "if", "@running", "@logger", ".", "verbose", "\"All gazelles running\"", "@loaded", "=", "true", "bind_application_ports", "unless", "@delay_port_binding", "else", "@logger", "....
Load gazelles and make the required bindings
[ "Load", "gazelles", "and", "make", "the", "required", "bindings" ]
9eb8ffdf713f66e06579d1a9170618f457e1065c
https://github.com/cotag/spider-gazelle/blob/9eb8ffdf713f66e06579d1a9170618f457e1065c/lib/spider-gazelle/spider.rb#L66-L85
valid
barkerest/hidapi
lib/hidapi/engine.rb
HIDAPI.Engine.enumerate
def enumerate(vendor_id = 0, product_id = 0, options = {}) raise HIDAPI::HidApiError, 'not initialized' unless @context if vendor_id.is_a?(Hash) || (vendor_id.is_a?(String) && options.empty?) options = vendor_id vendor_id = 0 product_id = 0 end if product_id.is_a?(Hash)...
ruby
def enumerate(vendor_id = 0, product_id = 0, options = {}) raise HIDAPI::HidApiError, 'not initialized' unless @context if vendor_id.is_a?(Hash) || (vendor_id.is_a?(String) && options.empty?) options = vendor_id vendor_id = 0 product_id = 0 end if product_id.is_a?(Hash)...
[ "def", "enumerate", "(", "vendor_id", "=", "0", ",", "product_id", "=", "0", ",", "options", "=", "{", "}", ")", "raise", "HIDAPI", "::", "HidApiError", ",", "'not initialized'", "unless", "@context", "if", "vendor_id", ".", "is_a?", "(", "Hash", ")", "|...
Creates a new engine. Enumerates the HID devices matching the vendor and product IDs. Both vendor_id and product_id are optional. They will act as a wild card if set to 0 (the default).
[ "Creates", "a", "new", "engine", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/engine.rb#L23-L64
valid
barkerest/hidapi
lib/hidapi/engine.rb
HIDAPI.Engine.get_device
def get_device(vendor_id, product_id, serial_number = nil, options = {}) raise ArgumentError, 'vendor_id must be provided' if vendor_id.to_i == 0 raise ArgumentError, 'product_id must be provided' if product_id.to_i == 0 if serial_number.is_a?(Hash) options = serial_number serial_numb...
ruby
def get_device(vendor_id, product_id, serial_number = nil, options = {}) raise ArgumentError, 'vendor_id must be provided' if vendor_id.to_i == 0 raise ArgumentError, 'product_id must be provided' if product_id.to_i == 0 if serial_number.is_a?(Hash) options = serial_number serial_numb...
[ "def", "get_device", "(", "vendor_id", ",", "product_id", ",", "serial_number", "=", "nil", ",", "options", "=", "{", "}", ")", "raise", "ArgumentError", ",", "'vendor_id must be provided'", "if", "vendor_id", ".", "to_i", "==", "0", "raise", "ArgumentError", ...
Gets the first device with the specified vendor_id, product_id, and optionally serial_number.
[ "Gets", "the", "first", "device", "with", "the", "specified", "vendor_id", "product_id", "and", "optionally", "serial_number", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/engine.rb#L68-L99
valid
barkerest/hidapi
lib/hidapi/engine.rb
HIDAPI.Engine.open
def open(vendor_id, product_id, serial_number = nil, options = {}) dev = get_device(vendor_id, product_id, serial_number, options) dev.open if dev end
ruby
def open(vendor_id, product_id, serial_number = nil, options = {}) dev = get_device(vendor_id, product_id, serial_number, options) dev.open if dev end
[ "def", "open", "(", "vendor_id", ",", "product_id", ",", "serial_number", "=", "nil", ",", "options", "=", "{", "}", ")", "dev", "=", "get_device", "(", "vendor_id", ",", "product_id", ",", "serial_number", ",", "options", ")", "dev", ".", "open", "if", ...
Opens the first device with the specified vendor_id, product_id, and optionally serial_number.
[ "Opens", "the", "first", "device", "with", "the", "specified", "vendor_id", "product_id", "and", "optionally", "serial_number", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/engine.rb#L103-L106
valid
barkerest/hidapi
lib/hidapi/engine.rb
HIDAPI.Engine.get_device_by_path
def get_device_by_path(path, options = {}) # Our linux setup routine creates convenient /dev/hidapi/* links. # If the user wants to open one of those, we can simple parse the link to generate # the path that the library expects. if File.exist?(path) hidapi_regex = /^\/dev\/hidapi\// ...
ruby
def get_device_by_path(path, options = {}) # Our linux setup routine creates convenient /dev/hidapi/* links. # If the user wants to open one of those, we can simple parse the link to generate # the path that the library expects. if File.exist?(path) hidapi_regex = /^\/dev\/hidapi\// ...
[ "def", "get_device_by_path", "(", "path", ",", "options", "=", "{", "}", ")", "if", "File", ".", "exist?", "(", "path", ")", "hidapi_regex", "=", "/", "\\/", "\\/", "\\/", "/", "usb_bus_regex", "=", "/", "\\/", "\\/", "\\/", "\\/", "\\d", "\\/", "\\d...
Gets the device with the specified path.
[ "Gets", "the", "device", "with", "the", "specified", "path", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/engine.rb#L110-L157
valid
barkerest/hidapi
lib/hidapi/engine.rb
HIDAPI.Engine.open_path
def open_path(path, options = {}) dev = get_device_by_path(path, options) dev.open if dev end
ruby
def open_path(path, options = {}) dev = get_device_by_path(path, options) dev.open if dev end
[ "def", "open_path", "(", "path", ",", "options", "=", "{", "}", ")", "dev", "=", "get_device_by_path", "(", "path", ",", "options", ")", "dev", ".", "open", "if", "dev", "end" ]
Opens the device with the specified path.
[ "Opens", "the", "device", "with", "the", "specified", "path", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/engine.rb#L161-L164
valid
barkerest/hidapi
lib/hidapi/engine.rb
HIDAPI.Engine.usb_code_for_current_locale
def usb_code_for_current_locale @usb_code_for_current_locale ||= begin locale = I18n.locale if locale locale = locale.to_s.partition('.')[0] # remove encoding result = HIDAPI::Language.get_by_code(locale) unless result lo...
ruby
def usb_code_for_current_locale @usb_code_for_current_locale ||= begin locale = I18n.locale if locale locale = locale.to_s.partition('.')[0] # remove encoding result = HIDAPI::Language.get_by_code(locale) unless result lo...
[ "def", "usb_code_for_current_locale", "@usb_code_for_current_locale", "||=", "begin", "locale", "=", "I18n", ".", "locale", "if", "locale", "locale", "=", "locale", ".", "to_s", ".", "partition", "(", "'.'", ")", "[", "0", "]", "result", "=", "HIDAPI", "::", ...
Gets the USB code for the current locale.
[ "Gets", "the", "USB", "code", "for", "the", "current", "locale", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/engine.rb#L168-L184
valid
barkerest/hidapi
lib/hidapi/device.rb
HIDAPI.Device.open
def open if open? self.open_count += 1 if open_count < 1 HIDAPI.debug "open_count for open device #{path} is #{open_count}" self.open_count = 1 end return self end self.open_count = 0 begin self.handle = usb_device.open raise 'n...
ruby
def open if open? self.open_count += 1 if open_count < 1 HIDAPI.debug "open_count for open device #{path} is #{open_count}" self.open_count = 1 end return self end self.open_count = 0 begin self.handle = usb_device.open raise 'n...
[ "def", "open", "if", "open?", "self", ".", "open_count", "+=", "1", "if", "open_count", "<", "1", "HIDAPI", ".", "debug", "\"open_count for open device #{path} is #{open_count}\"", "self", ".", "open_count", "=", "1", "end", "return", "self", "end", "self", ".",...
Opens the device. Returns the device.
[ "Opens", "the", "device", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/device.rb#L193-L256
valid
barkerest/hidapi
lib/hidapi/device.rb
HIDAPI.Device.read_timeout
def read_timeout(milliseconds) raise DeviceNotOpen unless open? mutex.synchronize do if input_reports.count > 0 data = input_reports.delete_at(0) HIDAPI.debug "read data from device #{path}: #{data.inspect}" return data end if shutdown_thread ...
ruby
def read_timeout(milliseconds) raise DeviceNotOpen unless open? mutex.synchronize do if input_reports.count > 0 data = input_reports.delete_at(0) HIDAPI.debug "read data from device #{path}: #{data.inspect}" return data end if shutdown_thread ...
[ "def", "read_timeout", "(", "milliseconds", ")", "raise", "DeviceNotOpen", "unless", "open?", "mutex", ".", "synchronize", "do", "if", "input_reports", ".", "count", ">", "0", "data", "=", "input_reports", ".", "delete_at", "(", "0", ")", "HIDAPI", ".", "deb...
Attempts to read from the device, waiting up to +milliseconds+ before returning. If milliseconds is less than 1, it will wait forever. If milliseconds is 0, then it will return immediately. Returns the next report on success. If no report is available and it is not waiting forever, it will return an empty string...
[ "Attempts", "to", "read", "from", "the", "device", "waiting", "up", "to", "+", "milliseconds", "+", "before", "returning", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/device.rb#L301-L353
valid
barkerest/hidapi
lib/hidapi/device.rb
HIDAPI.Device.send_feature_report
def send_feature_report(data) raise ArgumentError, 'data must not be blank' if data.nil? || data.length < 1 raise HIDAPI::DeviceNotOpen unless open? data, report_number, skipped_report_id = clean_output_data(data) mutex.synchronize do handle.control_transfer( bmRequestType:...
ruby
def send_feature_report(data) raise ArgumentError, 'data must not be blank' if data.nil? || data.length < 1 raise HIDAPI::DeviceNotOpen unless open? data, report_number, skipped_report_id = clean_output_data(data) mutex.synchronize do handle.control_transfer( bmRequestType:...
[ "def", "send_feature_report", "(", "data", ")", "raise", "ArgumentError", ",", "'data must not be blank'", "if", "data", ".", "nil?", "||", "data", ".", "length", "<", "1", "raise", "HIDAPI", "::", "DeviceNotOpen", "unless", "open?", "data", ",", "report_number"...
Sends a feature report to the device.
[ "Sends", "a", "feature", "report", "to", "the", "device", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/device.rb#L374-L391
valid
barkerest/hidapi
lib/hidapi/device.rb
HIDAPI.Device.get_feature_report
def get_feature_report(report_number, buffer_size = nil) buffer_size ||= input_ep_max_packet_size mutex.synchronize do handle.control_transfer( bmRequestType: LIBUSB::REQUEST_TYPE_CLASS | LIBUSB::RECIPIENT_INTERFACE | LIBUSB::ENDPOINT_IN, bRequest: 0x01, # HID Get_Report ...
ruby
def get_feature_report(report_number, buffer_size = nil) buffer_size ||= input_ep_max_packet_size mutex.synchronize do handle.control_transfer( bmRequestType: LIBUSB::REQUEST_TYPE_CLASS | LIBUSB::RECIPIENT_INTERFACE | LIBUSB::ENDPOINT_IN, bRequest: 0x01, # HID Get_Report ...
[ "def", "get_feature_report", "(", "report_number", ",", "buffer_size", "=", "nil", ")", "buffer_size", "||=", "input_ep_max_packet_size", "mutex", ".", "synchronize", "do", "handle", ".", "control_transfer", "(", "bmRequestType", ":", "LIBUSB", "::", "REQUEST_TYPE_CLA...
Gets a feature report from the device.
[ "Gets", "a", "feature", "report", "from", "the", "device", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/device.rb#L395-L409
valid
barkerest/hidapi
lib/hidapi/device.rb
HIDAPI.Device.read_string
def read_string(index, on_failure = '') begin # does not require an interface, so open from the usb_dev instead of using our open method. data = mutex.synchronize do if open? handle.string_descriptor_ascii(index) else usb_device.open { |handle| handle.st...
ruby
def read_string(index, on_failure = '') begin # does not require an interface, so open from the usb_dev instead of using our open method. data = mutex.synchronize do if open? handle.string_descriptor_ascii(index) else usb_device.open { |handle| handle.st...
[ "def", "read_string", "(", "index", ",", "on_failure", "=", "''", ")", "begin", "data", "=", "mutex", ".", "synchronize", "do", "if", "open?", "handle", ".", "string_descriptor_ascii", "(", "index", ")", "else", "usb_device", ".", "open", "{", "|", "handle...
Reads a string descriptor from the USB device.
[ "Reads", "a", "string", "descriptor", "from", "the", "USB", "device", "." ]
d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7
https://github.com/barkerest/hidapi/blob/d4e8b7db3b0a742071b50fc282bdf8d7a3e062a7/lib/hidapi/device.rb#L452-L469
valid
gtarnovan/simple_audit
lib/simple_audit/audit.rb
SimpleAudit.Audit.delta
def delta(other_audit) return self.change_log if other_audit.nil? {}.tap do |d| # first for keys present only in this audit (self.change_log.keys - other_audit.change_log.keys).each do |k| d[k] = [nil, self.change_log[k]] end # .. then for ke...
ruby
def delta(other_audit) return self.change_log if other_audit.nil? {}.tap do |d| # first for keys present only in this audit (self.change_log.keys - other_audit.change_log.keys).each do |k| d[k] = [nil, self.change_log[k]] end # .. then for ke...
[ "def", "delta", "(", "other_audit", ")", "return", "self", ".", "change_log", "if", "other_audit", ".", "nil?", "{", "}", ".", "tap", "do", "|", "d", "|", "(", "self", ".", "change_log", ".", "keys", "-", "other_audit", ".", "change_log", ".", "keys", ...
Computes the differences of the change logs between two audits. Returns a hash containing arrays of the form { :key_1 => [<value_in_other_audit>, <value_in_this_audit>], :key_2 => [<value_in_other_audit>, <value_in_this_audit>], }
[ "Computes", "the", "differences", "of", "the", "change", "logs", "between", "two", "audits", "." ]
c68b8b30c51117c75a838d066b60e31213598471
https://github.com/gtarnovan/simple_audit/blob/c68b8b30c51117c75a838d066b60e31213598471/lib/simple_audit/audit.rb#L16-L41
valid
gtarnovan/simple_audit
lib/simple_audit/helper.rb
SimpleAudit.Helper.render_audits
def render_audits(audited_model) return '' unless audited_model.respond_to?(:audits) audits = (audited_model.audits || []).dup.sort{|a,b| b.created_at <=> a.created_at} res = '' audits.each_with_index do |audit, index| older_audit = audits[index + 1] res += content_tag(:div, :cla...
ruby
def render_audits(audited_model) return '' unless audited_model.respond_to?(:audits) audits = (audited_model.audits || []).dup.sort{|a,b| b.created_at <=> a.created_at} res = '' audits.each_with_index do |audit, index| older_audit = audits[index + 1] res += content_tag(:div, :cla...
[ "def", "render_audits", "(", "audited_model", ")", "return", "''", "unless", "audited_model", ".", "respond_to?", "(", ":audits", ")", "audits", "=", "(", "audited_model", ".", "audits", "||", "[", "]", ")", ".", "dup", ".", "sort", "{", "|", "a", ",", ...
Render the change log for the given audited model
[ "Render", "the", "change", "log", "for", "the", "given", "audited", "model" ]
c68b8b30c51117c75a838d066b60e31213598471
https://github.com/gtarnovan/simple_audit/blob/c68b8b30c51117c75a838d066b60e31213598471/lib/simple_audit/helper.rb#L6-L34
valid
guard/guard-haml
lib/guard/haml.rb
Guard.Haml._output_paths
def _output_paths(file) input_file_dir = File.dirname(file) file_name = _output_filename(file) file_name = "#{file_name}.html" if _append_html_ext_to_output_path?(file_name) input_file_dir = input_file_dir.gsub(Regexp.new("#{options[:input]}(\/){0,1}"), '') if options[:input] if options[:...
ruby
def _output_paths(file) input_file_dir = File.dirname(file) file_name = _output_filename(file) file_name = "#{file_name}.html" if _append_html_ext_to_output_path?(file_name) input_file_dir = input_file_dir.gsub(Regexp.new("#{options[:input]}(\/){0,1}"), '') if options[:input] if options[:...
[ "def", "_output_paths", "(", "file", ")", "input_file_dir", "=", "File", ".", "dirname", "(", "file", ")", "file_name", "=", "_output_filename", "(", "file", ")", "file_name", "=", "\"#{file_name}.html\"", "if", "_append_html_ext_to_output_path?", "(", "file_name", ...
Get the file path to output the html based on the file being built. The output path is relative to where guard is being run. @param file [String, Array<String>] path to file being built @return [Array<String>] path(s) to file where output should be written
[ "Get", "the", "file", "path", "to", "output", "the", "html", "based", "on", "the", "file", "being", "built", ".", "The", "output", "path", "is", "relative", "to", "where", "guard", "is", "being", "run", "." ]
ea981b68ce86ff7dac1972b1c303b3426d2d263e
https://github.com/guard/guard-haml/blob/ea981b68ce86ff7dac1972b1c303b3426d2d263e/lib/guard/haml.rb#L84-L101
valid
guard/guard-haml
lib/guard/haml.rb
Guard.Haml._output_filename
def _output_filename(file) sub_strings = File.basename(file).split('.') base_name, extensions = sub_strings.first, sub_strings[1..-1] if extensions.last == 'haml' extensions.pop if extensions.empty? [base_name, options[:default_ext]].join('.') else ...
ruby
def _output_filename(file) sub_strings = File.basename(file).split('.') base_name, extensions = sub_strings.first, sub_strings[1..-1] if extensions.last == 'haml' extensions.pop if extensions.empty? [base_name, options[:default_ext]].join('.') else ...
[ "def", "_output_filename", "(", "file", ")", "sub_strings", "=", "File", ".", "basename", "(", "file", ")", ".", "split", "(", "'.'", ")", "base_name", ",", "extensions", "=", "sub_strings", ".", "first", ",", "sub_strings", "[", "1", "..", "-", "1", "...
Generate a file name based on the provided file path. Provide a logical extension. Examples: "path/foo.haml" -> "foo.html" "path/foo" -> "foo.html" "path/foo.bar" -> "foo.bar.html" "path/foo.bar.haml" -> "foo.bar" @param file String path to file @return String file name including ext...
[ "Generate", "a", "file", "name", "based", "on", "the", "provided", "file", "path", ".", "Provide", "a", "logical", "extension", "." ]
ea981b68ce86ff7dac1972b1c303b3426d2d263e
https://github.com/guard/guard-haml/blob/ea981b68ce86ff7dac1972b1c303b3426d2d263e/lib/guard/haml.rb#L115-L129
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp.rb
VCloudClient.Connection.get_vapp_by_name
def get_vapp_by_name(organization, vdcName, vAppName) result = nil get_vdc_by_name(organization, vdcName)[:vapps].each do |vapp| if vapp[0].downcase == vAppName.downcase result = get_vapp(vapp[1]) end end result end
ruby
def get_vapp_by_name(organization, vdcName, vAppName) result = nil get_vdc_by_name(organization, vdcName)[:vapps].each do |vapp| if vapp[0].downcase == vAppName.downcase result = get_vapp(vapp[1]) end end result end
[ "def", "get_vapp_by_name", "(", "organization", ",", "vdcName", ",", "vAppName", ")", "result", "=", "nil", "get_vdc_by_name", "(", "organization", ",", "vdcName", ")", "[", ":vapps", "]", ".", "each", "do", "|", "vapp", "|", "if", "vapp", "[", "0", "]",...
Friendly helper method to fetch a vApp by name - Organization object - Organization VDC Name - vApp name
[ "Friendly", "helper", "method", "to", "fetch", "a", "vApp", "by", "name", "-", "Organization", "object", "-", "Organization", "VDC", "Name", "-", "vApp", "name" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp.rb#L117-L127
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp.rb
VCloudClient.Connection.poweroff_vapp
def poweroff_vapp(vAppId) builder = Nokogiri::XML::Builder.new do |xml| xml.UndeployVAppParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5") { xml.UndeployPowerAction 'powerOff' } end params = { 'method' => :post, 'command' => "/vApp/vapp-#{vAppId}/actio...
ruby
def poweroff_vapp(vAppId) builder = Nokogiri::XML::Builder.new do |xml| xml.UndeployVAppParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5") { xml.UndeployPowerAction 'powerOff' } end params = { 'method' => :post, 'command' => "/vApp/vapp-#{vAppId}/actio...
[ "def", "poweroff_vapp", "(", "vAppId", ")", "builder", "=", "Nokogiri", "::", "XML", "::", "Builder", ".", "new", "do", "|", "xml", "|", "xml", ".", "UndeployVAppParams", "(", "\"xmlns\"", "=>", "\"http://www.vmware.com/vcloud/v1.5\"", ")", "{", "xml", ".", ...
Shutdown a given vapp
[ "Shutdown", "a", "given", "vapp" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp.rb#L145-L162
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp.rb
VCloudClient.Connection.create_vapp_from_template
def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_templateid, poweron=false) builder = Nokogiri::XML::Builder.new do |xml| xml.InstantiateVAppTemplateParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", ...
ruby
def create_vapp_from_template(vdc, vapp_name, vapp_description, vapp_templateid, poweron=false) builder = Nokogiri::XML::Builder.new do |xml| xml.InstantiateVAppTemplateParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", ...
[ "def", "create_vapp_from_template", "(", "vdc", ",", "vapp_name", ",", "vapp_description", ",", "vapp_templateid", ",", "poweron", "=", "false", ")", "builder", "=", "Nokogiri", "::", "XML", "::", "Builder", ".", "new", "do", "|", "xml", "|", "xml", ".", "...
Create a vapp starting from a template Params: - vdc: the associated VDC - vapp_name: name of the target vapp - vapp_description: description of the target vapp - vapp_templateid: ID of the vapp template
[ "Create", "a", "vapp", "starting", "from", "a", "template" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp.rb#L207-L233
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp.rb
VCloudClient.Connection.compose_vapp_from_vm
def compose_vapp_from_vm(vdc, vapp_name, vapp_description, vm_list={}, network_config={}) builder = Nokogiri::XML::Builder.new do |xml| xml.ComposeVAppParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1", "name" => vapp_name)...
ruby
def compose_vapp_from_vm(vdc, vapp_name, vapp_description, vm_list={}, network_config={}) builder = Nokogiri::XML::Builder.new do |xml| xml.ComposeVAppParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1", "name" => vapp_name)...
[ "def", "compose_vapp_from_vm", "(", "vdc", ",", "vapp_name", ",", "vapp_description", ",", "vm_list", "=", "{", "}", ",", "network_config", "=", "{", "}", ")", "builder", "=", "Nokogiri", "::", "XML", "::", "Builder", ".", "new", "do", "|", "xml", "|", ...
Compose a vapp using existing virtual machines Params: - vdc: the associated VDC - vapp_name: name of the target vapp - vapp_description: description of the target vapp - vm_list: hash with IDs of the VMs to be used in the composing process - network_config: hash of the network configuration for the vapp
[ "Compose", "a", "vapp", "using", "existing", "virtual", "machines" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp.rb#L244-L328
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp.rb
VCloudClient.Connection.add_vm_to_vapp
def add_vm_to_vapp(vapp, vm, network_config={}) builder = Nokogiri::XML::Builder.new do |xml| xml.RecomposeVAppParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1", "name" => vapp[:name]) { xml.SourcedItem...
ruby
def add_vm_to_vapp(vapp, vm, network_config={}) builder = Nokogiri::XML::Builder.new do |xml| xml.RecomposeVAppParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1", "name" => vapp[:name]) { xml.SourcedItem...
[ "def", "add_vm_to_vapp", "(", "vapp", ",", "vm", ",", "network_config", "=", "{", "}", ")", "builder", "=", "Nokogiri", "::", "XML", "::", "Builder", ".", "new", "do", "|", "xml", "|", "xml", ".", "RecomposeVAppParams", "(", "\"xmlns\"", "=>", "\"http://...
Create a new virtual machine from a template in an existing vApp. Params: - vapp: the target vapp - vm: hash with template ID and new VM name - network_config: hash of the network configuration for the VM
[ "Create", "a", "new", "virtual", "machine", "from", "a", "template", "in", "an", "existing", "vApp", "." ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp.rb#L337-L375
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp.rb
VCloudClient.Connection.clone_vapp
def clone_vapp(vdc_id, source_vapp_id, name, deploy="true", poweron="false", linked="false", delete_source="false") params = { "method" => :post, "command" => "/vdc/#{vdc_id}/action/cloneVApp" } builder = Nokogiri::XML::Builder.new do |xml| xml.CloneVAppParams( ...
ruby
def clone_vapp(vdc_id, source_vapp_id, name, deploy="true", poweron="false", linked="false", delete_source="false") params = { "method" => :post, "command" => "/vdc/#{vdc_id}/action/cloneVApp" } builder = Nokogiri::XML::Builder.new do |xml| xml.CloneVAppParams( ...
[ "def", "clone_vapp", "(", "vdc_id", ",", "source_vapp_id", ",", "name", ",", "deploy", "=", "\"true\"", ",", "poweron", "=", "\"false\"", ",", "linked", "=", "\"false\"", ",", "delete_source", "=", "\"false\"", ")", "params", "=", "{", "\"method\"", "=>", ...
Clone a vapp in a given VDC to a new Vapp
[ "Clone", "a", "vapp", "in", "a", "given", "VDC", "to", "a", "new", "Vapp" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp.rb#L413-L438
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp_networking.rb
VCloudClient.Connection.set_vapp_network_config
def set_vapp_network_config(vappid, network, config={}) params = { 'method' => :get, 'command' => "/vApp/vapp-#{vappid}/networkConfigSection" } netconfig_response, headers = send_request(params) picked_network = netconfig_response.css("NetworkConfig").select do |net| ne...
ruby
def set_vapp_network_config(vappid, network, config={}) params = { 'method' => :get, 'command' => "/vApp/vapp-#{vappid}/networkConfigSection" } netconfig_response, headers = send_request(params) picked_network = netconfig_response.css("NetworkConfig").select do |net| ne...
[ "def", "set_vapp_network_config", "(", "vappid", ",", "network", ",", "config", "=", "{", "}", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/vApp/vapp-#{vappid}/networkConfigSection\"", "}", "netconfig_response", ",", "headers", "=...
Set vApp Network Config Retrieve the existing network config section and edit it to ensure settings are not lost
[ "Set", "vApp", "Network", "Config" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp_networking.rb#L8-L53
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp_networking.rb
VCloudClient.Connection.set_vapp_port_forwarding_rules
def set_vapp_port_forwarding_rules(vappid, network_name, config={}) builder = Nokogiri::XML::Builder.new do |xml| xml.NetworkConfigSection( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1") { xml['ovf'].Info "Network configuratio...
ruby
def set_vapp_port_forwarding_rules(vappid, network_name, config={}) builder = Nokogiri::XML::Builder.new do |xml| xml.NetworkConfigSection( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1") { xml['ovf'].Info "Network configuratio...
[ "def", "set_vapp_port_forwarding_rules", "(", "vappid", ",", "network_name", ",", "config", "=", "{", "}", ")", "builder", "=", "Nokogiri", "::", "XML", "::", "Builder", ".", "new", "do", "|", "xml", "|", "xml", ".", "NetworkConfigSection", "(", "\"xmlns\"",...
Set vApp port forwarding rules - vappid: id of the vapp to be modified - network_name: name of the vapp network to be modified - config: hash with network configuration specifications, must contain an array inside :nat_rules with the nat rules to be applied.
[ "Set", "vApp", "port", "forwarding", "rules" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp_networking.rb#L107-L149
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp_networking.rb
VCloudClient.Connection.get_vapp_port_forwarding_rules
def get_vapp_port_forwarding_rules(vAppId) params = { 'method' => :get, 'command' => "/vApp/vapp-#{vAppId}/networkConfigSection" } response, headers = send_request(params) # FIXME: this will return nil if the vApp uses multiple vApp Networks # with Edge devices in natRout...
ruby
def get_vapp_port_forwarding_rules(vAppId) params = { 'method' => :get, 'command' => "/vApp/vapp-#{vAppId}/networkConfigSection" } response, headers = send_request(params) # FIXME: this will return nil if the vApp uses multiple vApp Networks # with Edge devices in natRout...
[ "def", "get_vapp_port_forwarding_rules", "(", "vAppId", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/vApp/vapp-#{vAppId}/networkConfigSection\"", "}", "response", ",", "headers", "=", "send_request", "(", "params", ")", "config", "=...
Get vApp port forwarding rules - vappid: id of the vApp
[ "Get", "vApp", "port", "forwarding", "rules" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp_networking.rb#L155-L188
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp_networking.rb
VCloudClient.Connection.merge_network_config
def merge_network_config(vapp_networks, new_network, config) net_configuration = new_network.css('Configuration').first fence_mode = new_network.css('FenceMode').first fence_mode.content = config[:fence_mode] || 'isolated' network_features = Nokogiri::XML::Node.new "Features", net_conf...
ruby
def merge_network_config(vapp_networks, new_network, config) net_configuration = new_network.css('Configuration').first fence_mode = new_network.css('FenceMode').first fence_mode.content = config[:fence_mode] || 'isolated' network_features = Nokogiri::XML::Node.new "Features", net_conf...
[ "def", "merge_network_config", "(", "vapp_networks", ",", "new_network", ",", "config", ")", "net_configuration", "=", "new_network", ".", "css", "(", "'Configuration'", ")", ".", "first", "fence_mode", "=", "new_network", ".", "css", "(", "'FenceMode'", ")", "....
Merge the Configuration section of a new network and add specific configuration
[ "Merge", "the", "Configuration", "section", "of", "a", "new", "network", "and", "add", "specific", "configuration" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp_networking.rb#L224-L249
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp_networking.rb
VCloudClient.Connection.add_network_to_vapp
def add_network_to_vapp(vAppId, network_section) params = { 'method' => :put, 'command' => "/vApp/vapp-#{vAppId}/networkConfigSection" } response, headers = send_request(params, network_section, "application/vnd.vmware.vcloud.networkConfigSection+xml") task_id = hea...
ruby
def add_network_to_vapp(vAppId, network_section) params = { 'method' => :put, 'command' => "/vApp/vapp-#{vAppId}/networkConfigSection" } response, headers = send_request(params, network_section, "application/vnd.vmware.vcloud.networkConfigSection+xml") task_id = hea...
[ "def", "add_network_to_vapp", "(", "vAppId", ",", "network_section", ")", "params", "=", "{", "'method'", "=>", ":put", ",", "'command'", "=>", "\"/vApp/vapp-#{vAppId}/networkConfigSection\"", "}", "response", ",", "headers", "=", "send_request", "(", "params", ",",...
Add a new network to a vApp
[ "Add", "a", "new", "network", "to", "a", "vApp" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp_networking.rb#L253-L263
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp_networking.rb
VCloudClient.Connection.create_fake_network_node
def create_fake_network_node(vapp_networks, network_name) parent_section = vapp_networks.css('NetworkConfigSection').first new_network = Nokogiri::XML::Node.new "NetworkConfig", parent_section new_network['networkName'] = network_name placeholder = Nokogiri::XML::Node.new "PLACEHOLDER", ...
ruby
def create_fake_network_node(vapp_networks, network_name) parent_section = vapp_networks.css('NetworkConfigSection').first new_network = Nokogiri::XML::Node.new "NetworkConfig", parent_section new_network['networkName'] = network_name placeholder = Nokogiri::XML::Node.new "PLACEHOLDER", ...
[ "def", "create_fake_network_node", "(", "vapp_networks", ",", "network_name", ")", "parent_section", "=", "vapp_networks", ".", "css", "(", "'NetworkConfigSection'", ")", ".", "first", "new_network", "=", "Nokogiri", "::", "XML", "::", "Node", ".", "new", "\"Netwo...
Create a fake NetworkConfig node whose content will be replaced later Note: this is a hack to avoid wrong merges through Nokogiri that would add a default: namespace
[ "Create", "a", "fake", "NetworkConfig", "node", "whose", "content", "will", "be", "replaced", "later" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp_networking.rb#L270-L278
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp_networking.rb
VCloudClient.Connection.create_internal_network_node
def create_internal_network_node(network_config) builder = Nokogiri::XML::Builder.new do |xml| xml.Configuration { xml.IpScopes { xml.IpScope { xml.IsInherited(network_config[:is_inherited] || "false") xml.Gateway network_config[:gateway] ...
ruby
def create_internal_network_node(network_config) builder = Nokogiri::XML::Builder.new do |xml| xml.Configuration { xml.IpScopes { xml.IpScope { xml.IsInherited(network_config[:is_inherited] || "false") xml.Gateway network_config[:gateway] ...
[ "def", "create_internal_network_node", "(", "network_config", ")", "builder", "=", "Nokogiri", "::", "XML", "::", "Builder", ".", "new", "do", "|", "xml", "|", "xml", ".", "Configuration", "{", "xml", ".", "IpScopes", "{", "xml", ".", "IpScope", "{", "xml"...
Create a fake Configuration node for internal networking
[ "Create", "a", "fake", "Configuration", "node", "for", "internal", "networking" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp_networking.rb#L282-L307
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vapp_networking.rb
VCloudClient.Connection.generate_network_section
def generate_network_section(vAppId, network, config, type) params = { 'method' => :get, 'command' => "/vApp/vapp-#{vAppId}/networkConfigSection" } vapp_networks, headers = send_request(params) create_fake_network_node(vapp_networks, network[:name]) if type....
ruby
def generate_network_section(vAppId, network, config, type) params = { 'method' => :get, 'command' => "/vApp/vapp-#{vAppId}/networkConfigSection" } vapp_networks, headers = send_request(params) create_fake_network_node(vapp_networks, network[:name]) if type....
[ "def", "generate_network_section", "(", "vAppId", ",", "network", ",", "config", ",", "type", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/vApp/vapp-#{vAppId}/networkConfigSection\"", "}", "vapp_networks", ",", "headers", "=", "se...
Create a NetworkConfigSection for a new internal or external network
[ "Create", "a", "NetworkConfigSection", "for", "a", "new", "internal", "or", "external", "network" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vapp_networking.rb#L311-L329
valid
vmware/vcloud-rest
lib/vcloud-rest/connection.rb
VCloudClient.Connection.login
def login params = { 'method' => :post, 'command' => '/sessions' } response, headers = send_request(params) if !headers.has_key?(:x_vcloud_authorization) raise "Unable to authenticate: missing x_vcloud_authorization header" end extensibility_link = response...
ruby
def login params = { 'method' => :post, 'command' => '/sessions' } response, headers = send_request(params) if !headers.has_key?(:x_vcloud_authorization) raise "Unable to authenticate: missing x_vcloud_authorization header" end extensibility_link = response...
[ "def", "login", "params", "=", "{", "'method'", "=>", ":post", ",", "'command'", "=>", "'/sessions'", "}", "response", ",", "headers", "=", "send_request", "(", "params", ")", "if", "!", "headers", ".", "has_key?", "(", ":x_vcloud_authorization", ")", "raise...
Authenticate against the specified server
[ "Authenticate", "against", "the", "specified", "server" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/connection.rb#L66-L82
valid
vmware/vcloud-rest
lib/vcloud-rest/connection.rb
VCloudClient.Connection.get_task
def get_task(taskid) params = { 'method' => :get, 'command' => "/task/#{taskid}" } response, headers = send_request(params) task = response.css('Task').first status = task['status'] start_time = task['startTime'] end_time = task['endTime'] { :status => ...
ruby
def get_task(taskid) params = { 'method' => :get, 'command' => "/task/#{taskid}" } response, headers = send_request(params) task = response.css('Task').first status = task['status'] start_time = task['startTime'] end_time = task['endTime'] { :status => ...
[ "def", "get_task", "(", "taskid", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/task/#{taskid}\"", "}", "response", ",", "headers", "=", "send_request", "(", "params", ")", "task", "=", "response", ".", "css", "(", "'Task'"...
Fetch information for a given task
[ "Fetch", "information", "for", "a", "given", "task" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/connection.rb#L100-L114
valid
vmware/vcloud-rest
lib/vcloud-rest/connection.rb
VCloudClient.Connection.wait_task_completion
def wait_task_completion(taskid) errormsg = nil task = {} loop do task = get_task(taskid) break if task[:status] != 'running' sleep 1 end if task[:status] == 'error' errormsg = task[:response].css("Error").first errormsg = "Error code #{errormsg['m...
ruby
def wait_task_completion(taskid) errormsg = nil task = {} loop do task = get_task(taskid) break if task[:status] != 'running' sleep 1 end if task[:status] == 'error' errormsg = task[:response].css("Error").first errormsg = "Error code #{errormsg['m...
[ "def", "wait_task_completion", "(", "taskid", ")", "errormsg", "=", "nil", "task", "=", "{", "}", "loop", "do", "task", "=", "get_task", "(", "taskid", ")", "break", "if", "task", "[", ":status", "]", "!=", "'running'", "sleep", "1", "end", "if", "task...
Poll a given task until completion
[ "Poll", "a", "given", "task", "until", "completion" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/connection.rb#L118-L135
valid
vmware/vcloud-rest
lib/vcloud-rest/connection.rb
VCloudClient.Connection.send_request
def send_request(params, payload=nil, content_type=nil) req_params = setup_request(params, payload, content_type) handled_request(req_params) do request = RestClient::Request.new(req_params) response = request.execute if ![200, 201, 202, 204].include?(response.code) ...
ruby
def send_request(params, payload=nil, content_type=nil) req_params = setup_request(params, payload, content_type) handled_request(req_params) do request = RestClient::Request.new(req_params) response = request.execute if ![200, 201, 202, 204].include?(response.code) ...
[ "def", "send_request", "(", "params", ",", "payload", "=", "nil", ",", "content_type", "=", "nil", ")", "req_params", "=", "setup_request", "(", "params", ",", "payload", ",", "content_type", ")", "handled_request", "(", "req_params", ")", "do", "request", "...
Sends a synchronous request to the vCloud API and returns the response as parsed XML + headers.
[ "Sends", "a", "synchronous", "request", "to", "the", "vCloud", "API", "and", "returns", "the", "response", "as", "parsed", "XML", "+", "headers", "." ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/connection.rb#L140-L156
valid
vmware/vcloud-rest
lib/vcloud-rest/connection.rb
VCloudClient.Connection.upload_file
def upload_file(uploadURL, uploadFile, progressUrl, config={}) raise ::IOError, "#{uploadFile} not found." unless File.exists?(uploadFile) # Set chunksize to 10M if not specified otherwise chunkSize = (config[:chunksize] || 10485760) # Set progress bar to default format if not specifie...
ruby
def upload_file(uploadURL, uploadFile, progressUrl, config={}) raise ::IOError, "#{uploadFile} not found." unless File.exists?(uploadFile) # Set chunksize to 10M if not specified otherwise chunkSize = (config[:chunksize] || 10485760) # Set progress bar to default format if not specifie...
[ "def", "upload_file", "(", "uploadURL", ",", "uploadFile", ",", "progressUrl", ",", "config", "=", "{", "}", ")", "raise", "::", "IOError", ",", "\"#{uploadFile} not found.\"", "unless", "File", ".", "exists?", "(", "uploadFile", ")", "chunkSize", "=", "(", ...
Upload a large file in configurable chunks, output an optional progressbar
[ "Upload", "a", "large", "file", "in", "configurable", "chunks", "output", "an", "optional", "progressbar" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/connection.rb#L328-L416
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/catalog.rb
VCloudClient.Connection.get_catalog
def get_catalog(catalogId) params = { 'method' => :get, 'command' => "/catalog/#{catalogId}" } response, headers = send_request(params) description = response.css("Description").first description = description.text unless description.nil? items = {} response.c...
ruby
def get_catalog(catalogId) params = { 'method' => :get, 'command' => "/catalog/#{catalogId}" } response, headers = send_request(params) description = response.css("Description").first description = description.text unless description.nil? items = {} response.c...
[ "def", "get_catalog", "(", "catalogId", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/catalog/#{catalogId}\"", "}", "response", ",", "headers", "=", "send_request", "(", "params", ")", "description", "=", "response", ".", "css"...
Fetch details about a given catalog
[ "Fetch", "details", "about", "a", "given", "catalog" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/catalog.rb#L5-L20
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.get_vm_disk_info
def get_vm_disk_info(vmid) response, headers = __get_disk_info(vmid) disks = [] response.css("Item").each do |entry| # Pick only entries with node "HostResource" resource = entry.css("rasd|HostResource").first next unless resource name = entry.css("rasd|ElementName")....
ruby
def get_vm_disk_info(vmid) response, headers = __get_disk_info(vmid) disks = [] response.css("Item").each do |entry| # Pick only entries with node "HostResource" resource = entry.css("rasd|HostResource").first next unless resource name = entry.css("rasd|ElementName")....
[ "def", "get_vm_disk_info", "(", "vmid", ")", "response", ",", "headers", "=", "__get_disk_info", "(", "vmid", ")", "disks", "=", "[", "]", "response", ".", "css", "(", "\"Item\"", ")", ".", "each", "do", "|", "entry", "|", "resource", "=", "entry", "."...
Retrieve information about Disks
[ "Retrieve", "information", "about", "Disks" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L33-L52
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.set_vm_disk_info
def set_vm_disk_info(vmid, disk_info={}) get_response, headers = __get_disk_info(vmid) if disk_info[:add] data = add_disk(get_response, disk_info) else data = edit_disk(get_response, disk_info) end params = { 'method' => :put, 'command' => "/vApp/vm-#{vmid...
ruby
def set_vm_disk_info(vmid, disk_info={}) get_response, headers = __get_disk_info(vmid) if disk_info[:add] data = add_disk(get_response, disk_info) else data = edit_disk(get_response, disk_info) end params = { 'method' => :put, 'command' => "/vApp/vm-#{vmid...
[ "def", "set_vm_disk_info", "(", "vmid", ",", "disk_info", "=", "{", "}", ")", "get_response", ",", "headers", "=", "__get_disk_info", "(", "vmid", ")", "if", "disk_info", "[", ":add", "]", "data", "=", "add_disk", "(", "get_response", ",", "disk_info", ")"...
Set information about Disks Disks can be added, deleted or modified
[ "Set", "information", "about", "Disks" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L58-L75
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.set_vm_cpus
def set_vm_cpus(vmid, cpu_number) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmid}/virtualHardwareSection/cpu" } get_response, headers = send_request(params) # Change attributes from the previous invocation get_response.css("rasd|ElementName").first.content = "...
ruby
def set_vm_cpus(vmid, cpu_number) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmid}/virtualHardwareSection/cpu" } get_response, headers = send_request(params) # Change attributes from the previous invocation get_response.css("rasd|ElementName").first.content = "...
[ "def", "set_vm_cpus", "(", "vmid", ",", "cpu_number", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/vApp/vm-#{vmid}/virtualHardwareSection/cpu\"", "}", "get_response", ",", "headers", "=", "send_request", "(", "params", ")", "get_r...
Set VM CPUs
[ "Set", "VM", "CPUs" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L79-L96
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.set_vm_ram
def set_vm_ram(vmid, memory_size) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmid}/virtualHardwareSection/memory" } get_response, headers = send_request(params) # Change attributes from the previous invocation get_response.css("rasd|ElementName").first.content ...
ruby
def set_vm_ram(vmid, memory_size) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmid}/virtualHardwareSection/memory" } get_response, headers = send_request(params) # Change attributes from the previous invocation get_response.css("rasd|ElementName").first.content ...
[ "def", "set_vm_ram", "(", "vmid", ",", "memory_size", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/vApp/vm-#{vmid}/virtualHardwareSection/memory\"", "}", "get_response", ",", "headers", "=", "send_request", "(", "params", ")", "ge...
Set VM RAM
[ "Set", "VM", "RAM" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L100-L117
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.edit_vm_network
def edit_vm_network(vmId, network, config={}) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmId}/networkConnectionSection" } netconfig_response, headers = send_request(params) if config[:primary_index] node = netconfig_response.css('PrimaryNetworkConnectionInde...
ruby
def edit_vm_network(vmId, network, config={}) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmId}/networkConnectionSection" } netconfig_response, headers = send_request(params) if config[:primary_index] node = netconfig_response.css('PrimaryNetworkConnectionInde...
[ "def", "edit_vm_network", "(", "vmId", ",", "network", ",", "config", "=", "{", "}", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/vApp/vm-#{vmId}/networkConnectionSection\"", "}", "netconfig_response", ",", "headers", "=", "send...
Edit VM Network Config Retrieve the existing network config section and edit it to ensure settings are not lost
[ "Edit", "VM", "Network", "Config" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L124-L172
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.add_vm_network
def add_vm_network(vmId, network, config={}) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmId}/networkConnectionSection" } netconfig_response, headers = send_request(params) parent_section = netconfig_response.css('NetworkConnectionSection').first # For some re...
ruby
def add_vm_network(vmId, network, config={}) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmId}/networkConnectionSection" } netconfig_response, headers = send_request(params) parent_section = netconfig_response.css('NetworkConnectionSection').first # For some re...
[ "def", "add_vm_network", "(", "vmId", ",", "network", ",", "config", "=", "{", "}", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/vApp/vm-#{vmId}/networkConnectionSection\"", "}", "netconfig_response", ",", "headers", "=", "send_...
Add a new network to a VM
[ "Add", "a", "new", "network", "to", "a", "VM" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L176-L235
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.delete_vm_network
def delete_vm_network(vmId, network) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmId}/networkConnectionSection" } netconfig_response, headers = send_request(params) picked_network = netconfig_response.css("NetworkConnection").select do |net| net.attribute('ne...
ruby
def delete_vm_network(vmId, network) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmId}/networkConnectionSection" } netconfig_response, headers = send_request(params) picked_network = netconfig_response.css("NetworkConnection").select do |net| net.attribute('ne...
[ "def", "delete_vm_network", "(", "vmId", ",", "network", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/vApp/vm-#{vmId}/networkConnectionSection\"", "}", "netconfig_response", ",", "headers", "=", "send_request", "(", "params", ")", ...
Remove an existing network
[ "Remove", "an", "existing", "network" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L239-L264
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.set_vm_guest_customization
def set_vm_guest_customization(vmid, computer_name, config={}) builder = Nokogiri::XML::Builder.new do |xml| xml.GuestCustomizationSection( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1") { xml['ovf'].Info "VM Guest Customiza...
ruby
def set_vm_guest_customization(vmid, computer_name, config={}) builder = Nokogiri::XML::Builder.new do |xml| xml.GuestCustomizationSection( "xmlns" => "http://www.vmware.com/vcloud/v1.5", "xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1") { xml['ovf'].Info "VM Guest Customiza...
[ "def", "set_vm_guest_customization", "(", "vmid", ",", "computer_name", ",", "config", "=", "{", "}", ")", "builder", "=", "Nokogiri", "::", "XML", "::", "Builder", ".", "new", "do", "|", "xml", "|", "xml", ".", "GuestCustomizationSection", "(", "\"xmlns\"",...
Set VM Guest Customization Config
[ "Set", "VM", "Guest", "Customization", "Config" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L268-L291
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.get_vm
def get_vm(vmId) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmId}" } response, headers = send_request(params) vm_name = response.css('Vm').attribute("name") vm_name = vm_name.text unless vm_name.nil? status = convert_vapp_status(response.css('Vm').attrib...
ruby
def get_vm(vmId) params = { 'method' => :get, 'command' => "/vApp/vm-#{vmId}" } response, headers = send_request(params) vm_name = response.css('Vm').attribute("name") vm_name = vm_name.text unless vm_name.nil? status = convert_vapp_status(response.css('Vm').attrib...
[ "def", "get_vm", "(", "vmId", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/vApp/vm-#{vmId}\"", "}", "response", ",", "headers", "=", "send_request", "(", "params", ")", "vm_name", "=", "response", ".", "css", "(", "'Vm'", ...
Fetch details about a given VM
[ "Fetch", "details", "about", "a", "given", "VM" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L330-L383
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.get_vm_by_name
def get_vm_by_name(organization, vdcName, vAppName, vmName) result = nil get_vapp_by_name(organization, vdcName, vAppName)[:vms_hash].each do |key, values| if key.downcase == vmName.downcase result = get_vm(values[:id]) end end result end
ruby
def get_vm_by_name(organization, vdcName, vAppName, vmName) result = nil get_vapp_by_name(organization, vdcName, vAppName)[:vms_hash].each do |key, values| if key.downcase == vmName.downcase result = get_vm(values[:id]) end end result end
[ "def", "get_vm_by_name", "(", "organization", ",", "vdcName", ",", "vAppName", ",", "vmName", ")", "result", "=", "nil", "get_vapp_by_name", "(", "organization", ",", "vdcName", ",", "vAppName", ")", "[", ":vms_hash", "]", ".", "each", "do", "|", "key", ",...
Friendly helper method to fetch a vApp by name - Organization object - Organization VDC Name - vApp Name - VM Name
[ "Friendly", "helper", "method", "to", "fetch", "a", "vApp", "by", "name", "-", "Organization", "object", "-", "Organization", "VDC", "Name", "-", "vApp", "Name", "-", "VM", "Name" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L391-L401
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.poweroff_vm
def poweroff_vm(vmId) builder = Nokogiri::XML::Builder.new do |xml| xml.UndeployVAppParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5") { xml.UndeployPowerAction 'powerOff' } end params = { 'method' => :post, 'command' => "/vApp/vm-#{vmId}/action/undepl...
ruby
def poweroff_vm(vmId) builder = Nokogiri::XML::Builder.new do |xml| xml.UndeployVAppParams( "xmlns" => "http://www.vmware.com/vcloud/v1.5") { xml.UndeployPowerAction 'powerOff' } end params = { 'method' => :post, 'command' => "/vApp/vm-#{vmId}/action/undepl...
[ "def", "poweroff_vm", "(", "vmId", ")", "builder", "=", "Nokogiri", "::", "XML", "::", "Builder", ".", "new", "do", "|", "xml", "|", "xml", ".", "UndeployVAppParams", "(", "\"xmlns\"", "=>", "\"http://www.vmware.com/vcloud/v1.5\"", ")", "{", "xml", ".", "Und...
Shutdown a given vm
[ "Shutdown", "a", "given", "vm" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L405-L422
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vm.rb
VCloudClient.Connection.acquire_ticket_vm
def acquire_ticket_vm(vmId) params = { 'method' => :post, 'command' => "/vApp/vm-#{vmId}/screen/action/acquireTicket" } response, headers = send_request(params) screen_ticket = response.css("ScreenTicket").text result = {} if screen_ticket =~ /mks:\/\/([^\/]*)\/(...
ruby
def acquire_ticket_vm(vmId) params = { 'method' => :post, 'command' => "/vApp/vm-#{vmId}/screen/action/acquireTicket" } response, headers = send_request(params) screen_ticket = response.css("ScreenTicket").text result = {} if screen_ticket =~ /mks:\/\/([^\/]*)\/(...
[ "def", "acquire_ticket_vm", "(", "vmId", ")", "params", "=", "{", "'method'", "=>", ":post", ",", "'command'", "=>", "\"/vApp/vm-#{vmId}/screen/action/acquireTicket\"", "}", "response", ",", "headers", "=", "send_request", "(", "params", ")", "screen_ticket", "=", ...
Retrieve a screen ticket that you can use with the VMRC browser plug-in to gain access to the console of a running VM.
[ "Retrieve", "a", "screen", "ticket", "that", "you", "can", "use", "with", "the", "VMRC", "browser", "plug", "-", "in", "to", "gain", "access", "to", "the", "console", "of", "a", "running", "VM", "." ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vm.rb#L478-L496
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/network.rb
VCloudClient.Connection.get_network
def get_network(networkId) response = get_base_network(networkId) name = response.css('OrgVdcNetwork').attribute('name').text description = response.css("Description").first description = description.text unless description.nil? gateway = response.css('Gateway') gateway = gateway....
ruby
def get_network(networkId) response = get_base_network(networkId) name = response.css('OrgVdcNetwork').attribute('name').text description = response.css("Description").first description = description.text unless description.nil? gateway = response.css('Gateway') gateway = gateway....
[ "def", "get_network", "(", "networkId", ")", "response", "=", "get_base_network", "(", "networkId", ")", "name", "=", "response", ".", "css", "(", "'OrgVdcNetwork'", ")", ".", "attribute", "(", "'name'", ")", ".", "text", "description", "=", "response", ".",...
Fetch details about a given Org VDC network
[ "Fetch", "details", "about", "a", "given", "Org", "VDC", "network" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/network.rb#L5-L32
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/org.rb
VCloudClient.Connection.get_organizations
def get_organizations params = { 'method' => :get, 'command' => '/org' } response, headers = send_request(params) orgs = response.css('OrgList Org') results = {} orgs.each do |org| results[org['name']] = org['href'].gsub(/.*\/org\//, "") end resu...
ruby
def get_organizations params = { 'method' => :get, 'command' => '/org' } response, headers = send_request(params) orgs = response.css('OrgList Org') results = {} orgs.each do |org| results[org['name']] = org['href'].gsub(/.*\/org\//, "") end resu...
[ "def", "get_organizations", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "'/org'", "}", "response", ",", "headers", "=", "send_request", "(", "params", ")", "orgs", "=", "response", ".", "css", "(", "'OrgList Org'", ")", "results", ...
Fetch existing organizations and their IDs
[ "Fetch", "existing", "organizations", "and", "their", "IDs" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/org.rb#L5-L19
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/org.rb
VCloudClient.Connection.get_tasks_list
def get_tasks_list(id) params = { 'method' => :get, 'command' => "/tasksList/#{id}" } response, headers = send_request(params) tasks = [] response.css('Task').each do |task| id = task['href'].gsub(/.*\/task\//, "") operation = task['operationName'] ...
ruby
def get_tasks_list(id) params = { 'method' => :get, 'command' => "/tasksList/#{id}" } response, headers = send_request(params) tasks = [] response.css('Task').each do |task| id = task['href'].gsub(/.*\/task\//, "") operation = task['operationName'] ...
[ "def", "get_tasks_list", "(", "id", ")", "params", "=", "{", "'method'", "=>", ":get", ",", "'command'", "=>", "\"/tasksList/#{id}\"", "}", "response", ",", "headers", "=", "send_request", "(", "params", ")", "tasks", "=", "[", "]", "response", ".", "css",...
Fetch tasks from a given task list Note: id can be retrieved using get_organization
[ "Fetch", "tasks", "from", "a", "given", "task", "list" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/org.rb#L96-L127
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vdc.rb
VCloudClient.Connection.get_vdc_id_by_name
def get_vdc_id_by_name(organization, vdcName) result = nil organization[:vdcs].each do |vdc| if vdc[0].downcase == vdcName.downcase result = vdc[1] end end result end
ruby
def get_vdc_id_by_name(organization, vdcName) result = nil organization[:vdcs].each do |vdc| if vdc[0].downcase == vdcName.downcase result = vdc[1] end end result end
[ "def", "get_vdc_id_by_name", "(", "organization", ",", "vdcName", ")", "result", "=", "nil", "organization", "[", ":vdcs", "]", ".", "each", "do", "|", "vdc", "|", "if", "vdc", "[", "0", "]", ".", "downcase", "==", "vdcName", ".", "downcase", "result", ...
Friendly helper method to fetch a Organization VDC Id by name - Organization object - Organization VDC Name
[ "Friendly", "helper", "method", "to", "fetch", "a", "Organization", "VDC", "Id", "by", "name", "-", "Organization", "object", "-", "Organization", "VDC", "Name" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vdc.rb#L53-L63
valid
vmware/vcloud-rest
lib/vcloud-rest/vcloud/vdc.rb
VCloudClient.Connection.get_vdc_by_name
def get_vdc_by_name(organization, vdcName) result = nil organization[:vdcs].each do |vdc| if vdc[0].downcase == vdcName.downcase result = get_vdc(vdc[1]) end end result end
ruby
def get_vdc_by_name(organization, vdcName) result = nil organization[:vdcs].each do |vdc| if vdc[0].downcase == vdcName.downcase result = get_vdc(vdc[1]) end end result end
[ "def", "get_vdc_by_name", "(", "organization", ",", "vdcName", ")", "result", "=", "nil", "organization", "[", ":vdcs", "]", ".", "each", "do", "|", "vdc", "|", "if", "vdc", "[", "0", "]", ".", "downcase", "==", "vdcName", ".", "downcase", "result", "=...
Friendly helper method to fetch a Organization VDC by name - Organization object - Organization VDC Name
[ "Friendly", "helper", "method", "to", "fetch", "a", "Organization", "VDC", "by", "name", "-", "Organization", "object", "-", "Organization", "VDC", "Name" ]
45425d93acf988946cac375b803100ad01206459
https://github.com/vmware/vcloud-rest/blob/45425d93acf988946cac375b803100ad01206459/lib/vcloud-rest/vcloud/vdc.rb#L69-L79
valid
markkorput/data-provider
lib/data_provider/container.rb
DataProvider.Container.add!
def add!(container) ### add container's providers ### # internally providers are added in reverse order (last one first) # so at runtime you it's easy and fast to grab the latest provider # so when adding now, we have to reverse the providers to get them in the original order container.pro...
ruby
def add!(container) ### add container's providers ### # internally providers are added in reverse order (last one first) # so at runtime you it's easy and fast to grab the latest provider # so when adding now, we have to reverse the providers to get them in the original order container.pro...
[ "def", "add!", "(", "container", ")", "container", ".", "providers", ".", "reverse", ".", "each", "do", "|", "definition", "|", "add_provider", "(", "*", "definition", ")", "end", "self", ".", "provides", "(", "container", ".", "provides", ")", "@fallback_...
"adding existing containers"-related methods adds all the providers defined in the given module to this class
[ "adding", "existing", "containers", "-", "related", "methods" ]
faf2d0e5bb88f31da8517974cd315dddb7ded80d
https://github.com/markkorput/data-provider/blob/faf2d0e5bb88f31da8517974cd315dddb7ded80d/lib/data_provider/container.rb#L149-L166
valid
markkorput/data-provider
lib/data_provider/container.rb
DataProvider.Container.get_provider
def get_provider(id, opts = {}) # get all matching providers matching_provider_args = providers.find_all{|args| args.first == id} # sort providers on priority, form high to low matching_provider_args.sort! do |args_a, args_b| # we want to sort from high priority to low, but providers wit...
ruby
def get_provider(id, opts = {}) # get all matching providers matching_provider_args = providers.find_all{|args| args.first == id} # sort providers on priority, form high to low matching_provider_args.sort! do |args_a, args_b| # we want to sort from high priority to low, but providers wit...
[ "def", "get_provider", "(", "id", ",", "opts", "=", "{", "}", ")", "matching_provider_args", "=", "providers", ".", "find_all", "{", "|", "args", "|", "args", ".", "first", "==", "id", "}", "matching_provider_args", ".", "sort!", "do", "|", "args_a", ","...
returns the requested provider as a Provider object
[ "returns", "the", "requested", "provider", "as", "a", "Provider", "object" ]
faf2d0e5bb88f31da8517974cd315dddb7ded80d
https://github.com/markkorput/data-provider/blob/faf2d0e5bb88f31da8517974cd315dddb7ded80d/lib/data_provider/container.rb#L296-L311
valid
rbialek/rack-tidy
lib/rack/tidy/cleaner.rb
Rack::Tidy.Cleaner.call!
def call!(env) @env = env.dup status, @headers, response = @app.call(@env) if should_clean? @headers.delete('Content-Length') response = Rack::Response.new( tidy_markup(response.respond_to?(:body) ? response.body : response), status, @headers ...
ruby
def call!(env) @env = env.dup status, @headers, response = @app.call(@env) if should_clean? @headers.delete('Content-Length') response = Rack::Response.new( tidy_markup(response.respond_to?(:body) ? response.body : response), status, @headers ...
[ "def", "call!", "(", "env", ")", "@env", "=", "env", ".", "dup", "status", ",", "@headers", ",", "response", "=", "@app", ".", "call", "(", "@env", ")", "if", "should_clean?", "@headers", ".", "delete", "(", "'Content-Length'", ")", "response", "=", "R...
thread safe version using shallow copy of env
[ "thread", "safe", "version", "using", "shallow", "copy", "of", "env" ]
fb563cd33da97a3f852c1a7fa0a5fcb51ccbe2c5
https://github.com/rbialek/rack-tidy/blob/fb563cd33da97a3f852c1a7fa0a5fcb51ccbe2c5/lib/rack/tidy/cleaner.rb#L34-L49
valid
stefankroes/scribble
lib/scribble/registry.rb
Scribble.Registry.for
def for *classes, &proc classes.each { |receiver_class| ForClassContext.new(self, receiver_class).instance_eval &proc } end
ruby
def for *classes, &proc classes.each { |receiver_class| ForClassContext.new(self, receiver_class).instance_eval &proc } end
[ "def", "for", "*", "classes", ",", "&", "proc", "classes", ".", "each", "{", "|", "receiver_class", "|", "ForClassContext", ".", "new", "(", "self", ",", "receiver_class", ")", ".", "instance_eval", "&", "proc", "}", "end" ]
For class context
[ "For", "class", "context" ]
bd889cff108c1785cd28150763abd9b31782b44f
https://github.com/stefankroes/scribble/blob/bd889cff108c1785cd28150763abd9b31782b44f/lib/scribble/registry.rb#L16-L18
valid
stefankroes/scribble
lib/scribble/registry.rb
Scribble.Registry.evaluate
def evaluate name, receiver, args, call = nil, context = nil matcher = Support::Matcher.new self, name, receiver, args matcher.match.new(receiver, call, context).send name, *args end
ruby
def evaluate name, receiver, args, call = nil, context = nil matcher = Support::Matcher.new self, name, receiver, args matcher.match.new(receiver, call, context).send name, *args end
[ "def", "evaluate", "name", ",", "receiver", ",", "args", ",", "call", "=", "nil", ",", "context", "=", "nil", "matcher", "=", "Support", "::", "Matcher", ".", "new", "self", ",", "name", ",", "receiver", ",", "args", "matcher", ".", "match", ".", "ne...
Evaluate or cast
[ "Evaluate", "or", "cast" ]
bd889cff108c1785cd28150763abd9b31782b44f
https://github.com/stefankroes/scribble/blob/bd889cff108c1785cd28150763abd9b31782b44f/lib/scribble/registry.rb#L65-L68
valid
mattbrictson/bundleup
lib/bundleup/console.rb
Bundleup.Console.progress
def progress(message, &block) spinner = %w[/ - \\ |].cycle print "\e[90m#{message}... \e[0m" result = observing_thread(block, 0.5, 0.1) do print "\r\e[90m#{message}... #{spinner.next} \e[0m" end puts "\r\e[90m#{message}... OK\e[0m" result rescue StandardError puts "...
ruby
def progress(message, &block) spinner = %w[/ - \\ |].cycle print "\e[90m#{message}... \e[0m" result = observing_thread(block, 0.5, 0.1) do print "\r\e[90m#{message}... #{spinner.next} \e[0m" end puts "\r\e[90m#{message}... OK\e[0m" result rescue StandardError puts "...
[ "def", "progress", "(", "message", ",", "&", "block", ")", "spinner", "=", "%w[", "/", " \\\\", "|", "]", ".", "cycle", "print", "\"\\e[90m#{message}... \\e[0m\"", "result", "=", "observing_thread", "(", "block", ",", "0.5", ",", "0.1", ")", "do", "print",...
Runs a block in the background and displays a spinner until it completes.
[ "Runs", "a", "block", "in", "the", "background", "and", "displays", "a", "spinner", "until", "it", "completes", "." ]
2d0c63fae76506a41af5827d5c7f6db570dfe473
https://github.com/mattbrictson/bundleup/blob/2d0c63fae76506a41af5827d5c7f6db570dfe473/lib/bundleup/console.rb#L32-L43
valid
mattbrictson/bundleup
lib/bundleup/console.rb
Bundleup.Console.tableize
def tableize(rows, &block) rows = rows.map(&block) if block widths = max_length_of_each_column(rows) rows.map do |row| row.zip(widths).map { |value, width| value.ljust(width) }.join(" ") end end
ruby
def tableize(rows, &block) rows = rows.map(&block) if block widths = max_length_of_each_column(rows) rows.map do |row| row.zip(widths).map { |value, width| value.ljust(width) }.join(" ") end end
[ "def", "tableize", "(", "rows", ",", "&", "block", ")", "rows", "=", "rows", ".", "map", "(", "&", "block", ")", "if", "block", "widths", "=", "max_length_of_each_column", "(", "rows", ")", "rows", ".", "map", "do", "|", "row", "|", "row", ".", "zi...
Given a two-dimensional Array of strings representing a table of data, translate each row into a single string by joining the values with whitespace such that all the columns are nicely aligned. If a block is given, map the rows through the block first. These two usages are equivalent: tableize(rows.map(&somet...
[ "Given", "a", "two", "-", "dimensional", "Array", "of", "strings", "representing", "a", "table", "of", "data", "translate", "each", "row", "into", "a", "single", "string", "by", "joining", "the", "values", "with", "whitespace", "such", "that", "all", "the", ...
2d0c63fae76506a41af5827d5c7f6db570dfe473
https://github.com/mattbrictson/bundleup/blob/2d0c63fae76506a41af5827d5c7f6db570dfe473/lib/bundleup/console.rb#L58-L64
valid
mattbrictson/bundleup
lib/bundleup/console.rb
Bundleup.Console.observing_thread
def observing_thread(callable, initial_wait, periodic_wait) thread = Thread.new(&callable) wait_for_exit(thread, initial_wait) loop do break if wait_for_exit(thread, periodic_wait) yield end thread.value end
ruby
def observing_thread(callable, initial_wait, periodic_wait) thread = Thread.new(&callable) wait_for_exit(thread, initial_wait) loop do break if wait_for_exit(thread, periodic_wait) yield end thread.value end
[ "def", "observing_thread", "(", "callable", ",", "initial_wait", ",", "periodic_wait", ")", "thread", "=", "Thread", ".", "new", "(", "&", "callable", ")", "wait_for_exit", "(", "thread", ",", "initial_wait", ")", "loop", "do", "break", "if", "wait_for_exit", ...
Starts the `callable` in a background thread and waits for it to complete. If the callable fails with an exception, it will be raised here. Otherwise the main thread is paused for an `initial_wait` time in seconds, and subsequently for `periodic_wait` repeatedly until the thread completes. After each wait, `yield` ...
[ "Starts", "the", "callable", "in", "a", "background", "thread", "and", "waits", "for", "it", "to", "complete", ".", "If", "the", "callable", "fails", "with", "an", "exception", "it", "will", "be", "raised", "here", ".", "Otherwise", "the", "main", "thread"...
2d0c63fae76506a41af5827d5c7f6db570dfe473
https://github.com/mattbrictson/bundleup/blob/2d0c63fae76506a41af5827d5c7f6db570dfe473/lib/bundleup/console.rb#L79-L88
valid
leesharma/rescuetime
lib/rescuetime/collection.rb
Rescuetime.Collection.all
def all requester = Rescuetime::Requester host = HOST parse_response requester.get(host, params) end
ruby
def all requester = Rescuetime::Requester host = HOST parse_response requester.get(host, params) end
[ "def", "all", "requester", "=", "Rescuetime", "::", "Requester", "host", "=", "HOST", "parse_response", "requester", ".", "get", "(", "host", ",", "params", ")", "end" ]
Performs the rescuetime query and returns an array or csv response. @return [Array, CSV] @see Rescuetime::Requester#get
[ "Performs", "the", "rescuetime", "query", "and", "returns", "an", "array", "or", "csv", "response", "." ]
c69e6d41f31dbaf5053be51a1e45293605612f1e
https://github.com/leesharma/rescuetime/blob/c69e6d41f31dbaf5053be51a1e45293605612f1e/lib/rescuetime/collection.rb#L41-L45
valid
leesharma/rescuetime
lib/rescuetime/collection.rb
Rescuetime.Collection.format
def format(format) # Guard: fail if the passed format isn't on the whitelist format = format.to_s formatters.all.include?(format) || raise(Errors::InvalidFormatError) @format = format self end
ruby
def format(format) # Guard: fail if the passed format isn't on the whitelist format = format.to_s formatters.all.include?(format) || raise(Errors::InvalidFormatError) @format = format self end
[ "def", "format", "(", "format", ")", "format", "=", "format", ".", "to_s", "formatters", ".", "all", ".", "include?", "(", "format", ")", "||", "raise", "(", "Errors", "::", "InvalidFormatError", ")", "@format", "=", "format", "self", "end" ]
Sets the report format to a valid type @param [#to_s] format desired report format (one of 'array' or 'csv') @return [Rescuetime::Collection] TODO: make chainable to the client
[ "Sets", "the", "report", "format", "to", "a", "valid", "type" ]
c69e6d41f31dbaf5053be51a1e45293605612f1e
https://github.com/leesharma/rescuetime/blob/c69e6d41f31dbaf5053be51a1e45293605612f1e/lib/rescuetime/collection.rb#L64-L71
valid