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 = old_was_active if old_buffer
@haml_buffer = old_buffer
end
|
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 = old_was_active if old_buffer
@haml_buffer = old_buffer
end
|
[
"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",
"=",
"old_was_active",
"if",
"old_buffer",
"@haml_buffer",
"=",
"old_buffer",
"end"
] |
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",
")",
"}",
"end"
] |
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",
"unless",
"to_close",
"-",
"1",
"-",
"i",
"==",
"0",
"&&",
"continuation_script?",
"(",
"line",
".",
"text",
")",
"}",
"end"
] |
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 push plain(line.strip!(3), :escape_html) if line.text[1, 2] == '=='
return push script(line.strip!(2), :escape_html) if line.text[1] == SCRIPT
return push flat_script(line.strip!(2), :escape_html) if line.text[1] == FLAT_SCRIPT
return push plain(line.strip!(1), :escape_html) if line.text[1] == ?\s || line.text[1..2] == '#{'
push plain(line)
when SCRIPT
return push plain(line.strip!(2)) if line.text[1] == SCRIPT
line.text = line.text[1..-1]
push script(line)
when FLAT_SCRIPT; push flat_script(line.strip!(1))
when SILENT_SCRIPT
return push haml_comment(line.text[2..-1]) if line.text[1] == SILENT_COMMENT
push silent_script(line)
when FILTER; push filter(line.text[1..-1].downcase)
when DOCTYPE
return push doctype(line.text) if line.text[0, 3] == '!!!'
return push plain(line.strip!(3), false) if line.text[1, 2] == '=='
return push script(line.strip!(2), false) if line.text[1] == SCRIPT
return push flat_script(line.strip!(2), false) if line.text[1] == FLAT_SCRIPT
return push plain(line.strip!(1), false) if line.text[1] == ?\s || line.text[1..2] == '#{'
push plain(line)
when ESCAPE
line.text = line.text[1..-1]
push plain(line)
else; push plain(line)
end
end
|
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 push plain(line.strip!(3), :escape_html) if line.text[1, 2] == '=='
return push script(line.strip!(2), :escape_html) if line.text[1] == SCRIPT
return push flat_script(line.strip!(2), :escape_html) if line.text[1] == FLAT_SCRIPT
return push plain(line.strip!(1), :escape_html) if line.text[1] == ?\s || line.text[1..2] == '#{'
push plain(line)
when SCRIPT
return push plain(line.strip!(2)) if line.text[1] == SCRIPT
line.text = line.text[1..-1]
push script(line)
when FLAT_SCRIPT; push flat_script(line.strip!(1))
when SILENT_SCRIPT
return push haml_comment(line.text[2..-1]) if line.text[1] == SILENT_COMMENT
push silent_script(line)
when FILTER; push filter(line.text[1..-1].downcase)
when DOCTYPE
return push doctype(line.text) if line.text[0, 3] == '!!!'
return push plain(line.strip!(3), false) if line.text[1, 2] == '=='
return push script(line.strip!(2), false) if line.text[1] == SCRIPT
return push flat_script(line.strip!(2), false) if line.text[1] == FLAT_SCRIPT
return push plain(line.strip!(1), false) if line.text[1] == ?\s || line.text[1..2] == '#{'
push plain(line)
when ESCAPE
line.text = line.text[1..-1]
push plain(line)
else; push plain(line)
end
end
|
[
"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",
"push",
"plain",
"(",
"line",
".",
"strip!",
"(",
"3",
")",
",",
":escape_html",
")",
"if",
"line",
".",
"text",
"[",
"1",
",",
"2",
"]",
"==",
"'=='",
"return",
"push",
"script",
"(",
"line",
".",
"strip!",
"(",
"2",
")",
",",
":escape_html",
")",
"if",
"line",
".",
"text",
"[",
"1",
"]",
"==",
"SCRIPT",
"return",
"push",
"flat_script",
"(",
"line",
".",
"strip!",
"(",
"2",
")",
",",
":escape_html",
")",
"if",
"line",
".",
"text",
"[",
"1",
"]",
"==",
"FLAT_SCRIPT",
"return",
"push",
"plain",
"(",
"line",
".",
"strip!",
"(",
"1",
")",
",",
":escape_html",
")",
"if",
"line",
".",
"text",
"[",
"1",
"]",
"==",
"?\\s",
"||",
"line",
".",
"text",
"[",
"1",
"..",
"2",
"]",
"==",
"'#{'",
"push",
"plain",
"(",
"line",
")",
"when",
"SCRIPT",
"return",
"push",
"plain",
"(",
"line",
".",
"strip!",
"(",
"2",
")",
")",
"if",
"line",
".",
"text",
"[",
"1",
"]",
"==",
"SCRIPT",
"line",
".",
"text",
"=",
"line",
".",
"text",
"[",
"1",
"..",
"-",
"1",
"]",
"push",
"script",
"(",
"line",
")",
"when",
"FLAT_SCRIPT",
";",
"push",
"flat_script",
"(",
"line",
".",
"strip!",
"(",
"1",
")",
")",
"when",
"SILENT_SCRIPT",
"return",
"push",
"haml_comment",
"(",
"line",
".",
"text",
"[",
"2",
"..",
"-",
"1",
"]",
")",
"if",
"line",
".",
"text",
"[",
"1",
"]",
"==",
"SILENT_COMMENT",
"push",
"silent_script",
"(",
"line",
")",
"when",
"FILTER",
";",
"push",
"filter",
"(",
"line",
".",
"text",
"[",
"1",
"..",
"-",
"1",
"]",
".",
"downcase",
")",
"when",
"DOCTYPE",
"return",
"push",
"doctype",
"(",
"line",
".",
"text",
")",
"if",
"line",
".",
"text",
"[",
"0",
",",
"3",
"]",
"==",
"'!!!'",
"return",
"push",
"plain",
"(",
"line",
".",
"strip!",
"(",
"3",
")",
",",
"false",
")",
"if",
"line",
".",
"text",
"[",
"1",
",",
"2",
"]",
"==",
"'=='",
"return",
"push",
"script",
"(",
"line",
".",
"strip!",
"(",
"2",
")",
",",
"false",
")",
"if",
"line",
".",
"text",
"[",
"1",
"]",
"==",
"SCRIPT",
"return",
"push",
"flat_script",
"(",
"line",
".",
"strip!",
"(",
"2",
")",
",",
"false",
")",
"if",
"line",
".",
"text",
"[",
"1",
"]",
"==",
"FLAT_SCRIPT",
"return",
"push",
"plain",
"(",
"line",
".",
"strip!",
"(",
"1",
")",
",",
"false",
")",
"if",
"line",
".",
"text",
"[",
"1",
"]",
"==",
"?\\s",
"||",
"line",
".",
"text",
"[",
"1",
"..",
"2",
"]",
"==",
"'#{'",
"push",
"plain",
"(",
"line",
")",
"when",
"ESCAPE",
"line",
".",
"text",
"=",
"line",
".",
"text",
"[",
"1",
"..",
"-",
"1",
"]",
"push",
"plain",
"(",
"line",
")",
"else",
";",
"push",
"plain",
"(",
"line",
")",
"end",
"end"
] |
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_interpolation(text)
else
parse = false
end
if block_opened? && !text.empty?
raise SyntaxError.new(Haml::Error.message(:illegal_nesting_content), @next_line.index)
end
ParseNode.new(:comment, @line.index + 1, :conditional => conditional, :text => text, :revealed => revealed, :parse => parse)
end
|
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_interpolation(text)
else
parse = false
end
if block_opened? && !text.empty?
raise SyntaxError.new(Haml::Error.message(:illegal_nesting_content), @next_line.index)
end
ParseNode.new(:comment, @line.index + 1, :conditional => conditional, :text => text, :revealed => revealed, :parse => parse)
end
|
[
"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_interpolation",
"(",
"text",
")",
"else",
"parse",
"=",
"false",
"end",
"if",
"block_opened?",
"&&",
"!",
"text",
".",
"empty?",
"raise",
"SyntaxError",
".",
"new",
"(",
"Haml",
"::",
"Error",
".",
"message",
"(",
":illegal_nesting_content",
")",
",",
"@next_line",
".",
"index",
")",
"end",
"ParseNode",
".",
"new",
"(",
":comment",
",",
"@line",
".",
"index",
"+",
"1",
",",
":conditional",
"=>",
"conditional",
",",
":text",
"=>",
"text",
",",
":revealed",
"=>",
"revealed",
",",
":parse",
"=>",
"parse",
")",
"end"
] |
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",
"[",
"3",
"..",
"-",
"1",
"]",
".",
"strip",
".",
"downcase",
".",
"scan",
"(",
"DOCTYPE_REGEX",
")",
"[",
"0",
"]",
"ParseNode",
".",
"new",
"(",
":doctype",
",",
"@line",
".",
"index",
"+",
"1",
",",
":version",
"=>",
"version",
",",
":type",
"=>",
"type",
",",
":encoding",
"=>",
"encoding",
")",
"end"
] |
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_element))
end
new_attributes_hash = old_attributes_hash = last_line = nil
object_ref = :nil
attributes_hashes = {}
while rest && !rest.empty?
case rest[0]
when ?{
break if old_attributes_hash
old_attributes_hash, rest, last_line = parse_old_attributes(rest)
attributes_hashes[:old] = old_attributes_hash
when ?(
break if new_attributes_hash
new_attributes_hash, rest, last_line = parse_new_attributes(rest)
attributes_hashes[:new] = new_attributes_hash
when ?[
break unless object_ref == :nil
object_ref, rest = balance(rest, ?[, ?])
else; break
end
end
if rest && !rest.empty?
nuke_whitespace, action, value = rest.scan(/(<>|><|[><])?([=\/\~&!])?(.*)?/)[0]
if nuke_whitespace
nuke_outer_whitespace = nuke_whitespace.include? '>'
nuke_inner_whitespace = nuke_whitespace.include? '<'
end
end
if @options.remove_whitespace
nuke_outer_whitespace = true
nuke_inner_whitespace = true
end
if value.nil?
value = ''
else
value.strip!
end
[tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
nuke_inner_whitespace, action, value, last_line || @line.index + 1]
end
|
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_element))
end
new_attributes_hash = old_attributes_hash = last_line = nil
object_ref = :nil
attributes_hashes = {}
while rest && !rest.empty?
case rest[0]
when ?{
break if old_attributes_hash
old_attributes_hash, rest, last_line = parse_old_attributes(rest)
attributes_hashes[:old] = old_attributes_hash
when ?(
break if new_attributes_hash
new_attributes_hash, rest, last_line = parse_new_attributes(rest)
attributes_hashes[:new] = new_attributes_hash
when ?[
break unless object_ref == :nil
object_ref, rest = balance(rest, ?[, ?])
else; break
end
end
if rest && !rest.empty?
nuke_whitespace, action, value = rest.scan(/(<>|><|[><])?([=\/\~&!])?(.*)?/)[0]
if nuke_whitespace
nuke_outer_whitespace = nuke_whitespace.include? '>'
nuke_inner_whitespace = nuke_whitespace.include? '<'
end
end
if @options.remove_whitespace
nuke_outer_whitespace = true
nuke_inner_whitespace = true
end
if value.nil?
value = ''
else
value.strip!
end
[tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
nuke_inner_whitespace, action, value, last_line || @line.index + 1]
end
|
[
"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_element",
")",
")",
"end",
"new_attributes_hash",
"=",
"old_attributes_hash",
"=",
"last_line",
"=",
"nil",
"object_ref",
"=",
":nil",
"attributes_hashes",
"=",
"{",
"}",
"while",
"rest",
"&&",
"!",
"rest",
".",
"empty?",
"case",
"rest",
"[",
"0",
"]",
"when",
"?{",
"break",
"if",
"old_attributes_hash",
"old_attributes_hash",
",",
"rest",
",",
"last_line",
"=",
"parse_old_attributes",
"(",
"rest",
")",
"attributes_hashes",
"[",
":old",
"]",
"=",
"old_attributes_hash",
"when",
"?(",
"break",
"if",
"new_attributes_hash",
"new_attributes_hash",
",",
"rest",
",",
"last_line",
"=",
"parse_new_attributes",
"(",
"rest",
")",
"attributes_hashes",
"[",
":new",
"]",
"=",
"new_attributes_hash",
"when",
"?[",
"break",
"unless",
"object_ref",
"==",
":nil",
"object_ref",
",",
"rest",
"=",
"balance",
"(",
"rest",
",",
"?[",
",",
"?]",
")",
"else",
";",
"break",
"end",
"end",
"if",
"rest",
"&&",
"!",
"rest",
".",
"empty?",
"nuke_whitespace",
",",
"action",
",",
"value",
"=",
"rest",
".",
"scan",
"(",
"/",
"\\/",
"\\~",
"/",
")",
"[",
"0",
"]",
"if",
"nuke_whitespace",
"nuke_outer_whitespace",
"=",
"nuke_whitespace",
".",
"include?",
"'>'",
"nuke_inner_whitespace",
"=",
"nuke_whitespace",
".",
"include?",
"'<'",
"end",
"end",
"if",
"@options",
".",
"remove_whitespace",
"nuke_outer_whitespace",
"=",
"true",
"nuke_inner_whitespace",
"=",
"true",
"end",
"if",
"value",
".",
"nil?",
"value",
"=",
"''",
"else",
"value",
".",
"strip!",
"end",
"[",
"tag_name",
",",
"attributes",
",",
"attributes_hashes",
",",
"object_ref",
",",
"nuke_outer_whitespace",
",",
"nuke_inner_whitespace",
",",
"action",
",",
"value",
",",
"last_line",
"||",
"@line",
".",
"index",
"+",
"1",
"]",
"end"
] |
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",
"<<",
"[",
":code",
",",
"\"#{resolve_newlines}#{text}#{newline}\"",
"]",
"@output_line",
"=",
"@output_line",
"+",
"text",
".",
"count",
"(",
"\"\\n\"",
")",
"+",
"newline",
".",
"count",
"(",
"\"\\n\"",
")",
"end"
] |
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
end
when :script
last[1].gsub!(/\(haml_temp, (.*?)\);$/, '(haml_temp.rstrip, \1);')
rstrip_buffer! index - 1
else
raise SyntaxError.new("[HAML BUG] Undefined entry in Haml::Compiler@to_merge.")
end
end
|
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
end
when :script
last[1].gsub!(/\(haml_temp, (.*?)\);$/, '(haml_temp.rstrip, \1);')
rstrip_buffer! index - 1
else
raise SyntaxError.new("[HAML BUG] Undefined entry in Haml::Compiler@to_merge.")
end
end
|
[
"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",
"end",
"when",
":script",
"last",
"[",
"1",
"]",
".",
"gsub!",
"(",
"/",
"\\(",
"\\)",
"/",
",",
"'(haml_temp.rstrip, \\1);'",
")",
"rstrip_buffer!",
"index",
"-",
"1",
"else",
"raise",
"SyntaxError",
".",
"new",
"(",
"\"[HAML BUG] Undefined entry in Haml::Compiler@to_merge.\"",
")",
"end",
"end"
] |
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",
"end"
] |
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
@since 4.0
|
[
"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",
"."
] |
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
end
message ||= proc { |obj| "waiting for true condition on #{obj.inspect}" }
# TODO: Consider throwing argument error for mixing block & options
proc = create_proc(opt, &blk)
Wait.until(timeout: timeout, message: message, interval: interval, object: self, &proc)
self
end
|
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
end
message ||= proc { |obj| "waiting for true condition on #{obj.inspect}" }
# TODO: Consider throwing argument error for mixing block & options
proc = create_proc(opt, &blk)
Wait.until(timeout: timeout, message: message, interval: interval, object: self, &proc)
self
end
|
[
"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",
"end",
"message",
"||=",
"proc",
"{",
"|",
"obj",
"|",
"\"waiting for true condition on #{obj.inspect}\"",
"}",
"# TODO: Consider throwing argument error for mixing block & options",
"proc",
"=",
"create_proc",
"(",
"opt",
",",
"blk",
")",
"Wait",
".",
"until",
"(",
"timeout",
":",
"timeout",
",",
"message",
":",
"message",
",",
"interval",
":",
"interval",
",",
"object",
":",
"self",
",",
"proc",
")",
"self",
"end"
] |
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.present? }
browser.text_field(name: "new_user_first_name").wait_until(timeout: 60, &:present?)
browser.text_field(name: "new_user_first_name").wait_until(timeout: 60, name: 'new_user_first_name')
@param [Integer] timeout seconds to wait before timing out
@param [String] message error message for when times out
|
[
"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]
message ||= proc { |obj| "waiting for #{obj.inspect} to become present" }
wait_until(timeout: timeout, interval: interval, message: message, element_reset: true, &:present?)
end
|
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]
message ||= proc { |obj| "waiting for #{obj.inspect} to become present" }
wait_until(timeout: timeout, interval: interval, message: message, element_reset: true, &:present?)
end
|
[
"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",
"]",
"message",
"||=",
"proc",
"{",
"|",
"obj",
"|",
"\"waiting for #{obj.inspect} to become present\"",
"}",
"wait_until",
"(",
"timeout",
":",
"timeout",
",",
"interval",
":",
"interval",
",",
"message",
":",
"message",
",",
"element_reset",
":",
"true",
",",
":present?",
")",
"end"
] |
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 before each try
@param [String] message error message for when times out
@see Watir::Wait
@see Watir::Element#present?
|
[
"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]
message ||= proc { |obj| "waiting for #{obj.inspect} not to be present" }
wait_while(timeout: timeout, interval: interval, message: message, element_reset: true, &:present?)
end
|
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]
message ||= proc { |obj| "waiting for #{obj.inspect} not to be present" }
wait_while(timeout: timeout, interval: interval, message: message, element_reset: true, &:present?)
end
|
[
"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",
"]",
"message",
"||=",
"proc",
"{",
"|",
"obj",
"|",
"\"waiting for #{obj.inspect} not to be present\"",
"}",
"wait_while",
"(",
"timeout",
":",
"timeout",
",",
"interval",
":",
"interval",
",",
"message",
":",
"message",
",",
"element_reset",
":",
"true",
",",
":present?",
")",
"end"
] |
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 try
@param [String] message error message for when times out
@see Watir::Wait
@see Watir::Element#present?
|
[
"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, @element, input_value[0..-2]) }
append(input_value[-1])
return if value == input_value
raise Exception::Error, "#set! value: '#{value}' does not match expected input: '#{input_value}'"
end
|
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, @element, input_value[0..-2]) }
append(input_value[-1])
return if value == input_value
raise Exception::Error, "#set! value: '#{value}' does not match expected input: '#{input_value}'"
end
|
[
"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",
",",
"@element",
",",
"input_value",
"[",
"0",
"..",
"-",
"2",
"]",
")",
"}",
"append",
"(",
"input_value",
"[",
"-",
"1",
"]",
")",
"return",
"if",
"value",
"==",
"input_value",
"raise",
"Exception",
"::",
"Error",
",",
"\"#set! value: '#{value}' does not match expected input: '#{input_value}'\"",
"end"
] |
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",
"=",
"driver",
".",
"execute_script",
"(",
"script",
",",
"args",
")",
"browser",
".",
"wrap_elements_in",
"(",
"self",
",",
"returned",
")",
"end"
] |
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] event_name
|
[
"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",
",",
"block",
")",
"unless",
"(",
"@ignored",
"&",
"ids",
")",
".",
"any?",
"end"
] |
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 "[DEPRECATION] #{msg}#{old} is deprecated. Use #{new} instead#{ref_msg}"
end
|
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 "[DEPRECATION] #{msg}#{old} is deprecated. Use #{new} instead#{ref_msg}"
end
|
[
"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",
"\"[DEPRECATION] #{msg}#{old} is deprecated. Use #{new} instead#{ref_msg}\"",
"end"
] |
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",
"(",
"self",
",",
"@driver",
".",
"execute_script",
"(",
"script",
",",
"args",
")",
")",
"end"
] |
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 Arguments will be available in the given script in the 'arguments' pseudo-array
|
[
"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",
"{",
"@driver",
".",
"manage",
".",
"window",
".",
"size",
"=",
"dimension",
"}",
"end",
"end"
] |
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",
".",
"manage",
".",
"window",
".",
"position",
"=",
"point",
"}",
"end",
"end"
] |
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.parse(expires) : expires
end
cookie[:domain] = opts[:domain] if opts.key?(:domain)
@control.add_cookie cookie
end
|
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.parse(expires) : expires
end
cookie[:domain] = opts[:domain] if opts.key?(:domain)
@control.add_cookie cookie
end
|
[
"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",
".",
"parse",
"(",
"expires",
")",
":",
"expires",
"end",
"cookie",
"[",
":domain",
"]",
"=",
"opts",
"[",
":domain",
"]",
"if",
"opts",
".",
"key?",
"(",
":domain",
")",
"@control",
".",
"add_cookie",
"cookie",
"end"
] |
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",
"(",
":name",
")",
",",
"c",
".",
"delete",
"(",
":value",
")",
",",
"c",
")",
"end",
"end"
] |
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_rx.inspect}"
end
|
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_rx.inspect}"
end
|
[
"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_rx.inspect}\"",
"end"
] |
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_or_rx.inspect}\"",
"end"
] |
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",
"filter_windows",
"extract_selector",
"(",
"args",
")",
",",
"all",
"end",
"end"
] |
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 scroll #{@object} to: #{param}!\"",
"if",
"args",
".",
"nil?",
"@object",
".",
"browser",
".",
"execute_script",
"(",
"args",
")",
"self",
"end"
] |
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",
":",
"true",
")",
")",
"end"
] |
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?
Wait.until(timeout, message) { present? }
yield self
else
WhenPresentDecorator.new(self, timeout, message)
end
end
|
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?
Wait.until(timeout, message) { present? }
yield self
else
WhenPresentDecorator.new(self, timeout, message)
end
end
|
[
"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?",
"Wait",
".",
"until",
"(",
"timeout",
",",
"message",
")",
"{",
"present?",
"}",
"yield",
"self",
"else",
"WhenPresentDecorator",
".",
"new",
"(",
"self",
",",
"timeout",
",",
"message",
")",
"end",
"end"
] |
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 to wait before timing out
@see Watir::Wait
@see Watir::Element#present?
|
[
"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(timeout, message) { enabled? }
yield self
else
WhenEnabledDecorator.new(self, timeout, message)
end
end
|
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(timeout, message) { enabled? }
yield self
else
WhenEnabledDecorator.new(self, timeout, message)
end
end
|
[
"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",
"(",
"timeout",
",",
"message",
")",
"{",
"enabled?",
"}",
"yield",
"self",
"else",
"WhenEnabledDecorator",
".",
"new",
"(",
"self",
",",
"timeout",
",",
"message",
")",
"end",
"end"
] |
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 block or object responding to #call'",
"end",
"end"
] |
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
@yieldparam [Watir::Browser]
|
[
"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 "Could not execute After Hooks because browser window was closed #{ex}"
end
|
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 "Could not execute After Hooks because browser window was closed #{ex}"
end
|
[
"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",
"\"Could not execute After Hooks because browser window was closed #{ex}\"",
"end"
] |
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]
# TODO: Change this to `reset!` after removing deprecation
return false
end
assert_exists
true
rescue UnknownObjectException, UnknownFrameException
false
end
|
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]
# TODO: Change this to `reset!` after removing deprecation
return false
end
assert_exists
true
rescue UnknownObjectException, UnknownFrameException
false
end
|
[
"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",
"]",
"# TODO: Change this to `reset!` after removing deprecation",
"return",
"false",
"end",
"assert_exists",
"true",
"rescue",
"UnknownObjectException",
",",
"UnknownFrameException",
"false",
"end"
] |
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 { |mod| action.key_up mod }
action.perform
else
@element.click
end
end
browser.after_hooks.run
end
|
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 { |mod| action.key_up mod }
action.perform
else
@element.click
end
end
browser.after_hooks.run
end
|
[
"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",
"{",
"|",
"mod",
"|",
"action",
".",
"key_up",
"mod",
"}",
"action",
".",
"perform",
"else",
"@element",
".",
"click",
"end",
"end",
"browser",
".",
"after_hooks",
".",
"run",
"end"
] |
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(name: "new_user_button").click(:shift)
@example Click an element with several modifier keys pressed
browser.element(name: "new_user_button").click(:shift, :control)
@param [:shift, :alt, :control, :command, :meta] modifiers to press while clicking.
|
[
"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",
"browser",
".",
"after_hooks",
".",
"run",
"value",
"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",
".",
"attribute",
"attribute_name",
"}",
"end"
] |
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",
"[",
"/",
"\\-",
"/",
"]",
"result",
"[",
"key",
".",
"tr",
"(",
"'-'",
",",
"'_'",
")",
".",
"to_sym",
"]",
"=",
"result",
".",
"delete",
"(",
"key",
")",
"end",
"result",
"end"
] |
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",
"+",
"(",
"dimensions",
"[",
"'height'",
"]",
"/",
"2",
")",
")",
"end"
] |
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.logger.deprecate 'Checking `#visible? == false` to determine a stale element',
'`#stale? == true`',
reference: 'http://watir.com/staleness-changes',
ids: [:stale_visible]
end
raise unknown_exception if displayed.nil?
displayed
end
|
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.logger.deprecate 'Checking `#visible? == false` to determine a stale element',
'`#stale? == true`',
reference: 'http://watir.com/staleness-changes',
ids: [:stale_visible]
end
raise unknown_exception if displayed.nil?
displayed
end
|
[
"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",
".",
"logger",
".",
"deprecate",
"'Checking `#visible? == false` to determine a stale element'",
",",
"'`#stale? == true`'",
",",
"reference",
":",
"'http://watir.com/staleness-changes'",
",",
"ids",
":",
"[",
":stale_visible",
"]",
"end",
"raise",
"unknown_exception",
"if",
"displayed",
".",
"nil?",
"displayed",
"end"
] |
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',
ids: [:stale_present]
end
displayed
rescue UnknownObjectException, UnknownFrameException
false
end
|
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',
ids: [:stale_present]
end
displayed
rescue UnknownObjectException, UnknownFrameException
false
end
|
[
"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'",
",",
"ids",
":",
"[",
":stale_present",
"]",
"end",
"displayed",
"rescue",
"UnknownObjectException",
",",
"UnknownFrameException",
"false",
"end"
] |
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))
end
end
|
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))
end
end
|
[
"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",
")",
")",
"end",
"end"
] |
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::ElementCollection] Returns an instance of a Watir::Element subclass
|
[
"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
construct_subtype(element, hash, tag_name).tap { |e| e.cache = el }
else
element.tap { |e| e.cache = el }
end
end
end
|
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
construct_subtype(element, hash, tag_name).tap { |e| e.cache = el }
else
element.tap { |e| e.cache = el }
end
end
end
|
[
"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",
"construct_subtype",
"(",
"element",
",",
"hash",
",",
"tag_name",
")",
".",
"tap",
"{",
"|",
"e",
"|",
"e",
".",
"cache",
"=",
"el",
"}",
"else",
"element",
".",
"tap",
"{",
"|",
"e",
"|",
"e",
".",
"cache",
"=",
"el",
"}",
"end",
"end",
"end"
] |
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",
")",
"end"
] |
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(branch.target, options)
if branch.remote?
references.create("HEAD", branch.target_id, force: true)
else
references.create("HEAD", branch.canonical_name, force: true)
end
else
commit = Commit.lookup(self, self.rev_parse_oid(target))
references.create("HEAD", commit.oid, force: true)
self.checkout_tree(commit, options)
end
end
|
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(branch.target, options)
if branch.remote?
references.create("HEAD", branch.target_id, force: true)
else
references.create("HEAD", branch.canonical_name, force: true)
end
else
commit = Commit.lookup(self, self.rev_parse_oid(target))
references.create("HEAD", commit.oid, force: true)
self.checkout_tree(commit, options)
end
end
|
[
"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",
"(",
"branch",
".",
"target",
",",
"options",
")",
"if",
"branch",
".",
"remote?",
"references",
".",
"create",
"(",
"\"HEAD\"",
",",
"branch",
".",
"target_id",
",",
"force",
":",
"true",
")",
"else",
"references",
".",
"create",
"(",
"\"HEAD\"",
",",
"branch",
".",
"canonical_name",
",",
"force",
":",
"true",
")",
"end",
"else",
"commit",
"=",
"Commit",
".",
"lookup",
"(",
"self",
",",
"self",
".",
"rev_parse_oid",
"(",
"target",
")",
")",
"references",
".",
"create",
"(",
"\"HEAD\"",
",",
"commit",
".",
"oid",
",",
"force",
":",
"true",
")",
"self",
".",
"checkout_tree",
"(",
"commit",
",",
"options",
")",
"end",
"end"
] |
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",
"(",
"name",
",",
"target",
")",
"end"
] |
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",
"::",
"TreeError",
"return",
"nil",
"end",
"blob",
"=",
"Rugged",
"::",
"Blob",
".",
"lookup",
"(",
"self",
",",
"blob_data",
"[",
":oid",
"]",
")",
"(",
"blob",
".",
"type",
"==",
":blob",
")",
"?",
"blob",
":",
"nil",
"end"
] |
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_url",
".",
"push",
"(",
"args",
")",
"end"
] |
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(strategy: :force)
end
|
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(strategy: :force)
end
|
[
"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",
"(",
"strategy",
":",
":force",
")",
"end"
] |
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. checkouts the submodule
|
[
"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",
"."
] |
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",
"|",
"access_token",
"|",
"access_token",
".",
"response",
"=",
"response",
"if",
"access_token",
".",
"respond_to?",
"(",
":response=",
")",
"end",
"end"
] |
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 with appropriate authentication details
|
[
"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",
")",
"end"
] |
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",
"(",
"';'",
")",
".",
"first",
"||",
"''",
")",
".",
"strip",
"end"
] |
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",
"]",
"||=",
"{",
"}",
"opts",
"[",
":headers",
"]",
"[",
"'Authorization'",
"]",
"=",
"header",
"(",
"verb",
",",
"url",
")",
"@client",
".",
"request",
"(",
"verb",
",",
"path",
",",
"opts",
",",
"block",
")",
"end"
] |
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, String] :expires_in (nil) the number of seconds in which the AccessToken will expire
@option opts [FixNum, String] :expires_at (nil) the epoch time in seconds in which AccessToken will expire
@option opts [FixNum, String] :algorithm (hmac-sha-256) the algorithm to use for the HMAC digest (one of 'hmac-sha-256', 'hmac-sha-1')
Make a request with the MAC 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
|
[
"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)
"MAC id=\"#{token}\", ts=\"#{timestamp}\", nonce=\"#{nonce}\", mac=\"#{mac}\""
end
|
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)
"MAC id=\"#{token}\", ts=\"#{timestamp}\", nonce=\"#{nonce}\", mac=\"#{mac}\""
end
|
[
"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",
")",
"\"MAC id=\\\"#{token}\\\", ts=\\\"#{timestamp}\\\", nonce=\\\"#{nonce}\\\", mac=\\\"#{mac}\\\"\"",
"end"
] |
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",
".",
"port",
",",
"''",
",",
"nil",
"]",
".",
"join",
"(",
"\"\\n\"",
")",
"Base64",
".",
"strict_encode64",
"(",
"OpenSSL",
"::",
"HMAC",
".",
"digest",
"(",
"@algorithm",
",",
"secret",
",",
"signature",
")",
")",
"end"
] |
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",
"else",
"raise",
"(",
"ArgumentError",
",",
"'Unsupported algorithm'",
")",
"end",
"end",
"end"
] |
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_class)
new_token.options = options
new_token.refresh_token = refresh_token unless new_token.refresh_token
new_token
end
|
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_class)
new_token.options = options
new_token.refresh_token = refresh_token unless new_token.refresh_token
new_token
end
|
[
"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_class",
")",
"new_token",
".",
"options",
"=",
"options",
"new_token",
".",
"refresh_token",
"=",
"refresh_token",
"unless",
"new_token",
".",
"refresh_token",
"new_token",
"end"
] |
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, :between => @between)
@commits = log.map { |c| Git::Object::Commit.new(@base, c['sha'], c) }
end
|
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, :between => @between)
@commits = log.map { |c| Git::Object::Commit.new(@base, c['sha'], c) }
end
|
[
"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",
",",
":between",
"=>",
"@between",
")",
"@commits",
"=",
"log",
".",
"map",
"{",
"|",
"c",
"|",
"Git",
"::",
"Object",
"::",
"Commit",
".",
"new",
"(",
"@base",
",",
"c",
"[",
"'sha'",
"]",
",",
"c",
")",
"}",
"end"
] |
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).
branches[branch.full.sub('remotes/', '')] ||= branch if branch.full =~ /^remotes\/.+/
branches
end[branch_name.to_s]
end
|
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).
branches[branch.full.sub('remotes/', '')] ||= branch if branch.full =~ /^remotes\/.+/
branches
end[branch_name.to_s]
end
|
[
"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). ",
"branches",
"[",
"branch",
".",
"full",
".",
"sub",
"(",
"'remotes/'",
",",
"''",
")",
"]",
"||=",
"branch",
"if",
"branch",
".",
"full",
"=~",
"/",
"\\/",
"/",
"branches",
"end",
"[",
"branch_name",
".",
"to_s",
"]",
"end"
] |
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 target branch name.
@return [Git::Branch] the target branch.
|
[
"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[:always]
arr_opts << '--exact-match' if opts[:exact_match] || opts[:"exact-match"]
arr_opts << '--dirty' if opts['dirty'] == true
arr_opts << "--dirty=#{opts['dirty']}" if opts['dirty'].is_a?(String)
arr_opts << "--abbrev=#{opts['abbrev']}" if opts[:abbrev]
arr_opts << "--candidates=#{opts['candidates']}" if opts[:candidates]
arr_opts << "--match=#{opts['match']}" if opts[:match]
arr_opts << committish if committish
return command('describe', arr_opts)
end
|
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[:always]
arr_opts << '--exact-match' if opts[:exact_match] || opts[:"exact-match"]
arr_opts << '--dirty' if opts['dirty'] == true
arr_opts << "--dirty=#{opts['dirty']}" if opts['dirty'].is_a?(String)
arr_opts << "--abbrev=#{opts['abbrev']}" if opts[:abbrev]
arr_opts << "--candidates=#{opts['candidates']}" if opts[:candidates]
arr_opts << "--match=#{opts['match']}" if opts[:match]
arr_opts << committish if committish
return command('describe', arr_opts)
end
|
[
"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",
"[",
":always",
"]",
"arr_opts",
"<<",
"'--exact-match'",
"if",
"opts",
"[",
":exact_match",
"]",
"||",
"opts",
"[",
":\"",
"\"",
"]",
"arr_opts",
"<<",
"'--dirty'",
"if",
"opts",
"[",
"'dirty'",
"]",
"==",
"true",
"arr_opts",
"<<",
"\"--dirty=#{opts['dirty']}\"",
"if",
"opts",
"[",
"'dirty'",
"]",
".",
"is_a?",
"(",
"String",
")",
"arr_opts",
"<<",
"\"--abbrev=#{opts['abbrev']}\"",
"if",
"opts",
"[",
":abbrev",
"]",
"arr_opts",
"<<",
"\"--candidates=#{opts['candidates']}\"",
"if",
"opts",
"[",
":candidates",
"]",
"arr_opts",
"<<",
"\"--match=#{opts['match']}\"",
"if",
"opts",
"[",
":match",
"]",
"arr_opts",
"<<",
"committish",
"if",
"committish",
"return",
"command",
"(",
"'describe'",
",",
"arr_opts",
")",
"end"
] |
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)
:path:: directory where the repo will be cloned
:remote:: name of remote (rather than 'origin')
:recursive:: after the clone is created, initialize all submodules within, using their default settings.
TODO - make this work with SSH password or auth_key
READ COMMANDS
Returns most recent tag that is reachable from a commit
accepts options:
:all
:tags
:contains
:debug
:exact_match
:dirty
:abbrev
:candidates
:long
:always
:math
@param [String|NilClass] committish target commit sha or object name
@param [{Symbol=>Object}] opts the given options
@return [String] the tag name
|
[
"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'",
",",
"arr_opts",
")",
"end"
] |
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 Ruby doesn't delete it
# when it finalizes the Tempfile.
tempfile.close!
end
arr_opts = []
arr_opts << "--format=#{opts[:format]}" if opts[:format]
arr_opts << "--prefix=#{opts[:prefix]}" if opts[:prefix]
arr_opts << "--remote=#{opts[:remote]}" if opts[:remote]
arr_opts << sha
arr_opts << '--' << opts[:path] if opts[:path]
command('archive', arr_opts, true, (opts[:add_gzip] ? '| gzip' : '') + " > #{escape file}")
return file
end
|
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 Ruby doesn't delete it
# when it finalizes the Tempfile.
tempfile.close!
end
arr_opts = []
arr_opts << "--format=#{opts[:format]}" if opts[:format]
arr_opts << "--prefix=#{opts[:prefix]}" if opts[:prefix]
arr_opts << "--remote=#{opts[:remote]}" if opts[:remote]
arr_opts << sha
arr_opts << '--' << opts[:path] if opts[:path]
command('archive', arr_opts, true, (opts[:add_gzip] ? '| gzip' : '') + " > #{escape file}")
return file
end
|
[
"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 Ruby doesn't delete it",
"# when it finalizes the Tempfile.",
"tempfile",
".",
"close!",
"end",
"arr_opts",
"=",
"[",
"]",
"arr_opts",
"<<",
"\"--format=#{opts[:format]}\"",
"if",
"opts",
"[",
":format",
"]",
"arr_opts",
"<<",
"\"--prefix=#{opts[:prefix]}\"",
"if",
"opts",
"[",
":prefix",
"]",
"arr_opts",
"<<",
"\"--remote=#{opts[:remote]}\"",
"if",
"opts",
"[",
":remote",
"]",
"arr_opts",
"<<",
"sha",
"arr_opts",
"<<",
"'--'",
"<<",
"opts",
"[",
":path",
"]",
"if",
"opts",
"[",
":path",
"]",
"command",
"(",
"'archive'",
",",
"arr_opts",
",",
"true",
",",
"(",
"opts",
"[",
":add_gzip",
"]",
"?",
"'| gzip'",
":",
"''",
")",
"+",
"\" > #{escape file}\"",
")",
"return",
"file",
"end"
] |
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",
"{",
"|",
"i",
"|",
"i",
".",
"to_i",
"}",
"end"
] |
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]}" if opts[:grep].is_a? String
arr_opts << "--author=#{opts[:author]}" if opts[:author].is_a? String
arr_opts << "#{opts[:between][0].to_s}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
arr_opts
end
|
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]}" if opts[:grep].is_a? String
arr_opts << "--author=#{opts[:author]}" if opts[:author].is_a? String
arr_opts << "#{opts[:between][0].to_s}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
arr_opts
end
|
[
"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]}\"",
"if",
"opts",
"[",
":grep",
"]",
".",
"is_a?",
"String",
"arr_opts",
"<<",
"\"--author=#{opts[:author]}\"",
"if",
"opts",
"[",
":author",
"]",
".",
"is_a?",
"String",
"arr_opts",
"<<",
"\"#{opts[:between][0].to_s}..#{opts[:between][1].to_s}\"",
"if",
"(",
"opts",
"[",
":between",
"]",
"&&",
"opts",
"[",
":between",
"]",
".",
"size",
"==",
"2",
")",
"arr_opts",
"end"
] |
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",
"opts",
"[",
":path_limiter",
"]",
"arr_opts",
"end"
] |
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:
# one to open the element and one to close it.
opener = Nokogiri::XML::Reader::TYPE_ELEMENT
closer = Nokogiri::XML::Reader::TYPE_END_ELEMENT
Enumerator.new do |y|
row, cells, cell = nil, {}, nil
cell_type = nil
cell_style_idx = nil
@book.files.file.open(path) do |xml|
Nokogiri::XML::Reader.from_io(xml).each do |node|
if (node.name.eql? 'row') and (node.node_type.eql? opener)
row = node.attributes
row['cells'] = Hash.new
cells = Hash.new
y << (include_meta_data ? row : cells) if node.self_closing?
elsif (node.name.eql? 'row') and (node.node_type.eql? closer)
processed_cells = fill_in_empty_cells(cells, row['r'], cell, use_simple_rows_format)
if @images_present
processed_cells.each do |cell_name, cell_value|
next unless cell_value.nil?
processed_cells[cell_name] = images_at(cell_name)
end
end
row['cells'] = processed_cells
y << (include_meta_data ? row : processed_cells)
elsif (node.name.eql? 'c') and (node.node_type.eql? opener)
cell_type = node.attributes['t']
cell_style_idx = node.attributes['s']
cell = node.attributes['r']
elsif (['v', 't'].include? node.name) and (node.node_type.eql? opener)
unless cell.nil?
node.read
cells[(use_simple_rows_format ? cell.tr("0-9", "") : cell)] = convert(node.value, cell_type, cell_style_idx)
end
end
end
end
end
end
end
|
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:
# one to open the element and one to close it.
opener = Nokogiri::XML::Reader::TYPE_ELEMENT
closer = Nokogiri::XML::Reader::TYPE_END_ELEMENT
Enumerator.new do |y|
row, cells, cell = nil, {}, nil
cell_type = nil
cell_style_idx = nil
@book.files.file.open(path) do |xml|
Nokogiri::XML::Reader.from_io(xml).each do |node|
if (node.name.eql? 'row') and (node.node_type.eql? opener)
row = node.attributes
row['cells'] = Hash.new
cells = Hash.new
y << (include_meta_data ? row : cells) if node.self_closing?
elsif (node.name.eql? 'row') and (node.node_type.eql? closer)
processed_cells = fill_in_empty_cells(cells, row['r'], cell, use_simple_rows_format)
if @images_present
processed_cells.each do |cell_name, cell_value|
next unless cell_value.nil?
processed_cells[cell_name] = images_at(cell_name)
end
end
row['cells'] = processed_cells
y << (include_meta_data ? row : processed_cells)
elsif (node.name.eql? 'c') and (node.node_type.eql? opener)
cell_type = node.attributes['t']
cell_style_idx = node.attributes['s']
cell = node.attributes['r']
elsif (['v', 't'].include? node.name) and (node.node_type.eql? opener)
unless cell.nil?
node.read
cells[(use_simple_rows_format ? cell.tr("0-9", "") : cell)] = convert(node.value, cell_type, cell_style_idx)
end
end
end
end
end
end
end
|
[
"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:",
"# one to open the element and one to close it.",
"opener",
"=",
"Nokogiri",
"::",
"XML",
"::",
"Reader",
"::",
"TYPE_ELEMENT",
"closer",
"=",
"Nokogiri",
"::",
"XML",
"::",
"Reader",
"::",
"TYPE_END_ELEMENT",
"Enumerator",
".",
"new",
"do",
"|",
"y",
"|",
"row",
",",
"cells",
",",
"cell",
"=",
"nil",
",",
"{",
"}",
",",
"nil",
"cell_type",
"=",
"nil",
"cell_style_idx",
"=",
"nil",
"@book",
".",
"files",
".",
"file",
".",
"open",
"(",
"path",
")",
"do",
"|",
"xml",
"|",
"Nokogiri",
"::",
"XML",
"::",
"Reader",
".",
"from_io",
"(",
"xml",
")",
".",
"each",
"do",
"|",
"node",
"|",
"if",
"(",
"node",
".",
"name",
".",
"eql?",
"'row'",
")",
"and",
"(",
"node",
".",
"node_type",
".",
"eql?",
"opener",
")",
"row",
"=",
"node",
".",
"attributes",
"row",
"[",
"'cells'",
"]",
"=",
"Hash",
".",
"new",
"cells",
"=",
"Hash",
".",
"new",
"y",
"<<",
"(",
"include_meta_data",
"?",
"row",
":",
"cells",
")",
"if",
"node",
".",
"self_closing?",
"elsif",
"(",
"node",
".",
"name",
".",
"eql?",
"'row'",
")",
"and",
"(",
"node",
".",
"node_type",
".",
"eql?",
"closer",
")",
"processed_cells",
"=",
"fill_in_empty_cells",
"(",
"cells",
",",
"row",
"[",
"'r'",
"]",
",",
"cell",
",",
"use_simple_rows_format",
")",
"if",
"@images_present",
"processed_cells",
".",
"each",
"do",
"|",
"cell_name",
",",
"cell_value",
"|",
"next",
"unless",
"cell_value",
".",
"nil?",
"processed_cells",
"[",
"cell_name",
"]",
"=",
"images_at",
"(",
"cell_name",
")",
"end",
"end",
"row",
"[",
"'cells'",
"]",
"=",
"processed_cells",
"y",
"<<",
"(",
"include_meta_data",
"?",
"row",
":",
"processed_cells",
")",
"elsif",
"(",
"node",
".",
"name",
".",
"eql?",
"'c'",
")",
"and",
"(",
"node",
".",
"node_type",
".",
"eql?",
"opener",
")",
"cell_type",
"=",
"node",
".",
"attributes",
"[",
"'t'",
"]",
"cell_style_idx",
"=",
"node",
".",
"attributes",
"[",
"'s'",
"]",
"cell",
"=",
"node",
".",
"attributes",
"[",
"'r'",
"]",
"elsif",
"(",
"[",
"'v'",
",",
"'t'",
"]",
".",
"include?",
"node",
".",
"name",
")",
"and",
"(",
"node",
".",
"node_type",
".",
"eql?",
"opener",
")",
"unless",
"cell",
".",
"nil?",
"node",
".",
"read",
"cells",
"[",
"(",
"use_simple_rows_format",
"?",
"cell",
".",
"tr",
"(",
"\"0-9\"",
",",
"\"\"",
")",
":",
"cell",
")",
"]",
"=",
"convert",
"(",
"node",
".",
"value",
",",
"cell_type",
",",
"cell_style_idx",
")",
"end",
"end",
"end",
"end",
"end",
"end",
"end"
] |
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_cells[id] = cells[id]
end
end
new_cells
end
|
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_cells[id] = cells[id]
end
end
new_cells
end
|
[
"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_cells",
"[",
"id",
"]",
"=",
"cells",
"[",
"id",
"]",
"end",
"end",
"new_cells",
"end"
] |
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 location.
sheet_rels_filepath = expand_to_rels_path(sheet_filepath)
parse_xml(sheet_rels_filepath).css("Relationship[@Id='#{drawing_rid}']").first.attributes['Target'].value
end
|
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 location.
sheet_rels_filepath = expand_to_rels_path(sheet_filepath)
parse_xml(sheet_rels_filepath).css("Relationship[@Id='#{drawing_rid}']").first.attributes['Target'].value
end
|
[
"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 location.",
"sheet_rels_filepath",
"=",
"expand_to_rels_path",
"(",
"sheet_filepath",
")",
"parse_xml",
"(",
"sheet_rels_filepath",
")",
".",
"css",
"(",
"\"Relationship[@Id='#{drawing_rid}']\"",
")",
".",
"first",
".",
"attributes",
"[",
"'Target'",
"]",
".",
"value",
"end"
] |
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_process(:level => level,
:exception => exception,
:message => message,
:extra => extra)
return 'ignored' if status == 'ignored'
rescue Rollbar::Ignore
return 'ignored'
end
level = lookup_exception_level(level, exception,
use_exception_level_filters)
begin
report(level, message, exception, extra, context)
rescue StandardError, SystemStackError => e
report_internal_error(e)
'error'
end
end
|
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_process(:level => level,
:exception => exception,
:message => message,
:extra => extra)
return 'ignored' if status == 'ignored'
rescue Rollbar::Ignore
return 'ignored'
end
level = lookup_exception_level(level, exception,
use_exception_level_filters)
begin
report(level, message, exception, extra, context)
rescue StandardError, SystemStackError => e
report_internal_error(e)
'error'
end
end
|
[
"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_process",
"(",
":level",
"=>",
"level",
",",
":exception",
"=>",
"exception",
",",
":message",
"=>",
"message",
",",
":extra",
"=>",
"extra",
")",
"return",
"'ignored'",
"if",
"status",
"==",
"'ignored'",
"rescue",
"Rollbar",
"::",
"Ignore",
"return",
"'ignored'",
"end",
"level",
"=",
"lookup_exception_level",
"(",
"level",
",",
"exception",
",",
"use_exception_level_filters",
")",
"begin",
"report",
"(",
"level",
",",
"message",
",",
"exception",
",",
"extra",
",",
"context",
")",
"rescue",
"StandardError",
",",
"SystemStackError",
"=>",
"e",
"report_internal_error",
"(",
"e",
")",
"'error'",
"end",
"end"
] |
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 contains a symbol key :custom_data_method_context
the value of the key will be used as the context for
configuration.custom_data_method and will be removed from the extra
hash.
@example
begin
foo = bar
rescue => e
Rollbar.log(e)
end
@example
Rollbar.log('This is a simple log message')
@example
Rollbar.log(e, 'This is a description of the exception')
|
[
"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.silenced do
begin
process_item(item)
rescue StandardError => e
report_internal_error(e)
raise
end
end
end
|
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.silenced do
begin
process_item(item)
rescue StandardError => e
report_internal_error(e)
raise
end
end
end
|
[
"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",
".",
"silenced",
"do",
"begin",
"process_item",
"(",
"item",
")",
"rescue",
"StandardError",
"=>",
"e",
"report_internal_error",
"(",
"e",
")",
"raise",
"end",
"end",
"end"
] |
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 Sidekiq queue.
3. The Sidekiq job tries to send the report to our API
4. The report fails, for example cause a network failure,
and a exception is raised
5. We report an internal error for that exception
6. We reraise the exception so Sidekiq job fails and
Sidekiq can retry the job reporting the original exception
7. Because the job failed and Sidekiq can be managed by rollbar we'll
report a new exception.
8. Go to point 2.
We'll then push to Sidekiq queue indefinitely until the network failure
is fixed.
Using Rollbar.silenced we avoid the above behavior but Sidekiq
will have a chance to retry the original job.
|
[
"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 StandardError => e
send_failsafe('build_item in exception_data', e)
log_error "[Rollbar] Exception: #{exception}"
return
end
begin
process_item(item)
rescue StandardError => e
send_failsafe('error in process_item', e)
log_error "[Rollbar] Item: #{item}"
return
end
begin
log_instance_link(item['data'])
rescue StandardError => e
send_failsafe('error logging instance link', e)
log_error "[Rollbar] Item: #{item}"
return
end
end
|
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 StandardError => e
send_failsafe('build_item in exception_data', e)
log_error "[Rollbar] Exception: #{exception}"
return
end
begin
process_item(item)
rescue StandardError => e
send_failsafe('error in process_item', e)
log_error "[Rollbar] Item: #{item}"
return
end
begin
log_instance_link(item['data'])
rescue StandardError => e
send_failsafe('error logging instance link', e)
log_error "[Rollbar] Item: #{item}"
return
end
end
|
[
"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",
"StandardError",
"=>",
"e",
"send_failsafe",
"(",
"'build_item in exception_data'",
",",
"e",
")",
"log_error",
"\"[Rollbar] Exception: #{exception}\"",
"return",
"end",
"begin",
"process_item",
"(",
"item",
")",
"rescue",
"StandardError",
"=>",
"e",
"send_failsafe",
"(",
"'error in process_item'",
",",
"e",
")",
"log_error",
"\"[Rollbar] Item: #{item}\"",
"return",
"end",
"begin",
"log_instance_link",
"(",
"item",
"[",
"'data'",
"]",
")",
"rescue",
"StandardError",
"=>",
"e",
"send_failsafe",
"(",
"'error logging instance link'",
",",
"e",
")",
"log_error",
"\"[Rollbar] Item: #{item}\"",
"return",
"end",
"end"
] |
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",
"exception",
"traceback",
".",
"If",
"that",
"fails",
"we",
"ll",
"fall",
"back",
"to",
"a",
"more",
"static",
"failsafe",
"response",
"."
] |
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,
:context => context
}
item = Item.new(options)
item.build
item
end
|
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,
:context => context
}
item = Item.new(options)
item.build
item
end
|
[
"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",
",",
":context",
"=>",
"context",
"}",
"item",
"=",
"Item",
".",
"new",
"(",
"options",
")",
"item",
".",
"build",
"item",
"end"
] |
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",
"]",
"result",
"=",
"Env",
".",
"new",
"result",
".",
"env",
"=",
"@env",
".",
"merge",
"(",
"var",
"=>",
"{",
"type",
":",
"typ",
",",
"fixed",
":",
"false",
"}",
")",
"return",
"result",
"end"
] |
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
return false if other.block == nil
return false unless @block.match(other.block)
end
# Check arg matches; logic is similar to pre_cond
states = [[0,0]] # [position in self, position in other]
until states.empty?
s_arg, o_arg = states.pop
return true if s_arg == @args.size && o_arg == other.args.size # everything matches
next if s_arg >= @args.size # match not possible, not enough args in self
if @args[s_arg].instance_of? DotsQuery then
if o_arg == other.args.size
# no args left in other, skip ...
states << [s_arg+1, o_arg]
else
states << [s_arg+1, o_arg+1] # match, no more matches to ...
states << [s_arg, o_arg+1] # match, more matches to ... coming
end
else
next if o_arg == other.args.size # match not possible, not enough args in other
s_arg_t = @args[s_arg]
s_arg_t = s_arg_t.type if s_arg_t.instance_of? AnnotatedArgType
o_arg_t = other.args[o_arg]
o_arg_t = o_arg_t.type if o_arg_t.instance_of? AnnotatedArgType
next unless s_arg_t.match(o_arg_t)
states << [s_arg+1, o_arg+1]
end
end
return false
end
|
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
return false if other.block == nil
return false unless @block.match(other.block)
end
# Check arg matches; logic is similar to pre_cond
states = [[0,0]] # [position in self, position in other]
until states.empty?
s_arg, o_arg = states.pop
return true if s_arg == @args.size && o_arg == other.args.size # everything matches
next if s_arg >= @args.size # match not possible, not enough args in self
if @args[s_arg].instance_of? DotsQuery then
if o_arg == other.args.size
# no args left in other, skip ...
states << [s_arg+1, o_arg]
else
states << [s_arg+1, o_arg+1] # match, no more matches to ...
states << [s_arg, o_arg+1] # match, more matches to ... coming
end
else
next if o_arg == other.args.size # match not possible, not enough args in other
s_arg_t = @args[s_arg]
s_arg_t = s_arg_t.type if s_arg_t.instance_of? AnnotatedArgType
o_arg_t = other.args[o_arg]
o_arg_t = o_arg_t.type if o_arg_t.instance_of? AnnotatedArgType
next unless s_arg_t.match(o_arg_t)
states << [s_arg+1, o_arg+1]
end
end
return false
end
|
[
"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",
"return",
"false",
"if",
"other",
".",
"block",
"==",
"nil",
"return",
"false",
"unless",
"@block",
".",
"match",
"(",
"other",
".",
"block",
")",
"end",
"# Check arg matches; logic is similar to pre_cond",
"states",
"=",
"[",
"[",
"0",
",",
"0",
"]",
"]",
"# [position in self, position in other]",
"until",
"states",
".",
"empty?",
"s_arg",
",",
"o_arg",
"=",
"states",
".",
"pop",
"return",
"true",
"if",
"s_arg",
"==",
"@args",
".",
"size",
"&&",
"o_arg",
"==",
"other",
".",
"args",
".",
"size",
"# everything matches",
"next",
"if",
"s_arg",
">=",
"@args",
".",
"size",
"# match not possible, not enough args in self",
"if",
"@args",
"[",
"s_arg",
"]",
".",
"instance_of?",
"DotsQuery",
"then",
"if",
"o_arg",
"==",
"other",
".",
"args",
".",
"size",
"# no args left in other, skip ...",
"states",
"<<",
"[",
"s_arg",
"+",
"1",
",",
"o_arg",
"]",
"else",
"states",
"<<",
"[",
"s_arg",
"+",
"1",
",",
"o_arg",
"+",
"1",
"]",
"# match, no more matches to ...",
"states",
"<<",
"[",
"s_arg",
",",
"o_arg",
"+",
"1",
"]",
"# match, more matches to ... coming",
"end",
"else",
"next",
"if",
"o_arg",
"==",
"other",
".",
"args",
".",
"size",
"# match not possible, not enough args in other",
"s_arg_t",
"=",
"@args",
"[",
"s_arg",
"]",
"s_arg_t",
"=",
"s_arg_t",
".",
"type",
"if",
"s_arg_t",
".",
"instance_of?",
"AnnotatedArgType",
"o_arg_t",
"=",
"other",
".",
"args",
"[",
"o_arg",
"]",
"o_arg_t",
"=",
"o_arg_t",
".",
"type",
"if",
"o_arg_t",
".",
"instance_of?",
"AnnotatedArgType",
"next",
"unless",
"s_arg_t",
".",
"match",
"(",
"o_arg_t",
")",
"states",
"<<",
"[",
"s_arg",
"+",
"1",
",",
"o_arg",
"+",
"1",
"]",
"end",
"end",
"return",
"false",
"end"
] |
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
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
end
|
[
"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",
"end"
] |
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 language when
TinyMCE language files are available, falling back to English if not
available. The :editor_selector and :language options can be used to
override these defaults.
@example
<%= tinymce(selector: "editorClass", theme: "inlite") %>
|
[
"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",
"(",
"options",
")",
"\"TinyMCERails.initialize('#{config}', #{options.to_javascript});\"",
".",
"html_safe",
"end"
] |
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(javascript, "\n")
end
|
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(javascript, "\n")
end
|
[
"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",
"(",
"javascript",
",",
"\"\\n\"",
")",
"end"
] |
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",
"]",
",",
"controller",
":",
"controllers",
"[",
":paranoid_verification_code",
"]",
"end"
] |
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.