id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
13,000 | haml/haml | lib/haml/helpers.rb | Haml.Helpers.with_haml_buffer | def with_haml_buffer(buffer)
@haml_buffer, old_buffer = buffer, @haml_buffer
old_buffer.active, old_was_active = false, old_buffer.active? if old_buffer
@haml_buffer.active, was_active = true, @haml_buffer.active?
yield
ensure
@haml_buffer.active = was_active
old_buffer.active = ... | ruby | def with_haml_buffer(buffer)
@haml_buffer, old_buffer = buffer, @haml_buffer
old_buffer.active, old_was_active = false, old_buffer.active? if old_buffer
@haml_buffer.active, was_active = true, @haml_buffer.active?
yield
ensure
@haml_buffer.active = was_active
old_buffer.active = ... | [
"def",
"with_haml_buffer",
"(",
"buffer",
")",
"@haml_buffer",
",",
"old_buffer",
"=",
"buffer",
",",
"@haml_buffer",
"old_buffer",
".",
"active",
",",
"old_was_active",
"=",
"false",
",",
"old_buffer",
".",
"active?",
"if",
"old_buffer",
"@haml_buffer",
".",
"a... | Runs a block of code with the given buffer as the currently active buffer.
@param buffer [Haml::Buffer] The Haml buffer to use temporarily
@yield A block in which the given buffer should be used | [
"Runs",
"a",
"block",
"of",
"code",
"with",
"the",
"given",
"buffer",
"as",
"the",
"currently",
"active",
"buffer",
"."
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/helpers.rb#L659-L668 |
13,001 | haml/haml | lib/haml/helpers.rb | Haml.Helpers.haml_bind_proc | def haml_bind_proc(&proc)
_hamlout = haml_buffer
#double assignment is to avoid warnings
_erbout = _erbout = _hamlout.buffer
proc { |*args| proc.call(*args) }
end | ruby | def haml_bind_proc(&proc)
_hamlout = haml_buffer
#double assignment is to avoid warnings
_erbout = _erbout = _hamlout.buffer
proc { |*args| proc.call(*args) }
end | [
"def",
"haml_bind_proc",
"(",
"&",
"proc",
")",
"_hamlout",
"=",
"haml_buffer",
"#double assignment is to avoid warnings",
"_erbout",
"=",
"_erbout",
"=",
"_hamlout",
".",
"buffer",
"proc",
"{",
"|",
"*",
"args",
"|",
"proc",
".",
"call",
"(",
"args",
")",
"... | Gives a proc the same local `_hamlout` and `_erbout` variables
that the current template has.
@param proc [#call] The proc to bind
@return [Proc] A new proc with the new variables bound | [
"Gives",
"a",
"proc",
"the",
"same",
"local",
"_hamlout",
"and",
"_erbout",
"variables",
"that",
"the",
"current",
"template",
"has",
"."
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/helpers.rb#L682-L687 |
13,002 | haml/haml | lib/haml/parser.rb | Haml.Parser.process_indent | def process_indent(line)
return unless line.tabs <= @template_tabs && @template_tabs > 0
to_close = @template_tabs - line.tabs
to_close.times {|i| close unless to_close - 1 - i == 0 && continuation_script?(line.text)}
end | ruby | def process_indent(line)
return unless line.tabs <= @template_tabs && @template_tabs > 0
to_close = @template_tabs - line.tabs
to_close.times {|i| close unless to_close - 1 - i == 0 && continuation_script?(line.text)}
end | [
"def",
"process_indent",
"(",
"line",
")",
"return",
"unless",
"line",
".",
"tabs",
"<=",
"@template_tabs",
"&&",
"@template_tabs",
">",
"0",
"to_close",
"=",
"@template_tabs",
"-",
"line",
".",
"tabs",
"to_close",
".",
"times",
"{",
"|",
"i",
"|",
"close"... | Processes and deals with lowering indentation. | [
"Processes",
"and",
"deals",
"with",
"lowering",
"indentation",
"."
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/parser.rb#L233-L238 |
13,003 | haml/haml | lib/haml/parser.rb | Haml.Parser.process_line | def process_line(line)
case line.text[0]
when DIV_CLASS; push div(line)
when DIV_ID
return push plain(line) if %w[{ @ $].include?(line.text[1])
push div(line)
when ELEMENT; push tag(line)
when COMMENT; push comment(line.text[1..-1].lstrip)
when SANITIZE
return... | ruby | def process_line(line)
case line.text[0]
when DIV_CLASS; push div(line)
when DIV_ID
return push plain(line) if %w[{ @ $].include?(line.text[1])
push div(line)
when ELEMENT; push tag(line)
when COMMENT; push comment(line.text[1..-1].lstrip)
when SANITIZE
return... | [
"def",
"process_line",
"(",
"line",
")",
"case",
"line",
".",
"text",
"[",
"0",
"]",
"when",
"DIV_CLASS",
";",
"push",
"div",
"(",
"line",
")",
"when",
"DIV_ID",
"return",
"push",
"plain",
"(",
"line",
")",
"if",
"%w[",
"{",
"@",
"$",
"]",
".",
"... | Processes a single line of Haml.
This method doesn't return anything; it simply processes the line and
adds the appropriate code to `@precompiled`. | [
"Processes",
"a",
"single",
"line",
"of",
"Haml",
"."
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/parser.rb#L252-L287 |
13,004 | haml/haml | lib/haml/parser.rb | Haml.Parser.comment | def comment(text)
if text[0..1] == '!['
revealed = true
text = text[1..-1]
else
revealed = false
end
conditional, text = balance(text, ?[, ?]) if text[0] == ?[
text.strip!
if contains_interpolation?(text)
parse = true
text = unescape_interpol... | ruby | def comment(text)
if text[0..1] == '!['
revealed = true
text = text[1..-1]
else
revealed = false
end
conditional, text = balance(text, ?[, ?]) if text[0] == ?[
text.strip!
if contains_interpolation?(text)
parse = true
text = unescape_interpol... | [
"def",
"comment",
"(",
"text",
")",
"if",
"text",
"[",
"0",
"..",
"1",
"]",
"==",
"'!['",
"revealed",
"=",
"true",
"text",
"=",
"text",
"[",
"1",
"..",
"-",
"1",
"]",
"else",
"revealed",
"=",
"false",
"end",
"conditional",
",",
"text",
"=",
"bala... | Renders an XHTML comment. | [
"Renders",
"an",
"XHTML",
"comment",
"."
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/parser.rb#L467-L490 |
13,005 | haml/haml | lib/haml/parser.rb | Haml.Parser.doctype | def doctype(text)
raise SyntaxError.new(Error.message(:illegal_nesting_header), @next_line.index) if block_opened?
version, type, encoding = text[3..-1].strip.downcase.scan(DOCTYPE_REGEX)[0]
ParseNode.new(:doctype, @line.index + 1, :version => version, :type => type, :encoding => encoding)
end | ruby | def doctype(text)
raise SyntaxError.new(Error.message(:illegal_nesting_header), @next_line.index) if block_opened?
version, type, encoding = text[3..-1].strip.downcase.scan(DOCTYPE_REGEX)[0]
ParseNode.new(:doctype, @line.index + 1, :version => version, :type => type, :encoding => encoding)
end | [
"def",
"doctype",
"(",
"text",
")",
"raise",
"SyntaxError",
".",
"new",
"(",
"Error",
".",
"message",
"(",
":illegal_nesting_header",
")",
",",
"@next_line",
".",
"index",
")",
"if",
"block_opened?",
"version",
",",
"type",
",",
"encoding",
"=",
"text",
"[... | Renders an XHTML doctype or XML shebang. | [
"Renders",
"an",
"XHTML",
"doctype",
"or",
"XML",
"shebang",
"."
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/parser.rb#L493-L497 |
13,006 | haml/haml | lib/haml/parser.rb | Haml.Parser.parse_tag | def parse_tag(text)
match = text.scan(/%([-:\w]+)([-:\w.#\@]*)(.+)?/)[0]
raise SyntaxError.new(Error.message(:invalid_tag, text)) unless match
tag_name, attributes, rest = match
if !attributes.empty? && (attributes =~ /[.#](\.|#|\z)/)
raise SyntaxError.new(Error.message(:illegal_elemen... | ruby | def parse_tag(text)
match = text.scan(/%([-:\w]+)([-:\w.#\@]*)(.+)?/)[0]
raise SyntaxError.new(Error.message(:invalid_tag, text)) unless match
tag_name, attributes, rest = match
if !attributes.empty? && (attributes =~ /[.#](\.|#|\z)/)
raise SyntaxError.new(Error.message(:illegal_elemen... | [
"def",
"parse_tag",
"(",
"text",
")",
"match",
"=",
"text",
".",
"scan",
"(",
"/",
"\\w",
"\\w",
"\\@",
"/",
")",
"[",
"0",
"]",
"raise",
"SyntaxError",
".",
"new",
"(",
"Error",
".",
"message",
"(",
":invalid_tag",
",",
"text",
")",
")",
"unless",... | Parses a line into tag_name, attributes, attributes_hash, object_ref, action, value | [
"Parses",
"a",
"line",
"into",
"tag_name",
"attributes",
"attributes_hash",
"object_ref",
"action",
"value"
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/parser.rb#L596-L646 |
13,007 | haml/haml | lib/haml/parser.rb | Haml.Parser.is_multiline? | def is_multiline?(text)
text && text.length > 1 && text[-1] == MULTILINE_CHAR_VALUE && text[-2] == ?\s && text !~ BLOCK_WITH_SPACES
end | ruby | def is_multiline?(text)
text && text.length > 1 && text[-1] == MULTILINE_CHAR_VALUE && text[-2] == ?\s && text !~ BLOCK_WITH_SPACES
end | [
"def",
"is_multiline?",
"(",
"text",
")",
"text",
"&&",
"text",
".",
"length",
">",
"1",
"&&",
"text",
"[",
"-",
"1",
"]",
"==",
"MULTILINE_CHAR_VALUE",
"&&",
"text",
"[",
"-",
"2",
"]",
"==",
"?\\s",
"&&",
"text",
"!~",
"BLOCK_WITH_SPACES",
"end"
] | Checks whether or not `line` is in a multiline sequence. | [
"Checks",
"whether",
"or",
"not",
"line",
"is",
"in",
"a",
"multiline",
"sequence",
"."
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/parser.rb#L780-L782 |
13,008 | haml/haml | lib/haml/compiler.rb | Haml.Compiler.push_silent | def push_silent(text, can_suppress = false)
flush_merged_text
return if can_suppress && @options.suppress_eval?
newline = (text == "end") ? ";" : "\n"
@temple << [:code, "#{resolve_newlines}#{text}#{newline}"]
@output_line = @output_line + text.count("\n") + newline.count("\n")
end | ruby | def push_silent(text, can_suppress = false)
flush_merged_text
return if can_suppress && @options.suppress_eval?
newline = (text == "end") ? ";" : "\n"
@temple << [:code, "#{resolve_newlines}#{text}#{newline}"]
@output_line = @output_line + text.count("\n") + newline.count("\n")
end | [
"def",
"push_silent",
"(",
"text",
",",
"can_suppress",
"=",
"false",
")",
"flush_merged_text",
"return",
"if",
"can_suppress",
"&&",
"@options",
".",
"suppress_eval?",
"newline",
"=",
"(",
"text",
"==",
"\"end\"",
")",
"?",
"\";\"",
":",
"\"\\n\"",
"@temple",... | Evaluates `text` in the context of the scope object, but
does not output the result. | [
"Evaluates",
"text",
"in",
"the",
"context",
"of",
"the",
"scope",
"object",
"but",
"does",
"not",
"output",
"the",
"result",
"."
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/compiler.rb#L219-L225 |
13,009 | haml/haml | lib/haml/compiler.rb | Haml.Compiler.rstrip_buffer! | def rstrip_buffer!(index = -1)
last = @to_merge[index]
if last.nil?
push_silent("_hamlout.rstrip!", false)
return
end
case last.first
when :text
last[1] = last[1].rstrip
if last[1].empty?
@to_merge.slice! index
rstrip_buffer! index
... | ruby | def rstrip_buffer!(index = -1)
last = @to_merge[index]
if last.nil?
push_silent("_hamlout.rstrip!", false)
return
end
case last.first
when :text
last[1] = last[1].rstrip
if last[1].empty?
@to_merge.slice! index
rstrip_buffer! index
... | [
"def",
"rstrip_buffer!",
"(",
"index",
"=",
"-",
"1",
")",
"last",
"=",
"@to_merge",
"[",
"index",
"]",
"if",
"last",
".",
"nil?",
"push_silent",
"(",
"\"_hamlout.rstrip!\"",
",",
"false",
")",
"return",
"end",
"case",
"last",
".",
"first",
"when",
":tex... | Get rid of and whitespace at the end of the buffer
or the merged text | [
"Get",
"rid",
"of",
"and",
"whitespace",
"at",
"the",
"end",
"of",
"the",
"buffer",
"or",
"the",
"merged",
"text"
] | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/compiler.rb#L309-L329 |
13,010 | haml/haml | lib/haml/filters.rb | Haml.Filters.remove_filter | def remove_filter(name)
defined.delete name.to_s.downcase
if constants.map(&:to_s).include?(name.to_s)
remove_const name.to_sym
end
end | ruby | def remove_filter(name)
defined.delete name.to_s.downcase
if constants.map(&:to_s).include?(name.to_s)
remove_const name.to_sym
end
end | [
"def",
"remove_filter",
"(",
"name",
")",
"defined",
".",
"delete",
"name",
".",
"to_s",
".",
"downcase",
"if",
"constants",
".",
"map",
"(",
":to_s",
")",
".",
"include?",
"(",
"name",
".",
"to_s",
")",
"remove_const",
"name",
".",
"to_sym",
"end",
"e... | Removes a filter from Haml. If the filter was removed, it returns
the Module that was removed upon success, or nil on failure. If you try
to redefine a filter, Haml will raise an error. Use this method first to
explicitly remove the filter before redefining it.
@return Module The filter module that has been removed... | [
"Removes",
"a",
"filter",
"from",
"Haml",
".",
"If",
"the",
"filter",
"was",
"removed",
"it",
"returns",
"the",
"Module",
"that",
"was",
"removed",
"upon",
"success",
"or",
"nil",
"on",
"failure",
".",
"If",
"you",
"try",
"to",
"redefine",
"a",
"filter",... | 9aa0fbe4a91b999978927be569d2ad0cd39076f1 | https://github.com/haml/haml/blob/9aa0fbe4a91b999978927be569d2ad0cd39076f1/lib/haml/filters.rb#L68-L73 |
13,011 | watir/watir | lib/watir/wait.rb | Watir.Waitable.wait_until | def wait_until(depr_timeout = nil, depr_message = nil, timeout: nil, message: nil, interval: nil, **opt, &blk)
if depr_message || depr_timeout
Watir.logger.deprecate 'Using arguments for #wait_until', 'keywords', ids: [:timeout_arguments]
timeout = depr_timeout
message = depr_message
... | ruby | def wait_until(depr_timeout = nil, depr_message = nil, timeout: nil, message: nil, interval: nil, **opt, &blk)
if depr_message || depr_timeout
Watir.logger.deprecate 'Using arguments for #wait_until', 'keywords', ids: [:timeout_arguments]
timeout = depr_timeout
message = depr_message
... | [
"def",
"wait_until",
"(",
"depr_timeout",
"=",
"nil",
",",
"depr_message",
"=",
"nil",
",",
"timeout",
":",
"nil",
",",
"message",
":",
"nil",
",",
"interval",
":",
"nil",
",",
"**",
"opt",
",",
"&",
"blk",
")",
"if",
"depr_message",
"||",
"depr_timeou... | Waits until the condition is true.
@example
browser.wait_until(timeout: 2) do |browser|
browser.windows.size == 1
end
@example
browser.text_field(name: "new_user_first_name").wait_until(&:present?).click
browser.text_field(name: "new_user_first_name").wait_until(message: 'foo') { |field| field.pres... | [
"Waits",
"until",
"the",
"condition",
"is",
"true",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/wait.rb#L114-L128 |
13,012 | watir/watir | lib/watir/wait.rb | Watir.Waitable.wait_until_present | def wait_until_present(depr_timeout = nil, timeout: nil, interval: nil, message: nil)
timeout = depr_timeout if depr_timeout
Watir.logger.deprecate "#{self.class}#wait_until_present",
"#{self.class}#wait_until(&:present?)",
ids: [:wait_until_present]... | ruby | def wait_until_present(depr_timeout = nil, timeout: nil, interval: nil, message: nil)
timeout = depr_timeout if depr_timeout
Watir.logger.deprecate "#{self.class}#wait_until_present",
"#{self.class}#wait_until(&:present?)",
ids: [:wait_until_present]... | [
"def",
"wait_until_present",
"(",
"depr_timeout",
"=",
"nil",
",",
"timeout",
":",
"nil",
",",
"interval",
":",
"nil",
",",
"message",
":",
"nil",
")",
"timeout",
"=",
"depr_timeout",
"if",
"depr_timeout",
"Watir",
".",
"logger",
".",
"deprecate",
"\"#{self.... | Waits until the element is present.
Element is always relocated, so this can be used in the case of an element going away and returning
@example
browser.text_field(name: "new_user_first_name").wait_until_present
@param [Integer] timeout seconds to wait before timing out
@param [Float] interval seconds to wait ... | [
"Waits",
"until",
"the",
"element",
"is",
"present",
".",
"Element",
"is",
"always",
"relocated",
"so",
"this",
"can",
"be",
"used",
"in",
"the",
"case",
"of",
"an",
"element",
"going",
"away",
"and",
"returning"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/wait.rb#L176-L184 |
13,013 | watir/watir | lib/watir/wait.rb | Watir.Waitable.wait_while_present | def wait_while_present(depr_timeout = nil, timeout: nil, interval: nil, message: nil)
timeout = depr_timeout if depr_timeout
Watir.logger.deprecate "#{self.class}#wait_while_present",
"#{self.class}#wait_while(&:present?)",
ids: [:wait_while_present]... | ruby | def wait_while_present(depr_timeout = nil, timeout: nil, interval: nil, message: nil)
timeout = depr_timeout if depr_timeout
Watir.logger.deprecate "#{self.class}#wait_while_present",
"#{self.class}#wait_while(&:present?)",
ids: [:wait_while_present]... | [
"def",
"wait_while_present",
"(",
"depr_timeout",
"=",
"nil",
",",
"timeout",
":",
"nil",
",",
"interval",
":",
"nil",
",",
"message",
":",
"nil",
")",
"timeout",
"=",
"depr_timeout",
"if",
"depr_timeout",
"Watir",
".",
"logger",
".",
"deprecate",
"\"#{self.... | Waits while the element is present.
Element is always relocated, so this can be used in the case of the element changing attributes
@example
browser.text_field(name: "abrakadbra").wait_while_present
@param [Integer] timeout seconds to wait before timing out
@param [Float] interval seconds to wait before each t... | [
"Waits",
"while",
"the",
"element",
"is",
"present",
".",
"Element",
"is",
"always",
"relocated",
"so",
"this",
"can",
"be",
"used",
"in",
"the",
"case",
"of",
"the",
"element",
"changing",
"attributes"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/wait.rb#L201-L209 |
13,014 | watir/watir | lib/watir/user_editable.rb | Watir.UserEditable.set! | def set!(*args)
msg = '#set! does not support special keys, use #set instead'
raise ArgumentError, msg if args.any? { |v| v.is_a?(::Symbol) }
input_value = args.join
set input_value[0]
return content_editable_set!(*args) if @content_editable
element_call { execute_js(:setValue, @el... | ruby | def set!(*args)
msg = '#set! does not support special keys, use #set instead'
raise ArgumentError, msg if args.any? { |v| v.is_a?(::Symbol) }
input_value = args.join
set input_value[0]
return content_editable_set!(*args) if @content_editable
element_call { execute_js(:setValue, @el... | [
"def",
"set!",
"(",
"*",
"args",
")",
"msg",
"=",
"'#set! does not support special keys, use #set instead'",
"raise",
"ArgumentError",
",",
"msg",
"if",
"args",
".",
"any?",
"{",
"|",
"v",
"|",
"v",
".",
"is_a?",
"(",
"::",
"Symbol",
")",
"}",
"input_value",... | Uses JavaScript to enter most of the given value.
Selenium is used to enter the first and last characters
@param [String, Symbol] args | [
"Uses",
"JavaScript",
"to",
"enter",
"most",
"of",
"the",
"given",
"value",
".",
"Selenium",
"is",
"used",
"to",
"enter",
"the",
"first",
"and",
"last",
"characters"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/user_editable.rb#L24-L37 |
13,015 | watir/watir | lib/watir/elements/iframe.rb | Watir.IFrame.execute_script | def execute_script(script, *args)
args.map! do |e|
e.is_a?(Element) ? e.wait_until(&:exists?).wd : e
end
returned = driver.execute_script(script, *args)
browser.wrap_elements_in(self, returned)
end | ruby | def execute_script(script, *args)
args.map! do |e|
e.is_a?(Element) ? e.wait_until(&:exists?).wd : e
end
returned = driver.execute_script(script, *args)
browser.wrap_elements_in(self, returned)
end | [
"def",
"execute_script",
"(",
"script",
",",
"*",
"args",
")",
"args",
".",
"map!",
"do",
"|",
"e",
"|",
"e",
".",
"is_a?",
"(",
"Element",
")",
"?",
"e",
".",
"wait_until",
"(",
":exists?",
")",
".",
"wd",
":",
"e",
"end",
"returned",
"=",
"driv... | Executes JavaScript snippet in context of frame.
@see Watir::Browser#execute_script | [
"Executes",
"JavaScript",
"snippet",
"in",
"context",
"of",
"frame",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/iframe.rb#L47-L54 |
13,016 | watir/watir | lib/watir/js_execution.rb | Watir.JSExecution.fire_event | def fire_event(event_name)
event_name = event_name.to_s.sub(/^on/, '').downcase
element_call { execute_js :fireEvent, @element, event_name }
end | ruby | def fire_event(event_name)
event_name = event_name.to_s.sub(/^on/, '').downcase
element_call { execute_js :fireEvent, @element, event_name }
end | [
"def",
"fire_event",
"(",
"event_name",
")",
"event_name",
"=",
"event_name",
".",
"to_s",
".",
"sub",
"(",
"/",
"/",
",",
"''",
")",
".",
"downcase",
"element_call",
"{",
"execute_js",
":fireEvent",
",",
"@element",
",",
"event_name",
"}",
"end"
] | Simulates JavaScript events on element.
Note that you may omit "on" from event name.
@example
browser.button(name: "new_user_button").fire_event :click
browser.button(name: "new_user_button").fire_event "mousemove"
browser.button(name: "new_user_button").fire_event "onmouseover"
@param [String, Symbol] ev... | [
"Simulates",
"JavaScript",
"events",
"on",
"element",
".",
"Note",
"that",
"you",
"may",
"omit",
"on",
"from",
"event",
"name",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/js_execution.rb#L22-L26 |
13,017 | watir/watir | lib/watir/elements/select.rb | Watir.Select.include? | def include?(str_or_rx)
option(text: str_or_rx).exist? || option(label: str_or_rx).exist?
end | ruby | def include?(str_or_rx)
option(text: str_or_rx).exist? || option(label: str_or_rx).exist?
end | [
"def",
"include?",
"(",
"str_or_rx",
")",
"option",
"(",
"text",
":",
"str_or_rx",
")",
".",
"exist?",
"||",
"option",
"(",
"label",
":",
"str_or_rx",
")",
".",
"exist?",
"end"
] | Returns true if the select list has one or more options where text or label matches the given value.
@param [String, Regexp] str_or_rx
@return [Boolean] | [
"Returns",
"true",
"if",
"the",
"select",
"list",
"has",
"one",
"or",
"more",
"options",
"where",
"text",
"or",
"label",
"matches",
"the",
"given",
"value",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/select.rb#L20-L22 |
13,018 | watir/watir | lib/watir/elements/select.rb | Watir.Select.select | def select(*str_or_rx)
results = str_or_rx.flatten.map { |v| select_by v }
results.first
end | ruby | def select(*str_or_rx)
results = str_or_rx.flatten.map { |v| select_by v }
results.first
end | [
"def",
"select",
"(",
"*",
"str_or_rx",
")",
"results",
"=",
"str_or_rx",
".",
"flatten",
".",
"map",
"{",
"|",
"v",
"|",
"select_by",
"v",
"}",
"results",
".",
"first",
"end"
] | Select the option whose text or label matches the given string.
@param [String, Regexp] str_or_rx
@raise [Watir::Exception::NoValueFoundException] if the value does not exist.
@return [String] The text of the option selected. If multiple options match, returns the first match. | [
"Select",
"the",
"option",
"whose",
"text",
"or",
"label",
"matches",
"the",
"given",
"string",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/select.rb#L32-L35 |
13,019 | watir/watir | lib/watir/elements/select.rb | Watir.Select.select_all | def select_all(*str_or_rx)
results = str_or_rx.flatten.map { |v| select_all_by v }
results.first
end | ruby | def select_all(*str_or_rx)
results = str_or_rx.flatten.map { |v| select_all_by v }
results.first
end | [
"def",
"select_all",
"(",
"*",
"str_or_rx",
")",
"results",
"=",
"str_or_rx",
".",
"flatten",
".",
"map",
"{",
"|",
"v",
"|",
"select_all_by",
"v",
"}",
"results",
".",
"first",
"end"
] | Select all options whose text or label matches the given string.
@param [String, Regexp] str_or_rx
@raise [Watir::Exception::NoValueFoundException] if the value does not exist.
@return [String] The text of the first option selected. | [
"Select",
"all",
"options",
"whose",
"text",
"or",
"label",
"matches",
"the",
"given",
"string",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/select.rb#L45-L48 |
13,020 | watir/watir | lib/watir/elements/select.rb | Watir.Select.select! | def select!(*str_or_rx)
results = str_or_rx.flatten.map { |v| select_by!(v, :single) }
results.first
end | ruby | def select!(*str_or_rx)
results = str_or_rx.flatten.map { |v| select_by!(v, :single) }
results.first
end | [
"def",
"select!",
"(",
"*",
"str_or_rx",
")",
"results",
"=",
"str_or_rx",
".",
"flatten",
".",
"map",
"{",
"|",
"v",
"|",
"select_by!",
"(",
"v",
",",
":single",
")",
"}",
"results",
".",
"first",
"end"
] | Uses JavaScript to select the option whose text matches the given string.
@param [String, Regexp] str_or_rx
@raise [Watir::Exception::NoValueFoundException] if the value does not exist. | [
"Uses",
"JavaScript",
"to",
"select",
"the",
"option",
"whose",
"text",
"matches",
"the",
"given",
"string",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/select.rb#L57-L60 |
13,021 | watir/watir | lib/watir/elements/select.rb | Watir.Select.select_all! | def select_all!(*str_or_rx)
results = str_or_rx.flatten.map { |v| select_by!(v, :multiple) }
results.first
end | ruby | def select_all!(*str_or_rx)
results = str_or_rx.flatten.map { |v| select_by!(v, :multiple) }
results.first
end | [
"def",
"select_all!",
"(",
"*",
"str_or_rx",
")",
"results",
"=",
"str_or_rx",
".",
"flatten",
".",
"map",
"{",
"|",
"v",
"|",
"select_by!",
"(",
"v",
",",
":multiple",
")",
"}",
"results",
".",
"first",
"end"
] | Uses JavaScript to select all options whose text matches the given string.
@param [String, Regexp] str_or_rx
@raise [Watir::Exception::NoValueFoundException] if the value does not exist. | [
"Uses",
"JavaScript",
"to",
"select",
"all",
"options",
"whose",
"text",
"matches",
"the",
"given",
"string",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/select.rb#L69-L72 |
13,022 | watir/watir | lib/watir/elements/file_field.rb | Watir.FileField.value= | def value=(path)
path = path.gsub(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
element_call { @element.send_keys path }
end | ruby | def value=(path)
path = path.gsub(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
element_call { @element.send_keys path }
end | [
"def",
"value",
"=",
"(",
"path",
")",
"path",
"=",
"path",
".",
"gsub",
"(",
"File",
"::",
"SEPARATOR",
",",
"File",
"::",
"ALT_SEPARATOR",
")",
"if",
"File",
"::",
"ALT_SEPARATOR",
"element_call",
"{",
"@element",
".",
"send_keys",
"path",
"}",
"end"
] | Sets the file field to the given path
@param [String] path | [
"Sets",
"the",
"file",
"field",
"to",
"the",
"given",
"path"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/file_field.rb#L22-L25 |
13,023 | watir/watir | lib/watir/navigation.rb | Watir.Navigation.goto | def goto(uri)
uri = "http://#{uri}" unless uri =~ URI::DEFAULT_PARSER.make_regexp
@driver.navigate.to uri
@after_hooks.run
uri
end | ruby | def goto(uri)
uri = "http://#{uri}" unless uri =~ URI::DEFAULT_PARSER.make_regexp
@driver.navigate.to uri
@after_hooks.run
uri
end | [
"def",
"goto",
"(",
"uri",
")",
"uri",
"=",
"\"http://#{uri}\"",
"unless",
"uri",
"=~",
"URI",
"::",
"DEFAULT_PARSER",
".",
"make_regexp",
"@driver",
".",
"navigate",
".",
"to",
"uri",
"@after_hooks",
".",
"run",
"uri",
"end"
] | Goes to the given URL.
@example
browser.goto "watir.github.io"
@param [String] uri The url.
@return [String] The url you end up at. | [
"Goes",
"to",
"the",
"given",
"URL",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/navigation.rb#L13-L20 |
13,024 | watir/watir | lib/watir/logger.rb | Watir.Logger.warn | def warn(message, ids: [], &block)
msg = ids.empty? ? '' : "[#{ids.map!(&:to_s).map(&:inspect).join(', ')}] "
msg += message
@logger.warn(msg, &block) unless (@ignored & ids).any?
end | ruby | def warn(message, ids: [], &block)
msg = ids.empty? ? '' : "[#{ids.map!(&:to_s).map(&:inspect).join(', ')}] "
msg += message
@logger.warn(msg, &block) unless (@ignored & ids).any?
end | [
"def",
"warn",
"(",
"message",
",",
"ids",
":",
"[",
"]",
",",
"&",
"block",
")",
"msg",
"=",
"ids",
".",
"empty?",
"?",
"''",
":",
"\"[#{ids.map!(&:to_s).map(&:inspect).join(', ')}] \"",
"msg",
"+=",
"message",
"@logger",
".",
"warn",
"(",
"msg",
",",
"... | Only log a warn message if it is not set to be ignored. | [
"Only",
"log",
"a",
"warn",
"message",
"if",
"it",
"is",
"not",
"set",
"to",
"be",
"ignored",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/logger.rb#L48-L52 |
13,025 | watir/watir | lib/watir/logger.rb | Watir.Logger.deprecate | def deprecate(old, new, reference: '', ids: [])
return if @ignored.include?('deprecations') || (@ignored & ids.map!(&:to_s)).any?
msg = ids.empty? ? '' : "[#{ids.map(&:inspect).join(', ')}] "
ref_msg = reference.empty? ? '.' : "; see explanation for this deprecation: #{reference}."
warn "[DEPRE... | ruby | def deprecate(old, new, reference: '', ids: [])
return if @ignored.include?('deprecations') || (@ignored & ids.map!(&:to_s)).any?
msg = ids.empty? ? '' : "[#{ids.map(&:inspect).join(', ')}] "
ref_msg = reference.empty? ? '.' : "; see explanation for this deprecation: #{reference}."
warn "[DEPRE... | [
"def",
"deprecate",
"(",
"old",
",",
"new",
",",
"reference",
":",
"''",
",",
"ids",
":",
"[",
"]",
")",
"return",
"if",
"@ignored",
".",
"include?",
"(",
"'deprecations'",
")",
"||",
"(",
"@ignored",
"&",
"ids",
".",
"map!",
"(",
":to_s",
")",
")"... | Marks code as deprecated with replacement.
@param [String] old
@param [String] new | [
"Marks",
"code",
"as",
"deprecated",
"with",
"replacement",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/logger.rb#L91-L97 |
13,026 | watir/watir | lib/watir/attribute_helper.rb | Watir.AttributeHelper.attribute | def attribute(type, method, attr)
typed_attributes[type] << [method, attr]
define_attribute(type, method, attr)
end | ruby | def attribute(type, method, attr)
typed_attributes[type] << [method, attr]
define_attribute(type, method, attr)
end | [
"def",
"attribute",
"(",
"type",
",",
"method",
",",
"attr",
")",
"typed_attributes",
"[",
"type",
"]",
"<<",
"[",
"method",
",",
"attr",
"]",
"define_attribute",
"(",
"type",
",",
"method",
",",
"attr",
")",
"end"
] | YARD macro to generated friendly
documentation for attributes.
@macro [attach] attribute
@method $2
@return [$1] value of $3 property | [
"YARD",
"macro",
"to",
"generated",
"friendly",
"documentation",
"for",
"attributes",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/attribute_helper.rb#L48-L51 |
13,027 | watir/watir | lib/watir/browser.rb | Watir.Browser.execute_script | def execute_script(script, *args)
args.map! do |e|
e.is_a?(Element) ? e.wait_until(&:exists?).wd : e
end
wrap_elements_in(self, @driver.execute_script(script, *args))
end | ruby | def execute_script(script, *args)
args.map! do |e|
e.is_a?(Element) ? e.wait_until(&:exists?).wd : e
end
wrap_elements_in(self, @driver.execute_script(script, *args))
end | [
"def",
"execute_script",
"(",
"script",
",",
"*",
"args",
")",
"args",
".",
"map!",
"do",
"|",
"e",
"|",
"e",
".",
"is_a?",
"(",
"Element",
")",
"?",
"e",
".",
"wait_until",
"(",
":exists?",
")",
".",
"wd",
":",
"e",
"end",
"wrap_elements_in",
"(",... | Executes JavaScript snippet.
If you are going to use the value snippet returns, make sure to use
`return` explicitly.
@example Check that Ajax requests are completed with jQuery
browser.execute_script("return jQuery.active") == 0
#=> true
@param [String] script JavaScript snippet to execute
@param args Ar... | [
"Executes",
"JavaScript",
"snippet",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/browser.rb#L216-L222 |
13,028 | watir/watir | lib/watir/window.rb | Watir.Window.resize_to | def resize_to(width, height)
Selenium::WebDriver::Dimension.new(Integer(width), Integer(height)).tap do |dimension|
use { @driver.manage.window.size = dimension }
end
end | ruby | def resize_to(width, height)
Selenium::WebDriver::Dimension.new(Integer(width), Integer(height)).tap do |dimension|
use { @driver.manage.window.size = dimension }
end
end | [
"def",
"resize_to",
"(",
"width",
",",
"height",
")",
"Selenium",
"::",
"WebDriver",
"::",
"Dimension",
".",
"new",
"(",
"Integer",
"(",
"width",
")",
",",
"Integer",
"(",
"height",
")",
")",
".",
"tap",
"do",
"|",
"dimension",
"|",
"use",
"{",
"@dri... | Resizes window to given width and height.
@example
browser.window.resize_to 1600, 1200
@param [Integer] width
@param [Integer] height | [
"Resizes",
"window",
"to",
"given",
"width",
"and",
"height",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/window.rb#L63-L67 |
13,029 | watir/watir | lib/watir/window.rb | Watir.Window.move_to | def move_to(x_coord, y_coord)
Selenium::WebDriver::Point.new(Integer(x_coord), Integer(y_coord)).tap do |point|
use { @driver.manage.window.position = point }
end
end | ruby | def move_to(x_coord, y_coord)
Selenium::WebDriver::Point.new(Integer(x_coord), Integer(y_coord)).tap do |point|
use { @driver.manage.window.position = point }
end
end | [
"def",
"move_to",
"(",
"x_coord",
",",
"y_coord",
")",
"Selenium",
"::",
"WebDriver",
"::",
"Point",
".",
"new",
"(",
"Integer",
"(",
"x_coord",
")",
",",
"Integer",
"(",
"y_coord",
")",
")",
".",
"tap",
"do",
"|",
"point",
"|",
"use",
"{",
"@driver"... | Moves window to given x and y coordinates.
@example
browser.window.move_to 300, 200
@param [Integer] x_coord
@param [Integer] y_coord | [
"Moves",
"window",
"to",
"given",
"x",
"and",
"y",
"coordinates",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/window.rb#L79-L83 |
13,030 | watir/watir | lib/watir/cookies.rb | Watir.Cookies.to_a | def to_a
@control.all_cookies.map do |e|
e.merge(expires: e[:expires] ? e[:expires].to_time : nil)
end
end | ruby | def to_a
@control.all_cookies.map do |e|
e.merge(expires: e[:expires] ? e[:expires].to_time : nil)
end
end | [
"def",
"to_a",
"@control",
".",
"all_cookies",
".",
"map",
"do",
"|",
"e",
"|",
"e",
".",
"merge",
"(",
"expires",
":",
"e",
"[",
":expires",
"]",
"?",
"e",
"[",
":expires",
"]",
".",
"to_time",
":",
"nil",
")",
"end",
"end"
] | Returns array of cookies.
@example
browser.cookies.to_a
#=> {:name=>"my_session", :value=>"BAh7B0kiD3Nlc3Npb25faWQGOgZFRkk", :domain=>"mysite.com"}
@return [Array<Hash>] | [
"Returns",
"array",
"of",
"cookies",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/cookies.rb#L19-L23 |
13,031 | watir/watir | lib/watir/cookies.rb | Watir.Cookies.add | def add(name, value, opts = {})
cookie = {
name: name,
value: value
}
cookie[:secure] = opts[:secure] if opts.key?(:secure)
cookie[:path] = opts[:path] if opts.key?(:path)
expires = opts[:expires]
if expires
cookie[:expires] = expires.is_a?(String) ? ::Time.pa... | ruby | def add(name, value, opts = {})
cookie = {
name: name,
value: value
}
cookie[:secure] = opts[:secure] if opts.key?(:secure)
cookie[:path] = opts[:path] if opts.key?(:path)
expires = opts[:expires]
if expires
cookie[:expires] = expires.is_a?(String) ? ::Time.pa... | [
"def",
"add",
"(",
"name",
",",
"value",
",",
"opts",
"=",
"{",
"}",
")",
"cookie",
"=",
"{",
"name",
":",
"name",
",",
"value",
":",
"value",
"}",
"cookie",
"[",
":secure",
"]",
"=",
"opts",
"[",
":secure",
"]",
"if",
"opts",
".",
"key?",
"(",... | Adds new cookie.
@example
browser.cookies.add 'my_session', 'BAh7B0kiD3Nlc3Npb25faWQGOgZFRkk', secure: true
@param [String] name
@param [String] value
@param [Hash] opts
@option opts [Boolean] :secure
@option opts [String] :path
@option opts [Time, DateTime, NilClass] :expires
@option opts [String] :domain | [
"Adds",
"new",
"cookie",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/cookies.rb#L55-L69 |
13,032 | watir/watir | lib/watir/cookies.rb | Watir.Cookies.load | def load(file = '.cookies')
YAML.safe_load(IO.read(file), [::Symbol, ::Time]).each do |c|
add(c.delete(:name), c.delete(:value), c)
end
end | ruby | def load(file = '.cookies')
YAML.safe_load(IO.read(file), [::Symbol, ::Time]).each do |c|
add(c.delete(:name), c.delete(:value), c)
end
end | [
"def",
"load",
"(",
"file",
"=",
"'.cookies'",
")",
"YAML",
".",
"safe_load",
"(",
"IO",
".",
"read",
"(",
"file",
")",
",",
"[",
"::",
"Symbol",
",",
"::",
"Time",
"]",
")",
".",
"each",
"do",
"|",
"c",
"|",
"add",
"(",
"c",
".",
"delete",
"... | Load cookies from file
@example
browser.cookies.load '.cookies'
@param [String] file | [
"Load",
"cookies",
"from",
"file"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/cookies.rb#L117-L121 |
13,033 | watir/watir | lib/watir/elements/table.rb | Watir.Table.headers | def headers(row = nil)
row ||= rows.first
header_type = row.th.exist? ? 'th' : 'td'
row.send("#{header_type}s")
end | ruby | def headers(row = nil)
row ||= rows.first
header_type = row.th.exist? ? 'th' : 'td'
row.send("#{header_type}s")
end | [
"def",
"headers",
"(",
"row",
"=",
"nil",
")",
"row",
"||=",
"rows",
".",
"first",
"header_type",
"=",
"row",
".",
"th",
".",
"exist?",
"?",
"'th'",
":",
"'td'",
"row",
".",
"send",
"(",
"\"#{header_type}s\"",
")",
"end"
] | Returns first row of Table with proper subtype
@return [TableCellCollection] | [
"Returns",
"first",
"row",
"of",
"Table",
"with",
"proper",
"subtype"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/table.rb#L44-L48 |
13,034 | watir/watir | lib/watir/radio_set.rb | Watir.RadioSet.select | def select(str_or_rx)
%i[value label].each do |key|
radio = radio(key => str_or_rx)
next unless radio.exist?
radio.click unless radio.selected?
return key == :value ? radio.value : radio.text
end
raise UnknownObjectException, "Unable to locate radio matching #{str_or_r... | ruby | def select(str_or_rx)
%i[value label].each do |key|
radio = radio(key => str_or_rx)
next unless radio.exist?
radio.click unless radio.selected?
return key == :value ? radio.value : radio.text
end
raise UnknownObjectException, "Unable to locate radio matching #{str_or_r... | [
"def",
"select",
"(",
"str_or_rx",
")",
"%i[",
"value",
"label",
"]",
".",
"each",
"do",
"|",
"key",
"|",
"radio",
"=",
"radio",
"(",
"key",
"=>",
"str_or_rx",
")",
"next",
"unless",
"radio",
".",
"exist?",
"radio",
".",
"click",
"unless",
"radio",
"... | Select the radio button whose value or label matches the given string.
@param [String, Regexp] str_or_rx
@raise [Watir::Exception::UnknownObjectException] if the Radio does not exist.
@return [String] The value or text of the radio selected. | [
"Select",
"the",
"radio",
"button",
"whose",
"value",
"or",
"label",
"matches",
"the",
"given",
"string",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/radio_set.rb#L132-L141 |
13,035 | watir/watir | lib/watir/radio_set.rb | Watir.RadioSet.selected? | def selected?(str_or_rx)
found = frame.radio(label: str_or_rx)
return found.selected? if found.exist?
raise UnknownObjectException, "Unable to locate radio matching #{str_or_rx.inspect}"
end | ruby | def selected?(str_or_rx)
found = frame.radio(label: str_or_rx)
return found.selected? if found.exist?
raise UnknownObjectException, "Unable to locate radio matching #{str_or_rx.inspect}"
end | [
"def",
"selected?",
"(",
"str_or_rx",
")",
"found",
"=",
"frame",
".",
"radio",
"(",
"label",
":",
"str_or_rx",
")",
"return",
"found",
".",
"selected?",
"if",
"found",
".",
"exist?",
"raise",
"UnknownObjectException",
",",
"\"Unable to locate radio matching #{str... | Returns true if any of the radio button label matches the given value.
@param [String, Regexp] str_or_rx
@raise [Watir::Exception::UnknownObjectException] if the options do not exist
@return [Boolean] | [
"Returns",
"true",
"if",
"any",
"of",
"the",
"radio",
"button",
"label",
"matches",
"the",
"given",
"value",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/radio_set.rb#L151-L156 |
13,036 | watir/watir | lib/watir/has_window.rb | Watir.HasWindow.windows | def windows(*args)
all = @driver.window_handles.map { |handle| Window.new(self, handle: handle) }
if args.empty?
all
else
filter_windows extract_selector(args), all
end
end | ruby | def windows(*args)
all = @driver.window_handles.map { |handle| Window.new(self, handle: handle) }
if args.empty?
all
else
filter_windows extract_selector(args), all
end
end | [
"def",
"windows",
"(",
"*",
"args",
")",
"all",
"=",
"@driver",
".",
"window_handles",
".",
"map",
"{",
"|",
"handle",
"|",
"Window",
".",
"new",
"(",
"self",
",",
"handle",
":",
"handle",
")",
"}",
"if",
"args",
".",
"empty?",
"all",
"else",
"filt... | Returns browser windows array.
@example
browser.windows(title: 'closeable window')
@return [Array<Window>] | [
"Returns",
"browser",
"windows",
"array",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/has_window.rb#L12-L20 |
13,037 | watir/watir | lib/watir/has_window.rb | Watir.HasWindow.window | def window(*args, &blk)
win = Window.new self, extract_selector(args)
win.use(&blk) if block_given?
win
end | ruby | def window(*args, &blk)
win = Window.new self, extract_selector(args)
win.use(&blk) if block_given?
win
end | [
"def",
"window",
"(",
"*",
"args",
",",
"&",
"blk",
")",
"win",
"=",
"Window",
".",
"new",
"self",
",",
"extract_selector",
"(",
"args",
")",
"win",
".",
"use",
"(",
"blk",
")",
"if",
"block_given?",
"win",
"end"
] | Returns browser window.
@example
browser.window(title: 'closeable window')
@return [Window] | [
"Returns",
"browser",
"window",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/has_window.rb#L31-L37 |
13,038 | watir/watir | lib/watir/scroll.rb | Watir.Scroll.to | def to(param = :top)
args = @object.is_a?(Watir::Element) ? element_scroll(param) : browser_scroll(param)
raise ArgumentError, "Don't know how to scroll #{@object} to: #{param}!" if args.nil?
@object.browser.execute_script(*args)
self
end | ruby | def to(param = :top)
args = @object.is_a?(Watir::Element) ? element_scroll(param) : browser_scroll(param)
raise ArgumentError, "Don't know how to scroll #{@object} to: #{param}!" if args.nil?
@object.browser.execute_script(*args)
self
end | [
"def",
"to",
"(",
"param",
"=",
":top",
")",
"args",
"=",
"@object",
".",
"is_a?",
"(",
"Watir",
"::",
"Element",
")",
"?",
"element_scroll",
"(",
"param",
")",
":",
"browser_scroll",
"(",
"param",
")",
"raise",
"ArgumentError",
",",
"\"Don't know how to s... | Scrolls to specified location.
@param [Symbol] param | [
"Scrolls",
"to",
"specified",
"location",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/scroll.rb#L26-L32 |
13,039 | watir/watir | lib/watir/adjacent.rb | Watir.Adjacent.children | def children(opt = {})
raise ArgumentError, '#children can not take an index value' if opt[:index]
xpath_adjacent(opt.merge(adjacent: :child, plural: true))
end | ruby | def children(opt = {})
raise ArgumentError, '#children can not take an index value' if opt[:index]
xpath_adjacent(opt.merge(adjacent: :child, plural: true))
end | [
"def",
"children",
"(",
"opt",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'#children can not take an index value'",
"if",
"opt",
"[",
":index",
"]",
"xpath_adjacent",
"(",
"opt",
".",
"merge",
"(",
"adjacent",
":",
":child",
",",
"plural",
":",
"tru... | Returns collection of elements of direct children of current element.
@example
children = browser.select_list(id: "new_user_languages").children
children == browser.select_list(id: "new_user_languages").options.to_a
#=> true | [
"Returns",
"collection",
"of",
"elements",
"of",
"direct",
"children",
"of",
"current",
"element",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/adjacent.rb#L105-L109 |
13,040 | watir/watir | lib/watir/legacy_wait.rb | Watir.EventuallyPresent.when_present | def when_present(timeout = nil)
msg = '#when_present'
repl_msg = '#wait_until_present if a wait is still needed'
Watir.logger.deprecate msg, repl_msg, ids: [:when_present]
timeout ||= Watir.default_timeout
message = "waiting for #{selector_string} to become present"
if block_given?... | ruby | def when_present(timeout = nil)
msg = '#when_present'
repl_msg = '#wait_until_present if a wait is still needed'
Watir.logger.deprecate msg, repl_msg, ids: [:when_present]
timeout ||= Watir.default_timeout
message = "waiting for #{selector_string} to become present"
if block_given?... | [
"def",
"when_present",
"(",
"timeout",
"=",
"nil",
")",
"msg",
"=",
"'#when_present'",
"repl_msg",
"=",
"'#wait_until_present if a wait is still needed'",
"Watir",
".",
"logger",
".",
"deprecate",
"msg",
",",
"repl_msg",
",",
"ids",
":",
"[",
":when_present",
"]",... | Waits until the element is present.
@example
browser.text_field(name: "new_user_first_name").when_present.click
browser.text_field(name: "new_user_first_name").when_present { |field| field.set "Watir" }
browser.text_field(name: "new_user_first_name").when_present(60).text
@param [Integer] timeout seconds t... | [
"Waits",
"until",
"the",
"element",
"is",
"present",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/legacy_wait.rb#L79-L93 |
13,041 | watir/watir | lib/watir/legacy_wait.rb | Watir.EventuallyPresent.when_enabled | def when_enabled(timeout = nil)
msg = '#when_enabled'
repl_msg = 'wait_until(&:enabled?)'
Watir.logger.deprecate msg, repl_msg, ids: [:when_enabled]
timeout ||= Watir.default_timeout
message = "waiting for #{selector_string} to become enabled"
if block_given?
Wait.until(tim... | ruby | def when_enabled(timeout = nil)
msg = '#when_enabled'
repl_msg = 'wait_until(&:enabled?)'
Watir.logger.deprecate msg, repl_msg, ids: [:when_enabled]
timeout ||= Watir.default_timeout
message = "waiting for #{selector_string} to become enabled"
if block_given?
Wait.until(tim... | [
"def",
"when_enabled",
"(",
"timeout",
"=",
"nil",
")",
"msg",
"=",
"'#when_enabled'",
"repl_msg",
"=",
"'wait_until(&:enabled?)'",
"Watir",
".",
"logger",
".",
"deprecate",
"msg",
",",
"repl_msg",
",",
"ids",
":",
"[",
":when_enabled",
"]",
"timeout",
"||=",
... | Waits until the element is enabled.
@example
browser.button(name: "new_user_button_2").when_enabled.click
@param [Integer] timeout seconds to wait before timing out
@see Watir::Wait
@see Watir::Element#enabled? | [
"Waits",
"until",
"the",
"element",
"is",
"enabled",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/legacy_wait.rb#L107-L121 |
13,042 | watir/watir | lib/watir/after_hooks.rb | Watir.AfterHooks.add | def add(after_hook = nil, &block)
if block_given?
@after_hooks << block
elsif after_hook.respond_to? :call
@after_hooks << after_hook
else
raise ArgumentError, 'expected block or object responding to #call'
end
end | ruby | def add(after_hook = nil, &block)
if block_given?
@after_hooks << block
elsif after_hook.respond_to? :call
@after_hooks << after_hook
else
raise ArgumentError, 'expected block or object responding to #call'
end
end | [
"def",
"add",
"(",
"after_hook",
"=",
"nil",
",",
"&",
"block",
")",
"if",
"block_given?",
"@after_hooks",
"<<",
"block",
"elsif",
"after_hook",
".",
"respond_to?",
":call",
"@after_hooks",
"<<",
"after_hook",
"else",
"raise",
"ArgumentError",
",",
"'expected bl... | Adds new after hook.
@example
browser.after_hooks.add do |browser|
browser.text.include?("Server Error") and puts "Application exception or 500 error!"
end
browser.goto "watir.com/404"
"Application exception or 500 error!"
@param [#call] after_hook Object responding to call
@yield after_hook block... | [
"Adds",
"new",
"after",
"hook",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/after_hooks.rb#L35-L43 |
13,043 | watir/watir | lib/watir/after_hooks.rb | Watir.AfterHooks.run | def run
# We can't just rescue exception because Firefox automatically closes alert when exception raised
return unless @after_hooks.any? && !@browser.alert.exists?
each { |after_hook| after_hook.call(@browser) }
rescue Selenium::WebDriver::Error::NoSuchWindowError => ex
Watir.logger.info "... | ruby | def run
# We can't just rescue exception because Firefox automatically closes alert when exception raised
return unless @after_hooks.any? && !@browser.alert.exists?
each { |after_hook| after_hook.call(@browser) }
rescue Selenium::WebDriver::Error::NoSuchWindowError => ex
Watir.logger.info "... | [
"def",
"run",
"# We can't just rescue exception because Firefox automatically closes alert when exception raised",
"return",
"unless",
"@after_hooks",
".",
"any?",
"&&",
"!",
"@browser",
".",
"alert",
".",
"exists?",
"each",
"{",
"|",
"after_hook",
"|",
"after_hook",
".",
... | Runs after hooks. | [
"Runs",
"after",
"hooks",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/after_hooks.rb#L67-L74 |
13,044 | watir/watir | lib/watir/elements/element.rb | Watir.Element.exists? | def exists?
if located? && stale?
Watir.logger.deprecate 'Checking `#exists? == false` to determine a stale element',
'`#stale? == true`',
reference: 'http://watir.com/staleness-changes',
ids: [:stale_exists]
... | ruby | def exists?
if located? && stale?
Watir.logger.deprecate 'Checking `#exists? == false` to determine a stale element',
'`#stale? == true`',
reference: 'http://watir.com/staleness-changes',
ids: [:stale_exists]
... | [
"def",
"exists?",
"if",
"located?",
"&&",
"stale?",
"Watir",
".",
"logger",
".",
"deprecate",
"'Checking `#exists? == false` to determine a stale element'",
",",
"'`#stale? == true`'",
",",
"reference",
":",
"'http://watir.com/staleness-changes'",
",",
"ids",
":",
"[",
":... | Returns true if element exists.
Checking for staleness is deprecated
@return [Boolean] | [
"Returns",
"true",
"if",
"element",
"exists",
".",
"Checking",
"for",
"staleness",
"is",
"deprecated"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/element.rb#L55-L69 |
13,045 | watir/watir | lib/watir/elements/element.rb | Watir.Element.click | def click(*modifiers)
# TODO: Should wait_for_enabled be default, or `Button` specific behavior?
element_call(:wait_for_enabled) do
if modifiers.any?
action = driver.action
modifiers.each { |mod| action.key_down mod }
action.click @element
modifiers.each { |mo... | ruby | def click(*modifiers)
# TODO: Should wait_for_enabled be default, or `Button` specific behavior?
element_call(:wait_for_enabled) do
if modifiers.any?
action = driver.action
modifiers.each { |mod| action.key_down mod }
action.click @element
modifiers.each { |mo... | [
"def",
"click",
"(",
"*",
"modifiers",
")",
"# TODO: Should wait_for_enabled be default, or `Button` specific behavior?",
"element_call",
"(",
":wait_for_enabled",
")",
"do",
"if",
"modifiers",
".",
"any?",
"action",
"=",
"driver",
".",
"action",
"modifiers",
".",
"each... | Clicks the element, optionally while pressing the given modifier keys.
Note that support for holding a modifier key is currently experimental,
and may not work at all.
@example Click an element
browser.element(name: "new_user_button").click
@example Click an element with shift key pressed
browser.element(na... | [
"Clicks",
"the",
"element",
"optionally",
"while",
"pressing",
"the",
"given",
"modifier",
"keys",
".",
"Note",
"that",
"support",
"for",
"holding",
"a",
"modifier",
"key",
"is",
"currently",
"experimental",
"and",
"may",
"not",
"work",
"at",
"all",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/element.rb#L143-L159 |
13,046 | watir/watir | lib/watir/elements/element.rb | Watir.Element.drag_and_drop_on | def drag_and_drop_on(other)
assert_is_element other
value = element_call(:wait_for_present) do
driver.action
.drag_and_drop(@element, other.wd)
.perform
end
browser.after_hooks.run
value
end | ruby | def drag_and_drop_on(other)
assert_is_element other
value = element_call(:wait_for_present) do
driver.action
.drag_and_drop(@element, other.wd)
.perform
end
browser.after_hooks.run
value
end | [
"def",
"drag_and_drop_on",
"(",
"other",
")",
"assert_is_element",
"other",
"value",
"=",
"element_call",
"(",
":wait_for_present",
")",
"do",
"driver",
".",
"action",
".",
"drag_and_drop",
"(",
"@element",
",",
"other",
".",
"wd",
")",
".",
"perform",
"end",
... | Drag and drop this element on to another element instance.
Note that browser support may vary.
@example
a = browser.div(id: "draggable")
b = browser.div(id: "droppable")
a.drag_and_drop_on b | [
"Drag",
"and",
"drop",
"this",
"element",
"on",
"to",
"another",
"element",
"instance",
".",
"Note",
"that",
"browser",
"support",
"may",
"vary",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/element.rb#L233-L243 |
13,047 | watir/watir | lib/watir/elements/element.rb | Watir.Element.drag_and_drop_by | def drag_and_drop_by(right_by, down_by)
element_call(:wait_for_present) do
driver.action
.drag_and_drop_by(@element, right_by, down_by)
.perform
end
end | ruby | def drag_and_drop_by(right_by, down_by)
element_call(:wait_for_present) do
driver.action
.drag_and_drop_by(@element, right_by, down_by)
.perform
end
end | [
"def",
"drag_and_drop_by",
"(",
"right_by",
",",
"down_by",
")",
"element_call",
"(",
":wait_for_present",
")",
"do",
"driver",
".",
"action",
".",
"drag_and_drop_by",
"(",
"@element",
",",
"right_by",
",",
"down_by",
")",
".",
"perform",
"end",
"end"
] | Drag and drop this element by the given offsets.
Note that browser support may vary.
@example
browser.div(id: "draggable").drag_and_drop_by 100, -200
@param [Integer] right_by
@param [Integer] down_by | [
"Drag",
"and",
"drop",
"this",
"element",
"by",
"the",
"given",
"offsets",
".",
"Note",
"that",
"browser",
"support",
"may",
"vary",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/element.rb#L256-L262 |
13,048 | watir/watir | lib/watir/elements/element.rb | Watir.Element.attribute_value | def attribute_value(attribute_name)
attribute_name = attribute_name.to_s.tr('_', '-') if attribute_name.is_a?(::Symbol)
element_call { @element.attribute attribute_name }
end | ruby | def attribute_value(attribute_name)
attribute_name = attribute_name.to_s.tr('_', '-') if attribute_name.is_a?(::Symbol)
element_call { @element.attribute attribute_name }
end | [
"def",
"attribute_value",
"(",
"attribute_name",
")",
"attribute_name",
"=",
"attribute_name",
".",
"to_s",
".",
"tr",
"(",
"'_'",
",",
"'-'",
")",
"if",
"attribute_name",
".",
"is_a?",
"(",
"::",
"Symbol",
")",
"element_call",
"{",
"@element",
".",
"attribu... | Returns given attribute value of element.
@example
browser.a(id: "link_2").attribute_value "title"
#=> "link_title_2"
@param [String, ::Symbol] attribute_name
@return [String, nil] | [
"Returns",
"given",
"attribute",
"value",
"of",
"element",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/element.rb#L285-L288 |
13,049 | watir/watir | lib/watir/elements/element.rb | Watir.Element.attribute_values | def attribute_values
result = element_call { execute_js(:attributeValues, @element) }
result.keys.each do |key|
next unless key == key[/[a-zA-Z\-]*/]
result[key.tr('-', '_').to_sym] = result.delete(key)
end
result
end | ruby | def attribute_values
result = element_call { execute_js(:attributeValues, @element) }
result.keys.each do |key|
next unless key == key[/[a-zA-Z\-]*/]
result[key.tr('-', '_').to_sym] = result.delete(key)
end
result
end | [
"def",
"attribute_values",
"result",
"=",
"element_call",
"{",
"execute_js",
"(",
":attributeValues",
",",
"@element",
")",
"}",
"result",
".",
"keys",
".",
"each",
"do",
"|",
"key",
"|",
"next",
"unless",
"key",
"==",
"key",
"[",
"/",
"\\-",
"/",
"]",
... | Returns all attribute values. Attributes with special characters are returned as String,
rest are returned as a Symbol.
@return [Hash]
@example
browser.pre(id: 'rspec').attribute_values
#=> {class:'ruby', id: 'rspec' } | [
"Returns",
"all",
"attribute",
"values",
".",
"Attributes",
"with",
"special",
"characters",
"are",
"returned",
"as",
"String",
"rest",
"are",
"returned",
"as",
"a",
"Symbol",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/element.rb#L302-L310 |
13,050 | watir/watir | lib/watir/elements/element.rb | Watir.Element.center | def center
point = location
dimensions = size
Selenium::WebDriver::Point.new(point.x + (dimensions['width'] / 2),
point.y + (dimensions['height'] / 2))
end | ruby | def center
point = location
dimensions = size
Selenium::WebDriver::Point.new(point.x + (dimensions['width'] / 2),
point.y + (dimensions['height'] / 2))
end | [
"def",
"center",
"point",
"=",
"location",
"dimensions",
"=",
"size",
"Selenium",
"::",
"WebDriver",
"::",
"Point",
".",
"new",
"(",
"point",
".",
"x",
"+",
"(",
"dimensions",
"[",
"'width'",
"]",
"/",
"2",
")",
",",
"point",
".",
"y",
"+",
"(",
"d... | Get centre coordinates of element
@example
browser.button(name: "new_user_button").centre
@return [Selenium::WebDriver::Point] | [
"Get",
"centre",
"coordinates",
"of",
"element"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/element.rb#L425-L430 |
13,051 | watir/watir | lib/watir/elements/element.rb | Watir.Element.visible? | def visible?
msg = '#visible? behavior will be changing slightly, consider switching to #present? ' \
'(more details: http://watir.com/element-existentialism/)'
Watir.logger.warn msg, ids: [:visible_element]
displayed = display_check
if displayed.nil? && display_check
Watir.l... | ruby | def visible?
msg = '#visible? behavior will be changing slightly, consider switching to #present? ' \
'(more details: http://watir.com/element-existentialism/)'
Watir.logger.warn msg, ids: [:visible_element]
displayed = display_check
if displayed.nil? && display_check
Watir.l... | [
"def",
"visible?",
"msg",
"=",
"'#visible? behavior will be changing slightly, consider switching to #present? '",
"'(more details: http://watir.com/element-existentialism/)'",
"Watir",
".",
"logger",
".",
"warn",
"msg",
",",
"ids",
":",
"[",
":visible_element",
"]",
"displayed",... | Returns true if this element is visible on the page.
Raises exception if element does not exist
@return [Boolean] | [
"Returns",
"true",
"if",
"this",
"element",
"is",
"visible",
"on",
"the",
"page",
".",
"Raises",
"exception",
"if",
"element",
"does",
"not",
"exist"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/element.rb#L459-L473 |
13,052 | watir/watir | lib/watir/elements/element.rb | Watir.Element.present? | def present?
displayed = display_check
if displayed.nil? && display_check
Watir.logger.deprecate 'Checking `#present? == false` to determine a stale element',
'`#stale? == true`',
reference: 'http://watir.com/staleness-changes',
... | ruby | def present?
displayed = display_check
if displayed.nil? && display_check
Watir.logger.deprecate 'Checking `#present? == false` to determine a stale element',
'`#stale? == true`',
reference: 'http://watir.com/staleness-changes',
... | [
"def",
"present?",
"displayed",
"=",
"display_check",
"if",
"displayed",
".",
"nil?",
"&&",
"display_check",
"Watir",
".",
"logger",
".",
"deprecate",
"'Checking `#present? == false` to determine a stale element'",
",",
"'`#stale? == true`'",
",",
"reference",
":",
"'http... | Returns true if the element exists and is visible on the page.
Returns false if element does not exist or exists but is not visible
@return [Boolean]
@see Watir::Wait | [
"Returns",
"true",
"if",
"the",
"element",
"exists",
"and",
"is",
"visible",
"on",
"the",
"page",
".",
"Returns",
"false",
"if",
"element",
"does",
"not",
"exist",
"or",
"exists",
"but",
"is",
"not",
"visible"
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/elements/element.rb#L494-L505 |
13,053 | watir/watir | lib/watir/element_collection.rb | Watir.ElementCollection.[] | def [](value)
if value.is_a?(Range)
to_a[value]
elsif @selector.key? :adjacent
to_a[value] || element_class.new(@query_scope, invalid_locator: true)
elsif @to_a && @to_a[value]
@to_a[value]
else
element_class.new(@query_scope, @selector.merge(index: value))
... | ruby | def [](value)
if value.is_a?(Range)
to_a[value]
elsif @selector.key? :adjacent
to_a[value] || element_class.new(@query_scope, invalid_locator: true)
elsif @to_a && @to_a[value]
@to_a[value]
else
element_class.new(@query_scope, @selector.merge(index: value))
... | [
"def",
"[]",
"(",
"value",
")",
"if",
"value",
".",
"is_a?",
"(",
"Range",
")",
"to_a",
"[",
"value",
"]",
"elsif",
"@selector",
".",
"key?",
":adjacent",
"to_a",
"[",
"value",
"]",
"||",
"element_class",
".",
"new",
"(",
"@query_scope",
",",
"invalid_... | Get the element at the given index or range.
Any call to an ElementCollection that includes an adjacent selector
can not be lazy loaded because it must store the correct type
Ranges can not be lazy loaded
@param [Integer, Range] value Index (0-based) or Range of desired element(s)
@return [Watir::Element, Watir... | [
"Get",
"the",
"element",
"at",
"the",
"given",
"index",
"or",
"range",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/element_collection.rb#L56-L66 |
13,054 | watir/watir | lib/watir/element_collection.rb | Watir.ElementCollection.to_a | def to_a
hash = {}
@to_a ||=
elements_with_tags.map.with_index do |(el, tag_name), idx|
selector = @selector.dup
selector[:index] = idx unless idx.zero?
element = element_class.new(@query_scope, selector)
if [HTMLElement, Input].include? element.class
... | ruby | def to_a
hash = {}
@to_a ||=
elements_with_tags.map.with_index do |(el, tag_name), idx|
selector = @selector.dup
selector[:index] = idx unless idx.zero?
element = element_class.new(@query_scope, selector)
if [HTMLElement, Input].include? element.class
... | [
"def",
"to_a",
"hash",
"=",
"{",
"}",
"@to_a",
"||=",
"elements_with_tags",
".",
"map",
".",
"with_index",
"do",
"|",
"(",
"el",
",",
"tag_name",
")",
",",
"idx",
"|",
"selector",
"=",
"@selector",
".",
"dup",
"selector",
"[",
":index",
"]",
"=",
"id... | This collection as an Array.
@return [Array<Watir::Element>] | [
"This",
"collection",
"as",
"an",
"Array",
"."
] | 2d8db09811c6221ae401b85b2f61f5fa66e463a3 | https://github.com/watir/watir/blob/2d8db09811c6221ae401b85b2f61f5fa66e463a3/lib/watir/element_collection.rb#L94-L107 |
13,055 | libgit2/rugged | lib/rugged/commit.rb | Rugged.Commit.diff | def diff(*args)
args.unshift(parents.first) if args.size == 1 && args.first.is_a?(Hash)
self.tree.diff(*args)
end | ruby | def diff(*args)
args.unshift(parents.first) if args.size == 1 && args.first.is_a?(Hash)
self.tree.diff(*args)
end | [
"def",
"diff",
"(",
"*",
"args",
")",
"args",
".",
"unshift",
"(",
"parents",
".",
"first",
")",
"if",
"args",
".",
"size",
"==",
"1",
"&&",
"args",
".",
"first",
".",
"is_a?",
"(",
"Hash",
")",
"self",
".",
"tree",
".",
"diff",
"(",
"args",
")... | Return a diff between this commit and its first parent or another commit or tree.
See Rugged::Tree#diff for more details. | [
"Return",
"a",
"diff",
"between",
"this",
"commit",
"and",
"its",
"first",
"parent",
"or",
"another",
"commit",
"or",
"tree",
"."
] | 33873e5df2bd38501814182ff79609ed4bd88012 | https://github.com/libgit2/rugged/blob/33873e5df2bd38501814182ff79609ed4bd88012/lib/rugged/commit.rb#L24-L27 |
13,056 | libgit2/rugged | lib/rugged/repository.rb | Rugged.Repository.checkout | def checkout(target, options = {})
options[:strategy] ||= :safe
options.delete(:paths)
return checkout_head(options) if target == "HEAD"
if target.kind_of?(Rugged::Branch)
branch = target
else
branch = branches[target]
end
if branch
self.checkout_tree... | ruby | def checkout(target, options = {})
options[:strategy] ||= :safe
options.delete(:paths)
return checkout_head(options) if target == "HEAD"
if target.kind_of?(Rugged::Branch)
branch = target
else
branch = branches[target]
end
if branch
self.checkout_tree... | [
"def",
"checkout",
"(",
"target",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":strategy",
"]",
"||=",
":safe",
"options",
".",
"delete",
"(",
":paths",
")",
"return",
"checkout_head",
"(",
"options",
")",
"if",
"target",
"==",
"\"HEAD\"",
"if",
... | Checkout the specified branch, reference or commit.
target - A revparse spec for the branch, reference or commit to check out.
options - Options passed to #checkout_tree. | [
"Checkout",
"the",
"specified",
"branch",
"reference",
"or",
"commit",
"."
] | 33873e5df2bd38501814182ff79609ed4bd88012 | https://github.com/libgit2/rugged/blob/33873e5df2bd38501814182ff79609ed4bd88012/lib/rugged/repository.rb#L29-L54 |
13,057 | libgit2/rugged | lib/rugged/repository.rb | Rugged.Repository.create_branch | def create_branch(name, sha_or_ref = "HEAD")
case sha_or_ref
when Rugged::Object
target = sha_or_ref.oid
else
target = rev_parse_oid(sha_or_ref)
end
branches.create(name, target)
end | ruby | def create_branch(name, sha_or_ref = "HEAD")
case sha_or_ref
when Rugged::Object
target = sha_or_ref.oid
else
target = rev_parse_oid(sha_or_ref)
end
branches.create(name, target)
end | [
"def",
"create_branch",
"(",
"name",
",",
"sha_or_ref",
"=",
"\"HEAD\"",
")",
"case",
"sha_or_ref",
"when",
"Rugged",
"::",
"Object",
"target",
"=",
"sha_or_ref",
".",
"oid",
"else",
"target",
"=",
"rev_parse_oid",
"(",
"sha_or_ref",
")",
"end",
"branches",
... | Create a new branch in the repository
name - The name of the branch (without a full reference path)
sha_or_ref - The target of the branch; either a String representing
an OID or a reference name, or a Rugged::Object instance.
Returns a Rugged::Branch object | [
"Create",
"a",
"new",
"branch",
"in",
"the",
"repository"
] | 33873e5df2bd38501814182ff79609ed4bd88012 | https://github.com/libgit2/rugged/blob/33873e5df2bd38501814182ff79609ed4bd88012/lib/rugged/repository.rb#L225-L234 |
13,058 | libgit2/rugged | lib/rugged/repository.rb | Rugged.Repository.blob_at | def blob_at(revision, path)
tree = Rugged::Commit.lookup(self, revision).tree
begin
blob_data = tree.path(path)
rescue Rugged::TreeError
return nil
end
blob = Rugged::Blob.lookup(self, blob_data[:oid])
(blob.type == :blob) ? blob : nil
end | ruby | def blob_at(revision, path)
tree = Rugged::Commit.lookup(self, revision).tree
begin
blob_data = tree.path(path)
rescue Rugged::TreeError
return nil
end
blob = Rugged::Blob.lookup(self, blob_data[:oid])
(blob.type == :blob) ? blob : nil
end | [
"def",
"blob_at",
"(",
"revision",
",",
"path",
")",
"tree",
"=",
"Rugged",
"::",
"Commit",
".",
"lookup",
"(",
"self",
",",
"revision",
")",
".",
"tree",
"begin",
"blob_data",
"=",
"tree",
".",
"path",
"(",
"path",
")",
"rescue",
"Rugged",
"::",
"Tr... | Get the blob at a path for a specific revision.
revision - The String SHA1.
path - The String file path.
Returns a Rugged::Blob object | [
"Get",
"the",
"blob",
"at",
"a",
"path",
"for",
"a",
"specific",
"revision",
"."
] | 33873e5df2bd38501814182ff79609ed4bd88012 | https://github.com/libgit2/rugged/blob/33873e5df2bd38501814182ff79609ed4bd88012/lib/rugged/repository.rb#L242-L251 |
13,059 | libgit2/rugged | lib/rugged/repository.rb | Rugged.Repository.push | def push(remote_or_url, *args)
unless remote_or_url.kind_of? Remote
remote_or_url = remotes[remote_or_url] || remotes.create_anonymous(remote_or_url)
end
remote_or_url.push(*args)
end | ruby | def push(remote_or_url, *args)
unless remote_or_url.kind_of? Remote
remote_or_url = remotes[remote_or_url] || remotes.create_anonymous(remote_or_url)
end
remote_or_url.push(*args)
end | [
"def",
"push",
"(",
"remote_or_url",
",",
"*",
"args",
")",
"unless",
"remote_or_url",
".",
"kind_of?",
"Remote",
"remote_or_url",
"=",
"remotes",
"[",
"remote_or_url",
"]",
"||",
"remotes",
".",
"create_anonymous",
"(",
"remote_or_url",
")",
"end",
"remote_or_u... | Push a list of refspecs to the given remote.
refspecs - A list of refspecs that should be pushed to the remote.
Returns a hash containing the pushed refspecs as keys and
any error messages or +nil+ as values. | [
"Push",
"a",
"list",
"of",
"refspecs",
"to",
"the",
"given",
"remote",
"."
] | 33873e5df2bd38501814182ff79609ed4bd88012 | https://github.com/libgit2/rugged/blob/33873e5df2bd38501814182ff79609ed4bd88012/lib/rugged/repository.rb#L267-L273 |
13,060 | libgit2/rugged | lib/rugged/submodule_collection.rb | Rugged.SubmoduleCollection.clone_submodule | def clone_submodule(repo, fetch_options)
# the remote was just added by setup_add, no need to check presence
repo.remotes['origin'].fetch(fetch_options)
repo.branches.create('master','origin/master')
repo.branches['master'].upstream = repo.branches['origin/master']
repo.checkout_head(str... | ruby | def clone_submodule(repo, fetch_options)
# the remote was just added by setup_add, no need to check presence
repo.remotes['origin'].fetch(fetch_options)
repo.branches.create('master','origin/master')
repo.branches['master'].upstream = repo.branches['origin/master']
repo.checkout_head(str... | [
"def",
"clone_submodule",
"(",
"repo",
",",
"fetch_options",
")",
"# the remote was just added by setup_add, no need to check presence",
"repo",
".",
"remotes",
"[",
"'origin'",
"]",
".",
"fetch",
"(",
"fetch_options",
")",
"repo",
".",
"branches",
".",
"create",
"(",... | currently libgit2's `git_submodule_add_setup` initializes a repo
with a workdir for the submodule. libgit2's `git_clone` however
requires the target for the clone to be an empty dir.
This provides a ghetto clone implementation that:
1. fetches the remote
2. sets up a master branch to be tracking origin/master
3.... | [
"currently",
"libgit2",
"s",
"git_submodule_add_setup",
"initializes",
"a",
"repo",
"with",
"a",
"workdir",
"for",
"the",
"submodule",
".",
"libgit2",
"s",
"git_clone",
"however",
"requires",
"the",
"target",
"for",
"the",
"clone",
"to",
"be",
"an",
"empty",
"... | 33873e5df2bd38501814182ff79609ed4bd88012 | https://github.com/libgit2/rugged/blob/33873e5df2bd38501814182ff79609ed4bd88012/lib/rugged/submodule_collection.rb#L43-L51 |
13,061 | oauth-xx/oauth2 | lib/oauth2/client.rb | OAuth2.Client.build_access_token | def build_access_token(response, access_token_opts, access_token_class)
access_token_class.from_hash(self, response.parsed.merge(access_token_opts)).tap do |access_token|
access_token.response = response if access_token.respond_to?(:response=)
end
end | ruby | def build_access_token(response, access_token_opts, access_token_class)
access_token_class.from_hash(self, response.parsed.merge(access_token_opts)).tap do |access_token|
access_token.response = response if access_token.respond_to?(:response=)
end
end | [
"def",
"build_access_token",
"(",
"response",
",",
"access_token_opts",
",",
"access_token_class",
")",
"access_token_class",
".",
"from_hash",
"(",
"self",
",",
"response",
".",
"parsed",
".",
"merge",
"(",
"access_token_opts",
")",
")",
".",
"tap",
"do",
"|",
... | Builds the access token from the response of the HTTP call
@return [AccessToken] the initialized AccessToken | [
"Builds",
"the",
"access",
"token",
"from",
"the",
"response",
"of",
"the",
"HTTP",
"call"
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/client.rb#L221-L225 |
13,062 | oauth-xx/oauth2 | lib/oauth2/authenticator.rb | OAuth2.Authenticator.apply | def apply(params)
case mode.to_sym
when :basic_auth
apply_basic_auth(params)
when :request_body
apply_params_auth(params)
else
raise NotImplementedError
end
end | ruby | def apply(params)
case mode.to_sym
when :basic_auth
apply_basic_auth(params)
when :request_body
apply_params_auth(params)
else
raise NotImplementedError
end
end | [
"def",
"apply",
"(",
"params",
")",
"case",
"mode",
".",
"to_sym",
"when",
":basic_auth",
"apply_basic_auth",
"(",
"params",
")",
"when",
":request_body",
"apply_params_auth",
"(",
"params",
")",
"else",
"raise",
"NotImplementedError",
"end",
"end"
] | Apply the request credentials used to authenticate to the Authorization Server
Depending on configuration, this might be as request params or as an
Authorization header.
User-provided params and header take precedence.
@param [Hash] params a Hash of params for the token endpoint
@return [Hash] params amended wi... | [
"Apply",
"the",
"request",
"credentials",
"used",
"to",
"authenticate",
"to",
"the",
"Authorization",
"Server"
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/authenticator.rb#L22-L31 |
13,063 | oauth-xx/oauth2 | lib/oauth2/authenticator.rb | OAuth2.Authenticator.apply_basic_auth | def apply_basic_auth(params)
headers = params.fetch(:headers, {})
headers = basic_auth_header.merge(headers)
params.merge(:headers => headers)
end | ruby | def apply_basic_auth(params)
headers = params.fetch(:headers, {})
headers = basic_auth_header.merge(headers)
params.merge(:headers => headers)
end | [
"def",
"apply_basic_auth",
"(",
"params",
")",
"headers",
"=",
"params",
".",
"fetch",
"(",
":headers",
",",
"{",
"}",
")",
"headers",
"=",
"basic_auth_header",
".",
"merge",
"(",
"headers",
")",
"params",
".",
"merge",
"(",
":headers",
"=>",
"headers",
... | Adds an `Authorization` header with Basic Auth credentials if and only if
it is not already set in the params. | [
"Adds",
"an",
"Authorization",
"header",
"with",
"Basic",
"Auth",
"credentials",
"if",
"and",
"only",
"if",
"it",
"is",
"not",
"already",
"set",
"in",
"the",
"params",
"."
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/authenticator.rb#L47-L51 |
13,064 | oauth-xx/oauth2 | lib/oauth2/response.rb | OAuth2.Response.content_type | def content_type
return nil unless response.headers
((response.headers.values_at('content-type', 'Content-Type').compact.first || '').split(';').first || '').strip
end | ruby | def content_type
return nil unless response.headers
((response.headers.values_at('content-type', 'Content-Type').compact.first || '').split(';').first || '').strip
end | [
"def",
"content_type",
"return",
"nil",
"unless",
"response",
".",
"headers",
"(",
"(",
"response",
".",
"headers",
".",
"values_at",
"(",
"'content-type'",
",",
"'Content-Type'",
")",
".",
"compact",
".",
"first",
"||",
"''",
")",
".",
"split",
"(",
"';'"... | Attempts to determine the content type of the response. | [
"Attempts",
"to",
"determine",
"the",
"content",
"type",
"of",
"the",
"response",
"."
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/response.rb#L84-L87 |
13,065 | oauth-xx/oauth2 | lib/oauth2/mac_token.rb | OAuth2.MACToken.request | def request(verb, path, opts = {}, &block)
url = client.connection.build_url(path, opts[:params]).to_s
opts[:headers] ||= {}
opts[:headers]['Authorization'] = header(verb, url)
@client.request(verb, path, opts, &block)
end | ruby | def request(verb, path, opts = {}, &block)
url = client.connection.build_url(path, opts[:params]).to_s
opts[:headers] ||= {}
opts[:headers]['Authorization'] = header(verb, url)
@client.request(verb, path, opts, &block)
end | [
"def",
"request",
"(",
"verb",
",",
"path",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"url",
"=",
"client",
".",
"connection",
".",
"build_url",
"(",
"path",
",",
"opts",
"[",
":params",
"]",
")",
".",
"to_s",
"opts",
"[",
":headers",
"... | Initalize a MACToken
@param [Client] client the OAuth2::Client instance
@param [String] token the Access Token value
@option [String] secret the secret key value
@param [Hash] opts the options to create the Access Token with
@option opts [String] :refresh_token (nil) the refresh_token value
@option opts [FixNum,... | [
"Initalize",
"a",
"MACToken"
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/mac_token.rb#L43-L50 |
13,066 | oauth-xx/oauth2 | lib/oauth2/mac_token.rb | OAuth2.MACToken.header | def header(verb, url)
timestamp = Time.now.utc.to_i
nonce = Digest::MD5.hexdigest([timestamp, SecureRandom.hex].join(':'))
uri = URI.parse(url)
raise(ArgumentError, "could not parse \"#{url}\" into URI") unless uri.is_a?(URI::HTTP)
mac = signature(timestamp, nonce, verb, uri)
"MA... | ruby | def header(verb, url)
timestamp = Time.now.utc.to_i
nonce = Digest::MD5.hexdigest([timestamp, SecureRandom.hex].join(':'))
uri = URI.parse(url)
raise(ArgumentError, "could not parse \"#{url}\" into URI") unless uri.is_a?(URI::HTTP)
mac = signature(timestamp, nonce, verb, uri)
"MA... | [
"def",
"header",
"(",
"verb",
",",
"url",
")",
"timestamp",
"=",
"Time",
".",
"now",
".",
"utc",
".",
"to_i",
"nonce",
"=",
"Digest",
"::",
"MD5",
".",
"hexdigest",
"(",
"[",
"timestamp",
",",
"SecureRandom",
".",
"hex",
"]",
".",
"join",
"(",
"':'... | Generate the MAC header
@param [Symbol] verb the HTTP request method
@param [String] url the HTTP URL path of the request | [
"Generate",
"the",
"MAC",
"header"
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/mac_token.rb#L61-L72 |
13,067 | oauth-xx/oauth2 | lib/oauth2/mac_token.rb | OAuth2.MACToken.signature | def signature(timestamp, nonce, verb, uri)
signature = [
timestamp,
nonce,
verb.to_s.upcase,
uri.request_uri,
uri.host,
uri.port,
'', nil
].join("\n")
Base64.strict_encode64(OpenSSL::HMAC.digest(@algorithm, secret, signature))
end | ruby | def signature(timestamp, nonce, verb, uri)
signature = [
timestamp,
nonce,
verb.to_s.upcase,
uri.request_uri,
uri.host,
uri.port,
'', nil
].join("\n")
Base64.strict_encode64(OpenSSL::HMAC.digest(@algorithm, secret, signature))
end | [
"def",
"signature",
"(",
"timestamp",
",",
"nonce",
",",
"verb",
",",
"uri",
")",
"signature",
"=",
"[",
"timestamp",
",",
"nonce",
",",
"verb",
".",
"to_s",
".",
"upcase",
",",
"uri",
".",
"request_uri",
",",
"uri",
".",
"host",
",",
"uri",
".",
"... | Generate the Base64-encoded HMAC digest signature
@param [Fixnum] timestamp the timestamp of the request in seconds since epoch
@param [String] nonce the MAC header nonce
@param [Symbol] verb the HTTP request method
@param [String] url the HTTP URL path of the request | [
"Generate",
"the",
"Base64",
"-",
"encoded",
"HMAC",
"digest",
"signature"
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/mac_token.rb#L80-L92 |
13,068 | oauth-xx/oauth2 | lib/oauth2/mac_token.rb | OAuth2.MACToken.algorithm= | def algorithm=(alg)
@algorithm = begin
case alg.to_s
when 'hmac-sha-1'
OpenSSL::Digest::SHA1.new
when 'hmac-sha-256'
OpenSSL::Digest::SHA256.new
else
raise(ArgumentError, 'Unsupported algorithm')
end
end
end | ruby | def algorithm=(alg)
@algorithm = begin
case alg.to_s
when 'hmac-sha-1'
OpenSSL::Digest::SHA1.new
when 'hmac-sha-256'
OpenSSL::Digest::SHA256.new
else
raise(ArgumentError, 'Unsupported algorithm')
end
end
end | [
"def",
"algorithm",
"=",
"(",
"alg",
")",
"@algorithm",
"=",
"begin",
"case",
"alg",
".",
"to_s",
"when",
"'hmac-sha-1'",
"OpenSSL",
"::",
"Digest",
"::",
"SHA1",
".",
"new",
"when",
"'hmac-sha-256'",
"OpenSSL",
"::",
"Digest",
"::",
"SHA256",
".",
"new",
... | Set the HMAC algorithm
@param [String] alg the algorithm to use (one of 'hmac-sha-1', 'hmac-sha-256') | [
"Set",
"the",
"HMAC",
"algorithm"
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/mac_token.rb#L97-L108 |
13,069 | oauth-xx/oauth2 | lib/oauth2/access_token.rb | OAuth2.AccessToken.refresh | def refresh(params = {}, access_token_opts = {}, access_token_class = self.class)
raise('A refresh_token is not available') unless refresh_token
params[:grant_type] = 'refresh_token'
params[:refresh_token] = refresh_token
new_token = @client.get_token(params, access_token_opts, access_token_clas... | ruby | def refresh(params = {}, access_token_opts = {}, access_token_class = self.class)
raise('A refresh_token is not available') unless refresh_token
params[:grant_type] = 'refresh_token'
params[:refresh_token] = refresh_token
new_token = @client.get_token(params, access_token_opts, access_token_clas... | [
"def",
"refresh",
"(",
"params",
"=",
"{",
"}",
",",
"access_token_opts",
"=",
"{",
"}",
",",
"access_token_class",
"=",
"self",
".",
"class",
")",
"raise",
"(",
"'A refresh_token is not available'",
")",
"unless",
"refresh_token",
"params",
"[",
":grant_type",
... | Refreshes the current Access Token
@return [AccessToken] a new AccessToken
@note options should be carried over to the new AccessToken | [
"Refreshes",
"the",
"current",
"Access",
"Token"
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/access_token.rb#L85-L93 |
13,070 | oauth-xx/oauth2 | lib/oauth2/access_token.rb | OAuth2.AccessToken.request | def request(verb, path, opts = {}, &block)
configure_authentication!(opts)
@client.request(verb, path, opts, &block)
end | ruby | def request(verb, path, opts = {}, &block)
configure_authentication!(opts)
@client.request(verb, path, opts, &block)
end | [
"def",
"request",
"(",
"verb",
",",
"path",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"configure_authentication!",
"(",
"opts",
")",
"@client",
".",
"request",
"(",
"verb",
",",
"path",
",",
"opts",
",",
"block",
")",
"end"
] | Make a request with the Access Token
@param [Symbol] verb the HTTP request method
@param [String] path the HTTP URL path of the request
@param [Hash] opts the options to make the request with
@see Client#request | [
"Make",
"a",
"request",
"with",
"the",
"Access",
"Token"
] | f08ff9da169136ab133aa2faab0d74a4407deffb | https://github.com/oauth-xx/oauth2/blob/f08ff9da169136ab133aa2faab0d74a4407deffb/lib/oauth2/access_token.rb#L111-L114 |
13,071 | ruby-git/ruby-git | lib/git/log.rb | Git.Log.run_log | def run_log
log = @base.lib.full_log_commits(:count => @count, :object => @object,
:path_limiter => @path, :since => @since,
:author => @author, :grep => @grep, :skip => @skip,
:until => @until, :... | ruby | def run_log
log = @base.lib.full_log_commits(:count => @count, :object => @object,
:path_limiter => @path, :since => @since,
:author => @author, :grep => @grep, :skip => @skip,
:until => @until, :... | [
"def",
"run_log",
"log",
"=",
"@base",
".",
"lib",
".",
"full_log_commits",
"(",
":count",
"=>",
"@count",
",",
":object",
"=>",
"@object",
",",
":path_limiter",
"=>",
"@path",
",",
":since",
"=>",
"@since",
",",
":author",
"=>",
"@author",
",",
":grep",
... | actually run the 'git log' command | [
"actually",
"run",
"the",
"git",
"log",
"command"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/log.rb#L118-L124 |
13,072 | ruby-git/ruby-git | lib/git/branches.rb | Git.Branches.[] | def [](branch_name)
@branches.values.inject(@branches) do |branches, branch|
branches[branch.full] ||= branch
# This is how Git (version 1.7.9.5) works.
# Lets you ignore the 'remotes' if its at the beginning of the branch full name (even if is not a real remote branch).
branche... | ruby | def [](branch_name)
@branches.values.inject(@branches) do |branches, branch|
branches[branch.full] ||= branch
# This is how Git (version 1.7.9.5) works.
# Lets you ignore the 'remotes' if its at the beginning of the branch full name (even if is not a real remote branch).
branche... | [
"def",
"[]",
"(",
"branch_name",
")",
"@branches",
".",
"values",
".",
"inject",
"(",
"@branches",
")",
"do",
"|",
"branches",
",",
"branch",
"|",
"branches",
"[",
"branch",
".",
"full",
"]",
"||=",
"branch",
"# This is how Git (version 1.7.9.5) works. ",
"# L... | Returns the target branch
Example:
Given (git branch -a):
master
remotes/working/master
g.branches['master'].full #=> 'master'
g.branches['working/master'].full => 'remotes/working/master'
g.branches['remotes/working/master'].full => 'remotes/working/master'
@param [#to_s] branch_name the targe... | [
"Returns",
"the",
"target",
"branch"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/branches.rb#L49-L59 |
13,073 | ruby-git/ruby-git | lib/git/lib.rb | Git.Lib.describe | def describe(committish=nil, opts={})
arr_opts = []
arr_opts << '--all' if opts[:all]
arr_opts << '--tags' if opts[:tags]
arr_opts << '--contains' if opts[:contains]
arr_opts << '--debug' if opts[:debug]
arr_opts << '--long' if opts[:long]
arr_opts << '--always' if opts[:alway... | ruby | def describe(committish=nil, opts={})
arr_opts = []
arr_opts << '--all' if opts[:all]
arr_opts << '--tags' if opts[:tags]
arr_opts << '--contains' if opts[:contains]
arr_opts << '--debug' if opts[:debug]
arr_opts << '--long' if opts[:long]
arr_opts << '--always' if opts[:alway... | [
"def",
"describe",
"(",
"committish",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
")",
"arr_opts",
"=",
"[",
"]",
"arr_opts",
"<<",
"'--all'",
"if",
"opts",
"[",
":all",
"]",
"arr_opts",
"<<",
"'--tags'",
"if",
"opts",
"[",
":tags",
"]",
"arr_opts",
"<<"... | tries to clone the given repo
returns {:repository} (if bare)
{:working_directory} otherwise
accepts options:
:bare:: no working directory
:branch:: name of branch to track (rather than 'master')
:depth:: the number of commits back to pull
:origin:: name of remote (same as remote)
... | [
"tries",
"to",
"clone",
"the",
"given",
"repo"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/lib.rb#L105-L126 |
13,074 | ruby-git/ruby-git | lib/git/lib.rb | Git.Lib.commit_data | def commit_data(sha)
sha = sha.to_s
cdata = command_lines('cat-file', ['commit', sha])
process_commit_data(cdata, sha, 0)
end | ruby | def commit_data(sha)
sha = sha.to_s
cdata = command_lines('cat-file', ['commit', sha])
process_commit_data(cdata, sha, 0)
end | [
"def",
"commit_data",
"(",
"sha",
")",
"sha",
"=",
"sha",
".",
"to_s",
"cdata",
"=",
"command_lines",
"(",
"'cat-file'",
",",
"[",
"'commit'",
",",
"sha",
"]",
")",
"process_commit_data",
"(",
"cdata",
",",
"sha",
",",
"0",
")",
"end"
] | returns useful array of raw commit object data | [
"returns",
"useful",
"array",
"of",
"raw",
"commit",
"object",
"data"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/lib.rb#L175-L179 |
13,075 | ruby-git/ruby-git | lib/git/lib.rb | Git.Lib.read_tree | def read_tree(treeish, opts = {})
arr_opts = []
arr_opts << "--prefix=#{opts[:prefix]}" if opts[:prefix]
arr_opts += [treeish]
command('read-tree', arr_opts)
end | ruby | def read_tree(treeish, opts = {})
arr_opts = []
arr_opts << "--prefix=#{opts[:prefix]}" if opts[:prefix]
arr_opts += [treeish]
command('read-tree', arr_opts)
end | [
"def",
"read_tree",
"(",
"treeish",
",",
"opts",
"=",
"{",
"}",
")",
"arr_opts",
"=",
"[",
"]",
"arr_opts",
"<<",
"\"--prefix=#{opts[:prefix]}\"",
"if",
"opts",
"[",
":prefix",
"]",
"arr_opts",
"+=",
"[",
"treeish",
"]",
"command",
"(",
"'read-tree'",
",",... | reads a tree into the current index file | [
"reads",
"a",
"tree",
"into",
"the",
"current",
"index",
"file"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/lib.rb#L808-L813 |
13,076 | ruby-git/ruby-git | lib/git/lib.rb | Git.Lib.archive | def archive(sha, file = nil, opts = {})
opts[:format] ||= 'zip'
if opts[:format] == 'tgz'
opts[:format] = 'tar'
opts[:add_gzip] = true
end
if !file
tempfile = Tempfile.new('archive')
file = tempfile.path
# delete it now, before we write to it, so that Ru... | ruby | def archive(sha, file = nil, opts = {})
opts[:format] ||= 'zip'
if opts[:format] == 'tgz'
opts[:format] = 'tar'
opts[:add_gzip] = true
end
if !file
tempfile = Tempfile.new('archive')
file = tempfile.path
# delete it now, before we write to it, so that Ru... | [
"def",
"archive",
"(",
"sha",
",",
"file",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
")",
"opts",
"[",
":format",
"]",
"||=",
"'zip'",
"if",
"opts",
"[",
":format",
"]",
"==",
"'tgz'",
"opts",
"[",
":format",
"]",
"=",
"'tar'",
"opts",
"[",
":add_g... | creates an archive file
options
:format (zip, tar)
:prefix
:remote
:path | [
"creates",
"an",
"archive",
"file"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/lib.rb#L853-L877 |
13,077 | ruby-git/ruby-git | lib/git/lib.rb | Git.Lib.current_command_version | def current_command_version
output = command('version', [], false)
version = output[/\d+\.\d+(\.\d+)+/]
version.split('.').collect {|i| i.to_i}
end | ruby | def current_command_version
output = command('version', [], false)
version = output[/\d+\.\d+(\.\d+)+/]
version.split('.').collect {|i| i.to_i}
end | [
"def",
"current_command_version",
"output",
"=",
"command",
"(",
"'version'",
",",
"[",
"]",
",",
"false",
")",
"version",
"=",
"output",
"[",
"/",
"\\d",
"\\.",
"\\d",
"\\.",
"\\d",
"/",
"]",
"version",
".",
"split",
"(",
"'.'",
")",
".",
"collect",
... | returns the current version of git, as an Array of Fixnums. | [
"returns",
"the",
"current",
"version",
"of",
"git",
"as",
"an",
"Array",
"of",
"Fixnums",
"."
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/lib.rb#L880-L884 |
13,078 | ruby-git/ruby-git | lib/git/lib.rb | Git.Lib.log_common_options | def log_common_options(opts)
arr_opts = []
arr_opts << "-#{opts[:count]}" if opts[:count]
arr_opts << "--no-color"
arr_opts << "--since=#{opts[:since]}" if opts[:since].is_a? String
arr_opts << "--until=#{opts[:until]}" if opts[:until].is_a? String
arr_opts << "--grep=#{opts[:grep]}... | ruby | def log_common_options(opts)
arr_opts = []
arr_opts << "-#{opts[:count]}" if opts[:count]
arr_opts << "--no-color"
arr_opts << "--since=#{opts[:since]}" if opts[:since].is_a? String
arr_opts << "--until=#{opts[:until]}" if opts[:until].is_a? String
arr_opts << "--grep=#{opts[:grep]}... | [
"def",
"log_common_options",
"(",
"opts",
")",
"arr_opts",
"=",
"[",
"]",
"arr_opts",
"<<",
"\"-#{opts[:count]}\"",
"if",
"opts",
"[",
":count",
"]",
"arr_opts",
"<<",
"\"--no-color\"",
"arr_opts",
"<<",
"\"--since=#{opts[:since]}\"",
"if",
"opts",
"[",
":since",
... | Returns an array holding the common options for the log commands
@param [Hash] opts the given options
@return [Array] the set of common options that the log command will use | [
"Returns",
"an",
"array",
"holding",
"the",
"common",
"options",
"for",
"the",
"log",
"commands"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/lib.rb#L1016-L1028 |
13,079 | ruby-git/ruby-git | lib/git/lib.rb | Git.Lib.log_path_options | def log_path_options(opts)
arr_opts = []
arr_opts << opts[:object] if opts[:object].is_a? String
arr_opts << '--' << opts[:path_limiter] if opts[:path_limiter]
arr_opts
end | ruby | def log_path_options(opts)
arr_opts = []
arr_opts << opts[:object] if opts[:object].is_a? String
arr_opts << '--' << opts[:path_limiter] if opts[:path_limiter]
arr_opts
end | [
"def",
"log_path_options",
"(",
"opts",
")",
"arr_opts",
"=",
"[",
"]",
"arr_opts",
"<<",
"opts",
"[",
":object",
"]",
"if",
"opts",
"[",
":object",
"]",
".",
"is_a?",
"String",
"arr_opts",
"<<",
"'--'",
"<<",
"opts",
"[",
":path_limiter",
"]",
"if",
"... | Retrurns an array holding path options for the log commands
@param [Hash] opts the given options
@return [Array] the set of path options that the log command will use | [
"Retrurns",
"an",
"array",
"holding",
"path",
"options",
"for",
"the",
"log",
"commands"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/lib.rb#L1034-L1040 |
13,080 | ruby-git/ruby-git | lib/git/base.rb | Git.Base.is_local_branch? | def is_local_branch?(branch)
branch_names = self.branches.local.map {|b| b.name}
branch_names.include?(branch)
end | ruby | def is_local_branch?(branch)
branch_names = self.branches.local.map {|b| b.name}
branch_names.include?(branch)
end | [
"def",
"is_local_branch?",
"(",
"branch",
")",
"branch_names",
"=",
"self",
".",
"branches",
".",
"local",
".",
"map",
"{",
"|",
"b",
"|",
"b",
".",
"name",
"}",
"branch_names",
".",
"include?",
"(",
"branch",
")",
"end"
] | returns +true+ if the branch exists locally | [
"returns",
"+",
"true",
"+",
"if",
"the",
"branch",
"exists",
"locally"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/base.rb#L163-L166 |
13,081 | ruby-git/ruby-git | lib/git/base.rb | Git.Base.is_remote_branch? | def is_remote_branch?(branch)
branch_names = self.branches.remote.map {|b| b.name}
branch_names.include?(branch)
end | ruby | def is_remote_branch?(branch)
branch_names = self.branches.remote.map {|b| b.name}
branch_names.include?(branch)
end | [
"def",
"is_remote_branch?",
"(",
"branch",
")",
"branch_names",
"=",
"self",
".",
"branches",
".",
"remote",
".",
"map",
"{",
"|",
"b",
"|",
"b",
".",
"name",
"}",
"branch_names",
".",
"include?",
"(",
"branch",
")",
"end"
] | returns +true+ if the branch exists remotely | [
"returns",
"+",
"true",
"+",
"if",
"the",
"branch",
"exists",
"remotely"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/base.rb#L169-L172 |
13,082 | ruby-git/ruby-git | lib/git/base.rb | Git.Base.is_branch? | def is_branch?(branch)
branch_names = self.branches.map {|b| b.name}
branch_names.include?(branch)
end | ruby | def is_branch?(branch)
branch_names = self.branches.map {|b| b.name}
branch_names.include?(branch)
end | [
"def",
"is_branch?",
"(",
"branch",
")",
"branch_names",
"=",
"self",
".",
"branches",
".",
"map",
"{",
"|",
"b",
"|",
"b",
".",
"name",
"}",
"branch_names",
".",
"include?",
"(",
"branch",
")",
"end"
] | returns +true+ if the branch exists | [
"returns",
"+",
"true",
"+",
"if",
"the",
"branch",
"exists"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/base.rb#L175-L178 |
13,083 | ruby-git/ruby-git | lib/git/base.rb | Git.Base.commit_all | def commit_all(message, opts = {})
opts = {:add_all => true}.merge(opts)
self.lib.commit(message, opts)
end | ruby | def commit_all(message, opts = {})
opts = {:add_all => true}.merge(opts)
self.lib.commit(message, opts)
end | [
"def",
"commit_all",
"(",
"message",
",",
"opts",
"=",
"{",
"}",
")",
"opts",
"=",
"{",
":add_all",
"=>",
"true",
"}",
".",
"merge",
"(",
"opts",
")",
"self",
".",
"lib",
".",
"commit",
"(",
"message",
",",
"opts",
")",
"end"
] | commits all pending changes in the index file to the git repository,
but automatically adds all modified files without having to explicitly
calling @git.add() on them. | [
"commits",
"all",
"pending",
"changes",
"in",
"the",
"index",
"file",
"to",
"the",
"git",
"repository",
"but",
"automatically",
"adds",
"all",
"modified",
"files",
"without",
"having",
"to",
"explicitly",
"calling"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/base.rb#L299-L302 |
13,084 | ruby-git/ruby-git | lib/git/base.rb | Git.Base.with_index | def with_index(new_index) # :yields: new_index
old_index = @index
set_index(new_index, false)
return_value = yield @index
set_index(old_index)
return_value
end | ruby | def with_index(new_index) # :yields: new_index
old_index = @index
set_index(new_index, false)
return_value = yield @index
set_index(old_index)
return_value
end | [
"def",
"with_index",
"(",
"new_index",
")",
"# :yields: new_index",
"old_index",
"=",
"@index",
"set_index",
"(",
"new_index",
",",
"false",
")",
"return_value",
"=",
"yield",
"@index",
"set_index",
"(",
"old_index",
")",
"return_value",
"end"
] | LOWER LEVEL INDEX OPERATIONS | [
"LOWER",
"LEVEL",
"INDEX",
"OPERATIONS"
] | 9bd4407c56068e1604f14a1b6c0c5a84868e6378 | https://github.com/ruby-git/ruby-git/blob/9bd4407c56068e1604f14a1b6c0c5a84868e6378/lib/git/base.rb#L456-L462 |
13,085 | pythonicrubyist/creek | lib/creek/sheet.rb | Creek.Creek::Sheet.rows_generator | def rows_generator include_meta_data=false, use_simple_rows_format=false
path = if @sheetfile.start_with? "/xl/" or @sheetfile.start_with? "xl/" then @sheetfile else "xl/#{@sheetfile}" end
if @book.files.file.exist?(path)
# SAX parsing, Each element in the stream comes through as two events:
... | ruby | def rows_generator include_meta_data=false, use_simple_rows_format=false
path = if @sheetfile.start_with? "/xl/" or @sheetfile.start_with? "xl/" then @sheetfile else "xl/#{@sheetfile}" end
if @book.files.file.exist?(path)
# SAX parsing, Each element in the stream comes through as two events:
... | [
"def",
"rows_generator",
"include_meta_data",
"=",
"false",
",",
"use_simple_rows_format",
"=",
"false",
"path",
"=",
"if",
"@sheetfile",
".",
"start_with?",
"\"/xl/\"",
"or",
"@sheetfile",
".",
"start_with?",
"\"xl/\"",
"then",
"@sheetfile",
"else",
"\"xl/#{@sheetfil... | Returns a hash per row that includes the cell ids and values.
Empty cells will be also included in the hash with a nil value. | [
"Returns",
"a",
"hash",
"per",
"row",
"that",
"includes",
"the",
"cell",
"ids",
"and",
"values",
".",
"Empty",
"cells",
"will",
"be",
"also",
"included",
"in",
"the",
"hash",
"with",
"a",
"nil",
"value",
"."
] | 1a5c99032ee736e8f24ebd524adffba068d236b4 | https://github.com/pythonicrubyist/creek/blob/1a5c99032ee736e8f24ebd524adffba068d236b4/lib/creek/sheet.rb#L83-L127 |
13,086 | pythonicrubyist/creek | lib/creek/sheet.rb | Creek.Creek::Sheet.fill_in_empty_cells | def fill_in_empty_cells(cells, row_number, last_col, use_simple_rows_format)
new_cells = Hash.new
unless cells.empty?
last_col = last_col.gsub(row_number, '')
("A"..last_col).to_a.each do |column|
id = use_simple_rows_format ? "#{column}" : "#{column}#{row_number}"
new_... | ruby | def fill_in_empty_cells(cells, row_number, last_col, use_simple_rows_format)
new_cells = Hash.new
unless cells.empty?
last_col = last_col.gsub(row_number, '')
("A"..last_col).to_a.each do |column|
id = use_simple_rows_format ? "#{column}" : "#{column}#{row_number}"
new_... | [
"def",
"fill_in_empty_cells",
"(",
"cells",
",",
"row_number",
",",
"last_col",
",",
"use_simple_rows_format",
")",
"new_cells",
"=",
"Hash",
".",
"new",
"unless",
"cells",
".",
"empty?",
"last_col",
"=",
"last_col",
".",
"gsub",
"(",
"row_number",
",",
"''",
... | The unzipped XML file does not contain any node for empty cells.
Empty cells are being padded in using this function | [
"The",
"unzipped",
"XML",
"file",
"does",
"not",
"contain",
"any",
"node",
"for",
"empty",
"cells",
".",
"Empty",
"cells",
"are",
"being",
"padded",
"in",
"using",
"this",
"function"
] | 1a5c99032ee736e8f24ebd524adffba068d236b4 | https://github.com/pythonicrubyist/creek/blob/1a5c99032ee736e8f24ebd524adffba068d236b4/lib/creek/sheet.rb#L144-L157 |
13,087 | pythonicrubyist/creek | lib/creek/sheet.rb | Creek.Creek::Sheet.extract_drawing_filepath | def extract_drawing_filepath
# Read drawing relationship ID from the sheet.
sheet_filepath = "xl/#{@sheetfile}"
drawing = parse_xml(sheet_filepath).css('drawing').first
return if drawing.nil?
drawing_rid = drawing.attributes['id'].value
# Read sheet rels to find drawing file's loca... | ruby | def extract_drawing_filepath
# Read drawing relationship ID from the sheet.
sheet_filepath = "xl/#{@sheetfile}"
drawing = parse_xml(sheet_filepath).css('drawing').first
return if drawing.nil?
drawing_rid = drawing.attributes['id'].value
# Read sheet rels to find drawing file's loca... | [
"def",
"extract_drawing_filepath",
"# Read drawing relationship ID from the sheet.",
"sheet_filepath",
"=",
"\"xl/#{@sheetfile}\"",
"drawing",
"=",
"parse_xml",
"(",
"sheet_filepath",
")",
".",
"css",
"(",
"'drawing'",
")",
".",
"first",
"return",
"if",
"drawing",
".",
... | Find drawing filepath for the current sheet.
Sheet xml contains drawing relationship ID.
Sheet relationships xml contains drawing file's location. | [
"Find",
"drawing",
"filepath",
"for",
"the",
"current",
"sheet",
".",
"Sheet",
"xml",
"contains",
"drawing",
"relationship",
"ID",
".",
"Sheet",
"relationships",
"xml",
"contains",
"drawing",
"file",
"s",
"location",
"."
] | 1a5c99032ee736e8f24ebd524adffba068d236b4 | https://github.com/pythonicrubyist/creek/blob/1a5c99032ee736e8f24ebd524adffba068d236b4/lib/creek/sheet.rb#L163-L174 |
13,088 | rollbar/rollbar-gem | lib/rollbar/notifier.rb | Rollbar.Notifier.log | def log(level, *args)
return 'disabled' unless enabled?
message, exception, extra, context = extract_arguments(args)
use_exception_level_filters = use_exception_level_filters?(extra)
return 'ignored' if ignored?(exception, use_exception_level_filters)
begin
status = call_before_... | ruby | def log(level, *args)
return 'disabled' unless enabled?
message, exception, extra, context = extract_arguments(args)
use_exception_level_filters = use_exception_level_filters?(extra)
return 'ignored' if ignored?(exception, use_exception_level_filters)
begin
status = call_before_... | [
"def",
"log",
"(",
"level",
",",
"*",
"args",
")",
"return",
"'disabled'",
"unless",
"enabled?",
"message",
",",
"exception",
",",
"extra",
",",
"context",
"=",
"extract_arguments",
"(",
"args",
")",
"use_exception_level_filters",
"=",
"use_exception_level_filters... | Sends a report to Rollbar.
Accepts any number of arguments. The last String argument will become
the message or description of the report. The last Exception argument
will become the associated exception for the report. The last hash
argument will be used as the extra data for the report.
If the extra hash conta... | [
"Sends",
"a",
"report",
"to",
"Rollbar",
"."
] | 83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6 | https://github.com/rollbar/rollbar-gem/blob/83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6/lib/rollbar/notifier.rb#L129-L157 |
13,089 | rollbar/rollbar-gem | lib/rollbar/notifier.rb | Rollbar.Notifier.process_from_async_handler | def process_from_async_handler(payload)
payload = Rollbar::JSON.load(payload) if payload.is_a?(String)
item = Item.build_with(payload,
:notifier => self,
:configuration => configuration,
:logger => logger)
Rollbar... | ruby | def process_from_async_handler(payload)
payload = Rollbar::JSON.load(payload) if payload.is_a?(String)
item = Item.build_with(payload,
:notifier => self,
:configuration => configuration,
:logger => logger)
Rollbar... | [
"def",
"process_from_async_handler",
"(",
"payload",
")",
"payload",
"=",
"Rollbar",
"::",
"JSON",
".",
"load",
"(",
"payload",
")",
"if",
"payload",
".",
"is_a?",
"(",
"String",
")",
"item",
"=",
"Item",
".",
"build_with",
"(",
"payload",
",",
":notifier"... | We will reraise exceptions in this method so async queues
can retry the job or, in general, handle an error report some way.
At same time that exception is silenced so we don't generate
infinite reports. This example is what we want to avoid:
1. New exception in a the project is raised
2. That report enqueued to... | [
"We",
"will",
"reraise",
"exceptions",
"in",
"this",
"method",
"so",
"async",
"queues",
"can",
"retry",
"the",
"job",
"or",
"in",
"general",
"handle",
"an",
"error",
"report",
"some",
"way",
"."
] | 83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6 | https://github.com/rollbar/rollbar-gem/blob/83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6/lib/rollbar/notifier.rb#L234-L251 |
13,090 | rollbar/rollbar-gem | lib/rollbar/notifier.rb | Rollbar.Notifier.report_internal_error | def report_internal_error(exception)
log_error '[Rollbar] Reporting internal error encountered while sending data to Rollbar.'
configuration.execute_hook(:on_report_internal_error, exception)
begin
item = build_item('error', nil, exception, { :internal => true }, nil)
rescue StandardEr... | ruby | def report_internal_error(exception)
log_error '[Rollbar] Reporting internal error encountered while sending data to Rollbar.'
configuration.execute_hook(:on_report_internal_error, exception)
begin
item = build_item('error', nil, exception, { :internal => true }, nil)
rescue StandardEr... | [
"def",
"report_internal_error",
"(",
"exception",
")",
"log_error",
"'[Rollbar] Reporting internal error encountered while sending data to Rollbar.'",
"configuration",
".",
"execute_hook",
"(",
":on_report_internal_error",
",",
"exception",
")",
"begin",
"item",
"=",
"build_item"... | Reports an internal error in the Rollbar library. This will be reported within the configured
Rollbar project. We'll first attempt to provide a report including the exception traceback.
If that fails, we'll fall back to a more static failsafe response. | [
"Reports",
"an",
"internal",
"error",
"in",
"the",
"Rollbar",
"library",
".",
"This",
"will",
"be",
"reported",
"within",
"the",
"configured",
"Rollbar",
"project",
".",
"We",
"ll",
"first",
"attempt",
"to",
"provide",
"a",
"report",
"including",
"the",
"exc... | 83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6 | https://github.com/rollbar/rollbar-gem/blob/83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6/lib/rollbar/notifier.rb#L444-L472 |
13,091 | rollbar/rollbar-gem | lib/rollbar/notifier.rb | Rollbar.Notifier.build_item | def build_item(level, message, exception, extra, context)
options = {
:level => level,
:message => message,
:exception => exception,
:extra => extra,
:configuration => configuration,
:logger => logger,
:scope => scope_object,
:notifier => self,
... | ruby | def build_item(level, message, exception, extra, context)
options = {
:level => level,
:message => message,
:exception => exception,
:extra => extra,
:configuration => configuration,
:logger => logger,
:scope => scope_object,
:notifier => self,
... | [
"def",
"build_item",
"(",
"level",
",",
"message",
",",
"exception",
",",
"extra",
",",
"context",
")",
"options",
"=",
"{",
":level",
"=>",
"level",
",",
":message",
"=>",
"message",
",",
":exception",
"=>",
"exception",
",",
":extra",
"=>",
"extra",
",... | Payload building functions | [
"Payload",
"building",
"functions"
] | 83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6 | https://github.com/rollbar/rollbar-gem/blob/83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6/lib/rollbar/notifier.rb#L476-L493 |
13,092 | plum-umd/rdl | lib/rdl/typecheck.rb | RDL::Typecheck.Env.bind | def bind(var, typ, force: false)
raise RuntimeError, "Can't update variable with fixed type" if !force && @env[var] && @env[var][:fixed]
result = Env.new
result.env = @env.merge(var => {type: typ, fixed: false})
return result
end | ruby | def bind(var, typ, force: false)
raise RuntimeError, "Can't update variable with fixed type" if !force && @env[var] && @env[var][:fixed]
result = Env.new
result.env = @env.merge(var => {type: typ, fixed: false})
return result
end | [
"def",
"bind",
"(",
"var",
",",
"typ",
",",
"force",
":",
"false",
")",
"raise",
"RuntimeError",
",",
"\"Can't update variable with fixed type\"",
"if",
"!",
"force",
"&&",
"@env",
"[",
"var",
"]",
"&&",
"@env",
"[",
"var",
"]",
"[",
":fixed",
"]",
"resu... | force should only be used with care! currently only used when type is being refined to a subtype in a lexical scope | [
"force",
"should",
"only",
"be",
"used",
"with",
"care!",
"currently",
"only",
"used",
"when",
"type",
"is",
"being",
"refined",
"to",
"a",
"subtype",
"in",
"a",
"lexical",
"scope"
] | c00134413f7a600fd395e7e7cd8b01f57f850830 | https://github.com/plum-umd/rdl/blob/c00134413f7a600fd395e7e7cd8b01f57f850830/lib/rdl/typecheck.rb#L69-L74 |
13,093 | plum-umd/rdl | lib/rdl/typecheck.rb | RDL::Typecheck.Env.merge | def merge(other)
result = Env.new
result.env = @env.merge(other.env)
return result
end | ruby | def merge(other)
result = Env.new
result.env = @env.merge(other.env)
return result
end | [
"def",
"merge",
"(",
"other",
")",
"result",
"=",
"Env",
".",
"new",
"result",
".",
"env",
"=",
"@env",
".",
"merge",
"(",
"other",
".",
"env",
")",
"return",
"result",
"end"
] | merges bindings in self with bindings in other, preferring bindings in other if there is a common key | [
"merges",
"bindings",
"in",
"self",
"with",
"bindings",
"in",
"other",
"preferring",
"bindings",
"in",
"other",
"if",
"there",
"is",
"a",
"common",
"key"
] | c00134413f7a600fd395e7e7cd8b01f57f850830 | https://github.com/plum-umd/rdl/blob/c00134413f7a600fd395e7e7cd8b01f57f850830/lib/rdl/typecheck.rb#L97-L101 |
13,094 | plum-umd/rdl | lib/rdl/types/method.rb | RDL::Type.MethodType.match | def match(other)
other = other.type if other.instance_of? AnnotatedArgType
return true if other.instance_of? WildQuery
return false unless other.instance_of? MethodType
return false unless @ret.match(other.ret)
if @block == nil
return false unless other.block == nil
else
... | ruby | def match(other)
other = other.type if other.instance_of? AnnotatedArgType
return true if other.instance_of? WildQuery
return false unless other.instance_of? MethodType
return false unless @ret.match(other.ret)
if @block == nil
return false unless other.block == nil
else
... | [
"def",
"match",
"(",
"other",
")",
"other",
"=",
"other",
".",
"type",
"if",
"other",
".",
"instance_of?",
"AnnotatedArgType",
"return",
"true",
"if",
"other",
".",
"instance_of?",
"WildQuery",
"return",
"false",
"unless",
"other",
".",
"instance_of?",
"Method... | other may not be a query | [
"other",
"may",
"not",
"be",
"a",
"query"
] | c00134413f7a600fd395e7e7cd8b01f57f850830 | https://github.com/plum-umd/rdl/blob/c00134413f7a600fd395e7e7cd8b01f57f850830/lib/rdl/types/method.rb#L308-L344 |
13,095 | spohlenz/tinymce-rails | lib/tinymce/rails/helper.rb | TinyMCE::Rails.Helper.tinymce | def tinymce(config=:default, options={})
javascript_tag(nonce: true) do
unless @_tinymce_configurations_added
concat tinymce_configurations_javascript
concat "\n"
@_tinymce_configurations_added = true
end
concat tinymce_javascript(config, options)
end
... | ruby | def tinymce(config=:default, options={})
javascript_tag(nonce: true) do
unless @_tinymce_configurations_added
concat tinymce_configurations_javascript
concat "\n"
@_tinymce_configurations_added = true
end
concat tinymce_javascript(config, options)
end
... | [
"def",
"tinymce",
"(",
"config",
"=",
":default",
",",
"options",
"=",
"{",
"}",
")",
"javascript_tag",
"(",
"nonce",
":",
"true",
")",
"do",
"unless",
"@_tinymce_configurations_added",
"concat",
"tinymce_configurations_javascript",
"concat",
"\"\\n\"",
"@_tinymce_c... | Initializes TinyMCE on the current page based on the global configuration.
Custom options can be set via the options hash, which will be passed to
the TinyMCE init function.
By default, all textareas with a class of "tinymce" will have the TinyMCE
editor applied. The current locale will also be used as the langua... | [
"Initializes",
"TinyMCE",
"on",
"the",
"current",
"page",
"based",
"on",
"the",
"global",
"configuration",
"."
] | 6f94b295f030939c8b3c7739f13812e42e6d920a | https://github.com/spohlenz/tinymce-rails/blob/6f94b295f030939c8b3c7739f13812e42e6d920a/lib/tinymce/rails/helper.rb#L18-L28 |
13,096 | spohlenz/tinymce-rails | lib/tinymce/rails/helper.rb | TinyMCE::Rails.Helper.tinymce_javascript | def tinymce_javascript(config=:default, options={})
options, config = config, :default if config.is_a?(Hash)
options = Configuration.new(options)
"TinyMCERails.initialize('#{config}', #{options.to_javascript});".html_safe
end | ruby | def tinymce_javascript(config=:default, options={})
options, config = config, :default if config.is_a?(Hash)
options = Configuration.new(options)
"TinyMCERails.initialize('#{config}', #{options.to_javascript});".html_safe
end | [
"def",
"tinymce_javascript",
"(",
"config",
"=",
":default",
",",
"options",
"=",
"{",
"}",
")",
"options",
",",
"config",
"=",
"config",
",",
":default",
"if",
"config",
".",
"is_a?",
"(",
"Hash",
")",
"options",
"=",
"Configuration",
".",
"new",
"(",
... | Returns the JavaScript code required to initialize TinyMCE. | [
"Returns",
"the",
"JavaScript",
"code",
"required",
"to",
"initialize",
"TinyMCE",
"."
] | 6f94b295f030939c8b3c7739f13812e42e6d920a | https://github.com/spohlenz/tinymce-rails/blob/6f94b295f030939c8b3c7739f13812e42e6d920a/lib/tinymce/rails/helper.rb#L31-L36 |
13,097 | spohlenz/tinymce-rails | lib/tinymce/rails/helper.rb | TinyMCE::Rails.Helper.tinymce_configurations_javascript | def tinymce_configurations_javascript(options={})
javascript = []
TinyMCE::Rails.each_configuration do |name, config|
config = config.merge(options) if options.present?
javascript << "TinyMCERails.configuration.#{name} = #{config.to_javascript};".html_safe
end
safe_join(javascr... | ruby | def tinymce_configurations_javascript(options={})
javascript = []
TinyMCE::Rails.each_configuration do |name, config|
config = config.merge(options) if options.present?
javascript << "TinyMCERails.configuration.#{name} = #{config.to_javascript};".html_safe
end
safe_join(javascr... | [
"def",
"tinymce_configurations_javascript",
"(",
"options",
"=",
"{",
"}",
")",
"javascript",
"=",
"[",
"]",
"TinyMCE",
"::",
"Rails",
".",
"each_configuration",
"do",
"|",
"name",
",",
"config",
"|",
"config",
"=",
"config",
".",
"merge",
"(",
"options",
... | Returns the JavaScript code for initializing each configuration defined within tinymce.yml. | [
"Returns",
"the",
"JavaScript",
"code",
"for",
"initializing",
"each",
"configuration",
"defined",
"within",
"tinymce",
".",
"yml",
"."
] | 6f94b295f030939c8b3c7739f13812e42e6d920a | https://github.com/spohlenz/tinymce-rails/blob/6f94b295f030939c8b3c7739f13812e42e6d920a/lib/tinymce/rails/helper.rb#L39-L48 |
13,098 | devise-security/devise-security | lib/devise-security/routes.rb | ActionDispatch::Routing.Mapper.devise_verification_code | def devise_verification_code(mapping, controllers)
resource :paranoid_verification_code, only: [:show, :update], path: mapping.path_names[:verification_code], controller: controllers[:paranoid_verification_code]
end | ruby | def devise_verification_code(mapping, controllers)
resource :paranoid_verification_code, only: [:show, :update], path: mapping.path_names[:verification_code], controller: controllers[:paranoid_verification_code]
end | [
"def",
"devise_verification_code",
"(",
"mapping",
",",
"controllers",
")",
"resource",
":paranoid_verification_code",
",",
"only",
":",
"[",
":show",
",",
":update",
"]",
",",
"path",
":",
"mapping",
".",
"path_names",
"[",
":verification_code",
"]",
",",
"cont... | route for handle paranoid verification | [
"route",
"for",
"handle",
"paranoid",
"verification"
] | d0b44a7bb249f6763641f45d34dd52e7fda3fca2 | https://github.com/devise-security/devise-security/blob/d0b44a7bb249f6763641f45d34dd52e7fda3fca2/lib/devise-security/routes.rb#L14-L16 |
13,099 | devise-security/devise-security | lib/devise-security/models/password_expirable.rb | Devise::Models.PasswordExpirable.password_too_old? | def password_too_old?
return false if new_record?
return false unless password_expiration_enabled?
return false if expire_password_on_demand?
password_changed_at < expire_password_after.seconds.ago
end | ruby | def password_too_old?
return false if new_record?
return false unless password_expiration_enabled?
return false if expire_password_on_demand?
password_changed_at < expire_password_after.seconds.ago
end | [
"def",
"password_too_old?",
"return",
"false",
"if",
"new_record?",
"return",
"false",
"unless",
"password_expiration_enabled?",
"return",
"false",
"if",
"expire_password_on_demand?",
"password_changed_at",
"<",
"expire_password_after",
".",
"seconds",
".",
"ago",
"end"
] | Is this password older than the configured expiration timeout?
@return [Boolean] | [
"Is",
"this",
"password",
"older",
"than",
"the",
"configured",
"expiration",
"timeout?"
] | d0b44a7bb249f6763641f45d34dd52e7fda3fca2 | https://github.com/devise-security/devise-security/blob/d0b44a7bb249f6763641f45d34dd52e7fda3fca2/lib/devise-security/models/password_expirable.rb#L81-L87 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.