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
sequence | docstring
stringlengths 8
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 94
266
|
---|---|---|---|---|---|---|---|---|---|---|---|
1,700 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb | RDoc.Fortran95parser.check_external_aliases | def check_external_aliases(subname, params, comment, test=nil)
@@external_aliases.each{ |alias_item|
if subname == alias_item["old_name"] ||
subname.upcase == alias_item["old_name"].upcase &&
@options.ignore_case
new_meth = initialize_external_method(alias_item["new_name"],
subname, params, @file_name,
comment)
new_meth.visibility = alias_item["visibility"]
progress "e"
@stats.num_methods += 1
alias_item["file_or_module"].add_method(new_meth)
if !alias_item["file_or_module"].include_requires?(@file_name, @options.ignore_case)
alias_item["file_or_module"].add_require(Require.new(@file_name, ""))
end
end
}
end | ruby | def check_external_aliases(subname, params, comment, test=nil)
@@external_aliases.each{ |alias_item|
if subname == alias_item["old_name"] ||
subname.upcase == alias_item["old_name"].upcase &&
@options.ignore_case
new_meth = initialize_external_method(alias_item["new_name"],
subname, params, @file_name,
comment)
new_meth.visibility = alias_item["visibility"]
progress "e"
@stats.num_methods += 1
alias_item["file_or_module"].add_method(new_meth)
if !alias_item["file_or_module"].include_requires?(@file_name, @options.ignore_case)
alias_item["file_or_module"].add_require(Require.new(@file_name, ""))
end
end
}
end | [
"def",
"check_external_aliases",
"(",
"subname",
",",
"params",
",",
"comment",
",",
"test",
"=",
"nil",
")",
"@@external_aliases",
".",
"each",
"{",
"|",
"alias_item",
"|",
"if",
"subname",
"==",
"alias_item",
"[",
"\"old_name\"",
"]",
"||",
"subname",
".",
"upcase",
"==",
"alias_item",
"[",
"\"old_name\"",
"]",
".",
"upcase",
"&&",
"@options",
".",
"ignore_case",
"new_meth",
"=",
"initialize_external_method",
"(",
"alias_item",
"[",
"\"new_name\"",
"]",
",",
"subname",
",",
"params",
",",
"@file_name",
",",
"comment",
")",
"new_meth",
".",
"visibility",
"=",
"alias_item",
"[",
"\"visibility\"",
"]",
"progress",
"\"e\"",
"@stats",
".",
"num_methods",
"+=",
"1",
"alias_item",
"[",
"\"file_or_module\"",
"]",
".",
"add_method",
"(",
"new_meth",
")",
"if",
"!",
"alias_item",
"[",
"\"file_or_module\"",
"]",
".",
"include_requires?",
"(",
"@file_name",
",",
"@options",
".",
"ignore_case",
")",
"alias_item",
"[",
"\"file_or_module\"",
"]",
".",
"add_require",
"(",
"Require",
".",
"new",
"(",
"@file_name",
",",
"\"\"",
")",
")",
"end",
"end",
"}",
"end"
] | Check external aliases | [
"Check",
"external",
"aliases"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb#L1328-L1348 |
1,701 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb | RDoc.Fortran95parser.united_to_one_line | def united_to_one_line(f90src)
return "" unless f90src
lines = f90src.split("\n")
previous_continuing = false
now_continuing = false
body = ""
lines.each{ |line|
words = line.split("")
next if words.empty? && previous_continuing
commentout = false
brank_flag = true ; brank_char = ""
squote = false ; dquote = false
ignore = false
words.collect! { |char|
if previous_continuing && brank_flag
now_continuing = true
ignore = true
case char
when "!" ; break
when " " ; brank_char << char ; next ""
when "&"
brank_flag = false
now_continuing = false
next ""
else
brank_flag = false
now_continuing = false
ignore = false
next brank_char + char
end
end
ignore = false
if now_continuing
next ""
elsif !(squote) && !(dquote) && !(commentout)
case char
when "!" ; commentout = true ; next char
when "\""; dquote = true ; next char
when "\'"; squote = true ; next char
when "&" ; now_continuing = true ; next ""
else next char
end
elsif commentout
next char
elsif squote
case char
when "\'"; squote = false ; next char
else next char
end
elsif dquote
case char
when "\""; dquote = false ; next char
else next char
end
end
}
if !ignore && !previous_continuing || !brank_flag
if previous_continuing
body << words.join("")
else
body << "\n" + words.join("")
end
end
previous_continuing = now_continuing ? true : nil
now_continuing = nil
}
return body
end | ruby | def united_to_one_line(f90src)
return "" unless f90src
lines = f90src.split("\n")
previous_continuing = false
now_continuing = false
body = ""
lines.each{ |line|
words = line.split("")
next if words.empty? && previous_continuing
commentout = false
brank_flag = true ; brank_char = ""
squote = false ; dquote = false
ignore = false
words.collect! { |char|
if previous_continuing && brank_flag
now_continuing = true
ignore = true
case char
when "!" ; break
when " " ; brank_char << char ; next ""
when "&"
brank_flag = false
now_continuing = false
next ""
else
brank_flag = false
now_continuing = false
ignore = false
next brank_char + char
end
end
ignore = false
if now_continuing
next ""
elsif !(squote) && !(dquote) && !(commentout)
case char
when "!" ; commentout = true ; next char
when "\""; dquote = true ; next char
when "\'"; squote = true ; next char
when "&" ; now_continuing = true ; next ""
else next char
end
elsif commentout
next char
elsif squote
case char
when "\'"; squote = false ; next char
else next char
end
elsif dquote
case char
when "\""; dquote = false ; next char
else next char
end
end
}
if !ignore && !previous_continuing || !brank_flag
if previous_continuing
body << words.join("")
else
body << "\n" + words.join("")
end
end
previous_continuing = now_continuing ? true : nil
now_continuing = nil
}
return body
end | [
"def",
"united_to_one_line",
"(",
"f90src",
")",
"return",
"\"\"",
"unless",
"f90src",
"lines",
"=",
"f90src",
".",
"split",
"(",
"\"\\n\"",
")",
"previous_continuing",
"=",
"false",
"now_continuing",
"=",
"false",
"body",
"=",
"\"\"",
"lines",
".",
"each",
"{",
"|",
"line",
"|",
"words",
"=",
"line",
".",
"split",
"(",
"\"\"",
")",
"next",
"if",
"words",
".",
"empty?",
"&&",
"previous_continuing",
"commentout",
"=",
"false",
"brank_flag",
"=",
"true",
";",
"brank_char",
"=",
"\"\"",
"squote",
"=",
"false",
";",
"dquote",
"=",
"false",
"ignore",
"=",
"false",
"words",
".",
"collect!",
"{",
"|",
"char",
"|",
"if",
"previous_continuing",
"&&",
"brank_flag",
"now_continuing",
"=",
"true",
"ignore",
"=",
"true",
"case",
"char",
"when",
"\"!\"",
";",
"break",
"when",
"\" \"",
";",
"brank_char",
"<<",
"char",
";",
"next",
"\"\"",
"when",
"\"&\"",
"brank_flag",
"=",
"false",
"now_continuing",
"=",
"false",
"next",
"\"\"",
"else",
"brank_flag",
"=",
"false",
"now_continuing",
"=",
"false",
"ignore",
"=",
"false",
"next",
"brank_char",
"+",
"char",
"end",
"end",
"ignore",
"=",
"false",
"if",
"now_continuing",
"next",
"\"\"",
"elsif",
"!",
"(",
"squote",
")",
"&&",
"!",
"(",
"dquote",
")",
"&&",
"!",
"(",
"commentout",
")",
"case",
"char",
"when",
"\"!\"",
";",
"commentout",
"=",
"true",
";",
"next",
"char",
"when",
"\"\\\"\"",
";",
"dquote",
"=",
"true",
";",
"next",
"char",
"when",
"\"\\'\"",
";",
"squote",
"=",
"true",
";",
"next",
"char",
"when",
"\"&\"",
";",
"now_continuing",
"=",
"true",
";",
"next",
"\"\"",
"else",
"next",
"char",
"end",
"elsif",
"commentout",
"next",
"char",
"elsif",
"squote",
"case",
"char",
"when",
"\"\\'\"",
";",
"squote",
"=",
"false",
";",
"next",
"char",
"else",
"next",
"char",
"end",
"elsif",
"dquote",
"case",
"char",
"when",
"\"\\\"\"",
";",
"dquote",
"=",
"false",
";",
"next",
"char",
"else",
"next",
"char",
"end",
"end",
"}",
"if",
"!",
"ignore",
"&&",
"!",
"previous_continuing",
"||",
"!",
"brank_flag",
"if",
"previous_continuing",
"body",
"<<",
"words",
".",
"join",
"(",
"\"\"",
")",
"else",
"body",
"<<",
"\"\\n\"",
"+",
"words",
".",
"join",
"(",
"\"\"",
")",
"end",
"end",
"previous_continuing",
"=",
"now_continuing",
"?",
"true",
":",
"nil",
"now_continuing",
"=",
"nil",
"}",
"return",
"body",
"end"
] | Continuous lines are united.
Comments in continuous lines are removed. | [
"Continuous",
"lines",
"are",
"united",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb#L1387-L1455 |
1,702 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb | RDoc.Fortran95parser.continuous_line? | def continuous_line?(line)
continuous = false
if /&\s*?(!.*)?$/ =~ line
continuous = true
if comment_out?($~.pre_match)
continuous = false
end
end
return continuous
end | ruby | def continuous_line?(line)
continuous = false
if /&\s*?(!.*)?$/ =~ line
continuous = true
if comment_out?($~.pre_match)
continuous = false
end
end
return continuous
end | [
"def",
"continuous_line?",
"(",
"line",
")",
"continuous",
"=",
"false",
"if",
"/",
"\\s",
"/",
"=~",
"line",
"continuous",
"=",
"true",
"if",
"comment_out?",
"(",
"$~",
".",
"pre_match",
")",
"continuous",
"=",
"false",
"end",
"end",
"return",
"continuous",
"end"
] | Continuous line checker | [
"Continuous",
"line",
"checker"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb#L1461-L1470 |
1,703 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb | RDoc.Fortran95parser.comment_out? | def comment_out?(line)
return nil unless line
commentout = false
squote = false ; dquote = false
line.split("").each { |char|
if !(squote) && !(dquote)
case char
when "!" ; commentout = true ; break
when "\""; dquote = true
when "\'"; squote = true
else next
end
elsif squote
case char
when "\'"; squote = false
else next
end
elsif dquote
case char
when "\""; dquote = false
else next
end
end
}
return commentout
end | ruby | def comment_out?(line)
return nil unless line
commentout = false
squote = false ; dquote = false
line.split("").each { |char|
if !(squote) && !(dquote)
case char
when "!" ; commentout = true ; break
when "\""; dquote = true
when "\'"; squote = true
else next
end
elsif squote
case char
when "\'"; squote = false
else next
end
elsif dquote
case char
when "\""; dquote = false
else next
end
end
}
return commentout
end | [
"def",
"comment_out?",
"(",
"line",
")",
"return",
"nil",
"unless",
"line",
"commentout",
"=",
"false",
"squote",
"=",
"false",
";",
"dquote",
"=",
"false",
"line",
".",
"split",
"(",
"\"\"",
")",
".",
"each",
"{",
"|",
"char",
"|",
"if",
"!",
"(",
"squote",
")",
"&&",
"!",
"(",
"dquote",
")",
"case",
"char",
"when",
"\"!\"",
";",
"commentout",
"=",
"true",
";",
"break",
"when",
"\"\\\"\"",
";",
"dquote",
"=",
"true",
"when",
"\"\\'\"",
";",
"squote",
"=",
"true",
"else",
"next",
"end",
"elsif",
"squote",
"case",
"char",
"when",
"\"\\'\"",
";",
"squote",
"=",
"false",
"else",
"next",
"end",
"elsif",
"dquote",
"case",
"char",
"when",
"\"\\\"\"",
";",
"dquote",
"=",
"false",
"else",
"next",
"end",
"end",
"}",
"return",
"commentout",
"end"
] | Comment out checker | [
"Comment",
"out",
"checker"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb#L1475-L1500 |
1,704 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb | RDoc.Fortran95parser.semicolon_to_linefeed | def semicolon_to_linefeed(text)
return "" unless text
lines = text.split("\n")
lines.collect!{ |line|
words = line.split("")
commentout = false
squote = false ; dquote = false
words.collect! { |char|
if !(squote) && !(dquote) && !(commentout)
case char
when "!" ; commentout = true ; next char
when "\""; dquote = true ; next char
when "\'"; squote = true ; next char
when ";" ; "\n"
else next char
end
elsif commentout
next char
elsif squote
case char
when "\'"; squote = false ; next char
else next char
end
elsif dquote
case char
when "\""; dquote = false ; next char
else next char
end
end
}
words.join("")
}
return lines.join("\n")
end | ruby | def semicolon_to_linefeed(text)
return "" unless text
lines = text.split("\n")
lines.collect!{ |line|
words = line.split("")
commentout = false
squote = false ; dquote = false
words.collect! { |char|
if !(squote) && !(dquote) && !(commentout)
case char
when "!" ; commentout = true ; next char
when "\""; dquote = true ; next char
when "\'"; squote = true ; next char
when ";" ; "\n"
else next char
end
elsif commentout
next char
elsif squote
case char
when "\'"; squote = false ; next char
else next char
end
elsif dquote
case char
when "\""; dquote = false ; next char
else next char
end
end
}
words.join("")
}
return lines.join("\n")
end | [
"def",
"semicolon_to_linefeed",
"(",
"text",
")",
"return",
"\"\"",
"unless",
"text",
"lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"lines",
".",
"collect!",
"{",
"|",
"line",
"|",
"words",
"=",
"line",
".",
"split",
"(",
"\"\"",
")",
"commentout",
"=",
"false",
"squote",
"=",
"false",
";",
"dquote",
"=",
"false",
"words",
".",
"collect!",
"{",
"|",
"char",
"|",
"if",
"!",
"(",
"squote",
")",
"&&",
"!",
"(",
"dquote",
")",
"&&",
"!",
"(",
"commentout",
")",
"case",
"char",
"when",
"\"!\"",
";",
"commentout",
"=",
"true",
";",
"next",
"char",
"when",
"\"\\\"\"",
";",
"dquote",
"=",
"true",
";",
"next",
"char",
"when",
"\"\\'\"",
";",
"squote",
"=",
"true",
";",
"next",
"char",
"when",
"\";\"",
";",
"\"\\n\"",
"else",
"next",
"char",
"end",
"elsif",
"commentout",
"next",
"char",
"elsif",
"squote",
"case",
"char",
"when",
"\"\\'\"",
";",
"squote",
"=",
"false",
";",
"next",
"char",
"else",
"next",
"char",
"end",
"elsif",
"dquote",
"case",
"char",
"when",
"\"\\\"\"",
";",
"dquote",
"=",
"false",
";",
"next",
"char",
"else",
"next",
"char",
"end",
"end",
"}",
"words",
".",
"join",
"(",
"\"\"",
")",
"}",
"return",
"lines",
".",
"join",
"(",
"\"\\n\"",
")",
"end"
] | Semicolons are replaced to line feed. | [
"Semicolons",
"are",
"replaced",
"to",
"line",
"feed",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb#L1505-L1538 |
1,705 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb | RDoc.Fortran95parser.remove_empty_head_lines | def remove_empty_head_lines(text)
return "" unless text
lines = text.split("\n")
header = true
lines.delete_if{ |line|
header = false if /\S/ =~ line
header && /^\s*?$/ =~ line
}
lines.join("\n")
end | ruby | def remove_empty_head_lines(text)
return "" unless text
lines = text.split("\n")
header = true
lines.delete_if{ |line|
header = false if /\S/ =~ line
header && /^\s*?$/ =~ line
}
lines.join("\n")
end | [
"def",
"remove_empty_head_lines",
"(",
"text",
")",
"return",
"\"\"",
"unless",
"text",
"lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"header",
"=",
"true",
"lines",
".",
"delete_if",
"{",
"|",
"line",
"|",
"header",
"=",
"false",
"if",
"/",
"\\S",
"/",
"=~",
"line",
"header",
"&&",
"/",
"\\s",
"/",
"=~",
"line",
"}",
"lines",
".",
"join",
"(",
"\"\\n\"",
")",
"end"
] | Empty lines in header are removed | [
"Empty",
"lines",
"in",
"header",
"are",
"removed"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_f95.rb#L1619-L1628 |
1,706 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb | Zlib.ZStream.end | def end
unless ready? then
warn "attempt to close uninitialized stream; ignored."
return nil
end
if in_stream? then
warn "attempt to close unfinished zstream; reset forced"
reset
end
reset_input
err = Zlib.send @func_end, pointer
Zlib.handle_error err, message
@flags = 0
# HACK this may be wrong
@output = nil
@next_out.free unless @next_out.nil?
@next_out = nil
nil
end | ruby | def end
unless ready? then
warn "attempt to close uninitialized stream; ignored."
return nil
end
if in_stream? then
warn "attempt to close unfinished zstream; reset forced"
reset
end
reset_input
err = Zlib.send @func_end, pointer
Zlib.handle_error err, message
@flags = 0
# HACK this may be wrong
@output = nil
@next_out.free unless @next_out.nil?
@next_out = nil
nil
end | [
"def",
"end",
"unless",
"ready?",
"then",
"warn",
"\"attempt to close uninitialized stream; ignored.\"",
"return",
"nil",
"end",
"if",
"in_stream?",
"then",
"warn",
"\"attempt to close unfinished zstream; reset forced\"",
"reset",
"end",
"reset_input",
"err",
"=",
"Zlib",
".",
"send",
"@func_end",
",",
"pointer",
"Zlib",
".",
"handle_error",
"err",
",",
"message",
"@flags",
"=",
"0",
"# HACK this may be wrong",
"@output",
"=",
"nil",
"@next_out",
".",
"free",
"unless",
"@next_out",
".",
"nil?",
"@next_out",
"=",
"nil",
"nil",
"end"
] | Closes the stream. All operations on the closed stream will raise an
exception. | [
"Closes",
"the",
"stream",
".",
"All",
"operations",
"on",
"the",
"closed",
"stream",
"will",
"raise",
"an",
"exception",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb#L319-L344 |
1,707 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb | Zlib.ZStream.reset | def reset
err = Zlib.send @func_reset, pointer
Zlib.handle_error err, message
@flags = READY
reset_input
end | ruby | def reset
err = Zlib.send @func_reset, pointer
Zlib.handle_error err, message
@flags = READY
reset_input
end | [
"def",
"reset",
"err",
"=",
"Zlib",
".",
"send",
"@func_reset",
",",
"pointer",
"Zlib",
".",
"handle_error",
"err",
",",
"message",
"@flags",
"=",
"READY",
"reset_input",
"end"
] | Resets and initializes the stream. All data in both input and output
buffer are discarded. | [
"Resets",
"and",
"initializes",
"the",
"stream",
".",
"All",
"data",
"in",
"both",
"input",
"and",
"output",
"buffer",
"are",
"discarded",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb#L415-L423 |
1,708 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb | Zlib.Deflate.do_deflate | def do_deflate(data, flush)
if data.nil? then
run '', Zlib::FINISH
else
data = StringValue data
if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
run data, flush
end
end
end | ruby | def do_deflate(data, flush)
if data.nil? then
run '', Zlib::FINISH
else
data = StringValue data
if flush != Zlib::NO_FLUSH or not data.empty? then # prevent BUF_ERROR
run data, flush
end
end
end | [
"def",
"do_deflate",
"(",
"data",
",",
"flush",
")",
"if",
"data",
".",
"nil?",
"then",
"run",
"''",
",",
"Zlib",
"::",
"FINISH",
"else",
"data",
"=",
"StringValue",
"data",
"if",
"flush",
"!=",
"Zlib",
"::",
"NO_FLUSH",
"or",
"not",
"data",
".",
"empty?",
"then",
"# prevent BUF_ERROR",
"run",
"data",
",",
"flush",
"end",
"end",
"end"
] | Performs the deflate operation and leaves the compressed data in the
output buffer | [
"Performs",
"the",
"deflate",
"operation",
"and",
"leaves",
"the",
"compressed",
"data",
"in",
"the",
"output",
"buffer"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb#L654-L664 |
1,709 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb | Zlib.Deflate.params | def params(level, strategy)
err = Zlib.deflateParams pointer, level, strategy
raise Zlib::BufError, 'buffer expansion not implemented' if
err == Zlib::BUF_ERROR
Zlib.handle_error err, message
nil
end | ruby | def params(level, strategy)
err = Zlib.deflateParams pointer, level, strategy
raise Zlib::BufError, 'buffer expansion not implemented' if
err == Zlib::BUF_ERROR
Zlib.handle_error err, message
nil
end | [
"def",
"params",
"(",
"level",
",",
"strategy",
")",
"err",
"=",
"Zlib",
".",
"deflateParams",
"pointer",
",",
"level",
",",
"strategy",
"raise",
"Zlib",
"::",
"BufError",
",",
"'buffer expansion not implemented'",
"if",
"err",
"==",
"Zlib",
"::",
"BUF_ERROR",
"Zlib",
".",
"handle_error",
"err",
",",
"message",
"nil",
"end"
] | Changes the parameters of the deflate stream. See zlib.h for details.
The output from the stream by changing the params is preserved in output
buffer. | [
"Changes",
"the",
"parameters",
"of",
"the",
"deflate",
"stream",
".",
"See",
"zlib",
".",
"h",
"for",
"details",
".",
"The",
"output",
"from",
"the",
"stream",
"by",
"changing",
"the",
"params",
"is",
"preserved",
"in",
"output",
"buffer",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb#L692-L701 |
1,710 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb | Zlib.GzipReader.check_footer | def check_footer
@zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
footer = @zstream.input.slice! 0, 8
rest = @io.read 8 - footer.length
footer << rest if rest
raise NoFooter, 'footer is not found' unless footer.length == 8
crc, length = footer.unpack 'VV'
@zstream[:total_in] += 8 # to rewind correctly
raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
raise LengthError, 'invalid compressed data -- length error' unless
length == @zstream.total_out
end | ruby | def check_footer
@zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
footer = @zstream.input.slice! 0, 8
rest = @io.read 8 - footer.length
footer << rest if rest
raise NoFooter, 'footer is not found' unless footer.length == 8
crc, length = footer.unpack 'VV'
@zstream[:total_in] += 8 # to rewind correctly
raise CRCError, 'invalid compressed data -- crc error' unless @crc == crc
raise LengthError, 'invalid compressed data -- length error' unless
length == @zstream.total_out
end | [
"def",
"check_footer",
"@zstream",
".",
"flags",
"|=",
"Zlib",
"::",
"GzipFile",
"::",
"FOOTER_FINISHED",
"footer",
"=",
"@zstream",
".",
"input",
".",
"slice!",
"0",
",",
"8",
"rest",
"=",
"@io",
".",
"read",
"8",
"-",
"footer",
".",
"length",
"footer",
"<<",
"rest",
"if",
"rest",
"raise",
"NoFooter",
",",
"'footer is not found'",
"unless",
"footer",
".",
"length",
"==",
"8",
"crc",
",",
"length",
"=",
"footer",
".",
"unpack",
"'VV'",
"@zstream",
"[",
":total_in",
"]",
"+=",
"8",
"# to rewind correctly",
"raise",
"CRCError",
",",
"'invalid compressed data -- crc error'",
"unless",
"@crc",
"==",
"crc",
"raise",
"LengthError",
",",
"'invalid compressed data -- length error'",
"unless",
"length",
"==",
"@zstream",
".",
"total_out",
"end"
] | HACK use a buffer class
Creates a GzipReader object associated with +io+. The GzipReader object
reads gzipped data from +io+, and parses/decompresses them. At least,
+io+ must have a +read+ method that behaves same as the +read+ method in
IO class.
If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
exception. | [
"HACK",
"use",
"a",
"buffer",
"class"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb#L961-L978 |
1,711 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb | Zlib.GzipWriter.make_header | def make_header
flags = 0
extra_flags = 0
flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
@level == Zlib::BEST_SPEED
extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
@level == Zlib::BEST_COMPRESSION
header = [
Zlib::GzipFile::MAGIC1, # byte 0
Zlib::GzipFile::MAGIC2, # byte 1
Zlib::GzipFile::METHOD_DEFLATE, # byte 2
flags, # byte 3
@mtime.to_i, # bytes 4-7
extra_flags, # byte 8
@os_code # byte 9
].pack 'CCCCVCC'
@io.write header
@io.write "#{@orig_name}\0" if @orig_name
@io.write "#{@comment}\0" if @comment
@zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
end | ruby | def make_header
flags = 0
extra_flags = 0
flags |= Zlib::GzipFile::FLAG_ORIG_NAME if @orig_name
flags |= Zlib::GzipFile::FLAG_COMMENT if @comment
extra_flags |= Zlib::GzipFile::EXTRAFLAG_FAST if
@level == Zlib::BEST_SPEED
extra_flags |= Zlib::GzipFile::EXTRAFLAG_SLOW if
@level == Zlib::BEST_COMPRESSION
header = [
Zlib::GzipFile::MAGIC1, # byte 0
Zlib::GzipFile::MAGIC2, # byte 1
Zlib::GzipFile::METHOD_DEFLATE, # byte 2
flags, # byte 3
@mtime.to_i, # bytes 4-7
extra_flags, # byte 8
@os_code # byte 9
].pack 'CCCCVCC'
@io.write header
@io.write "#{@orig_name}\0" if @orig_name
@io.write "#{@comment}\0" if @comment
@zstream.flags |= Zlib::GzipFile::HEADER_FINISHED
end | [
"def",
"make_header",
"flags",
"=",
"0",
"extra_flags",
"=",
"0",
"flags",
"|=",
"Zlib",
"::",
"GzipFile",
"::",
"FLAG_ORIG_NAME",
"if",
"@orig_name",
"flags",
"|=",
"Zlib",
"::",
"GzipFile",
"::",
"FLAG_COMMENT",
"if",
"@comment",
"extra_flags",
"|=",
"Zlib",
"::",
"GzipFile",
"::",
"EXTRAFLAG_FAST",
"if",
"@level",
"==",
"Zlib",
"::",
"BEST_SPEED",
"extra_flags",
"|=",
"Zlib",
"::",
"GzipFile",
"::",
"EXTRAFLAG_SLOW",
"if",
"@level",
"==",
"Zlib",
"::",
"BEST_COMPRESSION",
"header",
"=",
"[",
"Zlib",
"::",
"GzipFile",
"::",
"MAGIC1",
",",
"# byte 0",
"Zlib",
"::",
"GzipFile",
"::",
"MAGIC2",
",",
"# byte 1",
"Zlib",
"::",
"GzipFile",
"::",
"METHOD_DEFLATE",
",",
"# byte 2",
"flags",
",",
"# byte 3",
"@mtime",
".",
"to_i",
",",
"# bytes 4-7",
"extra_flags",
",",
"# byte 8",
"@os_code",
"# byte 9",
"]",
".",
"pack",
"'CCCCVCC'",
"@io",
".",
"write",
"header",
"@io",
".",
"write",
"\"#{@orig_name}\\0\"",
"if",
"@orig_name",
"@io",
".",
"write",
"\"#{@comment}\\0\"",
"if",
"@comment",
"@zstream",
".",
"flags",
"|=",
"Zlib",
"::",
"GzipFile",
"::",
"HEADER_FINISHED",
"end"
] | Writes out a gzip header | [
"Writes",
"out",
"a",
"gzip",
"header"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb#L1178-L1207 |
1,712 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb | Zlib.GzipWriter.make_footer | def make_footer
footer = [
@crc, # bytes 0-3
@zstream.total_in, # bytes 4-7
].pack 'VV'
@io.write footer
@zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
end | ruby | def make_footer
footer = [
@crc, # bytes 0-3
@zstream.total_in, # bytes 4-7
].pack 'VV'
@io.write footer
@zstream.flags |= Zlib::GzipFile::FOOTER_FINISHED
end | [
"def",
"make_footer",
"footer",
"=",
"[",
"@crc",
",",
"# bytes 0-3",
"@zstream",
".",
"total_in",
",",
"# bytes 4-7",
"]",
".",
"pack",
"'VV'",
"@io",
".",
"write",
"footer",
"@zstream",
".",
"flags",
"|=",
"Zlib",
"::",
"GzipFile",
"::",
"FOOTER_FINISHED",
"end"
] | Writes out a gzip footer | [
"Writes",
"out",
"a",
"gzip",
"footer"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb#L1212-L1221 |
1,713 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb | Zlib.GzipWriter.write | def write(data)
make_header unless header_finished?
data = String data
if data.length > 0 or sync? then
@crc = Zlib.crc32_c @crc, data, data.length
flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
@zstream.run data, flush
end
write_raw
end | ruby | def write(data)
make_header unless header_finished?
data = String data
if data.length > 0 or sync? then
@crc = Zlib.crc32_c @crc, data, data.length
flush = sync? ? Zlib::SYNC_FLUSH : Zlib::NO_FLUSH
@zstream.run data, flush
end
write_raw
end | [
"def",
"write",
"(",
"data",
")",
"make_header",
"unless",
"header_finished?",
"data",
"=",
"String",
"data",
"if",
"data",
".",
"length",
">",
"0",
"or",
"sync?",
"then",
"@crc",
"=",
"Zlib",
".",
"crc32_c",
"@crc",
",",
"data",
",",
"data",
".",
"length",
"flush",
"=",
"sync?",
"?",
"Zlib",
"::",
"SYNC_FLUSH",
":",
"Zlib",
"::",
"NO_FLUSH",
"@zstream",
".",
"run",
"data",
",",
"flush",
"end",
"write_raw",
"end"
] | Same as IO. | [
"Same",
"as",
"IO",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb#L1241-L1255 |
1,714 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb | Zlib.Inflate.<< | def <<(string)
string = StringValue string unless string.nil?
if finished? then
unless string.nil? then
@input ||= ''
@input << string
end
else
run string, Zlib::SYNC_FLUSH
end
end | ruby | def <<(string)
string = StringValue string unless string.nil?
if finished? then
unless string.nil? then
@input ||= ''
@input << string
end
else
run string, Zlib::SYNC_FLUSH
end
end | [
"def",
"<<",
"(",
"string",
")",
"string",
"=",
"StringValue",
"string",
"unless",
"string",
".",
"nil?",
"if",
"finished?",
"then",
"unless",
"string",
".",
"nil?",
"then",
"@input",
"||=",
"''",
"@input",
"<<",
"string",
"end",
"else",
"run",
"string",
",",
"Zlib",
"::",
"SYNC_FLUSH",
"end",
"end"
] | Creates a new inflate stream for decompression. See zlib.h for details
of the argument. If +window_bits+ is +nil+, the default value is used.
Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate,
but returns the Zlib::Inflate object itself. The output from the stream
is preserved in output buffer. | [
"Creates",
"a",
"new",
"inflate",
"stream",
"for",
"decompression",
".",
"See",
"zlib",
".",
"h",
"for",
"details",
"of",
"the",
"argument",
".",
"If",
"+",
"window_bits",
"+",
"is",
"+",
"nil",
"+",
"the",
"default",
"value",
"is",
"used",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/platform/i386-solaris/zlib.rb#L1327-L1338 |
1,715 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rexml/element.rb | REXML.Element.each_with_something | def each_with_something( test, max=0, name=nil )
num = 0
child=nil
@elements.each( name ){ |child|
yield child if test.call(child) and num += 1
return if max>0 and num == max
}
end | ruby | def each_with_something( test, max=0, name=nil )
num = 0
child=nil
@elements.each( name ){ |child|
yield child if test.call(child) and num += 1
return if max>0 and num == max
}
end | [
"def",
"each_with_something",
"(",
"test",
",",
"max",
"=",
"0",
",",
"name",
"=",
"nil",
")",
"num",
"=",
"0",
"child",
"=",
"nil",
"@elements",
".",
"each",
"(",
"name",
")",
"{",
"|",
"child",
"|",
"yield",
"child",
"if",
"test",
".",
"call",
"(",
"child",
")",
"and",
"num",
"+=",
"1",
"return",
"if",
"max",
">",
"0",
"and",
"num",
"==",
"max",
"}",
"end"
] | A private helper method | [
"A",
"private",
"helper",
"method"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rexml/element.rb#L705-L712 |
1,716 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/xmlrpc/server.rb | XMLRPC.BasicServer.check_arity | def check_arity(obj, n_args)
ary = obj.arity
if ary >= 0
n_args == ary
else
n_args >= (ary+1).abs
end
end | ruby | def check_arity(obj, n_args)
ary = obj.arity
if ary >= 0
n_args == ary
else
n_args >= (ary+1).abs
end
end | [
"def",
"check_arity",
"(",
"obj",
",",
"n_args",
")",
"ary",
"=",
"obj",
".",
"arity",
"if",
"ary",
">=",
"0",
"n_args",
"==",
"ary",
"else",
"n_args",
">=",
"(",
"ary",
"+",
"1",
")",
".",
"abs",
"end",
"end"
] | returns true, if the arity of "obj" matches | [
"returns",
"true",
"if",
"the",
"arity",
"of",
"obj",
"matches"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/xmlrpc/server.rb#L354-L362 |
1,717 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/security.rb | Gem::Security.Policy.verify_gem | def verify_gem(signature, data, chain, time = Time.now)
Gem.ensure_ssl_available
cert_class = OpenSSL::X509::Certificate
exc = Gem::Security::Exception
chain ||= []
chain = chain.map{ |str| cert_class.new(str) }
signer, ch_len = chain[-1], chain.size
# make sure signature is valid
if @verify_data
# get digest algorithm (TODO: this should be configurable)
dgst = @opt[:dgst_algo]
# verify the data signature (this is the most important part, so don't
# screw it up :D)
v = signer.public_key.verify(dgst.new, signature, data)
raise exc, "Invalid Gem Signature" unless v
# make sure the signer is valid
if @verify_signer
# make sure the signing cert is valid right now
v = signer.check_validity(nil, time)
raise exc, "Invalid Signature: #{v[:desc]}" unless v[:is_valid]
end
end
# make sure the certificate chain is valid
if @verify_chain
# iterate down over the chain and verify each certificate against it's
# issuer
(ch_len - 1).downto(1) do |i|
issuer, cert = chain[i - 1, 2]
v = cert.check_validity(issuer, time)
raise exc, "%s: cert = '%s', error = '%s'" % [
'Invalid Signing Chain', cert.subject, v[:desc]
] unless v[:is_valid]
end
# verify root of chain
if @verify_root
# make sure root is self-signed
root = chain[0]
raise exc, "%s: %s (subject = '%s', issuer = '%s')" % [
'Invalid Signing Chain Root',
'Subject does not match Issuer for Gem Signing Chain',
root.subject.to_s,
root.issuer.to_s,
] unless root.issuer.to_s == root.subject.to_s
# make sure root is valid
v = root.check_validity(root, time)
raise exc, "%s: cert = '%s', error = '%s'" % [
'Invalid Signing Chain Root', root.subject, v[:desc]
] unless v[:is_valid]
# verify that the chain root is trusted
if @only_trusted
# get digest algorithm, calculate checksum of root.subject
algo = @opt[:dgst_algo]
path = Gem::Security::Policy.trusted_cert_path(root, @opt)
# check to make sure trusted path exists
raise exc, "%s: cert = '%s', error = '%s'" % [
'Untrusted Signing Chain Root',
root.subject.to_s,
"path \"#{path}\" does not exist",
] unless File.exist?(path)
# load calculate digest from saved cert file
save_cert = OpenSSL::X509::Certificate.new(File.read(path))
save_dgst = algo.digest(save_cert.public_key.to_s)
# create digest of public key
pkey_str = root.public_key.to_s
cert_dgst = algo.digest(pkey_str)
# now compare the two digests, raise exception
# if they don't match
raise exc, "%s: %s (saved = '%s', root = '%s')" % [
'Invalid Signing Chain Root',
"Saved checksum doesn't match root checksum",
save_dgst, cert_dgst,
] unless save_dgst == cert_dgst
end
end
# return the signing chain
chain.map { |cert| cert.subject }
end
end | ruby | def verify_gem(signature, data, chain, time = Time.now)
Gem.ensure_ssl_available
cert_class = OpenSSL::X509::Certificate
exc = Gem::Security::Exception
chain ||= []
chain = chain.map{ |str| cert_class.new(str) }
signer, ch_len = chain[-1], chain.size
# make sure signature is valid
if @verify_data
# get digest algorithm (TODO: this should be configurable)
dgst = @opt[:dgst_algo]
# verify the data signature (this is the most important part, so don't
# screw it up :D)
v = signer.public_key.verify(dgst.new, signature, data)
raise exc, "Invalid Gem Signature" unless v
# make sure the signer is valid
if @verify_signer
# make sure the signing cert is valid right now
v = signer.check_validity(nil, time)
raise exc, "Invalid Signature: #{v[:desc]}" unless v[:is_valid]
end
end
# make sure the certificate chain is valid
if @verify_chain
# iterate down over the chain and verify each certificate against it's
# issuer
(ch_len - 1).downto(1) do |i|
issuer, cert = chain[i - 1, 2]
v = cert.check_validity(issuer, time)
raise exc, "%s: cert = '%s', error = '%s'" % [
'Invalid Signing Chain', cert.subject, v[:desc]
] unless v[:is_valid]
end
# verify root of chain
if @verify_root
# make sure root is self-signed
root = chain[0]
raise exc, "%s: %s (subject = '%s', issuer = '%s')" % [
'Invalid Signing Chain Root',
'Subject does not match Issuer for Gem Signing Chain',
root.subject.to_s,
root.issuer.to_s,
] unless root.issuer.to_s == root.subject.to_s
# make sure root is valid
v = root.check_validity(root, time)
raise exc, "%s: cert = '%s', error = '%s'" % [
'Invalid Signing Chain Root', root.subject, v[:desc]
] unless v[:is_valid]
# verify that the chain root is trusted
if @only_trusted
# get digest algorithm, calculate checksum of root.subject
algo = @opt[:dgst_algo]
path = Gem::Security::Policy.trusted_cert_path(root, @opt)
# check to make sure trusted path exists
raise exc, "%s: cert = '%s', error = '%s'" % [
'Untrusted Signing Chain Root',
root.subject.to_s,
"path \"#{path}\" does not exist",
] unless File.exist?(path)
# load calculate digest from saved cert file
save_cert = OpenSSL::X509::Certificate.new(File.read(path))
save_dgst = algo.digest(save_cert.public_key.to_s)
# create digest of public key
pkey_str = root.public_key.to_s
cert_dgst = algo.digest(pkey_str)
# now compare the two digests, raise exception
# if they don't match
raise exc, "%s: %s (saved = '%s', root = '%s')" % [
'Invalid Signing Chain Root',
"Saved checksum doesn't match root checksum",
save_dgst, cert_dgst,
] unless save_dgst == cert_dgst
end
end
# return the signing chain
chain.map { |cert| cert.subject }
end
end | [
"def",
"verify_gem",
"(",
"signature",
",",
"data",
",",
"chain",
",",
"time",
"=",
"Time",
".",
"now",
")",
"Gem",
".",
"ensure_ssl_available",
"cert_class",
"=",
"OpenSSL",
"::",
"X509",
"::",
"Certificate",
"exc",
"=",
"Gem",
"::",
"Security",
"::",
"Exception",
"chain",
"||=",
"[",
"]",
"chain",
"=",
"chain",
".",
"map",
"{",
"|",
"str",
"|",
"cert_class",
".",
"new",
"(",
"str",
")",
"}",
"signer",
",",
"ch_len",
"=",
"chain",
"[",
"-",
"1",
"]",
",",
"chain",
".",
"size",
"# make sure signature is valid",
"if",
"@verify_data",
"# get digest algorithm (TODO: this should be configurable)",
"dgst",
"=",
"@opt",
"[",
":dgst_algo",
"]",
"# verify the data signature (this is the most important part, so don't",
"# screw it up :D)",
"v",
"=",
"signer",
".",
"public_key",
".",
"verify",
"(",
"dgst",
".",
"new",
",",
"signature",
",",
"data",
")",
"raise",
"exc",
",",
"\"Invalid Gem Signature\"",
"unless",
"v",
"# make sure the signer is valid",
"if",
"@verify_signer",
"# make sure the signing cert is valid right now",
"v",
"=",
"signer",
".",
"check_validity",
"(",
"nil",
",",
"time",
")",
"raise",
"exc",
",",
"\"Invalid Signature: #{v[:desc]}\"",
"unless",
"v",
"[",
":is_valid",
"]",
"end",
"end",
"# make sure the certificate chain is valid",
"if",
"@verify_chain",
"# iterate down over the chain and verify each certificate against it's",
"# issuer",
"(",
"ch_len",
"-",
"1",
")",
".",
"downto",
"(",
"1",
")",
"do",
"|",
"i",
"|",
"issuer",
",",
"cert",
"=",
"chain",
"[",
"i",
"-",
"1",
",",
"2",
"]",
"v",
"=",
"cert",
".",
"check_validity",
"(",
"issuer",
",",
"time",
")",
"raise",
"exc",
",",
"\"%s: cert = '%s', error = '%s'\"",
"%",
"[",
"'Invalid Signing Chain'",
",",
"cert",
".",
"subject",
",",
"v",
"[",
":desc",
"]",
"]",
"unless",
"v",
"[",
":is_valid",
"]",
"end",
"# verify root of chain",
"if",
"@verify_root",
"# make sure root is self-signed",
"root",
"=",
"chain",
"[",
"0",
"]",
"raise",
"exc",
",",
"\"%s: %s (subject = '%s', issuer = '%s')\"",
"%",
"[",
"'Invalid Signing Chain Root'",
",",
"'Subject does not match Issuer for Gem Signing Chain'",
",",
"root",
".",
"subject",
".",
"to_s",
",",
"root",
".",
"issuer",
".",
"to_s",
",",
"]",
"unless",
"root",
".",
"issuer",
".",
"to_s",
"==",
"root",
".",
"subject",
".",
"to_s",
"# make sure root is valid",
"v",
"=",
"root",
".",
"check_validity",
"(",
"root",
",",
"time",
")",
"raise",
"exc",
",",
"\"%s: cert = '%s', error = '%s'\"",
"%",
"[",
"'Invalid Signing Chain Root'",
",",
"root",
".",
"subject",
",",
"v",
"[",
":desc",
"]",
"]",
"unless",
"v",
"[",
":is_valid",
"]",
"# verify that the chain root is trusted",
"if",
"@only_trusted",
"# get digest algorithm, calculate checksum of root.subject",
"algo",
"=",
"@opt",
"[",
":dgst_algo",
"]",
"path",
"=",
"Gem",
"::",
"Security",
"::",
"Policy",
".",
"trusted_cert_path",
"(",
"root",
",",
"@opt",
")",
"# check to make sure trusted path exists",
"raise",
"exc",
",",
"\"%s: cert = '%s', error = '%s'\"",
"%",
"[",
"'Untrusted Signing Chain Root'",
",",
"root",
".",
"subject",
".",
"to_s",
",",
"\"path \\\"#{path}\\\" does not exist\"",
",",
"]",
"unless",
"File",
".",
"exist?",
"(",
"path",
")",
"# load calculate digest from saved cert file",
"save_cert",
"=",
"OpenSSL",
"::",
"X509",
"::",
"Certificate",
".",
"new",
"(",
"File",
".",
"read",
"(",
"path",
")",
")",
"save_dgst",
"=",
"algo",
".",
"digest",
"(",
"save_cert",
".",
"public_key",
".",
"to_s",
")",
"# create digest of public key",
"pkey_str",
"=",
"root",
".",
"public_key",
".",
"to_s",
"cert_dgst",
"=",
"algo",
".",
"digest",
"(",
"pkey_str",
")",
"# now compare the two digests, raise exception",
"# if they don't match",
"raise",
"exc",
",",
"\"%s: %s (saved = '%s', root = '%s')\"",
"%",
"[",
"'Invalid Signing Chain Root'",
",",
"\"Saved checksum doesn't match root checksum\"",
",",
"save_dgst",
",",
"cert_dgst",
",",
"]",
"unless",
"save_dgst",
"==",
"cert_dgst",
"end",
"end",
"# return the signing chain",
"chain",
".",
"map",
"{",
"|",
"cert",
"|",
"cert",
".",
"subject",
"}",
"end",
"end"
] | Verify that the gem data with the given signature and signing chain
matched this security policy at the specified time. | [
"Verify",
"that",
"the",
"gem",
"data",
"with",
"the",
"given",
"signature",
"and",
"signing",
"chain",
"matched",
"this",
"security",
"policy",
"at",
"the",
"specified",
"time",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/1.8/rubygems/security.rb#L419-L509 |
1,718 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/yaml/yamlnode.rb | YAML.YamlNode.transform | def transform
t = nil
if @value.is_a? Hash
t = {}
@value.each { |k,v|
t[ k ] = v[1].transform
}
elsif @value.is_a? Array
t = []
@value.each { |v|
t.push v.transform
}
else
t = @value
end
YAML.transfer_method( @type_id, t )
end | ruby | def transform
t = nil
if @value.is_a? Hash
t = {}
@value.each { |k,v|
t[ k ] = v[1].transform
}
elsif @value.is_a? Array
t = []
@value.each { |v|
t.push v.transform
}
else
t = @value
end
YAML.transfer_method( @type_id, t )
end | [
"def",
"transform",
"t",
"=",
"nil",
"if",
"@value",
".",
"is_a?",
"Hash",
"t",
"=",
"{",
"}",
"@value",
".",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"t",
"[",
"k",
"]",
"=",
"v",
"[",
"1",
"]",
".",
"transform",
"}",
"elsif",
"@value",
".",
"is_a?",
"Array",
"t",
"=",
"[",
"]",
"@value",
".",
"each",
"{",
"|",
"v",
"|",
"t",
".",
"push",
"v",
".",
"transform",
"}",
"else",
"t",
"=",
"@value",
"end",
"YAML",
".",
"transfer_method",
"(",
"@type_id",
",",
"t",
")",
"end"
] | Transform this node fully into a native type | [
"Transform",
"this",
"node",
"fully",
"into",
"a",
"native",
"type"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/yaml/yamlnode.rb#L34-L50 |
1,719 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb | RDoc.RubyParser.collect_first_comment | def collect_first_comment
skip_tkspace
res = ''
first_line = true
tk = get_tk
while tk.kind_of?(TkCOMMENT)
if first_line && /\A#!/ =~ tk.text
skip_tkspace
tk = get_tk
elsif first_line && /\A#\s*-\*-/ =~ tk.text
first_line = false
skip_tkspace
tk = get_tk
else
first_line = false
res << tk.text << "\n"
tk = get_tk
if tk.kind_of? TkNL
skip_tkspace(false)
tk = get_tk
end
end
end
unget_tk(tk)
res
end | ruby | def collect_first_comment
skip_tkspace
res = ''
first_line = true
tk = get_tk
while tk.kind_of?(TkCOMMENT)
if first_line && /\A#!/ =~ tk.text
skip_tkspace
tk = get_tk
elsif first_line && /\A#\s*-\*-/ =~ tk.text
first_line = false
skip_tkspace
tk = get_tk
else
first_line = false
res << tk.text << "\n"
tk = get_tk
if tk.kind_of? TkNL
skip_tkspace(false)
tk = get_tk
end
end
end
unget_tk(tk)
res
end | [
"def",
"collect_first_comment",
"skip_tkspace",
"res",
"=",
"''",
"first_line",
"=",
"true",
"tk",
"=",
"get_tk",
"while",
"tk",
".",
"kind_of?",
"(",
"TkCOMMENT",
")",
"if",
"first_line",
"&&",
"/",
"\\A",
"/",
"=~",
"tk",
".",
"text",
"skip_tkspace",
"tk",
"=",
"get_tk",
"elsif",
"first_line",
"&&",
"/",
"\\A",
"\\s",
"\\*",
"/",
"=~",
"tk",
".",
"text",
"first_line",
"=",
"false",
"skip_tkspace",
"tk",
"=",
"get_tk",
"else",
"first_line",
"=",
"false",
"res",
"<<",
"tk",
".",
"text",
"<<",
"\"\\n\"",
"tk",
"=",
"get_tk",
"if",
"tk",
".",
"kind_of?",
"TkNL",
"skip_tkspace",
"(",
"false",
")",
"tk",
"=",
"get_tk",
"end",
"end",
"end",
"unget_tk",
"(",
"tk",
")",
"res",
"end"
] | Look for the first comment in a file that isn't
a shebang line. | [
"Look",
"for",
"the",
"first",
"comment",
"in",
"a",
"file",
"that",
"isn",
"t",
"a",
"shebang",
"line",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb#L1542-L1568 |
1,720 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb | RDoc.RubyParser.parse_method_parameters | def parse_method_parameters(method)
res = parse_method_or_yield_parameters(method)
res = "(" + res + ")" unless res[0] == ?(
method.params = res unless method.params
if method.block_params.nil?
skip_tkspace(false)
read_documentation_modifiers(method, METHOD_MODIFIERS)
end
end | ruby | def parse_method_parameters(method)
res = parse_method_or_yield_parameters(method)
res = "(" + res + ")" unless res[0] == ?(
method.params = res unless method.params
if method.block_params.nil?
skip_tkspace(false)
read_documentation_modifiers(method, METHOD_MODIFIERS)
end
end | [
"def",
"parse_method_parameters",
"(",
"method",
")",
"res",
"=",
"parse_method_or_yield_parameters",
"(",
"method",
")",
"res",
"=",
"\"(\"",
"+",
"res",
"+",
"\")\"",
"unless",
"res",
"[",
"0",
"]",
"==",
"?(",
"method",
".",
"params",
"=",
"res",
"unless",
"method",
".",
"params",
"if",
"method",
".",
"block_params",
".",
"nil?",
"skip_tkspace",
"(",
"false",
")",
"read_documentation_modifiers",
"(",
"method",
",",
"METHOD_MODIFIERS",
")",
"end",
"end"
] | Capture the method's parameters. Along the way,
look for a comment containing
# yields: ....
and add this as the block_params for the method | [
"Capture",
"the",
"method",
"s",
"parameters",
".",
"Along",
"the",
"way",
"look",
"for",
"a",
"comment",
"containing"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb#L2016-L2024 |
1,721 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb | RDoc.RubyParser.skip_optional_do_after_expression | def skip_optional_do_after_expression
skip_tkspace(false)
tk = get_tk
case tk
when TkLPAREN, TkfLPAREN
end_token = TkRPAREN
else
end_token = TkNL
end
nest = 0
@scanner.instance_eval{@continue = false}
loop do
puts("\nWhile: #{tk}, #{@scanner.continue} " +
"#{@scanner.lex_state} #{nest}") if $DEBUG
case tk
when TkSEMICOLON
break
when TkLPAREN, TkfLPAREN
nest += 1
when TkDO
break if nest.zero?
when end_token
if end_token == TkRPAREN
nest -= 1
break if @scanner.lex_state == EXPR_END and nest.zero?
else
break unless @scanner.continue
end
end
tk = get_tk
end
skip_tkspace(false)
if peek_tk.kind_of? TkDO
get_tk
end
end | ruby | def skip_optional_do_after_expression
skip_tkspace(false)
tk = get_tk
case tk
when TkLPAREN, TkfLPAREN
end_token = TkRPAREN
else
end_token = TkNL
end
nest = 0
@scanner.instance_eval{@continue = false}
loop do
puts("\nWhile: #{tk}, #{@scanner.continue} " +
"#{@scanner.lex_state} #{nest}") if $DEBUG
case tk
when TkSEMICOLON
break
when TkLPAREN, TkfLPAREN
nest += 1
when TkDO
break if nest.zero?
when end_token
if end_token == TkRPAREN
nest -= 1
break if @scanner.lex_state == EXPR_END and nest.zero?
else
break unless @scanner.continue
end
end
tk = get_tk
end
skip_tkspace(false)
if peek_tk.kind_of? TkDO
get_tk
end
end | [
"def",
"skip_optional_do_after_expression",
"skip_tkspace",
"(",
"false",
")",
"tk",
"=",
"get_tk",
"case",
"tk",
"when",
"TkLPAREN",
",",
"TkfLPAREN",
"end_token",
"=",
"TkRPAREN",
"else",
"end_token",
"=",
"TkNL",
"end",
"nest",
"=",
"0",
"@scanner",
".",
"instance_eval",
"{",
"@continue",
"=",
"false",
"}",
"loop",
"do",
"puts",
"(",
"\"\\nWhile: #{tk}, #{@scanner.continue} \"",
"+",
"\"#{@scanner.lex_state} #{nest}\"",
")",
"if",
"$DEBUG",
"case",
"tk",
"when",
"TkSEMICOLON",
"break",
"when",
"TkLPAREN",
",",
"TkfLPAREN",
"nest",
"+=",
"1",
"when",
"TkDO",
"break",
"if",
"nest",
".",
"zero?",
"when",
"end_token",
"if",
"end_token",
"==",
"TkRPAREN",
"nest",
"-=",
"1",
"break",
"if",
"@scanner",
".",
"lex_state",
"==",
"EXPR_END",
"and",
"nest",
".",
"zero?",
"else",
"break",
"unless",
"@scanner",
".",
"continue",
"end",
"end",
"tk",
"=",
"get_tk",
"end",
"skip_tkspace",
"(",
"false",
")",
"if",
"peek_tk",
".",
"kind_of?",
"TkDO",
"get_tk",
"end",
"end"
] | while, until, and for have an optional | [
"while",
"until",
"and",
"for",
"have",
"an",
"optional"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb#L2088-L2125 |
1,722 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb | RDoc.RubyParser.get_class_specification | def get_class_specification
tk = get_tk
return "self" if tk.kind_of?(TkSELF)
res = ""
while tk.kind_of?(TkCOLON2) ||
tk.kind_of?(TkCOLON3) ||
tk.kind_of?(TkCONSTANT)
res += tk.text
tk = get_tk
end
unget_tk(tk)
skip_tkspace(false)
get_tkread # empty out read buffer
tk = get_tk
case tk
when TkNL, TkCOMMENT, TkSEMICOLON
unget_tk(tk)
return res
end
res += parse_call_parameters(tk)
res
end | ruby | def get_class_specification
tk = get_tk
return "self" if tk.kind_of?(TkSELF)
res = ""
while tk.kind_of?(TkCOLON2) ||
tk.kind_of?(TkCOLON3) ||
tk.kind_of?(TkCONSTANT)
res += tk.text
tk = get_tk
end
unget_tk(tk)
skip_tkspace(false)
get_tkread # empty out read buffer
tk = get_tk
case tk
when TkNL, TkCOMMENT, TkSEMICOLON
unget_tk(tk)
return res
end
res += parse_call_parameters(tk)
res
end | [
"def",
"get_class_specification",
"tk",
"=",
"get_tk",
"return",
"\"self\"",
"if",
"tk",
".",
"kind_of?",
"(",
"TkSELF",
")",
"res",
"=",
"\"\"",
"while",
"tk",
".",
"kind_of?",
"(",
"TkCOLON2",
")",
"||",
"tk",
".",
"kind_of?",
"(",
"TkCOLON3",
")",
"||",
"tk",
".",
"kind_of?",
"(",
"TkCONSTANT",
")",
"res",
"+=",
"tk",
".",
"text",
"tk",
"=",
"get_tk",
"end",
"unget_tk",
"(",
"tk",
")",
"skip_tkspace",
"(",
"false",
")",
"get_tkread",
"# empty out read buffer",
"tk",
"=",
"get_tk",
"case",
"tk",
"when",
"TkNL",
",",
"TkCOMMENT",
",",
"TkSEMICOLON",
"unget_tk",
"(",
"tk",
")",
"return",
"res",
"end",
"res",
"+=",
"parse_call_parameters",
"(",
"tk",
")",
"res",
"end"
] | Return a superclass, which can be either a constant
of an expression | [
"Return",
"a",
"superclass",
"which",
"can",
"be",
"either",
"a",
"constant",
"of",
"an",
"expression"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb#L2130-L2158 |
1,723 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb | RDoc.RubyParser.get_constant | def get_constant
res = ""
skip_tkspace(false)
tk = get_tk
while tk.kind_of?(TkCOLON2) ||
tk.kind_of?(TkCOLON3) ||
tk.kind_of?(TkCONSTANT)
res += tk.text
tk = get_tk
end
# if res.empty?
# warn("Unexpected token #{tk} in constant")
# end
unget_tk(tk)
res
end | ruby | def get_constant
res = ""
skip_tkspace(false)
tk = get_tk
while tk.kind_of?(TkCOLON2) ||
tk.kind_of?(TkCOLON3) ||
tk.kind_of?(TkCONSTANT)
res += tk.text
tk = get_tk
end
# if res.empty?
# warn("Unexpected token #{tk} in constant")
# end
unget_tk(tk)
res
end | [
"def",
"get_constant",
"res",
"=",
"\"\"",
"skip_tkspace",
"(",
"false",
")",
"tk",
"=",
"get_tk",
"while",
"tk",
".",
"kind_of?",
"(",
"TkCOLON2",
")",
"||",
"tk",
".",
"kind_of?",
"(",
"TkCOLON3",
")",
"||",
"tk",
".",
"kind_of?",
"(",
"TkCONSTANT",
")",
"res",
"+=",
"tk",
".",
"text",
"tk",
"=",
"get_tk",
"end",
"# if res.empty?",
"# warn(\"Unexpected token #{tk} in constant\")",
"# end ",
"unget_tk",
"(",
"tk",
")",
"res",
"end"
] | Parse a constant, which might be qualified by
one or more class or module names | [
"Parse",
"a",
"constant",
"which",
"might",
"be",
"qualified",
"by",
"one",
"or",
"more",
"class",
"or",
"module",
"names"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb#L2202-L2220 |
1,724 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb | RDoc.RubyParser.get_constant_with_optional_parens | def get_constant_with_optional_parens
skip_tkspace(false)
nest = 0
while (tk = peek_tk).kind_of?(TkLPAREN) || tk.kind_of?(TkfLPAREN)
get_tk
skip_tkspace(true)
nest += 1
end
name = get_constant
while nest > 0
skip_tkspace(true)
tk = get_tk
nest -= 1 if tk.kind_of?(TkRPAREN)
end
name
end | ruby | def get_constant_with_optional_parens
skip_tkspace(false)
nest = 0
while (tk = peek_tk).kind_of?(TkLPAREN) || tk.kind_of?(TkfLPAREN)
get_tk
skip_tkspace(true)
nest += 1
end
name = get_constant
while nest > 0
skip_tkspace(true)
tk = get_tk
nest -= 1 if tk.kind_of?(TkRPAREN)
end
name
end | [
"def",
"get_constant_with_optional_parens",
"skip_tkspace",
"(",
"false",
")",
"nest",
"=",
"0",
"while",
"(",
"tk",
"=",
"peek_tk",
")",
".",
"kind_of?",
"(",
"TkLPAREN",
")",
"||",
"tk",
".",
"kind_of?",
"(",
"TkfLPAREN",
")",
"get_tk",
"skip_tkspace",
"(",
"true",
")",
"nest",
"+=",
"1",
"end",
"name",
"=",
"get_constant",
"while",
"nest",
">",
"0",
"skip_tkspace",
"(",
"true",
")",
"tk",
"=",
"get_tk",
"nest",
"-=",
"1",
"if",
"tk",
".",
"kind_of?",
"(",
"TkRPAREN",
")",
"end",
"name",
"end"
] | Get a constant that may be surrounded by parens | [
"Get",
"a",
"constant",
"that",
"may",
"be",
"surrounded",
"by",
"parens"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb#L2224-L2241 |
1,725 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb | RDoc.RubyParser.read_directive | def read_directive(allowed)
tk = get_tk
puts "directive: #{tk.inspect}" if $DEBUG
result = nil
if tk.kind_of?(TkCOMMENT)
if tk.text =~ /\s*:?(\w+):\s*(.*)/
directive = $1.downcase
if allowed.include?(directive)
result = [directive, $2]
end
end
else
unget_tk(tk)
end
result
end | ruby | def read_directive(allowed)
tk = get_tk
puts "directive: #{tk.inspect}" if $DEBUG
result = nil
if tk.kind_of?(TkCOMMENT)
if tk.text =~ /\s*:?(\w+):\s*(.*)/
directive = $1.downcase
if allowed.include?(directive)
result = [directive, $2]
end
end
else
unget_tk(tk)
end
result
end | [
"def",
"read_directive",
"(",
"allowed",
")",
"tk",
"=",
"get_tk",
"puts",
"\"directive: #{tk.inspect}\"",
"if",
"$DEBUG",
"result",
"=",
"nil",
"if",
"tk",
".",
"kind_of?",
"(",
"TkCOMMENT",
")",
"if",
"tk",
".",
"text",
"=~",
"/",
"\\s",
"\\w",
"\\s",
"/",
"directive",
"=",
"$1",
".",
"downcase",
"if",
"allowed",
".",
"include?",
"(",
"directive",
")",
"result",
"=",
"[",
"directive",
",",
"$2",
"]",
"end",
"end",
"else",
"unget_tk",
"(",
"tk",
")",
"end",
"result",
"end"
] | Directives are modifier comments that can appear after class, module,
or method names. For example
def fred # :yields: a, b
or
class SM # :nodoc:
we return the directive name and any parameters as a two element array | [
"Directives",
"are",
"modifier",
"comments",
"that",
"can",
"appear",
"after",
"class",
"module",
"or",
"method",
"names",
".",
"For",
"example"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/parsers/parse_rb.rb#L2254-L2269 |
1,726 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/soap/wsdlDriver.rb | SOAP.WSDLDriverFactory.create_driver | def create_driver(servicename = nil, portname = nil)
warn("WSDLDriverFactory#create_driver is depricated. Use create_rpc_driver instead.")
port = find_port(servicename, portname)
WSDLDriver.new(@wsdl, port, nil)
end | ruby | def create_driver(servicename = nil, portname = nil)
warn("WSDLDriverFactory#create_driver is depricated. Use create_rpc_driver instead.")
port = find_port(servicename, portname)
WSDLDriver.new(@wsdl, port, nil)
end | [
"def",
"create_driver",
"(",
"servicename",
"=",
"nil",
",",
"portname",
"=",
"nil",
")",
"warn",
"(",
"\"WSDLDriverFactory#create_driver is depricated. Use create_rpc_driver instead.\"",
")",
"port",
"=",
"find_port",
"(",
"servicename",
",",
"portname",
")",
"WSDLDriver",
".",
"new",
"(",
"@wsdl",
",",
"port",
",",
"nil",
")",
"end"
] | depricated old interface | [
"depricated",
"old",
"interface"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/soap/wsdlDriver.rb#L45-L49 |
1,727 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb | Generators.MarkUp.markup | def markup(str, remove_para=false)
return '' unless str
unless defined? @markup
@markup = SM::SimpleMarkup.new
# class names, variable names, or instance variables
@markup.add_special(/(
\w+(::\w+)*[.\#]\w+(\([\.\w+\*\/\+\-\=\<\>]+\))? # A::B.meth(**) (for operator in Fortran95)
| \#\w+(\([.\w\*\/\+\-\=\<\>]+\))? # meth(**) (for operator in Fortran95)
| \b([A-Z]\w*(::\w+)*[.\#]\w+) # A::B.meth
| \b([A-Z]\w+(::\w+)*) # A::B..
| \#\w+[!?=]? # #meth_name
| \b\w+([_\/\.]+\w+)*[!?=]? # meth_name
)/x,
:CROSSREF)
# external hyperlinks
@markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
# and links of the form <text>[<url>]
@markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
# @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK)
end
unless defined? @html_formatter
@html_formatter = HyperlinkHtml.new(self.path, self)
end
# Convert leading comment markers to spaces, but only
# if all non-blank lines have them
if str =~ /^(?>\s*)[^\#]/
content = str
else
content = str.gsub(/^\s*(#+)/) { $1.tr('#',' ') }
end
res = @markup.convert(content, @html_formatter)
if remove_para
res.sub!(/^<p>/, '')
res.sub!(/<\/p>$/, '')
end
res
end | ruby | def markup(str, remove_para=false)
return '' unless str
unless defined? @markup
@markup = SM::SimpleMarkup.new
# class names, variable names, or instance variables
@markup.add_special(/(
\w+(::\w+)*[.\#]\w+(\([\.\w+\*\/\+\-\=\<\>]+\))? # A::B.meth(**) (for operator in Fortran95)
| \#\w+(\([.\w\*\/\+\-\=\<\>]+\))? # meth(**) (for operator in Fortran95)
| \b([A-Z]\w*(::\w+)*[.\#]\w+) # A::B.meth
| \b([A-Z]\w+(::\w+)*) # A::B..
| \#\w+[!?=]? # #meth_name
| \b\w+([_\/\.]+\w+)*[!?=]? # meth_name
)/x,
:CROSSREF)
# external hyperlinks
@markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
# and links of the form <text>[<url>]
@markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
# @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK)
end
unless defined? @html_formatter
@html_formatter = HyperlinkHtml.new(self.path, self)
end
# Convert leading comment markers to spaces, but only
# if all non-blank lines have them
if str =~ /^(?>\s*)[^\#]/
content = str
else
content = str.gsub(/^\s*(#+)/) { $1.tr('#',' ') }
end
res = @markup.convert(content, @html_formatter)
if remove_para
res.sub!(/^<p>/, '')
res.sub!(/<\/p>$/, '')
end
res
end | [
"def",
"markup",
"(",
"str",
",",
"remove_para",
"=",
"false",
")",
"return",
"''",
"unless",
"str",
"unless",
"defined?",
"@markup",
"@markup",
"=",
"SM",
"::",
"SimpleMarkup",
".",
"new",
"# class names, variable names, or instance variables",
"@markup",
".",
"add_special",
"(",
"/",
"\\w",
"\\w",
"\\#",
"\\w",
"\\(",
"\\.",
"\\w",
"\\*",
"\\/",
"\\+",
"\\-",
"\\=",
"\\<",
"\\>",
"\\)",
"\\#",
"\\w",
"\\(",
"\\w",
"\\*",
"\\/",
"\\+",
"\\-",
"\\=",
"\\<",
"\\>",
"\\)",
"\\b",
"\\w",
"\\w",
"\\#",
"\\w",
"\\b",
"\\w",
"\\w",
"\\#",
"\\w",
"\\b",
"\\w",
"\\/",
"\\.",
"\\w",
"/x",
",",
":CROSSREF",
")",
"# external hyperlinks",
"@markup",
".",
"add_special",
"(",
"/",
"\\.",
"\\S",
"\\w",
"/",
",",
":HYPERLINK",
")",
"# and links of the form <text>[<url>]",
"@markup",
".",
"add_special",
"(",
"/",
"\\{",
"\\}",
"\\b",
"\\S",
"\\[",
"\\S",
"\\.",
"\\S",
"\\]",
"/",
",",
":TIDYLINK",
")",
"# @markup.add_special(/\\b(\\S+?\\[\\S+?\\.\\S+?\\])/, :TIDYLINK)",
"end",
"unless",
"defined?",
"@html_formatter",
"@html_formatter",
"=",
"HyperlinkHtml",
".",
"new",
"(",
"self",
".",
"path",
",",
"self",
")",
"end",
"# Convert leading comment markers to spaces, but only",
"# if all non-blank lines have them",
"if",
"str",
"=~",
"/",
"\\s",
"\\#",
"/",
"content",
"=",
"str",
"else",
"content",
"=",
"str",
".",
"gsub",
"(",
"/",
"\\s",
"/",
")",
"{",
"$1",
".",
"tr",
"(",
"'#'",
",",
"' '",
")",
"}",
"end",
"res",
"=",
"@markup",
".",
"convert",
"(",
"content",
",",
"@html_formatter",
")",
"if",
"remove_para",
"res",
".",
"sub!",
"(",
"/",
"/",
",",
"''",
")",
"res",
".",
"sub!",
"(",
"/",
"\\/",
"/",
",",
"''",
")",
"end",
"res",
"end"
] | Convert a string in markup format into HTML. We keep a cached
SimpleMarkup object lying around after the first time we're
called per object. | [
"Convert",
"a",
"string",
"in",
"markup",
"format",
"into",
"HTML",
".",
"We",
"keep",
"a",
"cached",
"SimpleMarkup",
"object",
"lying",
"around",
"after",
"the",
"first",
"time",
"we",
"re",
"called",
"per",
"object",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb#L209-L252 |
1,728 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb | Generators.ContextUser.build_method_detail_list | def build_method_detail_list(section)
outer = []
methods = @methods.sort
for singleton in [true, false]
for vis in [ :public, :protected, :private ]
res = []
methods.each do |m|
if m.section == section and
m.document_self and
m.visibility == vis and
m.singleton == singleton
row = {}
if m.call_seq
row["callseq"] = m.call_seq.gsub(/->/, '→')
else
row["name"] = CGI.escapeHTML(m.name)
row["params"] = m.params
end
desc = m.description.strip
row["m_desc"] = desc unless desc.empty?
row["aref"] = m.aref
row["visibility"] = m.visibility.to_s
alias_names = []
m.aliases.each do |other|
if other.viewer # won't be if the alias is private
alias_names << {
'name' => other.name,
'aref' => other.viewer.as_href(path)
}
end
end
unless alias_names.empty?
row["aka"] = alias_names
end
if @options.inline_source
code = m.source_code
row["sourcecode"] = code if code
else
code = m.src_url
if code
row["codeurl"] = code
row["imgurl"] = m.img_url
end
end
res << row
end
end
if res.size > 0
outer << {
"type" => vis.to_s.capitalize,
"category" => singleton ? "Class" : "Instance",
"methods" => res
}
end
end
end
outer
end | ruby | def build_method_detail_list(section)
outer = []
methods = @methods.sort
for singleton in [true, false]
for vis in [ :public, :protected, :private ]
res = []
methods.each do |m|
if m.section == section and
m.document_self and
m.visibility == vis and
m.singleton == singleton
row = {}
if m.call_seq
row["callseq"] = m.call_seq.gsub(/->/, '→')
else
row["name"] = CGI.escapeHTML(m.name)
row["params"] = m.params
end
desc = m.description.strip
row["m_desc"] = desc unless desc.empty?
row["aref"] = m.aref
row["visibility"] = m.visibility.to_s
alias_names = []
m.aliases.each do |other|
if other.viewer # won't be if the alias is private
alias_names << {
'name' => other.name,
'aref' => other.viewer.as_href(path)
}
end
end
unless alias_names.empty?
row["aka"] = alias_names
end
if @options.inline_source
code = m.source_code
row["sourcecode"] = code if code
else
code = m.src_url
if code
row["codeurl"] = code
row["imgurl"] = m.img_url
end
end
res << row
end
end
if res.size > 0
outer << {
"type" => vis.to_s.capitalize,
"category" => singleton ? "Class" : "Instance",
"methods" => res
}
end
end
end
outer
end | [
"def",
"build_method_detail_list",
"(",
"section",
")",
"outer",
"=",
"[",
"]",
"methods",
"=",
"@methods",
".",
"sort",
"for",
"singleton",
"in",
"[",
"true",
",",
"false",
"]",
"for",
"vis",
"in",
"[",
":public",
",",
":protected",
",",
":private",
"]",
"res",
"=",
"[",
"]",
"methods",
".",
"each",
"do",
"|",
"m",
"|",
"if",
"m",
".",
"section",
"==",
"section",
"and",
"m",
".",
"document_self",
"and",
"m",
".",
"visibility",
"==",
"vis",
"and",
"m",
".",
"singleton",
"==",
"singleton",
"row",
"=",
"{",
"}",
"if",
"m",
".",
"call_seq",
"row",
"[",
"\"callseq\"",
"]",
"=",
"m",
".",
"call_seq",
".",
"gsub",
"(",
"/",
"/",
",",
"'→'",
")",
"else",
"row",
"[",
"\"name\"",
"]",
"=",
"CGI",
".",
"escapeHTML",
"(",
"m",
".",
"name",
")",
"row",
"[",
"\"params\"",
"]",
"=",
"m",
".",
"params",
"end",
"desc",
"=",
"m",
".",
"description",
".",
"strip",
"row",
"[",
"\"m_desc\"",
"]",
"=",
"desc",
"unless",
"desc",
".",
"empty?",
"row",
"[",
"\"aref\"",
"]",
"=",
"m",
".",
"aref",
"row",
"[",
"\"visibility\"",
"]",
"=",
"m",
".",
"visibility",
".",
"to_s",
"alias_names",
"=",
"[",
"]",
"m",
".",
"aliases",
".",
"each",
"do",
"|",
"other",
"|",
"if",
"other",
".",
"viewer",
"# won't be if the alias is private",
"alias_names",
"<<",
"{",
"'name'",
"=>",
"other",
".",
"name",
",",
"'aref'",
"=>",
"other",
".",
"viewer",
".",
"as_href",
"(",
"path",
")",
"}",
"end",
"end",
"unless",
"alias_names",
".",
"empty?",
"row",
"[",
"\"aka\"",
"]",
"=",
"alias_names",
"end",
"if",
"@options",
".",
"inline_source",
"code",
"=",
"m",
".",
"source_code",
"row",
"[",
"\"sourcecode\"",
"]",
"=",
"code",
"if",
"code",
"else",
"code",
"=",
"m",
".",
"src_url",
"if",
"code",
"row",
"[",
"\"codeurl\"",
"]",
"=",
"code",
"row",
"[",
"\"imgurl\"",
"]",
"=",
"m",
".",
"img_url",
"end",
"end",
"res",
"<<",
"row",
"end",
"end",
"if",
"res",
".",
"size",
">",
"0",
"outer",
"<<",
"{",
"\"type\"",
"=>",
"vis",
".",
"to_s",
".",
"capitalize",
",",
"\"category\"",
"=>",
"singleton",
"?",
"\"Class\"",
":",
"\"Instance\"",
",",
"\"methods\"",
"=>",
"res",
"}",
"end",
"end",
"end",
"outer",
"end"
] | Build an array of arrays of method details. The outer array has up
to six entries, public, private, and protected for both class
methods, the other for instance methods. The inner arrays contain
a hash for each method | [
"Build",
"an",
"array",
"of",
"arrays",
"of",
"method",
"details",
".",
"The",
"outer",
"array",
"has",
"up",
"to",
"six",
"entries",
"public",
"private",
"and",
"protected",
"for",
"both",
"class",
"methods",
"the",
"other",
"for",
"instance",
"methods",
".",
"The",
"inner",
"arrays",
"contain",
"a",
"hash",
"for",
"each",
"method"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb#L432-L492 |
1,729 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb | Generators.ContextUser.build_class_list | def build_class_list(level, from, section, infile=nil)
res = ""
prefix = " ::" * level;
from.modules.sort.each do |mod|
next unless mod.section == section
next if infile && !mod.defined_in?(infile)
if mod.document_self
res <<
prefix <<
"Module " <<
href(url(mod.viewer.path), "link", mod.full_name) <<
"<br />\n" <<
build_class_list(level + 1, mod, section, infile)
end
end
from.classes.sort.each do |cls|
next unless cls.section == section
next if infile && !cls.defined_in?(infile)
if cls.document_self
res <<
prefix <<
"Class " <<
href(url(cls.viewer.path), "link", cls.full_name) <<
"<br />\n" <<
build_class_list(level + 1, cls, section, infile)
end
end
res
end | ruby | def build_class_list(level, from, section, infile=nil)
res = ""
prefix = " ::" * level;
from.modules.sort.each do |mod|
next unless mod.section == section
next if infile && !mod.defined_in?(infile)
if mod.document_self
res <<
prefix <<
"Module " <<
href(url(mod.viewer.path), "link", mod.full_name) <<
"<br />\n" <<
build_class_list(level + 1, mod, section, infile)
end
end
from.classes.sort.each do |cls|
next unless cls.section == section
next if infile && !cls.defined_in?(infile)
if cls.document_self
res <<
prefix <<
"Class " <<
href(url(cls.viewer.path), "link", cls.full_name) <<
"<br />\n" <<
build_class_list(level + 1, cls, section, infile)
end
end
res
end | [
"def",
"build_class_list",
"(",
"level",
",",
"from",
",",
"section",
",",
"infile",
"=",
"nil",
")",
"res",
"=",
"\"\"",
"prefix",
"=",
"\" ::\"",
"*",
"level",
";",
"from",
".",
"modules",
".",
"sort",
".",
"each",
"do",
"|",
"mod",
"|",
"next",
"unless",
"mod",
".",
"section",
"==",
"section",
"next",
"if",
"infile",
"&&",
"!",
"mod",
".",
"defined_in?",
"(",
"infile",
")",
"if",
"mod",
".",
"document_self",
"res",
"<<",
"prefix",
"<<",
"\"Module \"",
"<<",
"href",
"(",
"url",
"(",
"mod",
".",
"viewer",
".",
"path",
")",
",",
"\"link\"",
",",
"mod",
".",
"full_name",
")",
"<<",
"\"<br />\\n\"",
"<<",
"build_class_list",
"(",
"level",
"+",
"1",
",",
"mod",
",",
"section",
",",
"infile",
")",
"end",
"end",
"from",
".",
"classes",
".",
"sort",
".",
"each",
"do",
"|",
"cls",
"|",
"next",
"unless",
"cls",
".",
"section",
"==",
"section",
"next",
"if",
"infile",
"&&",
"!",
"cls",
".",
"defined_in?",
"(",
"infile",
")",
"if",
"cls",
".",
"document_self",
"res",
"<<",
"prefix",
"<<",
"\"Class \"",
"<<",
"href",
"(",
"url",
"(",
"cls",
".",
"viewer",
".",
"path",
")",
",",
"\"link\"",
",",
"cls",
".",
"full_name",
")",
"<<",
"\"<br />\\n\"",
"<<",
"build_class_list",
"(",
"level",
"+",
"1",
",",
"cls",
",",
"section",
",",
"infile",
")",
"end",
"end",
"res",
"end"
] | Build the structured list of classes and modules contained
in this context. | [
"Build",
"the",
"structured",
"list",
"of",
"classes",
"and",
"modules",
"contained",
"in",
"this",
"context",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb#L497-L528 |
1,730 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb | Generators.HTMLGenerator.load_html_template | def load_html_template
template = @options.template
unless template =~ %r{/|\\}
template = File.join("rdoc/generators/template",
@options.generator.key, template)
end
require template
extend RDoc::Page
rescue LoadError
$stderr.puts "Could not find HTML template '#{template}'"
exit 99
end | ruby | def load_html_template
template = @options.template
unless template =~ %r{/|\\}
template = File.join("rdoc/generators/template",
@options.generator.key, template)
end
require template
extend RDoc::Page
rescue LoadError
$stderr.puts "Could not find HTML template '#{template}'"
exit 99
end | [
"def",
"load_html_template",
"template",
"=",
"@options",
".",
"template",
"unless",
"template",
"=~",
"%r{",
"\\\\",
"}",
"template",
"=",
"File",
".",
"join",
"(",
"\"rdoc/generators/template\"",
",",
"@options",
".",
"generator",
".",
"key",
",",
"template",
")",
"end",
"require",
"template",
"extend",
"RDoc",
"::",
"Page",
"rescue",
"LoadError",
"$stderr",
".",
"puts",
"\"Could not find HTML template '#{template}'\"",
"exit",
"99",
"end"
] | Load up the HTML template specified in the options.
If the template name contains a slash, use it literally | [
"Load",
"up",
"the",
"HTML",
"template",
"specified",
"in",
"the",
"options",
".",
"If",
"the",
"template",
"name",
"contains",
"a",
"slash",
"use",
"it",
"literally"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb#L1206-L1217 |
1,731 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb | Generators.HTMLGenerator.write_style_sheet | def write_style_sheet
template = TemplatePage.new(RDoc::Page::STYLE)
unless @options.css
File.open(CSS_NAME, "w") do |f|
values = { "fonts" => RDoc::Page::FONTS }
template.write_html_on(f, values)
end
end
end | ruby | def write_style_sheet
template = TemplatePage.new(RDoc::Page::STYLE)
unless @options.css
File.open(CSS_NAME, "w") do |f|
values = { "fonts" => RDoc::Page::FONTS }
template.write_html_on(f, values)
end
end
end | [
"def",
"write_style_sheet",
"template",
"=",
"TemplatePage",
".",
"new",
"(",
"RDoc",
"::",
"Page",
"::",
"STYLE",
")",
"unless",
"@options",
".",
"css",
"File",
".",
"open",
"(",
"CSS_NAME",
",",
"\"w\"",
")",
"do",
"|",
"f",
"|",
"values",
"=",
"{",
"\"fonts\"",
"=>",
"RDoc",
"::",
"Page",
"::",
"FONTS",
"}",
"template",
".",
"write_html_on",
"(",
"f",
",",
"values",
")",
"end",
"end",
"end"
] | Write out the style sheet used by the main frames | [
"Write",
"out",
"the",
"style",
"sheet",
"used",
"by",
"the",
"main",
"frames"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb#L1223-L1231 |
1,732 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb | Generators.HTMLGenerator.main_url | def main_url
main_page = @options.main_page
ref = nil
if main_page
ref = AllReferences[main_page]
if ref
ref = ref.path
else
$stderr.puts "Could not find main page #{main_page}"
end
end
unless ref
for file in @files
if file.document_self
ref = file.path
break
end
end
end
unless ref
$stderr.puts "Couldn't find anything to document"
$stderr.puts "Perhaps you've used :stopdoc: in all classes"
exit(1)
end
ref
end | ruby | def main_url
main_page = @options.main_page
ref = nil
if main_page
ref = AllReferences[main_page]
if ref
ref = ref.path
else
$stderr.puts "Could not find main page #{main_page}"
end
end
unless ref
for file in @files
if file.document_self
ref = file.path
break
end
end
end
unless ref
$stderr.puts "Couldn't find anything to document"
$stderr.puts "Perhaps you've used :stopdoc: in all classes"
exit(1)
end
ref
end | [
"def",
"main_url",
"main_page",
"=",
"@options",
".",
"main_page",
"ref",
"=",
"nil",
"if",
"main_page",
"ref",
"=",
"AllReferences",
"[",
"main_page",
"]",
"if",
"ref",
"ref",
"=",
"ref",
".",
"path",
"else",
"$stderr",
".",
"puts",
"\"Could not find main page #{main_page}\"",
"end",
"end",
"unless",
"ref",
"for",
"file",
"in",
"@files",
"if",
"file",
".",
"document_self",
"ref",
"=",
"file",
".",
"path",
"break",
"end",
"end",
"end",
"unless",
"ref",
"$stderr",
".",
"puts",
"\"Couldn't find anything to document\"",
"$stderr",
".",
"puts",
"\"Perhaps you've used :stopdoc: in all classes\"",
"exit",
"(",
"1",
")",
"end",
"ref",
"end"
] | return the url of the main page | [
"return",
"the",
"url",
"of",
"the",
"main",
"page"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb#L1361-L1389 |
1,733 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb | Generators.HTMLGeneratorInOne.generate_xml | def generate_xml
values = {
'charset' => @options.charset,
'files' => gen_into(@files),
'classes' => gen_into(@classes),
'title' => CGI.escapeHTML(@options.title),
}
# this method is defined in the template file
write_extra_pages if defined? write_extra_pages
template = TemplatePage.new(RDoc::Page::ONE_PAGE)
if @options.op_name
opfile = File.open(@options.op_name, "w")
else
opfile = $stdout
end
template.write_html_on(opfile, values)
end | ruby | def generate_xml
values = {
'charset' => @options.charset,
'files' => gen_into(@files),
'classes' => gen_into(@classes),
'title' => CGI.escapeHTML(@options.title),
}
# this method is defined in the template file
write_extra_pages if defined? write_extra_pages
template = TemplatePage.new(RDoc::Page::ONE_PAGE)
if @options.op_name
opfile = File.open(@options.op_name, "w")
else
opfile = $stdout
end
template.write_html_on(opfile, values)
end | [
"def",
"generate_xml",
"values",
"=",
"{",
"'charset'",
"=>",
"@options",
".",
"charset",
",",
"'files'",
"=>",
"gen_into",
"(",
"@files",
")",
",",
"'classes'",
"=>",
"gen_into",
"(",
"@classes",
")",
",",
"'title'",
"=>",
"CGI",
".",
"escapeHTML",
"(",
"@options",
".",
"title",
")",
",",
"}",
"# this method is defined in the template file",
"write_extra_pages",
"if",
"defined?",
"write_extra_pages",
"template",
"=",
"TemplatePage",
".",
"new",
"(",
"RDoc",
"::",
"Page",
"::",
"ONE_PAGE",
")",
"if",
"@options",
".",
"op_name",
"opfile",
"=",
"File",
".",
"open",
"(",
"@options",
".",
"op_name",
",",
"\"w\"",
")",
"else",
"opfile",
"=",
"$stdout",
"end",
"template",
".",
"write_html_on",
"(",
"opfile",
",",
"values",
")",
"end"
] | Generate all the HTML. For the one-file case, we generate
all the information in to one big hash | [
"Generate",
"all",
"the",
"HTML",
".",
"For",
"the",
"one",
"-",
"file",
"case",
"we",
"generate",
"all",
"the",
"information",
"in",
"to",
"one",
"big",
"hash"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/html_generator.rb#L1451-L1470 |
1,734 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/diagram.rb | RDoc.Diagram.draw | def draw
unless @options.quiet
$stderr.print "Diagrams: "
$stderr.flush
end
@info.each_with_index do |i, file_count|
@done_modules = {}
@local_names = find_names(i)
@global_names = []
@global_graph = graph = DOT::Digraph.new('name' => 'TopLevel',
'fontname' => FONT,
'fontsize' => '8',
'bgcolor' => 'lightcyan1',
'compound' => 'true')
# it's a little hack %) i'm too lazy to create a separate class
# for default node
graph << DOT::Node.new('name' => 'node',
'fontname' => FONT,
'color' => 'black',
'fontsize' => 8)
i.modules.each do |mod|
draw_module(mod, graph, true, i.file_relative_name)
end
add_classes(i, graph, i.file_relative_name)
i.diagram = convert_to_png("f_#{file_count}", graph)
# now go through and document each top level class and
# module independently
i.modules.each_with_index do |mod, count|
@done_modules = {}
@local_names = find_names(mod)
@global_names = []
@global_graph = graph = DOT::Digraph.new('name' => 'TopLevel',
'fontname' => FONT,
'fontsize' => '8',
'bgcolor' => 'lightcyan1',
'compound' => 'true')
graph << DOT::Node.new('name' => 'node',
'fontname' => FONT,
'color' => 'black',
'fontsize' => 8)
draw_module(mod, graph, true)
mod.diagram = convert_to_png("m_#{file_count}_#{count}",
graph)
end
end
$stderr.puts unless @options.quiet
end | ruby | def draw
unless @options.quiet
$stderr.print "Diagrams: "
$stderr.flush
end
@info.each_with_index do |i, file_count|
@done_modules = {}
@local_names = find_names(i)
@global_names = []
@global_graph = graph = DOT::Digraph.new('name' => 'TopLevel',
'fontname' => FONT,
'fontsize' => '8',
'bgcolor' => 'lightcyan1',
'compound' => 'true')
# it's a little hack %) i'm too lazy to create a separate class
# for default node
graph << DOT::Node.new('name' => 'node',
'fontname' => FONT,
'color' => 'black',
'fontsize' => 8)
i.modules.each do |mod|
draw_module(mod, graph, true, i.file_relative_name)
end
add_classes(i, graph, i.file_relative_name)
i.diagram = convert_to_png("f_#{file_count}", graph)
# now go through and document each top level class and
# module independently
i.modules.each_with_index do |mod, count|
@done_modules = {}
@local_names = find_names(mod)
@global_names = []
@global_graph = graph = DOT::Digraph.new('name' => 'TopLevel',
'fontname' => FONT,
'fontsize' => '8',
'bgcolor' => 'lightcyan1',
'compound' => 'true')
graph << DOT::Node.new('name' => 'node',
'fontname' => FONT,
'color' => 'black',
'fontsize' => 8)
draw_module(mod, graph, true)
mod.diagram = convert_to_png("m_#{file_count}_#{count}",
graph)
end
end
$stderr.puts unless @options.quiet
end | [
"def",
"draw",
"unless",
"@options",
".",
"quiet",
"$stderr",
".",
"print",
"\"Diagrams: \"",
"$stderr",
".",
"flush",
"end",
"@info",
".",
"each_with_index",
"do",
"|",
"i",
",",
"file_count",
"|",
"@done_modules",
"=",
"{",
"}",
"@local_names",
"=",
"find_names",
"(",
"i",
")",
"@global_names",
"=",
"[",
"]",
"@global_graph",
"=",
"graph",
"=",
"DOT",
"::",
"Digraph",
".",
"new",
"(",
"'name'",
"=>",
"'TopLevel'",
",",
"'fontname'",
"=>",
"FONT",
",",
"'fontsize'",
"=>",
"'8'",
",",
"'bgcolor'",
"=>",
"'lightcyan1'",
",",
"'compound'",
"=>",
"'true'",
")",
"# it's a little hack %) i'm too lazy to create a separate class",
"# for default node",
"graph",
"<<",
"DOT",
"::",
"Node",
".",
"new",
"(",
"'name'",
"=>",
"'node'",
",",
"'fontname'",
"=>",
"FONT",
",",
"'color'",
"=>",
"'black'",
",",
"'fontsize'",
"=>",
"8",
")",
"i",
".",
"modules",
".",
"each",
"do",
"|",
"mod",
"|",
"draw_module",
"(",
"mod",
",",
"graph",
",",
"true",
",",
"i",
".",
"file_relative_name",
")",
"end",
"add_classes",
"(",
"i",
",",
"graph",
",",
"i",
".",
"file_relative_name",
")",
"i",
".",
"diagram",
"=",
"convert_to_png",
"(",
"\"f_#{file_count}\"",
",",
"graph",
")",
"# now go through and document each top level class and",
"# module independently",
"i",
".",
"modules",
".",
"each_with_index",
"do",
"|",
"mod",
",",
"count",
"|",
"@done_modules",
"=",
"{",
"}",
"@local_names",
"=",
"find_names",
"(",
"mod",
")",
"@global_names",
"=",
"[",
"]",
"@global_graph",
"=",
"graph",
"=",
"DOT",
"::",
"Digraph",
".",
"new",
"(",
"'name'",
"=>",
"'TopLevel'",
",",
"'fontname'",
"=>",
"FONT",
",",
"'fontsize'",
"=>",
"'8'",
",",
"'bgcolor'",
"=>",
"'lightcyan1'",
",",
"'compound'",
"=>",
"'true'",
")",
"graph",
"<<",
"DOT",
"::",
"Node",
".",
"new",
"(",
"'name'",
"=>",
"'node'",
",",
"'fontname'",
"=>",
"FONT",
",",
"'color'",
"=>",
"'black'",
",",
"'fontsize'",
"=>",
"8",
")",
"draw_module",
"(",
"mod",
",",
"graph",
",",
"true",
")",
"mod",
".",
"diagram",
"=",
"convert_to_png",
"(",
"\"m_#{file_count}_#{count}\"",
",",
"graph",
")",
"end",
"end",
"$stderr",
".",
"puts",
"unless",
"@options",
".",
"quiet",
"end"
] | Pass in the set of top level objects. The method also creates the
subdirectory to hold the images
Draw the diagrams. We traverse the files, drawing a diagram for each. We
also traverse each top-level class and module in that file drawing a
diagram for these too. | [
"Pass",
"in",
"the",
"set",
"of",
"top",
"level",
"objects",
".",
"The",
"method",
"also",
"creates",
"the",
"subdirectory",
"to",
"hold",
"the",
"images"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/diagram.rb#L50-L103 |
1,735 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/code_objects.rb | RDoc.Context.find_symbol | def find_symbol(symbol, method=nil)
result = nil
case symbol
when /^::(.*)/
result = toplevel.find_symbol($1)
when /::/
modules = symbol.split(/::/)
unless modules.empty?
module_name = modules.shift
result = find_module_named(module_name)
if result
modules.each do |module_name|
result = result.find_module_named(module_name)
break unless result
end
end
end
else
# if a method is specified, then we're definitely looking for
# a module, otherwise it could be any symbol
if method
result = find_module_named(symbol)
else
result = find_local_symbol(symbol)
if result.nil?
if symbol =~ /^[A-Z]/
result = parent
while result && result.name != symbol
result = result.parent
end
end
end
end
end
if result && method
if !result.respond_to?(:find_local_symbol)
p result.name
p method
fail
end
result = result.find_local_symbol(method)
end
result
end | ruby | def find_symbol(symbol, method=nil)
result = nil
case symbol
when /^::(.*)/
result = toplevel.find_symbol($1)
when /::/
modules = symbol.split(/::/)
unless modules.empty?
module_name = modules.shift
result = find_module_named(module_name)
if result
modules.each do |module_name|
result = result.find_module_named(module_name)
break unless result
end
end
end
else
# if a method is specified, then we're definitely looking for
# a module, otherwise it could be any symbol
if method
result = find_module_named(symbol)
else
result = find_local_symbol(symbol)
if result.nil?
if symbol =~ /^[A-Z]/
result = parent
while result && result.name != symbol
result = result.parent
end
end
end
end
end
if result && method
if !result.respond_to?(:find_local_symbol)
p result.name
p method
fail
end
result = result.find_local_symbol(method)
end
result
end | [
"def",
"find_symbol",
"(",
"symbol",
",",
"method",
"=",
"nil",
")",
"result",
"=",
"nil",
"case",
"symbol",
"when",
"/",
"/",
"result",
"=",
"toplevel",
".",
"find_symbol",
"(",
"$1",
")",
"when",
"/",
"/",
"modules",
"=",
"symbol",
".",
"split",
"(",
"/",
"/",
")",
"unless",
"modules",
".",
"empty?",
"module_name",
"=",
"modules",
".",
"shift",
"result",
"=",
"find_module_named",
"(",
"module_name",
")",
"if",
"result",
"modules",
".",
"each",
"do",
"|",
"module_name",
"|",
"result",
"=",
"result",
".",
"find_module_named",
"(",
"module_name",
")",
"break",
"unless",
"result",
"end",
"end",
"end",
"else",
"# if a method is specified, then we're definitely looking for",
"# a module, otherwise it could be any symbol",
"if",
"method",
"result",
"=",
"find_module_named",
"(",
"symbol",
")",
"else",
"result",
"=",
"find_local_symbol",
"(",
"symbol",
")",
"if",
"result",
".",
"nil?",
"if",
"symbol",
"=~",
"/",
"/",
"result",
"=",
"parent",
"while",
"result",
"&&",
"result",
".",
"name",
"!=",
"symbol",
"result",
"=",
"result",
".",
"parent",
"end",
"end",
"end",
"end",
"end",
"if",
"result",
"&&",
"method",
"if",
"!",
"result",
".",
"respond_to?",
"(",
":find_local_symbol",
")",
"p",
"result",
".",
"name",
"p",
"method",
"fail",
"end",
"result",
"=",
"result",
".",
"find_local_symbol",
"(",
"method",
")",
"end",
"result",
"end"
] | allow us to sort modules by name
Look up the given symbol. If method is non-nil, then
we assume the symbol references a module that
contains that method | [
"allow",
"us",
"to",
"sort",
"modules",
"by",
"name",
"Look",
"up",
"the",
"given",
"symbol",
".",
"If",
"method",
"is",
"non",
"-",
"nil",
"then",
"we",
"assume",
"the",
"symbol",
"references",
"a",
"module",
"that",
"contains",
"that",
"method"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/code_objects.rb#L377-L420 |
1,736 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb | ActiveSupport.MessageVerifier.secure_compare | def secure_compare(a, b)
if a.length == b.length
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end | ruby | def secure_compare(a, b)
if a.length == b.length
result = 0
for i in 0..(a.length - 1)
result |= a[i] ^ b[i]
end
result == 0
else
false
end
end | [
"def",
"secure_compare",
"(",
"a",
",",
"b",
")",
"if",
"a",
".",
"length",
"==",
"b",
".",
"length",
"result",
"=",
"0",
"for",
"i",
"in",
"0",
"..",
"(",
"a",
".",
"length",
"-",
"1",
")",
"result",
"|=",
"a",
"[",
"i",
"]",
"^",
"b",
"[",
"i",
"]",
"end",
"result",
"==",
"0",
"else",
"false",
"end",
"end"
] | constant-time comparison algorithm to prevent timing attacks | [
"constant",
"-",
"time",
"comparison",
"algorithm",
"to",
"prevent",
"timing",
"attacks"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb#L42-L52 |
1,737 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rss/parser.rb | RSS.ListenerMixin.parse_pi_content | def parse_pi_content(content)
params = {}
content.scan(CONTENT_PATTERN) do |name, quote, value|
params[name] = value
end
params
end | ruby | def parse_pi_content(content)
params = {}
content.scan(CONTENT_PATTERN) do |name, quote, value|
params[name] = value
end
params
end | [
"def",
"parse_pi_content",
"(",
"content",
")",
"params",
"=",
"{",
"}",
"content",
".",
"scan",
"(",
"CONTENT_PATTERN",
")",
"do",
"|",
"name",
",",
"quote",
",",
"value",
"|",
"params",
"[",
"name",
"]",
"=",
"value",
"end",
"params",
"end"
] | Extract the first name="value" pair from content.
Works with single quotes according to the constant
CONTENT_PATTERN. Return a Hash. | [
"Extract",
"the",
"first",
"name",
"=",
"value",
"pair",
"from",
"content",
".",
"Works",
"with",
"single",
"quotes",
"according",
"to",
"the",
"constant",
"CONTENT_PATTERN",
".",
"Return",
"a",
"Hash",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rss/parser.rb#L379-L385 |
1,738 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rss/parser.rb | RSS.Parser.normalize_rss | def normalize_rss(rss)
return rss if maybe_xml?(rss)
uri = to_uri(rss)
if uri.respond_to?(:read)
uri.read
elsif !rss.tainted? and File.readable?(rss)
File.open(rss) {|f| f.read}
else
rss
end
end | ruby | def normalize_rss(rss)
return rss if maybe_xml?(rss)
uri = to_uri(rss)
if uri.respond_to?(:read)
uri.read
elsif !rss.tainted? and File.readable?(rss)
File.open(rss) {|f| f.read}
else
rss
end
end | [
"def",
"normalize_rss",
"(",
"rss",
")",
"return",
"rss",
"if",
"maybe_xml?",
"(",
"rss",
")",
"uri",
"=",
"to_uri",
"(",
"rss",
")",
"if",
"uri",
".",
"respond_to?",
"(",
":read",
")",
"uri",
".",
"read",
"elsif",
"!",
"rss",
".",
"tainted?",
"and",
"File",
".",
"readable?",
"(",
"rss",
")",
"File",
".",
"open",
"(",
"rss",
")",
"{",
"|",
"f",
"|",
"f",
".",
"read",
"}",
"else",
"rss",
"end",
"end"
] | Try to get the XML associated with +rss+.
Return +rss+ if it already looks like XML, or treat it as a URI,
or a file to get the XML, | [
"Try",
"to",
"get",
"the",
"XML",
"associated",
"with",
"+",
"rss",
"+",
".",
"Return",
"+",
"rss",
"+",
"if",
"it",
"already",
"looks",
"like",
"XML",
"or",
"treat",
"it",
"as",
"a",
"URI",
"or",
"a",
"file",
"to",
"get",
"the",
"XML"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rss/parser.rb#L97-L109 |
1,739 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rcov-0.9.8-java/lib/rcov/rcovtask.rb | Rcov.RcovTask.define | def define
lib_path = @libs.join(File::PATH_SEPARATOR)
actual_name = Hash === name ? name.keys.first : name
unless Rake.application.last_comment
desc "Analyze code coverage with tests" +
(@name==:rcov ? "" : " for #{actual_name}")
end
task @name do
run_code = ''
RakeFileUtils.verbose(@verbose) do
run_code =
case rcov_path
when nil, ''
"-S rcov"
else %!"#{rcov_path}"!
end
ruby_opts = @ruby_opts.clone
ruby_opts.push( "-I#{lib_path}" )
ruby_opts.push run_code
ruby_opts.push( "-w" ) if @warning
ruby ruby_opts.join(" ") + " " + option_list +
%[ -o "#{@output_dir}" ] +
file_list.collect { |fn| %["#{fn}"] }.join(' ')
end
end
desc "Remove rcov products for #{actual_name}"
task paste("clobber_", actual_name) do
rm_r @output_dir rescue nil
end
clobber_task = paste("clobber_", actual_name)
task :clobber => [clobber_task]
task actual_name => clobber_task
self
end | ruby | def define
lib_path = @libs.join(File::PATH_SEPARATOR)
actual_name = Hash === name ? name.keys.first : name
unless Rake.application.last_comment
desc "Analyze code coverage with tests" +
(@name==:rcov ? "" : " for #{actual_name}")
end
task @name do
run_code = ''
RakeFileUtils.verbose(@verbose) do
run_code =
case rcov_path
when nil, ''
"-S rcov"
else %!"#{rcov_path}"!
end
ruby_opts = @ruby_opts.clone
ruby_opts.push( "-I#{lib_path}" )
ruby_opts.push run_code
ruby_opts.push( "-w" ) if @warning
ruby ruby_opts.join(" ") + " " + option_list +
%[ -o "#{@output_dir}" ] +
file_list.collect { |fn| %["#{fn}"] }.join(' ')
end
end
desc "Remove rcov products for #{actual_name}"
task paste("clobber_", actual_name) do
rm_r @output_dir rescue nil
end
clobber_task = paste("clobber_", actual_name)
task :clobber => [clobber_task]
task actual_name => clobber_task
self
end | [
"def",
"define",
"lib_path",
"=",
"@libs",
".",
"join",
"(",
"File",
"::",
"PATH_SEPARATOR",
")",
"actual_name",
"=",
"Hash",
"===",
"name",
"?",
"name",
".",
"keys",
".",
"first",
":",
"name",
"unless",
"Rake",
".",
"application",
".",
"last_comment",
"desc",
"\"Analyze code coverage with tests\"",
"+",
"(",
"@name",
"==",
":rcov",
"?",
"\"\"",
":",
"\" for #{actual_name}\"",
")",
"end",
"task",
"@name",
"do",
"run_code",
"=",
"''",
"RakeFileUtils",
".",
"verbose",
"(",
"@verbose",
")",
"do",
"run_code",
"=",
"case",
"rcov_path",
"when",
"nil",
",",
"''",
"\"-S rcov\"",
"else",
"%!\"#{rcov_path}\"!",
"end",
"ruby_opts",
"=",
"@ruby_opts",
".",
"clone",
"ruby_opts",
".",
"push",
"(",
"\"-I#{lib_path}\"",
")",
"ruby_opts",
".",
"push",
"run_code",
"ruby_opts",
".",
"push",
"(",
"\"-w\"",
")",
"if",
"@warning",
"ruby",
"ruby_opts",
".",
"join",
"(",
"\" \"",
")",
"+",
"\" \"",
"+",
"option_list",
"+",
"%[ -o \"#{@output_dir}\" ]",
"+",
"file_list",
".",
"collect",
"{",
"|",
"fn",
"|",
"%[\"#{fn}\"]",
"}",
".",
"join",
"(",
"' '",
")",
"end",
"end",
"desc",
"\"Remove rcov products for #{actual_name}\"",
"task",
"paste",
"(",
"\"clobber_\"",
",",
"actual_name",
")",
"do",
"rm_r",
"@output_dir",
"rescue",
"nil",
"end",
"clobber_task",
"=",
"paste",
"(",
"\"clobber_\"",
",",
"actual_name",
")",
"task",
":clobber",
"=>",
"[",
"clobber_task",
"]",
"task",
"actual_name",
"=>",
"clobber_task",
"self",
"end"
] | Create a testing task.
Create the tasks defined by this task lib. | [
"Create",
"a",
"testing",
"task",
".",
"Create",
"the",
"tasks",
"defined",
"by",
"this",
"task",
"lib",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rcov-0.9.8-java/lib/rcov/rcovtask.rb#L98-L134 |
1,740 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb | RDoc.RDoc.update_output_dir | def update_output_dir(op_dir, time)
File.open(output_flag_file(op_dir), "w") {|f| f.puts time.rfc2822 }
end | ruby | def update_output_dir(op_dir, time)
File.open(output_flag_file(op_dir), "w") {|f| f.puts time.rfc2822 }
end | [
"def",
"update_output_dir",
"(",
"op_dir",
",",
"time",
")",
"File",
".",
"open",
"(",
"output_flag_file",
"(",
"op_dir",
")",
",",
"\"w\"",
")",
"{",
"|",
"f",
"|",
"f",
".",
"puts",
"time",
".",
"rfc2822",
"}",
"end"
] | Update the flag file in an output directory. | [
"Update",
"the",
"flag",
"file",
"in",
"an",
"output",
"directory",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb#L105-L107 |
1,741 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb | RDoc.RDoc.normalized_file_list | def normalized_file_list(options, relative_files, force_doc = false,
exclude_pattern = nil)
file_list = []
relative_files.each do |rel_file_name|
next if exclude_pattern && exclude_pattern =~ rel_file_name
stat = File.stat(rel_file_name)
case type = stat.ftype
when "file"
next if @last_created and stat.mtime < @last_created
if force_doc or ::RDoc::Parser.can_parse(rel_file_name) then
file_list << rel_file_name.sub(/^\.\//, '')
end
when "directory"
next if rel_file_name == "CVS" || rel_file_name == ".svn"
dot_doc = File.join(rel_file_name, DOT_DOC_FILENAME)
if File.file?(dot_doc)
file_list.concat(parse_dot_doc_file(rel_file_name, dot_doc, options))
else
file_list.concat(list_files_in_directory(rel_file_name, options))
end
else
raise RDoc::Error, "I can't deal with a #{type} #{rel_file_name}"
end
end
file_list
end | ruby | def normalized_file_list(options, relative_files, force_doc = false,
exclude_pattern = nil)
file_list = []
relative_files.each do |rel_file_name|
next if exclude_pattern && exclude_pattern =~ rel_file_name
stat = File.stat(rel_file_name)
case type = stat.ftype
when "file"
next if @last_created and stat.mtime < @last_created
if force_doc or ::RDoc::Parser.can_parse(rel_file_name) then
file_list << rel_file_name.sub(/^\.\//, '')
end
when "directory"
next if rel_file_name == "CVS" || rel_file_name == ".svn"
dot_doc = File.join(rel_file_name, DOT_DOC_FILENAME)
if File.file?(dot_doc)
file_list.concat(parse_dot_doc_file(rel_file_name, dot_doc, options))
else
file_list.concat(list_files_in_directory(rel_file_name, options))
end
else
raise RDoc::Error, "I can't deal with a #{type} #{rel_file_name}"
end
end
file_list
end | [
"def",
"normalized_file_list",
"(",
"options",
",",
"relative_files",
",",
"force_doc",
"=",
"false",
",",
"exclude_pattern",
"=",
"nil",
")",
"file_list",
"=",
"[",
"]",
"relative_files",
".",
"each",
"do",
"|",
"rel_file_name",
"|",
"next",
"if",
"exclude_pattern",
"&&",
"exclude_pattern",
"=~",
"rel_file_name",
"stat",
"=",
"File",
".",
"stat",
"(",
"rel_file_name",
")",
"case",
"type",
"=",
"stat",
".",
"ftype",
"when",
"\"file\"",
"next",
"if",
"@last_created",
"and",
"stat",
".",
"mtime",
"<",
"@last_created",
"if",
"force_doc",
"or",
"::",
"RDoc",
"::",
"Parser",
".",
"can_parse",
"(",
"rel_file_name",
")",
"then",
"file_list",
"<<",
"rel_file_name",
".",
"sub",
"(",
"/",
"\\.",
"\\/",
"/",
",",
"''",
")",
"end",
"when",
"\"directory\"",
"next",
"if",
"rel_file_name",
"==",
"\"CVS\"",
"||",
"rel_file_name",
"==",
"\".svn\"",
"dot_doc",
"=",
"File",
".",
"join",
"(",
"rel_file_name",
",",
"DOT_DOC_FILENAME",
")",
"if",
"File",
".",
"file?",
"(",
"dot_doc",
")",
"file_list",
".",
"concat",
"(",
"parse_dot_doc_file",
"(",
"rel_file_name",
",",
"dot_doc",
",",
"options",
")",
")",
"else",
"file_list",
".",
"concat",
"(",
"list_files_in_directory",
"(",
"rel_file_name",
",",
"options",
")",
")",
"end",
"else",
"raise",
"RDoc",
"::",
"Error",
",",
"\"I can't deal with a #{type} #{rel_file_name}\"",
"end",
"end",
"file_list",
"end"
] | Given a list of files and directories, create a list of all the Ruby
files they contain.
If +force_doc+ is true we always add the given files, if false, only
add files that we guarantee we can parse. It is true when looking at
files given on the command line, false when recursing through
subdirectories.
The effect of this is that if you want a file with a non-standard
extension parsed, you must name it explicitly. | [
"Given",
"a",
"list",
"of",
"files",
"and",
"directories",
"create",
"a",
"list",
"of",
"all",
"the",
"Ruby",
"files",
"they",
"contain",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb#L146-L174 |
1,742 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb | RDoc.RDoc.list_files_in_directory | def list_files_in_directory(dir, options)
files = Dir.glob File.join(dir, "*")
normalized_file_list options, files, false, options.exclude
end | ruby | def list_files_in_directory(dir, options)
files = Dir.glob File.join(dir, "*")
normalized_file_list options, files, false, options.exclude
end | [
"def",
"list_files_in_directory",
"(",
"dir",
",",
"options",
")",
"files",
"=",
"Dir",
".",
"glob",
"File",
".",
"join",
"(",
"dir",
",",
"\"*\"",
")",
"normalized_file_list",
"options",
",",
"files",
",",
"false",
",",
"options",
".",
"exclude",
"end"
] | Return a list of the files to be processed in a directory. We know that
this directory doesn't have a .document file, so we're looking for real
files. However we may well contain subdirectories which must be tested
for .document files. | [
"Return",
"a",
"list",
"of",
"the",
"files",
"to",
"be",
"processed",
"in",
"a",
"directory",
".",
"We",
"know",
"that",
"this",
"directory",
"doesn",
"t",
"have",
"a",
".",
"document",
"file",
"so",
"we",
"re",
"looking",
"for",
"real",
"files",
".",
"However",
"we",
"may",
"well",
"contain",
"subdirectories",
"which",
"must",
"be",
"tested",
"for",
".",
"document",
"files",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb#L182-L186 |
1,743 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb | RDoc.RDoc.parse_files | def parse_files(options)
@stats = Stats.new options.verbosity
files = options.files
files = ["."] if files.empty?
file_list = normalized_file_list(options, files, true, options.exclude)
return [] if file_list.empty?
file_info = []
file_list.each do |filename|
@stats.add_file filename
content = if RUBY_VERSION >= '1.9' then
File.open(filename, "r:ascii-8bit") { |f| f.read }
else
File.read filename
end
if defined? Encoding then
if /coding:\s*(\S+)/ =~ content[/\A(?:.*\n){0,2}/]
if enc = ::Encoding.find($1)
content.force_encoding(enc)
end
end
end
top_level = ::RDoc::TopLevel.new filename
parser = ::RDoc::Parser.for top_level, filename, content, options,
@stats
file_info << parser.scan
end
file_info
end | ruby | def parse_files(options)
@stats = Stats.new options.verbosity
files = options.files
files = ["."] if files.empty?
file_list = normalized_file_list(options, files, true, options.exclude)
return [] if file_list.empty?
file_info = []
file_list.each do |filename|
@stats.add_file filename
content = if RUBY_VERSION >= '1.9' then
File.open(filename, "r:ascii-8bit") { |f| f.read }
else
File.read filename
end
if defined? Encoding then
if /coding:\s*(\S+)/ =~ content[/\A(?:.*\n){0,2}/]
if enc = ::Encoding.find($1)
content.force_encoding(enc)
end
end
end
top_level = ::RDoc::TopLevel.new filename
parser = ::RDoc::Parser.for top_level, filename, content, options,
@stats
file_info << parser.scan
end
file_info
end | [
"def",
"parse_files",
"(",
"options",
")",
"@stats",
"=",
"Stats",
".",
"new",
"options",
".",
"verbosity",
"files",
"=",
"options",
".",
"files",
"files",
"=",
"[",
"\".\"",
"]",
"if",
"files",
".",
"empty?",
"file_list",
"=",
"normalized_file_list",
"(",
"options",
",",
"files",
",",
"true",
",",
"options",
".",
"exclude",
")",
"return",
"[",
"]",
"if",
"file_list",
".",
"empty?",
"file_info",
"=",
"[",
"]",
"file_list",
".",
"each",
"do",
"|",
"filename",
"|",
"@stats",
".",
"add_file",
"filename",
"content",
"=",
"if",
"RUBY_VERSION",
">=",
"'1.9'",
"then",
"File",
".",
"open",
"(",
"filename",
",",
"\"r:ascii-8bit\"",
")",
"{",
"|",
"f",
"|",
"f",
".",
"read",
"}",
"else",
"File",
".",
"read",
"filename",
"end",
"if",
"defined?",
"Encoding",
"then",
"if",
"/",
"\\s",
"\\S",
"/",
"=~",
"content",
"[",
"/",
"\\A",
"\\n",
"/",
"]",
"if",
"enc",
"=",
"::",
"Encoding",
".",
"find",
"(",
"$1",
")",
"content",
".",
"force_encoding",
"(",
"enc",
")",
"end",
"end",
"end",
"top_level",
"=",
"::",
"RDoc",
"::",
"TopLevel",
".",
"new",
"filename",
"parser",
"=",
"::",
"RDoc",
"::",
"Parser",
".",
"for",
"top_level",
",",
"filename",
",",
"content",
",",
"options",
",",
"@stats",
"file_info",
"<<",
"parser",
".",
"scan",
"end",
"file_info",
"end"
] | Parse each file on the command line, recursively entering directories. | [
"Parse",
"each",
"file",
"on",
"the",
"command",
"line",
"recursively",
"entering",
"directories",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb#L191-L229 |
1,744 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb | RDoc.RDoc.document | def document(argv)
TopLevel::reset
@options = Options.new GENERATORS
@options.parse argv
@last_created = nil
unless @options.all_one_file then
@last_created = setup_output_dir @options.op_dir, @options.force_update
end
start_time = Time.now
file_info = parse_files @options
@options.title = "RDoc Documentation"
if file_info.empty?
$stderr.puts "\nNo newer files." unless @options.quiet
else
@gen = @options.generator
$stderr.puts "\nGenerating #{@gen.key.upcase}..." unless @options.quiet
require @gen.file_name
gen_class = ::RDoc::Generator.const_get @gen.class_name
@gen = gen_class.for @options
pwd = Dir.pwd
Dir.chdir @options.op_dir unless @options.all_one_file
begin
Diagram.new(file_info, @options).draw if @options.diagram
@gen.generate(file_info)
update_output_dir(".", start_time)
ensure
Dir.chdir(pwd)
end
end
unless @options.quiet
puts
@stats.print
end
end | ruby | def document(argv)
TopLevel::reset
@options = Options.new GENERATORS
@options.parse argv
@last_created = nil
unless @options.all_one_file then
@last_created = setup_output_dir @options.op_dir, @options.force_update
end
start_time = Time.now
file_info = parse_files @options
@options.title = "RDoc Documentation"
if file_info.empty?
$stderr.puts "\nNo newer files." unless @options.quiet
else
@gen = @options.generator
$stderr.puts "\nGenerating #{@gen.key.upcase}..." unless @options.quiet
require @gen.file_name
gen_class = ::RDoc::Generator.const_get @gen.class_name
@gen = gen_class.for @options
pwd = Dir.pwd
Dir.chdir @options.op_dir unless @options.all_one_file
begin
Diagram.new(file_info, @options).draw if @options.diagram
@gen.generate(file_info)
update_output_dir(".", start_time)
ensure
Dir.chdir(pwd)
end
end
unless @options.quiet
puts
@stats.print
end
end | [
"def",
"document",
"(",
"argv",
")",
"TopLevel",
"::",
"reset",
"@options",
"=",
"Options",
".",
"new",
"GENERATORS",
"@options",
".",
"parse",
"argv",
"@last_created",
"=",
"nil",
"unless",
"@options",
".",
"all_one_file",
"then",
"@last_created",
"=",
"setup_output_dir",
"@options",
".",
"op_dir",
",",
"@options",
".",
"force_update",
"end",
"start_time",
"=",
"Time",
".",
"now",
"file_info",
"=",
"parse_files",
"@options",
"@options",
".",
"title",
"=",
"\"RDoc Documentation\"",
"if",
"file_info",
".",
"empty?",
"$stderr",
".",
"puts",
"\"\\nNo newer files.\"",
"unless",
"@options",
".",
"quiet",
"else",
"@gen",
"=",
"@options",
".",
"generator",
"$stderr",
".",
"puts",
"\"\\nGenerating #{@gen.key.upcase}...\"",
"unless",
"@options",
".",
"quiet",
"require",
"@gen",
".",
"file_name",
"gen_class",
"=",
"::",
"RDoc",
"::",
"Generator",
".",
"const_get",
"@gen",
".",
"class_name",
"@gen",
"=",
"gen_class",
".",
"for",
"@options",
"pwd",
"=",
"Dir",
".",
"pwd",
"Dir",
".",
"chdir",
"@options",
".",
"op_dir",
"unless",
"@options",
".",
"all_one_file",
"begin",
"Diagram",
".",
"new",
"(",
"file_info",
",",
"@options",
")",
".",
"draw",
"if",
"@options",
".",
"diagram",
"@gen",
".",
"generate",
"(",
"file_info",
")",
"update_output_dir",
"(",
"\".\"",
",",
"start_time",
")",
"ensure",
"Dir",
".",
"chdir",
"(",
"pwd",
")",
"end",
"end",
"unless",
"@options",
".",
"quiet",
"puts",
"@stats",
".",
"print",
"end",
"end"
] | Format up one or more files according to the given arguments.
For simplicity, _argv_ is an array of strings, equivalent to the strings
that would be passed on the command line. (This isn't a coincidence, as
we _do_ pass in ARGV when running interactively). For a list of options,
see rdoc/rdoc.rb. By default, output will be stored in a directory
called +doc+ below the current directory, so make sure you're somewhere
writable before invoking.
Throws: RDoc::Error on error | [
"Format",
"up",
"one",
"or",
"more",
"files",
"according",
"to",
"the",
"given",
"arguments",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/rdoc.rb#L243-L290 |
1,745 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rss/utils.rb | RSS.Utils.new_with_value_if_need | def new_with_value_if_need(klass, value)
if value.is_a?(klass)
value
else
klass.new(value)
end
end | ruby | def new_with_value_if_need(klass, value)
if value.is_a?(klass)
value
else
klass.new(value)
end
end | [
"def",
"new_with_value_if_need",
"(",
"klass",
",",
"value",
")",
"if",
"value",
".",
"is_a?",
"(",
"klass",
")",
"value",
"else",
"klass",
".",
"new",
"(",
"value",
")",
"end",
"end"
] | If +value+ is an instance of class +klass+, return it, else
create a new instance of +klass+ with value +value+. | [
"If",
"+",
"value",
"+",
"is",
"an",
"instance",
"of",
"class",
"+",
"klass",
"+",
"return",
"it",
"else",
"create",
"a",
"new",
"instance",
"of",
"+",
"klass",
"+",
"with",
"value",
"+",
"value",
"+",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rss/utils.rb#L27-L33 |
1,746 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/code_objects.rb | RDoc.Context.methods_matching | def methods_matching(methods, singleton = false)
count = 0
@method_list.each do |m|
if methods.include? m.name and m.singleton == singleton then
yield m
count += 1
end
end
return if count == methods.size || singleton
# perhaps we need to look at attributes
@attributes.each do |a|
yield a if methods.include? a.name
end
end | ruby | def methods_matching(methods, singleton = false)
count = 0
@method_list.each do |m|
if methods.include? m.name and m.singleton == singleton then
yield m
count += 1
end
end
return if count == methods.size || singleton
# perhaps we need to look at attributes
@attributes.each do |a|
yield a if methods.include? a.name
end
end | [
"def",
"methods_matching",
"(",
"methods",
",",
"singleton",
"=",
"false",
")",
"count",
"=",
"0",
"@method_list",
".",
"each",
"do",
"|",
"m",
"|",
"if",
"methods",
".",
"include?",
"m",
".",
"name",
"and",
"m",
".",
"singleton",
"==",
"singleton",
"then",
"yield",
"m",
"count",
"+=",
"1",
"end",
"end",
"return",
"if",
"count",
"==",
"methods",
".",
"size",
"||",
"singleton",
"# perhaps we need to look at attributes",
"@attributes",
".",
"each",
"do",
"|",
"a",
"|",
"yield",
"a",
"if",
"methods",
".",
"include?",
"a",
".",
"name",
"end",
"end"
] | Yields Method and Attr entries matching the list of names in +methods+.
Attributes are only returned when +singleton+ is false. | [
"Yields",
"Method",
"and",
"Attr",
"entries",
"matching",
"the",
"list",
"of",
"names",
"in",
"+",
"methods",
"+",
".",
"Attributes",
"are",
"only",
"returned",
"when",
"+",
"singleton",
"+",
"is",
"false",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/code_objects.rb#L249-L266 |
1,747 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/code_objects.rb | RDoc.Context.find_module_named | def find_module_named(name)
# First check the enclosed modules, then check the module itself,
# then check the enclosing modules (this mirrors the check done by
# the Ruby parser)
res = @modules[name] || @classes[name]
return res if res
return self if self.name == name
find_enclosing_module_named(name)
end | ruby | def find_module_named(name)
# First check the enclosed modules, then check the module itself,
# then check the enclosing modules (this mirrors the check done by
# the Ruby parser)
res = @modules[name] || @classes[name]
return res if res
return self if self.name == name
find_enclosing_module_named(name)
end | [
"def",
"find_module_named",
"(",
"name",
")",
"# First check the enclosed modules, then check the module itself,",
"# then check the enclosing modules (this mirrors the check done by",
"# the Ruby parser)",
"res",
"=",
"@modules",
"[",
"name",
"]",
"||",
"@classes",
"[",
"name",
"]",
"return",
"res",
"if",
"res",
"return",
"self",
"if",
"self",
".",
"name",
"==",
"name",
"find_enclosing_module_named",
"(",
"name",
")",
"end"
] | Find a named module | [
"Find",
"a",
"named",
"module"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/code_objects.rb#L429-L437 |
1,748 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/code_objects.rb | RDoc.TopLevel.add_class_or_module | def add_class_or_module(collection, class_type, name, superclass)
cls = collection[name]
if cls then
cls.superclass = superclass unless cls.module?
puts "Reusing class/module #{cls.full_name}" if $DEBUG_RDOC
else
if class_type == NormalModule then
all = @@all_modules
else
all = @@all_classes
end
cls = all[name]
if !cls then
cls = class_type.new name, superclass
all[name] = cls unless @done_documenting
else
# If the class has been encountered already, check that its
# superclass has been set (it may not have been, depending on
# the context in which it was encountered).
if class_type == NormalClass
if !cls.superclass then
cls.superclass = superclass
end
end
end
collection[name] = cls unless @done_documenting
cls.parent = self
end
cls
end | ruby | def add_class_or_module(collection, class_type, name, superclass)
cls = collection[name]
if cls then
cls.superclass = superclass unless cls.module?
puts "Reusing class/module #{cls.full_name}" if $DEBUG_RDOC
else
if class_type == NormalModule then
all = @@all_modules
else
all = @@all_classes
end
cls = all[name]
if !cls then
cls = class_type.new name, superclass
all[name] = cls unless @done_documenting
else
# If the class has been encountered already, check that its
# superclass has been set (it may not have been, depending on
# the context in which it was encountered).
if class_type == NormalClass
if !cls.superclass then
cls.superclass = superclass
end
end
end
collection[name] = cls unless @done_documenting
cls.parent = self
end
cls
end | [
"def",
"add_class_or_module",
"(",
"collection",
",",
"class_type",
",",
"name",
",",
"superclass",
")",
"cls",
"=",
"collection",
"[",
"name",
"]",
"if",
"cls",
"then",
"cls",
".",
"superclass",
"=",
"superclass",
"unless",
"cls",
".",
"module?",
"puts",
"\"Reusing class/module #{cls.full_name}\"",
"if",
"$DEBUG_RDOC",
"else",
"if",
"class_type",
"==",
"NormalModule",
"then",
"all",
"=",
"@@all_modules",
"else",
"all",
"=",
"@@all_classes",
"end",
"cls",
"=",
"all",
"[",
"name",
"]",
"if",
"!",
"cls",
"then",
"cls",
"=",
"class_type",
".",
"new",
"name",
",",
"superclass",
"all",
"[",
"name",
"]",
"=",
"cls",
"unless",
"@done_documenting",
"else",
"# If the class has been encountered already, check that its",
"# superclass has been set (it may not have been, depending on",
"# the context in which it was encountered).",
"if",
"class_type",
"==",
"NormalClass",
"if",
"!",
"cls",
".",
"superclass",
"then",
"cls",
".",
"superclass",
"=",
"superclass",
"end",
"end",
"end",
"collection",
"[",
"name",
"]",
"=",
"cls",
"unless",
"@done_documenting",
"cls",
".",
"parent",
"=",
"self",
"end",
"cls",
"end"
] | Adding a class or module to a TopLevel is special, as we only want one
copy of a particular top-level class. For example, if both file A and
file B implement class C, we only want one ClassModule object for C.
This code arranges to share classes and modules between files. | [
"Adding",
"a",
"class",
"or",
"module",
"to",
"a",
"TopLevel",
"is",
"special",
"as",
"we",
"only",
"want",
"one",
"copy",
"of",
"a",
"particular",
"top",
"-",
"level",
"class",
".",
"For",
"example",
"if",
"both",
"file",
"A",
"and",
"file",
"B",
"implement",
"class",
"C",
"we",
"only",
"want",
"one",
"ClassModule",
"object",
"for",
"C",
".",
"This",
"code",
"arranges",
"to",
"share",
"classes",
"and",
"modules",
"between",
"files",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/code_objects.rb#L618-L653 |
1,749 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/code_objects.rb | RDoc.ClassModule.superclass | def superclass
raise NoMethodError, "#{full_name} is a module" if module?
scope = self
begin
superclass = scope.classes.find { |c| c.name == @superclass }
return superclass.full_name if superclass
scope = scope.parent
end until scope.nil? or TopLevel === scope
@superclass
end | ruby | def superclass
raise NoMethodError, "#{full_name} is a module" if module?
scope = self
begin
superclass = scope.classes.find { |c| c.name == @superclass }
return superclass.full_name if superclass
scope = scope.parent
end until scope.nil? or TopLevel === scope
@superclass
end | [
"def",
"superclass",
"raise",
"NoMethodError",
",",
"\"#{full_name} is a module\"",
"if",
"module?",
"scope",
"=",
"self",
"begin",
"superclass",
"=",
"scope",
".",
"classes",
".",
"find",
"{",
"|",
"c",
"|",
"c",
".",
"name",
"==",
"@superclass",
"}",
"return",
"superclass",
".",
"full_name",
"if",
"superclass",
"scope",
"=",
"scope",
".",
"parent",
"end",
"until",
"scope",
".",
"nil?",
"or",
"TopLevel",
"===",
"scope",
"@superclass",
"end"
] | Get the superclass of this class. Attempts to retrieve the superclass'
real name by following module nesting. | [
"Get",
"the",
"superclass",
"of",
"this",
"class",
".",
"Attempts",
"to",
"retrieve",
"the",
"superclass",
"real",
"name",
"by",
"following",
"module",
"nesting",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/code_objects.rb#L748-L761 |
1,750 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/response.rb | Rack.Response.write | def write(str)
s = str.to_s
@length += Rack::Utils.bytesize(s)
@writer.call s
header["Content-Length"] = @length.to_s
str
end | ruby | def write(str)
s = str.to_s
@length += Rack::Utils.bytesize(s)
@writer.call s
header["Content-Length"] = @length.to_s
str
end | [
"def",
"write",
"(",
"str",
")",
"s",
"=",
"str",
".",
"to_s",
"@length",
"+=",
"Rack",
"::",
"Utils",
".",
"bytesize",
"(",
"s",
")",
"@writer",
".",
"call",
"s",
"header",
"[",
"\"Content-Length\"",
"]",
"=",
"@length",
".",
"to_s",
"str",
"end"
] | Append to body and update Content-Length.
NOTE: Do not mix #write and direct #body access! | [
"Append",
"to",
"body",
"and",
"update",
"Content",
"-",
"Length",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/response.rb#L125-L132 |
1,751 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rexml/attribute.rb | REXML.Attribute.to_s | def to_s
return @normalized if @normalized
doctype = nil
if @element
doc = @element.document
doctype = doc.doctype if doc
end
@normalized = Text::normalize( @unnormalized, doctype )
@unnormalized = nil
@normalized
end | ruby | def to_s
return @normalized if @normalized
doctype = nil
if @element
doc = @element.document
doctype = doc.doctype if doc
end
@normalized = Text::normalize( @unnormalized, doctype )
@unnormalized = nil
@normalized
end | [
"def",
"to_s",
"return",
"@normalized",
"if",
"@normalized",
"doctype",
"=",
"nil",
"if",
"@element",
"doc",
"=",
"@element",
".",
"document",
"doctype",
"=",
"doc",
".",
"doctype",
"if",
"doc",
"end",
"@normalized",
"=",
"Text",
"::",
"normalize",
"(",
"@unnormalized",
",",
"doctype",
")",
"@unnormalized",
"=",
"nil",
"@normalized",
"end"
] | Returns the attribute value, with entities replaced | [
"Returns",
"the",
"attribute",
"value",
"with",
"entities",
"replaced"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rexml/attribute.rb#L114-L126 |
1,752 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rexml/attribute.rb | REXML.Attribute.value | def value
return @unnormalized if @unnormalized
doctype = nil
if @element
doc = @element.document
doctype = doc.doctype if doc
end
@unnormalized = Text::unnormalize( @normalized, doctype )
@normalized = nil
@unnormalized
end | ruby | def value
return @unnormalized if @unnormalized
doctype = nil
if @element
doc = @element.document
doctype = doc.doctype if doc
end
@unnormalized = Text::unnormalize( @normalized, doctype )
@normalized = nil
@unnormalized
end | [
"def",
"value",
"return",
"@unnormalized",
"if",
"@unnormalized",
"doctype",
"=",
"nil",
"if",
"@element",
"doc",
"=",
"@element",
".",
"document",
"doctype",
"=",
"doc",
".",
"doctype",
"if",
"doc",
"end",
"@unnormalized",
"=",
"Text",
"::",
"unnormalize",
"(",
"@normalized",
",",
"doctype",
")",
"@normalized",
"=",
"nil",
"@unnormalized",
"end"
] | Returns the UNNORMALIZED value of this attribute. That is, entities
have been expanded to their values | [
"Returns",
"the",
"UNNORMALIZED",
"value",
"of",
"this",
"attribute",
".",
"That",
"is",
"entities",
"have",
"been",
"expanded",
"to",
"their",
"values"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rexml/attribute.rb#L130-L140 |
1,753 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb | Rake.TaskManager.resolve_args_with_dependencies | def resolve_args_with_dependencies(args, hash) # :nodoc:
fail "Task Argument Error" if hash.size != 1
key, value = hash.map { |k, v| [k,v] }.first
if args.empty?
task_name = key
arg_names = []
deps = value
elsif key == :needs
task_name = args.shift
arg_names = args
deps = value
else
task_name = args.shift
arg_names = key
deps = value
end
deps = [deps] unless deps.respond_to?(:to_ary)
[task_name, arg_names, deps]
end | ruby | def resolve_args_with_dependencies(args, hash) # :nodoc:
fail "Task Argument Error" if hash.size != 1
key, value = hash.map { |k, v| [k,v] }.first
if args.empty?
task_name = key
arg_names = []
deps = value
elsif key == :needs
task_name = args.shift
arg_names = args
deps = value
else
task_name = args.shift
arg_names = key
deps = value
end
deps = [deps] unless deps.respond_to?(:to_ary)
[task_name, arg_names, deps]
end | [
"def",
"resolve_args_with_dependencies",
"(",
"args",
",",
"hash",
")",
"# :nodoc:",
"fail",
"\"Task Argument Error\"",
"if",
"hash",
".",
"size",
"!=",
"1",
"key",
",",
"value",
"=",
"hash",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"[",
"k",
",",
"v",
"]",
"}",
".",
"first",
"if",
"args",
".",
"empty?",
"task_name",
"=",
"key",
"arg_names",
"=",
"[",
"]",
"deps",
"=",
"value",
"elsif",
"key",
"==",
":needs",
"task_name",
"=",
"args",
".",
"shift",
"arg_names",
"=",
"args",
"deps",
"=",
"value",
"else",
"task_name",
"=",
"args",
".",
"shift",
"arg_names",
"=",
"key",
"deps",
"=",
"value",
"end",
"deps",
"=",
"[",
"deps",
"]",
"unless",
"deps",
".",
"respond_to?",
"(",
":to_ary",
")",
"[",
"task_name",
",",
"arg_names",
",",
"deps",
"]",
"end"
] | Resolve task arguments for a task or rule when there are
dependencies declared.
The patterns recognized by this argument resolving function are:
task :t => [:d]
task :t, [a] => [:d]
task :t, :needs => [:d] (deprecated)
task :t, :a, :needs => [:d] (deprecated) | [
"Resolve",
"task",
"arguments",
"for",
"a",
"task",
"or",
"rule",
"when",
"there",
"are",
"dependencies",
"declared",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb#L1777-L1795 |
1,754 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb | Rake.Application.top_level | def top_level
standard_exception_handling do
if options.show_tasks
display_tasks_and_comments
elsif options.show_prereqs
display_prerequisites
else
top_level_tasks.each { |task_name| invoke_task(task_name) }
end
end
end | ruby | def top_level
standard_exception_handling do
if options.show_tasks
display_tasks_and_comments
elsif options.show_prereqs
display_prerequisites
else
top_level_tasks.each { |task_name| invoke_task(task_name) }
end
end
end | [
"def",
"top_level",
"standard_exception_handling",
"do",
"if",
"options",
".",
"show_tasks",
"display_tasks_and_comments",
"elsif",
"options",
".",
"show_prereqs",
"display_prerequisites",
"else",
"top_level_tasks",
".",
"each",
"{",
"|",
"task_name",
"|",
"invoke_task",
"(",
"task_name",
")",
"}",
"end",
"end",
"end"
] | Run the top level tasks of a Rake application. | [
"Run",
"the",
"top",
"level",
"tasks",
"of",
"a",
"Rake",
"application",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb#L2022-L2032 |
1,755 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/ri_generator.rb | Generators.RIGenerator.method_list | def method_list(cls)
list = cls.method_list
unless @options.show_all
list = list.find_all do |m|
m.visibility == :public || m.visibility == :protected || m.force_documentation
end
end
c = []
i = []
list.sort.each do |m|
if m.singleton
c << m
else
i << m
end
end
return c,i
end | ruby | def method_list(cls)
list = cls.method_list
unless @options.show_all
list = list.find_all do |m|
m.visibility == :public || m.visibility == :protected || m.force_documentation
end
end
c = []
i = []
list.sort.each do |m|
if m.singleton
c << m
else
i << m
end
end
return c,i
end | [
"def",
"method_list",
"(",
"cls",
")",
"list",
"=",
"cls",
".",
"method_list",
"unless",
"@options",
".",
"show_all",
"list",
"=",
"list",
".",
"find_all",
"do",
"|",
"m",
"|",
"m",
".",
"visibility",
"==",
":public",
"||",
"m",
".",
"visibility",
"==",
":protected",
"||",
"m",
".",
"force_documentation",
"end",
"end",
"c",
"=",
"[",
"]",
"i",
"=",
"[",
"]",
"list",
".",
"sort",
".",
"each",
"do",
"|",
"m",
"|",
"if",
"m",
".",
"singleton",
"c",
"<<",
"m",
"else",
"i",
"<<",
"m",
"end",
"end",
"return",
"c",
",",
"i",
"end"
] | return a list of class and instance methods that we'll be
documenting | [
"return",
"a",
"list",
"of",
"class",
"and",
"instance",
"methods",
"that",
"we",
"ll",
"be",
"documenting"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/ri_generator.rb#L171-L189 |
1,756 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rcov-0.9.8-java/lib/rcov/differential_analyzer.rb | Rcov.DifferentialAnalyzer.reset | def reset
@@mutex.synchronize do
if self.class.hook_level == 0
# Unfortunately there's no way to report this as covered with rcov:
# if we run the tests under rcov self.class.hook_level will be >= 1 !
# It is however executed when we run the tests normally.
Rcov::RCOV__.send(@reset_meth)
@start_raw_data = data_default
@end_raw_data = data_default
else
@start_raw_data = @end_raw_data = raw_data_absolute
end
@raw_data_relative = data_default
@aggregated_data = data_default
end
end | ruby | def reset
@@mutex.synchronize do
if self.class.hook_level == 0
# Unfortunately there's no way to report this as covered with rcov:
# if we run the tests under rcov self.class.hook_level will be >= 1 !
# It is however executed when we run the tests normally.
Rcov::RCOV__.send(@reset_meth)
@start_raw_data = data_default
@end_raw_data = data_default
else
@start_raw_data = @end_raw_data = raw_data_absolute
end
@raw_data_relative = data_default
@aggregated_data = data_default
end
end | [
"def",
"reset",
"@@mutex",
".",
"synchronize",
"do",
"if",
"self",
".",
"class",
".",
"hook_level",
"==",
"0",
"# Unfortunately there's no way to report this as covered with rcov:",
"# if we run the tests under rcov self.class.hook_level will be >= 1 !",
"# It is however executed when we run the tests normally.",
"Rcov",
"::",
"RCOV__",
".",
"send",
"(",
"@reset_meth",
")",
"@start_raw_data",
"=",
"data_default",
"@end_raw_data",
"=",
"data_default",
"else",
"@start_raw_data",
"=",
"@end_raw_data",
"=",
"raw_data_absolute",
"end",
"@raw_data_relative",
"=",
"data_default",
"@aggregated_data",
"=",
"data_default",
"end",
"end"
] | Remove the data collected so far. Further collection will start from
scratch. | [
"Remove",
"the",
"data",
"collected",
"so",
"far",
".",
"Further",
"collection",
"will",
"start",
"from",
"scratch",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/rcov-0.9.8-java/lib/rcov/differential_analyzer.rb#L57-L72 |
1,757 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/net/ftp.rb | Net.FTP.putbinaryfile | def putbinaryfile(localfile, remotefile = File.basename(localfile),
blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
if @resume
begin
rest_offset = size(remotefile)
rescue Net::FTPPermError
rest_offset = nil
end
else
rest_offset = nil
end
f = open(localfile)
begin
f.binmode
storbinary("STOR " + remotefile, f, blocksize, rest_offset, &block)
ensure
f.close
end
end | ruby | def putbinaryfile(localfile, remotefile = File.basename(localfile),
blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
if @resume
begin
rest_offset = size(remotefile)
rescue Net::FTPPermError
rest_offset = nil
end
else
rest_offset = nil
end
f = open(localfile)
begin
f.binmode
storbinary("STOR " + remotefile, f, blocksize, rest_offset, &block)
ensure
f.close
end
end | [
"def",
"putbinaryfile",
"(",
"localfile",
",",
"remotefile",
"=",
"File",
".",
"basename",
"(",
"localfile",
")",
",",
"blocksize",
"=",
"DEFAULT_BLOCKSIZE",
",",
"&",
"block",
")",
"# :yield: data",
"if",
"@resume",
"begin",
"rest_offset",
"=",
"size",
"(",
"remotefile",
")",
"rescue",
"Net",
"::",
"FTPPermError",
"rest_offset",
"=",
"nil",
"end",
"else",
"rest_offset",
"=",
"nil",
"end",
"f",
"=",
"open",
"(",
"localfile",
")",
"begin",
"f",
".",
"binmode",
"storbinary",
"(",
"\"STOR \"",
"+",
"remotefile",
",",
"f",
",",
"blocksize",
",",
"rest_offset",
",",
"block",
")",
"ensure",
"f",
".",
"close",
"end",
"end"
] | Transfers +localfile+ to the server in binary mode, storing the result in
+remotefile+. If a block is supplied, calls it, passing in the transmitted
data in +blocksize+ chunks. | [
"Transfers",
"+",
"localfile",
"+",
"to",
"the",
"server",
"in",
"binary",
"mode",
"storing",
"the",
"result",
"in",
"+",
"remotefile",
"+",
".",
"If",
"a",
"block",
"is",
"supplied",
"calls",
"it",
"passing",
"in",
"the",
"transmitted",
"data",
"in",
"+",
"blocksize",
"+",
"chunks",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/net/ftp.rb#L602-L620 |
1,758 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_cache.rb | RI.ClassEntry.load_from | def load_from(dir)
Dir.foreach(dir) do |name|
next if name =~ /^\./
# convert from external to internal form, and
# extract the instance/class flag
if name =~ /^(.*?)-(c|i).yaml$/
external_name = $1
is_class_method = $2 == "c"
internal_name = RiWriter.external_to_internal(external_name)
list = is_class_method ? @class_methods : @instance_methods
path = File.join(dir, name)
list << MethodEntry.new(path, internal_name, is_class_method, self)
else
full_name = File.join(dir, name)
if File.directory?(full_name)
inf_class = @inferior_classes.find {|c| c.name == name }
if inf_class
inf_class.add_path(full_name)
else
inf_class = ClassEntry.new(full_name, name, self)
@inferior_classes << inf_class
end
inf_class.load_from(full_name)
end
end
end
end | ruby | def load_from(dir)
Dir.foreach(dir) do |name|
next if name =~ /^\./
# convert from external to internal form, and
# extract the instance/class flag
if name =~ /^(.*?)-(c|i).yaml$/
external_name = $1
is_class_method = $2 == "c"
internal_name = RiWriter.external_to_internal(external_name)
list = is_class_method ? @class_methods : @instance_methods
path = File.join(dir, name)
list << MethodEntry.new(path, internal_name, is_class_method, self)
else
full_name = File.join(dir, name)
if File.directory?(full_name)
inf_class = @inferior_classes.find {|c| c.name == name }
if inf_class
inf_class.add_path(full_name)
else
inf_class = ClassEntry.new(full_name, name, self)
@inferior_classes << inf_class
end
inf_class.load_from(full_name)
end
end
end
end | [
"def",
"load_from",
"(",
"dir",
")",
"Dir",
".",
"foreach",
"(",
"dir",
")",
"do",
"|",
"name",
"|",
"next",
"if",
"name",
"=~",
"/",
"\\.",
"/",
"# convert from external to internal form, and",
"# extract the instance/class flag",
"if",
"name",
"=~",
"/",
"/",
"external_name",
"=",
"$1",
"is_class_method",
"=",
"$2",
"==",
"\"c\"",
"internal_name",
"=",
"RiWriter",
".",
"external_to_internal",
"(",
"external_name",
")",
"list",
"=",
"is_class_method",
"?",
"@class_methods",
":",
"@instance_methods",
"path",
"=",
"File",
".",
"join",
"(",
"dir",
",",
"name",
")",
"list",
"<<",
"MethodEntry",
".",
"new",
"(",
"path",
",",
"internal_name",
",",
"is_class_method",
",",
"self",
")",
"else",
"full_name",
"=",
"File",
".",
"join",
"(",
"dir",
",",
"name",
")",
"if",
"File",
".",
"directory?",
"(",
"full_name",
")",
"inf_class",
"=",
"@inferior_classes",
".",
"find",
"{",
"|",
"c",
"|",
"c",
".",
"name",
"==",
"name",
"}",
"if",
"inf_class",
"inf_class",
".",
"add_path",
"(",
"full_name",
")",
"else",
"inf_class",
"=",
"ClassEntry",
".",
"new",
"(",
"full_name",
",",
"name",
",",
"self",
")",
"@inferior_classes",
"<<",
"inf_class",
"end",
"inf_class",
".",
"load_from",
"(",
"full_name",
")",
"end",
"end",
"end",
"end"
] | read in our methods and any classes
and modules in our namespace. Methods are
stored in files called name-c|i.yaml,
where the 'name' portion is the external
form of the method name and the c|i is a class|instance
flag | [
"read",
"in",
"our",
"methods",
"and",
"any",
"classes",
"and",
"modules",
"in",
"our",
"namespace",
".",
"Methods",
"are",
"stored",
"in",
"files",
"called",
"name",
"-",
"c|i",
".",
"yaml",
"where",
"the",
"name",
"portion",
"is",
"the",
"external",
"form",
"of",
"the",
"method",
"name",
"and",
"the",
"c|i",
"is",
"a",
"class|instance",
"flag"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_cache.rb#L30-L58 |
1,759 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_cache.rb | RI.ClassEntry.recursively_find_methods_matching | def recursively_find_methods_matching(name, is_class_method)
res = local_methods_matching(name, is_class_method)
@inferior_classes.each do |c|
res.concat(c.recursively_find_methods_matching(name, is_class_method))
end
res
end | ruby | def recursively_find_methods_matching(name, is_class_method)
res = local_methods_matching(name, is_class_method)
@inferior_classes.each do |c|
res.concat(c.recursively_find_methods_matching(name, is_class_method))
end
res
end | [
"def",
"recursively_find_methods_matching",
"(",
"name",
",",
"is_class_method",
")",
"res",
"=",
"local_methods_matching",
"(",
"name",
",",
"is_class_method",
")",
"@inferior_classes",
".",
"each",
"do",
"|",
"c",
"|",
"res",
".",
"concat",
"(",
"c",
".",
"recursively_find_methods_matching",
"(",
"name",
",",
"is_class_method",
")",
")",
"end",
"res",
"end"
] | Find methods matching 'name' in ourselves and in
any classes we contain | [
"Find",
"methods",
"matching",
"name",
"in",
"ourselves",
"and",
"in",
"any",
"classes",
"we",
"contain"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_cache.rb#L85-L91 |
1,760 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_cache.rb | RI.ClassEntry.all_method_names | def all_method_names
res = @class_methods.map {|m| m.full_name }
@instance_methods.each {|m| res << m.full_name}
res
end | ruby | def all_method_names
res = @class_methods.map {|m| m.full_name }
@instance_methods.each {|m| res << m.full_name}
res
end | [
"def",
"all_method_names",
"res",
"=",
"@class_methods",
".",
"map",
"{",
"|",
"m",
"|",
"m",
".",
"full_name",
"}",
"@instance_methods",
".",
"each",
"{",
"|",
"m",
"|",
"res",
"<<",
"m",
".",
"full_name",
"}",
"res",
"end"
] | Return a list of all out method names | [
"Return",
"a",
"list",
"of",
"all",
"out",
"method",
"names"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_cache.rb#L102-L106 |
1,761 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_cache.rb | RI.ClassEntry.local_methods_matching | def local_methods_matching(name, is_class_method)
list = case is_class_method
when nil then @class_methods + @instance_methods
when true then @class_methods
when false then @instance_methods
else fail "Unknown is_class_method: #{is_class_method.inspect}"
end
list.find_all {|m| m.name; m.name[name]}
end | ruby | def local_methods_matching(name, is_class_method)
list = case is_class_method
when nil then @class_methods + @instance_methods
when true then @class_methods
when false then @instance_methods
else fail "Unknown is_class_method: #{is_class_method.inspect}"
end
list.find_all {|m| m.name; m.name[name]}
end | [
"def",
"local_methods_matching",
"(",
"name",
",",
"is_class_method",
")",
"list",
"=",
"case",
"is_class_method",
"when",
"nil",
"then",
"@class_methods",
"+",
"@instance_methods",
"when",
"true",
"then",
"@class_methods",
"when",
"false",
"then",
"@instance_methods",
"else",
"fail",
"\"Unknown is_class_method: #{is_class_method.inspect}\"",
"end",
"list",
".",
"find_all",
"{",
"|",
"m",
"|",
"m",
".",
"name",
";",
"m",
".",
"name",
"[",
"name",
"]",
"}",
"end"
] | Return a list of all our methods matching a given string.
Is +is_class_methods+ if 'nil', we don't care if the method
is a class method or not, otherwise we only return
those methods that match | [
"Return",
"a",
"list",
"of",
"all",
"our",
"methods",
"matching",
"a",
"given",
"string",
".",
"Is",
"+",
"is_class_methods",
"+",
"if",
"nil",
"we",
"don",
"t",
"care",
"if",
"the",
"method",
"is",
"a",
"class",
"method",
"or",
"not",
"otherwise",
"we",
"only",
"return",
"those",
"methods",
"that",
"match"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_cache.rb#L114-L124 |
1,762 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb | RDoc::Generator.MarkUp.markup | def markup(str, remove_para = false)
return '' unless str
# Convert leading comment markers to spaces, but only if all non-blank
# lines have them
if str =~ /^(?>\s*)[^\#]/ then
content = str
else
content = str.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }
end
res = formatter.convert content
if remove_para then
res.sub!(/^<p>/, '')
res.sub!(/<\/p>$/, '')
end
res
end | ruby | def markup(str, remove_para = false)
return '' unless str
# Convert leading comment markers to spaces, but only if all non-blank
# lines have them
if str =~ /^(?>\s*)[^\#]/ then
content = str
else
content = str.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }
end
res = formatter.convert content
if remove_para then
res.sub!(/^<p>/, '')
res.sub!(/<\/p>$/, '')
end
res
end | [
"def",
"markup",
"(",
"str",
",",
"remove_para",
"=",
"false",
")",
"return",
"''",
"unless",
"str",
"# Convert leading comment markers to spaces, but only if all non-blank",
"# lines have them",
"if",
"str",
"=~",
"/",
"\\s",
"\\#",
"/",
"then",
"content",
"=",
"str",
"else",
"content",
"=",
"str",
".",
"gsub",
"(",
"/",
"\\s",
"/",
")",
"{",
"$1",
".",
"tr",
"'#'",
",",
"' '",
"}",
"end",
"res",
"=",
"formatter",
".",
"convert",
"content",
"if",
"remove_para",
"then",
"res",
".",
"sub!",
"(",
"/",
"/",
",",
"''",
")",
"res",
".",
"sub!",
"(",
"/",
"\\/",
"/",
",",
"''",
")",
"end",
"res",
"end"
] | Convert a string in markup format into HTML. | [
"Convert",
"a",
"string",
"in",
"markup",
"format",
"into",
"HTML",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb#L59-L78 |
1,763 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb | RDoc::Generator.Context.as_href | def as_href(from_path)
if @options.all_one_file
"#" + path
else
RDoc::Markup::ToHtml.gen_relative_url from_path, path
end
end | ruby | def as_href(from_path)
if @options.all_one_file
"#" + path
else
RDoc::Markup::ToHtml.gen_relative_url from_path, path
end
end | [
"def",
"as_href",
"(",
"from_path",
")",
"if",
"@options",
".",
"all_one_file",
"\"#\"",
"+",
"path",
"else",
"RDoc",
"::",
"Markup",
"::",
"ToHtml",
".",
"gen_relative_url",
"from_path",
",",
"path",
"end",
"end"
] | Returns a reference to outselves to be used as an href= the form depends
on whether we're all in one file or in multiple files | [
"Returns",
"a",
"reference",
"to",
"outselves",
"to",
"be",
"used",
"as",
"an",
"href",
"=",
"the",
"form",
"depends",
"on",
"whether",
"we",
"re",
"all",
"in",
"one",
"file",
"or",
"in",
"multiple",
"files"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb#L179-L185 |
1,764 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb | RDoc::Generator.Context.collect_methods | def collect_methods
list = @context.method_list
unless @options.show_all then
list = list.select do |m|
m.visibility == :public or
m.visibility == :protected or
m.force_documentation
end
end
@methods = list.collect do |m|
RDoc::Generator::Method.new m, self, @options
end
end | ruby | def collect_methods
list = @context.method_list
unless @options.show_all then
list = list.select do |m|
m.visibility == :public or
m.visibility == :protected or
m.force_documentation
end
end
@methods = list.collect do |m|
RDoc::Generator::Method.new m, self, @options
end
end | [
"def",
"collect_methods",
"list",
"=",
"@context",
".",
"method_list",
"unless",
"@options",
".",
"show_all",
"then",
"list",
"=",
"list",
".",
"select",
"do",
"|",
"m",
"|",
"m",
".",
"visibility",
"==",
":public",
"or",
"m",
".",
"visibility",
"==",
":protected",
"or",
"m",
".",
"force_documentation",
"end",
"end",
"@methods",
"=",
"list",
".",
"collect",
"do",
"|",
"m",
"|",
"RDoc",
"::",
"Generator",
"::",
"Method",
".",
"new",
"m",
",",
"self",
",",
"@options",
"end",
"end"
] | Create a list of Method objects for each method in the corresponding
context object. If the @options.show_all variable is set (corresponding
to the <tt>--all</tt> option, we include all methods, otherwise just the
public ones. | [
"Create",
"a",
"list",
"of",
"Method",
"objects",
"for",
"each",
"method",
"in",
"the",
"corresponding",
"context",
"object",
".",
"If",
"the"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb#L193-L207 |
1,765 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb | RDoc::Generator.Context.add_table_of_sections | def add_table_of_sections
toc = []
@context.sections.each do |section|
if section.title then
toc << {
'secname' => section.title,
'href' => section.sequence
}
end
end
@values['toc'] = toc unless toc.empty?
end | ruby | def add_table_of_sections
toc = []
@context.sections.each do |section|
if section.title then
toc << {
'secname' => section.title,
'href' => section.sequence
}
end
end
@values['toc'] = toc unless toc.empty?
end | [
"def",
"add_table_of_sections",
"toc",
"=",
"[",
"]",
"@context",
".",
"sections",
".",
"each",
"do",
"|",
"section",
"|",
"if",
"section",
".",
"title",
"then",
"toc",
"<<",
"{",
"'secname'",
"=>",
"section",
".",
"title",
",",
"'href'",
"=>",
"section",
".",
"sequence",
"}",
"end",
"end",
"@values",
"[",
"'toc'",
"]",
"=",
"toc",
"unless",
"toc",
".",
"empty?",
"end"
] | create table of contents if we contain sections | [
"create",
"table",
"of",
"contents",
"if",
"we",
"contain",
"sections"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb#L462-L474 |
1,766 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb | RDoc::Generator.Class.http_url | def http_url(full_name, prefix)
path = full_name.dup
path.gsub!(/<<\s*(\w*)/, 'from-\1') if path['<<']
::File.join(prefix, path.split("::")) + ".html"
end | ruby | def http_url(full_name, prefix)
path = full_name.dup
path.gsub!(/<<\s*(\w*)/, 'from-\1') if path['<<']
::File.join(prefix, path.split("::")) + ".html"
end | [
"def",
"http_url",
"(",
"full_name",
",",
"prefix",
")",
"path",
"=",
"full_name",
".",
"dup",
"path",
".",
"gsub!",
"(",
"/",
"\\s",
"\\w",
"/",
",",
"'from-\\1'",
")",
"if",
"path",
"[",
"'<<'",
"]",
"::",
"File",
".",
"join",
"(",
"prefix",
",",
"path",
".",
"split",
"(",
"\"::\"",
")",
")",
"+",
"\".html\"",
"end"
] | Returns the relative file name to store this class in, which is also its
url | [
"Returns",
"the",
"relative",
"file",
"name",
"to",
"store",
"this",
"class",
"in",
"which",
"is",
"also",
"its",
"url"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/rdoc/generator.rb#L512-L518 |
1,767 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/const_generator.rb | FFI.ConstGenerator.to_ruby | def to_ruby
@constants.sort_by { |name,| name }.map do |name, constant|
if constant.value.nil? then
"# #{name} not available"
else
constant.to_ruby
end
end.join "\n"
end | ruby | def to_ruby
@constants.sort_by { |name,| name }.map do |name, constant|
if constant.value.nil? then
"# #{name} not available"
else
constant.to_ruby
end
end.join "\n"
end | [
"def",
"to_ruby",
"@constants",
".",
"sort_by",
"{",
"|",
"name",
",",
"|",
"name",
"}",
".",
"map",
"do",
"|",
"name",
",",
"constant",
"|",
"if",
"constant",
".",
"value",
".",
"nil?",
"then",
"\"# #{name} not available\"",
"else",
"constant",
".",
"to_ruby",
"end",
"end",
".",
"join",
"\"\\n\"",
"end"
] | Outputs values for discovered constants. If the constant's value was
not discovered it is not omitted. | [
"Outputs",
"values",
"for",
"discovered",
"constants",
".",
"If",
"the",
"constant",
"s",
"value",
"was",
"not",
"discovered",
"it",
"is",
"not",
"omitted",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/tools/const_generator.rb#L130-L138 |
1,768 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_descriptions.rb | RI.ModuleDescription.merge_in | def merge_in(old)
merge(@class_methods, old.class_methods)
merge(@instance_methods, old.instance_methods)
merge(@attributes, old.attributes)
merge(@constants, old.constants)
merge(@includes, old.includes)
if @comment.nil? || @comment.empty?
@comment = old.comment
else
unless old.comment.nil? or old.comment.empty? then
@comment << SM::Flow::RULE.new
@comment.concat old.comment
end
end
end | ruby | def merge_in(old)
merge(@class_methods, old.class_methods)
merge(@instance_methods, old.instance_methods)
merge(@attributes, old.attributes)
merge(@constants, old.constants)
merge(@includes, old.includes)
if @comment.nil? || @comment.empty?
@comment = old.comment
else
unless old.comment.nil? or old.comment.empty? then
@comment << SM::Flow::RULE.new
@comment.concat old.comment
end
end
end | [
"def",
"merge_in",
"(",
"old",
")",
"merge",
"(",
"@class_methods",
",",
"old",
".",
"class_methods",
")",
"merge",
"(",
"@instance_methods",
",",
"old",
".",
"instance_methods",
")",
"merge",
"(",
"@attributes",
",",
"old",
".",
"attributes",
")",
"merge",
"(",
"@constants",
",",
"old",
".",
"constants",
")",
"merge",
"(",
"@includes",
",",
"old",
".",
"includes",
")",
"if",
"@comment",
".",
"nil?",
"||",
"@comment",
".",
"empty?",
"@comment",
"=",
"old",
".",
"comment",
"else",
"unless",
"old",
".",
"comment",
".",
"nil?",
"or",
"old",
".",
"comment",
".",
"empty?",
"then",
"@comment",
"<<",
"SM",
"::",
"Flow",
"::",
"RULE",
".",
"new",
"@comment",
".",
"concat",
"old",
".",
"comment",
"end",
"end",
"end"
] | merge in another class desscription into this one | [
"merge",
"in",
"another",
"class",
"desscription",
"into",
"this",
"one"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_descriptions.rb#L89-L103 |
1,769 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/irb/workspace.rb | IRB.WorkSpace.filter_backtrace | def filter_backtrace(bt)
case IRB.conf[:CONTEXT_MODE]
when 0
return nil if bt =~ /\(irb_local_binding\)/
when 1
if(bt =~ %r!/tmp/irb-binding! or
bt =~ %r!irb/.*\.rb! or
bt =~ /irb\.rb/)
return nil
end
when 2
return nil if bt =~ /irb\/.*\.rb/
when 3
return nil if bt =~ /irb\/.*\.rb/
bt.sub!(/:\s*in `irb_binding'/){""}
end
bt
end | ruby | def filter_backtrace(bt)
case IRB.conf[:CONTEXT_MODE]
when 0
return nil if bt =~ /\(irb_local_binding\)/
when 1
if(bt =~ %r!/tmp/irb-binding! or
bt =~ %r!irb/.*\.rb! or
bt =~ /irb\.rb/)
return nil
end
when 2
return nil if bt =~ /irb\/.*\.rb/
when 3
return nil if bt =~ /irb\/.*\.rb/
bt.sub!(/:\s*in `irb_binding'/){""}
end
bt
end | [
"def",
"filter_backtrace",
"(",
"bt",
")",
"case",
"IRB",
".",
"conf",
"[",
":CONTEXT_MODE",
"]",
"when",
"0",
"return",
"nil",
"if",
"bt",
"=~",
"/",
"\\(",
"\\)",
"/",
"when",
"1",
"if",
"(",
"bt",
"=~",
"%r!",
"!",
"or",
"bt",
"=~",
"%r!",
"\\.",
"!",
"or",
"bt",
"=~",
"/",
"\\.",
"/",
")",
"return",
"nil",
"end",
"when",
"2",
"return",
"nil",
"if",
"bt",
"=~",
"/",
"\\/",
"\\.",
"/",
"when",
"3",
"return",
"nil",
"if",
"bt",
"=~",
"/",
"\\/",
"\\.",
"/",
"bt",
".",
"sub!",
"(",
"/",
"\\s",
"/",
")",
"{",
"\"\"",
"}",
"end",
"bt",
"end"
] | error message manipulator | [
"error",
"message",
"manipulator"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/irb/workspace.rb#L85-L102 |
1,770 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_reader.rb | RI.RiReader.get_method | def get_method(method_entry)
path = method_entry.path_name
File.open(path) { |f| RI::Description.deserialize(f) }
end | ruby | def get_method(method_entry)
path = method_entry.path_name
File.open(path) { |f| RI::Description.deserialize(f) }
end | [
"def",
"get_method",
"(",
"method_entry",
")",
"path",
"=",
"method_entry",
".",
"path_name",
"File",
".",
"open",
"(",
"path",
")",
"{",
"|",
"f",
"|",
"RI",
"::",
"Description",
".",
"deserialize",
"(",
"f",
")",
"}",
"end"
] | return the MethodDescription for a given MethodEntry
by deserializing the YAML | [
"return",
"the",
"MethodDescription",
"for",
"a",
"given",
"MethodEntry",
"by",
"deserializing",
"the",
"YAML"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_reader.rb#L44-L47 |
1,771 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_reader.rb | RI.RiReader.get_class | def get_class(class_entry)
result = nil
for path in class_entry.path_names
path = RiWriter.class_desc_path(path, class_entry)
desc = File.open(path) {|f| RI::Description.deserialize(f) }
if result
result.merge_in(desc)
else
result = desc
end
end
result
end | ruby | def get_class(class_entry)
result = nil
for path in class_entry.path_names
path = RiWriter.class_desc_path(path, class_entry)
desc = File.open(path) {|f| RI::Description.deserialize(f) }
if result
result.merge_in(desc)
else
result = desc
end
end
result
end | [
"def",
"get_class",
"(",
"class_entry",
")",
"result",
"=",
"nil",
"for",
"path",
"in",
"class_entry",
".",
"path_names",
"path",
"=",
"RiWriter",
".",
"class_desc_path",
"(",
"path",
",",
"class_entry",
")",
"desc",
"=",
"File",
".",
"open",
"(",
"path",
")",
"{",
"|",
"f",
"|",
"RI",
"::",
"Description",
".",
"deserialize",
"(",
"f",
")",
"}",
"if",
"result",
"result",
".",
"merge_in",
"(",
"desc",
")",
"else",
"result",
"=",
"desc",
"end",
"end",
"result",
"end"
] | Return a class description | [
"Return",
"a",
"class",
"description"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_reader.rb#L50-L62 |
1,772 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_options.rb | RI.Options.parse | def parse(args)
old_argv = ARGV.dup
ARGV.replace(args)
begin
go = GetoptLong.new(*OptionList.options)
go.quiet = true
go.each do |opt, arg|
case opt
when "--help" then OptionList.usage
when "--version" then show_version
when "--list-names" then @list_names = true
when "--no-pager" then @use_stdout = true
when "--classes" then @list_classes = true
when "--java" then @java_classes = true
when "--system" then @use_system = true
when "--site" then @use_site = true
when "--home" then @use_home = true
when "--gems" then @use_gems = true
when "--doc-dir"
if File.directory?(arg)
@doc_dirs << arg
else
$stderr.puts "Invalid directory: #{arg}"
exit 1
end
when "--format"
@formatter = RI::TextFormatter.for(arg)
unless @formatter
$stderr.print "Invalid formatter (should be one of "
$stderr.puts RI::TextFormatter.list + ")"
exit 1
end
when "--width"
begin
@width = Integer(arg)
rescue
$stderr.puts "Invalid width: '#{arg}'"
exit 1
end
end
end
rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
OptionList.error(error.message)
end
end | ruby | def parse(args)
old_argv = ARGV.dup
ARGV.replace(args)
begin
go = GetoptLong.new(*OptionList.options)
go.quiet = true
go.each do |opt, arg|
case opt
when "--help" then OptionList.usage
when "--version" then show_version
when "--list-names" then @list_names = true
when "--no-pager" then @use_stdout = true
when "--classes" then @list_classes = true
when "--java" then @java_classes = true
when "--system" then @use_system = true
when "--site" then @use_site = true
when "--home" then @use_home = true
when "--gems" then @use_gems = true
when "--doc-dir"
if File.directory?(arg)
@doc_dirs << arg
else
$stderr.puts "Invalid directory: #{arg}"
exit 1
end
when "--format"
@formatter = RI::TextFormatter.for(arg)
unless @formatter
$stderr.print "Invalid formatter (should be one of "
$stderr.puts RI::TextFormatter.list + ")"
exit 1
end
when "--width"
begin
@width = Integer(arg)
rescue
$stderr.puts "Invalid width: '#{arg}'"
exit 1
end
end
end
rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
OptionList.error(error.message)
end
end | [
"def",
"parse",
"(",
"args",
")",
"old_argv",
"=",
"ARGV",
".",
"dup",
"ARGV",
".",
"replace",
"(",
"args",
")",
"begin",
"go",
"=",
"GetoptLong",
".",
"new",
"(",
"OptionList",
".",
"options",
")",
"go",
".",
"quiet",
"=",
"true",
"go",
".",
"each",
"do",
"|",
"opt",
",",
"arg",
"|",
"case",
"opt",
"when",
"\"--help\"",
"then",
"OptionList",
".",
"usage",
"when",
"\"--version\"",
"then",
"show_version",
"when",
"\"--list-names\"",
"then",
"@list_names",
"=",
"true",
"when",
"\"--no-pager\"",
"then",
"@use_stdout",
"=",
"true",
"when",
"\"--classes\"",
"then",
"@list_classes",
"=",
"true",
"when",
"\"--java\"",
"then",
"@java_classes",
"=",
"true",
"when",
"\"--system\"",
"then",
"@use_system",
"=",
"true",
"when",
"\"--site\"",
"then",
"@use_site",
"=",
"true",
"when",
"\"--home\"",
"then",
"@use_home",
"=",
"true",
"when",
"\"--gems\"",
"then",
"@use_gems",
"=",
"true",
"when",
"\"--doc-dir\"",
"if",
"File",
".",
"directory?",
"(",
"arg",
")",
"@doc_dirs",
"<<",
"arg",
"else",
"$stderr",
".",
"puts",
"\"Invalid directory: #{arg}\"",
"exit",
"1",
"end",
"when",
"\"--format\"",
"@formatter",
"=",
"RI",
"::",
"TextFormatter",
".",
"for",
"(",
"arg",
")",
"unless",
"@formatter",
"$stderr",
".",
"print",
"\"Invalid formatter (should be one of \"",
"$stderr",
".",
"puts",
"RI",
"::",
"TextFormatter",
".",
"list",
"+",
"\")\"",
"exit",
"1",
"end",
"when",
"\"--width\"",
"begin",
"@width",
"=",
"Integer",
"(",
"arg",
")",
"rescue",
"$stderr",
".",
"puts",
"\"Invalid width: '#{arg}'\"",
"exit",
"1",
"end",
"end",
"end",
"rescue",
"GetoptLong",
"::",
"InvalidOption",
",",
"GetoptLong",
"::",
"MissingArgument",
"=>",
"error",
"OptionList",
".",
"error",
"(",
"error",
".",
"message",
")",
"end",
"end"
] | Parse command line options. | [
"Parse",
"command",
"line",
"options",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/ri/ri_options.rb#L250-L304 |
1,773 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/rdoc.rb | RDoc.RDoc.parse_files | def parse_files(options)
file_info = []
files = options.files
files = ["."] if files.empty?
file_list = normalized_file_list(options, files, true)
file_list.each do |fn|
$stderr.printf("\n%35s: ", File.basename(fn)) unless options.quiet
content = File.open(fn, "r") {|f| f.read}
top_level = TopLevel.new(fn)
parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)
file_info << parser.scan
@stats.num_files += 1
end
file_info
end | ruby | def parse_files(options)
file_info = []
files = options.files
files = ["."] if files.empty?
file_list = normalized_file_list(options, files, true)
file_list.each do |fn|
$stderr.printf("\n%35s: ", File.basename(fn)) unless options.quiet
content = File.open(fn, "r") {|f| f.read}
top_level = TopLevel.new(fn)
parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)
file_info << parser.scan
@stats.num_files += 1
end
file_info
end | [
"def",
"parse_files",
"(",
"options",
")",
"file_info",
"=",
"[",
"]",
"files",
"=",
"options",
".",
"files",
"files",
"=",
"[",
"\".\"",
"]",
"if",
"files",
".",
"empty?",
"file_list",
"=",
"normalized_file_list",
"(",
"options",
",",
"files",
",",
"true",
")",
"file_list",
".",
"each",
"do",
"|",
"fn",
"|",
"$stderr",
".",
"printf",
"(",
"\"\\n%35s: \"",
",",
"File",
".",
"basename",
"(",
"fn",
")",
")",
"unless",
"options",
".",
"quiet",
"content",
"=",
"File",
".",
"open",
"(",
"fn",
",",
"\"r\"",
")",
"{",
"|",
"f",
"|",
"f",
".",
"read",
"}",
"top_level",
"=",
"TopLevel",
".",
"new",
"(",
"fn",
")",
"parser",
"=",
"ParserFactory",
".",
"parser_for",
"(",
"top_level",
",",
"fn",
",",
"content",
",",
"options",
",",
"@stats",
")",
"file_info",
"<<",
"parser",
".",
"scan",
"@stats",
".",
"num_files",
"+=",
"1",
"end",
"file_info",
"end"
] | Parse each file on the command line, recursively entering
directories | [
"Parse",
"each",
"file",
"on",
"the",
"command",
"line",
"recursively",
"entering",
"directories"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/rdoc.rb#L210-L231 |
1,774 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.7-java/lib/jdbc_adapter/missing_functionality_helper.rb | JdbcSpec.MissingFunctionalityHelper.alter_table | def alter_table(table_name, options = {}) #:nodoc:
table_name = table_name.to_s.downcase
altered_table_name = "altered_#{table_name}"
caller = lambda {|definition| yield definition if block_given?}
transaction do
# A temporary table might improve performance here, but
# it doesn't seem to maintain indices across the whole move.
move_table(table_name, altered_table_name,
options)
move_table(altered_table_name, table_name, &caller)
end
end | ruby | def alter_table(table_name, options = {}) #:nodoc:
table_name = table_name.to_s.downcase
altered_table_name = "altered_#{table_name}"
caller = lambda {|definition| yield definition if block_given?}
transaction do
# A temporary table might improve performance here, but
# it doesn't seem to maintain indices across the whole move.
move_table(table_name, altered_table_name,
options)
move_table(altered_table_name, table_name, &caller)
end
end | [
"def",
"alter_table",
"(",
"table_name",
",",
"options",
"=",
"{",
"}",
")",
"#:nodoc:",
"table_name",
"=",
"table_name",
".",
"to_s",
".",
"downcase",
"altered_table_name",
"=",
"\"altered_#{table_name}\"",
"caller",
"=",
"lambda",
"{",
"|",
"definition",
"|",
"yield",
"definition",
"if",
"block_given?",
"}",
"transaction",
"do",
"# A temporary table might improve performance here, but",
"# it doesn't seem to maintain indices across the whole move.",
"move_table",
"(",
"table_name",
",",
"altered_table_name",
",",
"options",
")",
"move_table",
"(",
"altered_table_name",
",",
"table_name",
",",
"caller",
")",
"end",
"end"
] | Taken from SQLite adapter | [
"Taken",
"from",
"SQLite",
"adapter"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.7-java/lib/jdbc_adapter/missing_functionality_helper.rb#L5-L17 |
1,775 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb | YAML.BaseNode.select | def select( ypath_str )
matches = match_path( ypath_str )
#
# Create a new generic view of the elements selected
#
if matches
result = []
matches.each { |m|
result.push m.last
}
YAML.transfer( 'seq', result )
end
end | ruby | def select( ypath_str )
matches = match_path( ypath_str )
#
# Create a new generic view of the elements selected
#
if matches
result = []
matches.each { |m|
result.push m.last
}
YAML.transfer( 'seq', result )
end
end | [
"def",
"select",
"(",
"ypath_str",
")",
"matches",
"=",
"match_path",
"(",
"ypath_str",
")",
"#",
"# Create a new generic view of the elements selected",
"#",
"if",
"matches",
"result",
"=",
"[",
"]",
"matches",
".",
"each",
"{",
"|",
"m",
"|",
"result",
".",
"push",
"m",
".",
"last",
"}",
"YAML",
".",
"transfer",
"(",
"'seq'",
",",
"result",
")",
"end",
"end"
] | Search for YPath entry and return
qualified nodes. | [
"Search",
"for",
"YPath",
"entry",
"and",
"return",
"qualified",
"nodes",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb#L17-L30 |
1,776 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb | YAML.BaseNode.select! | def select!( ypath_str )
matches = match_path( ypath_str )
#
# Create a new generic view of the elements selected
#
if matches
result = []
matches.each { |m|
result.push m.last.transform
}
result
end
end | ruby | def select!( ypath_str )
matches = match_path( ypath_str )
#
# Create a new generic view of the elements selected
#
if matches
result = []
matches.each { |m|
result.push m.last.transform
}
result
end
end | [
"def",
"select!",
"(",
"ypath_str",
")",
"matches",
"=",
"match_path",
"(",
"ypath_str",
")",
"#",
"# Create a new generic view of the elements selected",
"#",
"if",
"matches",
"result",
"=",
"[",
"]",
"matches",
".",
"each",
"{",
"|",
"m",
"|",
"result",
".",
"push",
"m",
".",
"last",
".",
"transform",
"}",
"result",
"end",
"end"
] | Search for YPath entry and return
transformed nodes. | [
"Search",
"for",
"YPath",
"entry",
"and",
"return",
"transformed",
"nodes",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb#L36-L49 |
1,777 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb | YAML.BaseNode.search | def search( ypath_str )
matches = match_path( ypath_str )
if matches
matches.collect { |m|
path = []
m.each_index { |i|
path.push m[i] if ( i % 2 ).zero?
}
"/" + path.compact.join( "/" )
}
end
end | ruby | def search( ypath_str )
matches = match_path( ypath_str )
if matches
matches.collect { |m|
path = []
m.each_index { |i|
path.push m[i] if ( i % 2 ).zero?
}
"/" + path.compact.join( "/" )
}
end
end | [
"def",
"search",
"(",
"ypath_str",
")",
"matches",
"=",
"match_path",
"(",
"ypath_str",
")",
"if",
"matches",
"matches",
".",
"collect",
"{",
"|",
"m",
"|",
"path",
"=",
"[",
"]",
"m",
".",
"each_index",
"{",
"|",
"i",
"|",
"path",
".",
"push",
"m",
"[",
"i",
"]",
"if",
"(",
"i",
"%",
"2",
")",
".",
"zero?",
"}",
"\"/\"",
"+",
"path",
".",
"compact",
".",
"join",
"(",
"\"/\"",
")",
"}",
"end",
"end"
] | Search for YPath entry and return a list of
qualified paths. | [
"Search",
"for",
"YPath",
"entry",
"and",
"return",
"a",
"list",
"of",
"qualified",
"paths",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb#L55-L67 |
1,778 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb | YAML.BaseNode.match_path | def match_path( ypath_str )
depth = 0
matches = []
YPath.each_path( ypath_str ) do |ypath|
seg = match_segment( ypath, 0 )
matches += seg if seg
end
matches.uniq
end | ruby | def match_path( ypath_str )
depth = 0
matches = []
YPath.each_path( ypath_str ) do |ypath|
seg = match_segment( ypath, 0 )
matches += seg if seg
end
matches.uniq
end | [
"def",
"match_path",
"(",
"ypath_str",
")",
"depth",
"=",
"0",
"matches",
"=",
"[",
"]",
"YPath",
".",
"each_path",
"(",
"ypath_str",
")",
"do",
"|",
"ypath",
"|",
"seg",
"=",
"match_segment",
"(",
"ypath",
",",
"0",
")",
"matches",
"+=",
"seg",
"if",
"seg",
"end",
"matches",
".",
"uniq",
"end"
] | YPath search returning a complete depth array | [
"YPath",
"search",
"returning",
"a",
"complete",
"depth",
"array"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb#L80-L88 |
1,779 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb | YAML.BaseNode.match_segment | def match_segment( ypath, depth )
deep_nodes = []
seg = ypath.segments[ depth ]
if seg == "/"
unless String === @value
idx = -1
@value.collect { |v|
idx += 1
if Hash === @value
match_init = [v[0].transform, v[1]]
match_deep = v[1].match_segment( ypath, depth )
else
match_init = [idx, v]
match_deep = v.match_segment( ypath, depth )
end
if match_deep
match_deep.each { |m|
deep_nodes.push( match_init + m )
}
end
}
end
depth += 1
seg = ypath.segments[ depth ]
end
match_nodes =
case seg
when "."
[[nil, self]]
when ".."
[["..", nil]]
when "*"
if @value.is_a? Enumerable
idx = -1
@value.collect { |h|
idx += 1
if Hash === @value
[h[0].transform, h[1]]
else
[idx, h]
end
}
end
else
if seg =~ /^"(.*)"$/
seg = $1
elsif seg =~ /^'(.*)'$/
seg = $1
end
if ( v = at( seg ) )
[[ seg, v ]]
end
end
return deep_nodes unless match_nodes
pred = ypath.predicates[ depth ]
if pred
case pred
when /^\.=/
pred = $' # '
match_nodes.reject! { |n|
n.last.value != pred
}
else
match_nodes.reject! { |n|
n.last.at( pred ).nil?
}
end
end
return match_nodes + deep_nodes unless ypath.segments.length > depth + 1
#puts "DEPTH: #{depth + 1}"
deep_nodes = []
match_nodes.each { |n|
if n[1].is_a? BaseNode
match_deep = n[1].match_segment( ypath, depth + 1 )
if match_deep
match_deep.each { |m|
deep_nodes.push( n + m )
}
end
else
deep_nodes = []
end
}
deep_nodes = nil if deep_nodes.length == 0
deep_nodes
end | ruby | def match_segment( ypath, depth )
deep_nodes = []
seg = ypath.segments[ depth ]
if seg == "/"
unless String === @value
idx = -1
@value.collect { |v|
idx += 1
if Hash === @value
match_init = [v[0].transform, v[1]]
match_deep = v[1].match_segment( ypath, depth )
else
match_init = [idx, v]
match_deep = v.match_segment( ypath, depth )
end
if match_deep
match_deep.each { |m|
deep_nodes.push( match_init + m )
}
end
}
end
depth += 1
seg = ypath.segments[ depth ]
end
match_nodes =
case seg
when "."
[[nil, self]]
when ".."
[["..", nil]]
when "*"
if @value.is_a? Enumerable
idx = -1
@value.collect { |h|
idx += 1
if Hash === @value
[h[0].transform, h[1]]
else
[idx, h]
end
}
end
else
if seg =~ /^"(.*)"$/
seg = $1
elsif seg =~ /^'(.*)'$/
seg = $1
end
if ( v = at( seg ) )
[[ seg, v ]]
end
end
return deep_nodes unless match_nodes
pred = ypath.predicates[ depth ]
if pred
case pred
when /^\.=/
pred = $' # '
match_nodes.reject! { |n|
n.last.value != pred
}
else
match_nodes.reject! { |n|
n.last.at( pred ).nil?
}
end
end
return match_nodes + deep_nodes unless ypath.segments.length > depth + 1
#puts "DEPTH: #{depth + 1}"
deep_nodes = []
match_nodes.each { |n|
if n[1].is_a? BaseNode
match_deep = n[1].match_segment( ypath, depth + 1 )
if match_deep
match_deep.each { |m|
deep_nodes.push( n + m )
}
end
else
deep_nodes = []
end
}
deep_nodes = nil if deep_nodes.length == 0
deep_nodes
end | [
"def",
"match_segment",
"(",
"ypath",
",",
"depth",
")",
"deep_nodes",
"=",
"[",
"]",
"seg",
"=",
"ypath",
".",
"segments",
"[",
"depth",
"]",
"if",
"seg",
"==",
"\"/\"",
"unless",
"String",
"===",
"@value",
"idx",
"=",
"-",
"1",
"@value",
".",
"collect",
"{",
"|",
"v",
"|",
"idx",
"+=",
"1",
"if",
"Hash",
"===",
"@value",
"match_init",
"=",
"[",
"v",
"[",
"0",
"]",
".",
"transform",
",",
"v",
"[",
"1",
"]",
"]",
"match_deep",
"=",
"v",
"[",
"1",
"]",
".",
"match_segment",
"(",
"ypath",
",",
"depth",
")",
"else",
"match_init",
"=",
"[",
"idx",
",",
"v",
"]",
"match_deep",
"=",
"v",
".",
"match_segment",
"(",
"ypath",
",",
"depth",
")",
"end",
"if",
"match_deep",
"match_deep",
".",
"each",
"{",
"|",
"m",
"|",
"deep_nodes",
".",
"push",
"(",
"match_init",
"+",
"m",
")",
"}",
"end",
"}",
"end",
"depth",
"+=",
"1",
"seg",
"=",
"ypath",
".",
"segments",
"[",
"depth",
"]",
"end",
"match_nodes",
"=",
"case",
"seg",
"when",
"\".\"",
"[",
"[",
"nil",
",",
"self",
"]",
"]",
"when",
"\"..\"",
"[",
"[",
"\"..\"",
",",
"nil",
"]",
"]",
"when",
"\"*\"",
"if",
"@value",
".",
"is_a?",
"Enumerable",
"idx",
"=",
"-",
"1",
"@value",
".",
"collect",
"{",
"|",
"h",
"|",
"idx",
"+=",
"1",
"if",
"Hash",
"===",
"@value",
"[",
"h",
"[",
"0",
"]",
".",
"transform",
",",
"h",
"[",
"1",
"]",
"]",
"else",
"[",
"idx",
",",
"h",
"]",
"end",
"}",
"end",
"else",
"if",
"seg",
"=~",
"/",
"/",
"seg",
"=",
"$1",
"elsif",
"seg",
"=~",
"/",
"/",
"seg",
"=",
"$1",
"end",
"if",
"(",
"v",
"=",
"at",
"(",
"seg",
")",
")",
"[",
"[",
"seg",
",",
"v",
"]",
"]",
"end",
"end",
"return",
"deep_nodes",
"unless",
"match_nodes",
"pred",
"=",
"ypath",
".",
"predicates",
"[",
"depth",
"]",
"if",
"pred",
"case",
"pred",
"when",
"/",
"\\.",
"/",
"pred",
"=",
"$'",
"# '",
"match_nodes",
".",
"reject!",
"{",
"|",
"n",
"|",
"n",
".",
"last",
".",
"value",
"!=",
"pred",
"}",
"else",
"match_nodes",
".",
"reject!",
"{",
"|",
"n",
"|",
"n",
".",
"last",
".",
"at",
"(",
"pred",
")",
".",
"nil?",
"}",
"end",
"end",
"return",
"match_nodes",
"+",
"deep_nodes",
"unless",
"ypath",
".",
"segments",
".",
"length",
">",
"depth",
"+",
"1",
"#puts \"DEPTH: #{depth + 1}\"",
"deep_nodes",
"=",
"[",
"]",
"match_nodes",
".",
"each",
"{",
"|",
"n",
"|",
"if",
"n",
"[",
"1",
"]",
".",
"is_a?",
"BaseNode",
"match_deep",
"=",
"n",
"[",
"1",
"]",
".",
"match_segment",
"(",
"ypath",
",",
"depth",
"+",
"1",
")",
"if",
"match_deep",
"match_deep",
".",
"each",
"{",
"|",
"m",
"|",
"deep_nodes",
".",
"push",
"(",
"n",
"+",
"m",
")",
"}",
"end",
"else",
"deep_nodes",
"=",
"[",
"]",
"end",
"}",
"deep_nodes",
"=",
"nil",
"if",
"deep_nodes",
".",
"length",
"==",
"0",
"deep_nodes",
"end"
] | Search a node for a single YPath segment | [
"Search",
"a",
"node",
"for",
"a",
"single",
"YPath",
"segment"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb#L93-L179 |
1,780 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb | YAML.BaseNode.[] | def []( *key )
if Hash === @value
v = @value.detect { |k,| k.transform == key.first }
v[1] if v
elsif Array === @value
@value.[]( *key )
end
end | ruby | def []( *key )
if Hash === @value
v = @value.detect { |k,| k.transform == key.first }
v[1] if v
elsif Array === @value
@value.[]( *key )
end
end | [
"def",
"[]",
"(",
"*",
"key",
")",
"if",
"Hash",
"===",
"@value",
"v",
"=",
"@value",
".",
"detect",
"{",
"|",
"k",
",",
"|",
"k",
".",
"transform",
"==",
"key",
".",
"first",
"}",
"v",
"[",
"1",
"]",
"if",
"v",
"elsif",
"Array",
"===",
"@value",
"@value",
".",
"[]",
"(",
"key",
")",
"end",
"end"
] | We want the node to act like as Hash
if it is. | [
"We",
"want",
"the",
"node",
"to",
"act",
"like",
"as",
"Hash",
"if",
"it",
"is",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/yaml/basenode.rb#L185-L192 |
1,781 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/markup/simple_markup/to_latex.rb | SM.ToLaTeX.escape | def escape(str)
# $stderr.print "FE: ", str
s = str.
# sub(/\s+$/, '').
gsub(/([_\${}&%#])/, "#{BS}\\1").
gsub(/\\/, BACKSLASH).
gsub(/\^/, HAT).
gsub(/~/, TILDE).
gsub(/</, LESSTHAN).
gsub(/>/, GREATERTHAN).
gsub(/,,/, ",{},").
gsub(/\`/, BACKQUOTE)
# $stderr.print "-> ", s, "\n"
s
end | ruby | def escape(str)
# $stderr.print "FE: ", str
s = str.
# sub(/\s+$/, '').
gsub(/([_\${}&%#])/, "#{BS}\\1").
gsub(/\\/, BACKSLASH).
gsub(/\^/, HAT).
gsub(/~/, TILDE).
gsub(/</, LESSTHAN).
gsub(/>/, GREATERTHAN).
gsub(/,,/, ",{},").
gsub(/\`/, BACKQUOTE)
# $stderr.print "-> ", s, "\n"
s
end | [
"def",
"escape",
"(",
"str",
")",
"# $stderr.print \"FE: \", str",
"s",
"=",
"str",
".",
"# sub(/\\s+$/, '').",
"gsub",
"(",
"/",
"\\$",
"/",
",",
"\"#{BS}\\\\1\"",
")",
".",
"gsub",
"(",
"/",
"\\\\",
"/",
",",
"BACKSLASH",
")",
".",
"gsub",
"(",
"/",
"\\^",
"/",
",",
"HAT",
")",
".",
"gsub",
"(",
"/",
"/",
",",
"TILDE",
")",
".",
"gsub",
"(",
"/",
"/",
",",
"LESSTHAN",
")",
".",
"gsub",
"(",
"/",
"/",
",",
"GREATERTHAN",
")",
".",
"gsub",
"(",
"/",
"/",
",",
"\",{},\"",
")",
".",
"gsub",
"(",
"/",
"\\`",
"/",
",",
"BACKQUOTE",
")",
"# $stderr.print \"-> \", s, \"\\n\"",
"s",
"end"
] | Escape a LaTeX string | [
"Escape",
"a",
"LaTeX",
"string"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/markup/simple_markup/to_latex.rb#L64-L78 |
1,782 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb | FFI.Library.attach_function | def attach_function(mname, a2, a3, a4=nil, a5 = nil)
cname, arg_types, ret_type, opts = (a4 && (a2.is_a?(String) || a2.is_a?(Symbol))) ? [ a2, a3, a4, a5 ] : [ mname.to_s, a2, a3, a4 ]
# Convert :foo to the native type
arg_types.map! { |e| find_type(e) }
options = Hash.new
options[:convention] = defined?(@ffi_convention) ? @ffi_convention : :default
options[:type_map] = defined?(@ffi_typedefs) ? @ffi_typedefs : nil
options[:enums] = defined?(@ffi_enum_map) ? @ffi_enum_map : nil
options.merge!(opts) if opts.is_a?(Hash)
# Try to locate the function in any of the libraries
invokers = []
load_error = nil
ffi_libraries.each do |lib|
begin
invokers << FFI.create_invoker(lib, cname.to_s, arg_types, find_type(ret_type), options)
rescue LoadError => ex
load_error = ex
end if invokers.empty?
end
invoker = invokers.compact.shift
raise load_error if load_error && invoker.nil?
#raise FFI::NotFoundError.new(cname.to_s, *libraries) unless invoker
invoker.attach(self, mname.to_s)
invoker # Return a version that can be called via #call
end | ruby | def attach_function(mname, a2, a3, a4=nil, a5 = nil)
cname, arg_types, ret_type, opts = (a4 && (a2.is_a?(String) || a2.is_a?(Symbol))) ? [ a2, a3, a4, a5 ] : [ mname.to_s, a2, a3, a4 ]
# Convert :foo to the native type
arg_types.map! { |e| find_type(e) }
options = Hash.new
options[:convention] = defined?(@ffi_convention) ? @ffi_convention : :default
options[:type_map] = defined?(@ffi_typedefs) ? @ffi_typedefs : nil
options[:enums] = defined?(@ffi_enum_map) ? @ffi_enum_map : nil
options.merge!(opts) if opts.is_a?(Hash)
# Try to locate the function in any of the libraries
invokers = []
load_error = nil
ffi_libraries.each do |lib|
begin
invokers << FFI.create_invoker(lib, cname.to_s, arg_types, find_type(ret_type), options)
rescue LoadError => ex
load_error = ex
end if invokers.empty?
end
invoker = invokers.compact.shift
raise load_error if load_error && invoker.nil?
#raise FFI::NotFoundError.new(cname.to_s, *libraries) unless invoker
invoker.attach(self, mname.to_s)
invoker # Return a version that can be called via #call
end | [
"def",
"attach_function",
"(",
"mname",
",",
"a2",
",",
"a3",
",",
"a4",
"=",
"nil",
",",
"a5",
"=",
"nil",
")",
"cname",
",",
"arg_types",
",",
"ret_type",
",",
"opts",
"=",
"(",
"a4",
"&&",
"(",
"a2",
".",
"is_a?",
"(",
"String",
")",
"||",
"a2",
".",
"is_a?",
"(",
"Symbol",
")",
")",
")",
"?",
"[",
"a2",
",",
"a3",
",",
"a4",
",",
"a5",
"]",
":",
"[",
"mname",
".",
"to_s",
",",
"a2",
",",
"a3",
",",
"a4",
"]",
"# Convert :foo to the native type",
"arg_types",
".",
"map!",
"{",
"|",
"e",
"|",
"find_type",
"(",
"e",
")",
"}",
"options",
"=",
"Hash",
".",
"new",
"options",
"[",
":convention",
"]",
"=",
"defined?",
"(",
"@ffi_convention",
")",
"?",
"@ffi_convention",
":",
":default",
"options",
"[",
":type_map",
"]",
"=",
"defined?",
"(",
"@ffi_typedefs",
")",
"?",
"@ffi_typedefs",
":",
"nil",
"options",
"[",
":enums",
"]",
"=",
"defined?",
"(",
"@ffi_enum_map",
")",
"?",
"@ffi_enum_map",
":",
"nil",
"options",
".",
"merge!",
"(",
"opts",
")",
"if",
"opts",
".",
"is_a?",
"(",
"Hash",
")",
"# Try to locate the function in any of the libraries",
"invokers",
"=",
"[",
"]",
"load_error",
"=",
"nil",
"ffi_libraries",
".",
"each",
"do",
"|",
"lib",
"|",
"begin",
"invokers",
"<<",
"FFI",
".",
"create_invoker",
"(",
"lib",
",",
"cname",
".",
"to_s",
",",
"arg_types",
",",
"find_type",
"(",
"ret_type",
")",
",",
"options",
")",
"rescue",
"LoadError",
"=>",
"ex",
"load_error",
"=",
"ex",
"end",
"if",
"invokers",
".",
"empty?",
"end",
"invoker",
"=",
"invokers",
".",
"compact",
".",
"shift",
"raise",
"load_error",
"if",
"load_error",
"&&",
"invoker",
".",
"nil?",
"#raise FFI::NotFoundError.new(cname.to_s, *libraries) unless invoker",
"invoker",
".",
"attach",
"(",
"self",
",",
"mname",
".",
"to_s",
")",
"invoker",
"# Return a version that can be called via #call",
"end"
] | Attach C function +name+ to this module.
If you want to provide an alternate name for the module function, supply
it after the +name+, otherwise the C function name will be used.
After the +name+, the C function argument types are provided as an Array.
The C function return type is provided last. | [
"Attach",
"C",
"function",
"+",
"name",
"+",
"to",
"this",
"module",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/site_ruby/shared/ffi/library.rb#L81-L108 |
1,783 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb | ActiveSupport.Dependencies.qualified_const_defined? | def qualified_const_defined?(path)
raise NameError, "#{path.inspect} is not a valid constant name!" unless
/^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ path
names = path.to_s.split('::')
names.shift if names.first.empty?
# We can't use defined? because it will invoke const_missing for the parent
# of the name we are checking.
names.inject(Object) do |mod, name|
return false unless uninherited_const_defined?(mod, name)
mod.const_get name
end
return true
end | ruby | def qualified_const_defined?(path)
raise NameError, "#{path.inspect} is not a valid constant name!" unless
/^(::)?([A-Z]\w*)(::[A-Z]\w*)*$/ =~ path
names = path.to_s.split('::')
names.shift if names.first.empty?
# We can't use defined? because it will invoke const_missing for the parent
# of the name we are checking.
names.inject(Object) do |mod, name|
return false unless uninherited_const_defined?(mod, name)
mod.const_get name
end
return true
end | [
"def",
"qualified_const_defined?",
"(",
"path",
")",
"raise",
"NameError",
",",
"\"#{path.inspect} is not a valid constant name!\"",
"unless",
"/",
"\\w",
"\\w",
"/",
"=~",
"path",
"names",
"=",
"path",
".",
"to_s",
".",
"split",
"(",
"'::'",
")",
"names",
".",
"shift",
"if",
"names",
".",
"first",
".",
"empty?",
"# We can't use defined? because it will invoke const_missing for the parent",
"# of the name we are checking.",
"names",
".",
"inject",
"(",
"Object",
")",
"do",
"|",
"mod",
",",
"name",
"|",
"return",
"false",
"unless",
"uninherited_const_defined?",
"(",
"mod",
",",
"name",
")",
"mod",
".",
"const_get",
"name",
"end",
"return",
"true",
"end"
] | Is the provided constant path defined? | [
"Is",
"the",
"provided",
"constant",
"path",
"defined?"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb#L278-L292 |
1,784 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb | ActiveSupport.Dependencies.search_for_file | def search_for_file(path_suffix)
path_suffix = path_suffix + '.rb' unless path_suffix.ends_with? '.rb'
load_paths.each do |root|
path = File.join(root, path_suffix)
return path if File.file? path
end
nil # Gee, I sure wish we had first_match ;-)
end | ruby | def search_for_file(path_suffix)
path_suffix = path_suffix + '.rb' unless path_suffix.ends_with? '.rb'
load_paths.each do |root|
path = File.join(root, path_suffix)
return path if File.file? path
end
nil # Gee, I sure wish we had first_match ;-)
end | [
"def",
"search_for_file",
"(",
"path_suffix",
")",
"path_suffix",
"=",
"path_suffix",
"+",
"'.rb'",
"unless",
"path_suffix",
".",
"ends_with?",
"'.rb'",
"load_paths",
".",
"each",
"do",
"|",
"root",
"|",
"path",
"=",
"File",
".",
"join",
"(",
"root",
",",
"path_suffix",
")",
"return",
"path",
"if",
"File",
".",
"file?",
"path",
"end",
"nil",
"# Gee, I sure wish we had first_match ;-)",
"end"
] | Search for a file in load_paths matching the provided suffix. | [
"Search",
"for",
"a",
"file",
"in",
"load_paths",
"matching",
"the",
"provided",
"suffix",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb#L330-L337 |
1,785 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb | ActiveSupport.Dependencies.autoload_module! | def autoload_module!(into, const_name, qualified_name, path_suffix)
return nil unless base_path = autoloadable_module?(path_suffix)
mod = Module.new
into.const_set const_name, mod
autoloaded_constants << qualified_name unless load_once_paths.include?(base_path)
return mod
end | ruby | def autoload_module!(into, const_name, qualified_name, path_suffix)
return nil unless base_path = autoloadable_module?(path_suffix)
mod = Module.new
into.const_set const_name, mod
autoloaded_constants << qualified_name unless load_once_paths.include?(base_path)
return mod
end | [
"def",
"autoload_module!",
"(",
"into",
",",
"const_name",
",",
"qualified_name",
",",
"path_suffix",
")",
"return",
"nil",
"unless",
"base_path",
"=",
"autoloadable_module?",
"(",
"path_suffix",
")",
"mod",
"=",
"Module",
".",
"new",
"into",
".",
"const_set",
"const_name",
",",
"mod",
"autoloaded_constants",
"<<",
"qualified_name",
"unless",
"load_once_paths",
".",
"include?",
"(",
"base_path",
")",
"return",
"mod",
"end"
] | Attempt to autoload the provided module name by searching for a directory
matching the expect path suffix. If found, the module is created and assigned
to +into+'s constants with the name +const_name+. Provided that the directory
was loaded from a reloadable base path, it is added to the set of constants
that are to be unloaded. | [
"Attempt",
"to",
"autoload",
"the",
"provided",
"module",
"name",
"by",
"searching",
"for",
"a",
"directory",
"matching",
"the",
"expect",
"path",
"suffix",
".",
"If",
"found",
"the",
"module",
"is",
"created",
"and",
"assigned",
"to",
"+",
"into",
"+",
"s",
"constants",
"with",
"the",
"name",
"+",
"const_name",
"+",
".",
"Provided",
"that",
"the",
"directory",
"was",
"loaded",
"from",
"a",
"reloadable",
"base",
"path",
"it",
"is",
"added",
"to",
"the",
"set",
"of",
"constants",
"that",
"are",
"to",
"be",
"unloaded",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb#L357-L363 |
1,786 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb | ActiveSupport.Dependencies.qualified_name_for | def qualified_name_for(mod, name)
mod_name = to_constant_name mod
(%w(Object Kernel).include? mod_name) ? name.to_s : "#{mod_name}::#{name}"
end | ruby | def qualified_name_for(mod, name)
mod_name = to_constant_name mod
(%w(Object Kernel).include? mod_name) ? name.to_s : "#{mod_name}::#{name}"
end | [
"def",
"qualified_name_for",
"(",
"mod",
",",
"name",
")",
"mod_name",
"=",
"to_constant_name",
"mod",
"(",
"%w(",
"Object",
"Kernel",
")",
".",
"include?",
"mod_name",
")",
"?",
"name",
".",
"to_s",
":",
"\"#{mod_name}::#{name}\"",
"end"
] | Return the constant path for the provided parent and constant name. | [
"Return",
"the",
"constant",
"path",
"for",
"the",
"provided",
"parent",
"and",
"constant",
"name",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb#L390-L393 |
1,787 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb | ActiveSupport.Dependencies.load_missing_constant | def load_missing_constant(from_mod, const_name)
log_call from_mod, const_name
if from_mod == Kernel
if ::Object.const_defined?(const_name)
log "Returning Object::#{const_name} for Kernel::#{const_name}"
return ::Object.const_get(const_name)
else
log "Substituting Object for Kernel"
from_mod = Object
end
end
# If we have an anonymous module, all we can do is attempt to load from Object.
from_mod = Object if from_mod.name.blank?
unless qualified_const_defined?(from_mod.name) && from_mod.name.constantize.object_id == from_mod.object_id
raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!"
end
raise ArgumentError, "#{from_mod} is not missing constant #{const_name}!" if uninherited_const_defined?(from_mod, const_name)
qualified_name = qualified_name_for from_mod, const_name
path_suffix = qualified_name.underscore
name_error = NameError.new("uninitialized constant #{qualified_name}")
file_path = search_for_file(path_suffix)
if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load
require_or_load file_path
raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless uninherited_const_defined?(from_mod, const_name)
return from_mod.const_get(const_name)
elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix)
return mod
elsif (parent = from_mod.parent) && parent != from_mod &&
! from_mod.parents.any? { |p| uninherited_const_defined?(p, const_name) }
# If our parents do not have a constant named +const_name+ then we are free
# to attempt to load upwards. If they do have such a constant, then this
# const_missing must be due to from_mod::const_name, which should not
# return constants from from_mod's parents.
begin
return parent.const_missing(const_name)
rescue NameError => e
raise unless e.missing_name? qualified_name_for(parent, const_name)
raise name_error
end
else
raise name_error
end
end | ruby | def load_missing_constant(from_mod, const_name)
log_call from_mod, const_name
if from_mod == Kernel
if ::Object.const_defined?(const_name)
log "Returning Object::#{const_name} for Kernel::#{const_name}"
return ::Object.const_get(const_name)
else
log "Substituting Object for Kernel"
from_mod = Object
end
end
# If we have an anonymous module, all we can do is attempt to load from Object.
from_mod = Object if from_mod.name.blank?
unless qualified_const_defined?(from_mod.name) && from_mod.name.constantize.object_id == from_mod.object_id
raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!"
end
raise ArgumentError, "#{from_mod} is not missing constant #{const_name}!" if uninherited_const_defined?(from_mod, const_name)
qualified_name = qualified_name_for from_mod, const_name
path_suffix = qualified_name.underscore
name_error = NameError.new("uninitialized constant #{qualified_name}")
file_path = search_for_file(path_suffix)
if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load
require_or_load file_path
raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless uninherited_const_defined?(from_mod, const_name)
return from_mod.const_get(const_name)
elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix)
return mod
elsif (parent = from_mod.parent) && parent != from_mod &&
! from_mod.parents.any? { |p| uninherited_const_defined?(p, const_name) }
# If our parents do not have a constant named +const_name+ then we are free
# to attempt to load upwards. If they do have such a constant, then this
# const_missing must be due to from_mod::const_name, which should not
# return constants from from_mod's parents.
begin
return parent.const_missing(const_name)
rescue NameError => e
raise unless e.missing_name? qualified_name_for(parent, const_name)
raise name_error
end
else
raise name_error
end
end | [
"def",
"load_missing_constant",
"(",
"from_mod",
",",
"const_name",
")",
"log_call",
"from_mod",
",",
"const_name",
"if",
"from_mod",
"==",
"Kernel",
"if",
"::",
"Object",
".",
"const_defined?",
"(",
"const_name",
")",
"log",
"\"Returning Object::#{const_name} for Kernel::#{const_name}\"",
"return",
"::",
"Object",
".",
"const_get",
"(",
"const_name",
")",
"else",
"log",
"\"Substituting Object for Kernel\"",
"from_mod",
"=",
"Object",
"end",
"end",
"# If we have an anonymous module, all we can do is attempt to load from Object.",
"from_mod",
"=",
"Object",
"if",
"from_mod",
".",
"name",
".",
"blank?",
"unless",
"qualified_const_defined?",
"(",
"from_mod",
".",
"name",
")",
"&&",
"from_mod",
".",
"name",
".",
"constantize",
".",
"object_id",
"==",
"from_mod",
".",
"object_id",
"raise",
"ArgumentError",
",",
"\"A copy of #{from_mod} has been removed from the module tree but is still active!\"",
"end",
"raise",
"ArgumentError",
",",
"\"#{from_mod} is not missing constant #{const_name}!\"",
"if",
"uninherited_const_defined?",
"(",
"from_mod",
",",
"const_name",
")",
"qualified_name",
"=",
"qualified_name_for",
"from_mod",
",",
"const_name",
"path_suffix",
"=",
"qualified_name",
".",
"underscore",
"name_error",
"=",
"NameError",
".",
"new",
"(",
"\"uninitialized constant #{qualified_name}\"",
")",
"file_path",
"=",
"search_for_file",
"(",
"path_suffix",
")",
"if",
"file_path",
"&&",
"!",
"loaded",
".",
"include?",
"(",
"File",
".",
"expand_path",
"(",
"file_path",
")",
")",
"# We found a matching file to load",
"require_or_load",
"file_path",
"raise",
"LoadError",
",",
"\"Expected #{file_path} to define #{qualified_name}\"",
"unless",
"uninherited_const_defined?",
"(",
"from_mod",
",",
"const_name",
")",
"return",
"from_mod",
".",
"const_get",
"(",
"const_name",
")",
"elsif",
"mod",
"=",
"autoload_module!",
"(",
"from_mod",
",",
"const_name",
",",
"qualified_name",
",",
"path_suffix",
")",
"return",
"mod",
"elsif",
"(",
"parent",
"=",
"from_mod",
".",
"parent",
")",
"&&",
"parent",
"!=",
"from_mod",
"&&",
"!",
"from_mod",
".",
"parents",
".",
"any?",
"{",
"|",
"p",
"|",
"uninherited_const_defined?",
"(",
"p",
",",
"const_name",
")",
"}",
"# If our parents do not have a constant named +const_name+ then we are free",
"# to attempt to load upwards. If they do have such a constant, then this",
"# const_missing must be due to from_mod::const_name, which should not",
"# return constants from from_mod's parents.",
"begin",
"return",
"parent",
".",
"const_missing",
"(",
"const_name",
")",
"rescue",
"NameError",
"=>",
"e",
"raise",
"unless",
"e",
".",
"missing_name?",
"qualified_name_for",
"(",
"parent",
",",
"const_name",
")",
"raise",
"name_error",
"end",
"else",
"raise",
"name_error",
"end",
"end"
] | Load the constant named +const_name+ which is missing from +from_mod+. If
it is not possible to load the constant into from_mod, try its parent module
using const_missing. | [
"Load",
"the",
"constant",
"named",
"+",
"const_name",
"+",
"which",
"is",
"missing",
"from",
"+",
"from_mod",
"+",
".",
"If",
"it",
"is",
"not",
"possible",
"to",
"load",
"the",
"constant",
"into",
"from_mod",
"try",
"its",
"parent",
"module",
"using",
"const_missing",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb#L398-L445 |
1,788 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb | ActiveSupport.Dependencies.remove_unloadable_constants! | def remove_unloadable_constants!
autoloaded_constants.each { |const| remove_constant const }
autoloaded_constants.clear
explicitly_unloadable_constants.each { |const| remove_constant const }
end | ruby | def remove_unloadable_constants!
autoloaded_constants.each { |const| remove_constant const }
autoloaded_constants.clear
explicitly_unloadable_constants.each { |const| remove_constant const }
end | [
"def",
"remove_unloadable_constants!",
"autoloaded_constants",
".",
"each",
"{",
"|",
"const",
"|",
"remove_constant",
"const",
"}",
"autoloaded_constants",
".",
"clear",
"explicitly_unloadable_constants",
".",
"each",
"{",
"|",
"const",
"|",
"remove_constant",
"const",
"}",
"end"
] | Remove the constants that have been autoloaded, and those that have been
marked for unloading. | [
"Remove",
"the",
"constants",
"that",
"have",
"been",
"autoloaded",
"and",
"those",
"that",
"have",
"been",
"marked",
"for",
"unloading",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb#L449-L453 |
1,789 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb | ActiveSupport.Dependencies.autoloaded? | def autoloaded?(desc)
# No name => anonymous module.
return false if desc.is_a?(Module) && desc.name.blank?
name = to_constant_name desc
return false unless qualified_const_defined? name
return autoloaded_constants.include?(name)
end | ruby | def autoloaded?(desc)
# No name => anonymous module.
return false if desc.is_a?(Module) && desc.name.blank?
name = to_constant_name desc
return false unless qualified_const_defined? name
return autoloaded_constants.include?(name)
end | [
"def",
"autoloaded?",
"(",
"desc",
")",
"# No name => anonymous module.",
"return",
"false",
"if",
"desc",
".",
"is_a?",
"(",
"Module",
")",
"&&",
"desc",
".",
"name",
".",
"blank?",
"name",
"=",
"to_constant_name",
"desc",
"return",
"false",
"unless",
"qualified_const_defined?",
"name",
"return",
"autoloaded_constants",
".",
"include?",
"(",
"name",
")",
"end"
] | Determine if the given constant has been automatically loaded. | [
"Determine",
"if",
"the",
"given",
"constant",
"has",
"been",
"automatically",
"loaded",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb#L456-L462 |
1,790 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb | ActiveSupport.Dependencies.mark_for_unload | def mark_for_unload(const_desc)
name = to_constant_name const_desc
if explicitly_unloadable_constants.include? name
return false
else
explicitly_unloadable_constants << name
return true
end
end | ruby | def mark_for_unload(const_desc)
name = to_constant_name const_desc
if explicitly_unloadable_constants.include? name
return false
else
explicitly_unloadable_constants << name
return true
end
end | [
"def",
"mark_for_unload",
"(",
"const_desc",
")",
"name",
"=",
"to_constant_name",
"const_desc",
"if",
"explicitly_unloadable_constants",
".",
"include?",
"name",
"return",
"false",
"else",
"explicitly_unloadable_constants",
"<<",
"name",
"return",
"true",
"end",
"end"
] | Mark the provided constant name for unloading. This constant will be
unloaded on each request, not just the next one. | [
"Mark",
"the",
"provided",
"constant",
"name",
"for",
"unloading",
".",
"This",
"constant",
"will",
"be",
"unloaded",
"on",
"each",
"request",
"not",
"just",
"the",
"next",
"one",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb#L472-L480 |
1,791 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/yaml/baseemitter.rb | YAML.BaseEmitter.indent_text | def indent_text( text, mod, first_line = true )
return "" if text.to_s.empty?
spacing = indent( mod )
text = text.gsub( /\A([^\n])/, "#{ spacing }\\1" ) if first_line
return text.gsub( /\n^([^\n])/, "\n#{spacing}\\1" )
end | ruby | def indent_text( text, mod, first_line = true )
return "" if text.to_s.empty?
spacing = indent( mod )
text = text.gsub( /\A([^\n])/, "#{ spacing }\\1" ) if first_line
return text.gsub( /\n^([^\n])/, "\n#{spacing}\\1" )
end | [
"def",
"indent_text",
"(",
"text",
",",
"mod",
",",
"first_line",
"=",
"true",
")",
"return",
"\"\"",
"if",
"text",
".",
"to_s",
".",
"empty?",
"spacing",
"=",
"indent",
"(",
"mod",
")",
"text",
"=",
"text",
".",
"gsub",
"(",
"/",
"\\A",
"\\n",
"/",
",",
"\"#{ spacing }\\\\1\"",
")",
"if",
"first_line",
"return",
"text",
".",
"gsub",
"(",
"/",
"\\n",
"\\n",
"/",
",",
"\"\\n#{spacing}\\\\1\"",
")",
"end"
] | Write a text block with the current indent | [
"Write",
"a",
"text",
"block",
"with",
"the",
"current",
"indent"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/yaml/baseemitter.rb#L100-L105 |
1,792 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.9/yaml/baseemitter.rb | YAML.BaseEmitter.indent | def indent( mod = nil )
#p [ self.id, level, mod, :INDENT ]
if level <= 0
mod ||= 0
else
mod ||= options(:Indent)
mod += ( level - 1 ) * options(:Indent)
end
return " " * mod
end | ruby | def indent( mod = nil )
#p [ self.id, level, mod, :INDENT ]
if level <= 0
mod ||= 0
else
mod ||= options(:Indent)
mod += ( level - 1 ) * options(:Indent)
end
return " " * mod
end | [
"def",
"indent",
"(",
"mod",
"=",
"nil",
")",
"#p [ self.id, level, mod, :INDENT ]",
"if",
"level",
"<=",
"0",
"mod",
"||=",
"0",
"else",
"mod",
"||=",
"options",
"(",
":Indent",
")",
"mod",
"+=",
"(",
"level",
"-",
"1",
")",
"*",
"options",
"(",
":Indent",
")",
"end",
"return",
"\" \"",
"*",
"mod",
"end"
] | Write a current indent | [
"Write",
"a",
"current",
"indent"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.9/yaml/baseemitter.rb#L110-L119 |
1,793 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/net/ftp.rb | Net.FTP.getbinaryfile | def getbinaryfile(remotefile, localfile = File.basename(remotefile),
blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
if @resume
rest_offset = File.size?(localfile)
f = open(localfile, "a")
else
rest_offset = nil
f = open(localfile, "w")
end
begin
f.binmode
retrbinary("RETR " + remotefile, blocksize, rest_offset) do |data|
f.write(data)
yield(data) if block
end
ensure
f.close
end
end | ruby | def getbinaryfile(remotefile, localfile = File.basename(remotefile),
blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
if @resume
rest_offset = File.size?(localfile)
f = open(localfile, "a")
else
rest_offset = nil
f = open(localfile, "w")
end
begin
f.binmode
retrbinary("RETR " + remotefile, blocksize, rest_offset) do |data|
f.write(data)
yield(data) if block
end
ensure
f.close
end
end | [
"def",
"getbinaryfile",
"(",
"remotefile",
",",
"localfile",
"=",
"File",
".",
"basename",
"(",
"remotefile",
")",
",",
"blocksize",
"=",
"DEFAULT_BLOCKSIZE",
",",
"&",
"block",
")",
"# :yield: data",
"if",
"@resume",
"rest_offset",
"=",
"File",
".",
"size?",
"(",
"localfile",
")",
"f",
"=",
"open",
"(",
"localfile",
",",
"\"a\"",
")",
"else",
"rest_offset",
"=",
"nil",
"f",
"=",
"open",
"(",
"localfile",
",",
"\"w\"",
")",
"end",
"begin",
"f",
".",
"binmode",
"retrbinary",
"(",
"\"RETR \"",
"+",
"remotefile",
",",
"blocksize",
",",
"rest_offset",
")",
"do",
"|",
"data",
"|",
"f",
".",
"write",
"(",
"data",
")",
"yield",
"(",
"data",
")",
"if",
"block",
"end",
"ensure",
"f",
".",
"close",
"end",
"end"
] | Retrieves +remotefile+ in binary mode, storing the result in +localfile+.
If a block is supplied, it is passed the retrieved data in +blocksize+
chunks. | [
"Retrieves",
"+",
"remotefile",
"+",
"in",
"binary",
"mode",
"storing",
"the",
"result",
"in",
"+",
"localfile",
"+",
".",
"If",
"a",
"block",
"is",
"supplied",
"it",
"is",
"passed",
"the",
"retrieved",
"data",
"in",
"+",
"blocksize",
"+",
"chunks",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/net/ftp.rb#L493-L511 |
1,794 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rinda/ring.rb | Rinda.RingServer.do_write | def do_write(msg)
Thread.new do
begin
tuple, sec = Marshal.load(msg)
@ts.write(tuple, sec)
rescue
end
end
end | ruby | def do_write(msg)
Thread.new do
begin
tuple, sec = Marshal.load(msg)
@ts.write(tuple, sec)
rescue
end
end
end | [
"def",
"do_write",
"(",
"msg",
")",
"Thread",
".",
"new",
"do",
"begin",
"tuple",
",",
"sec",
"=",
"Marshal",
".",
"load",
"(",
"msg",
")",
"@ts",
".",
"write",
"(",
"tuple",
",",
"sec",
")",
"rescue",
"end",
"end",
"end"
] | Extracts the response URI from +msg+ and adds it to TupleSpace where it
will be picked up by +reply_service+ for notification. | [
"Extracts",
"the",
"response",
"URI",
"from",
"+",
"msg",
"+",
"and",
"adds",
"it",
"to",
"TupleSpace",
"where",
"it",
"will",
"be",
"picked",
"up",
"by",
"+",
"reply_service",
"+",
"for",
"notification",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rinda/ring.rb#L57-L65 |
1,795 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rinda/ring.rb | Rinda.RingFinger.lookup_ring | def lookup_ring(timeout=5, &block)
return lookup_ring_any(timeout) unless block_given?
msg = Marshal.dump([[:lookup_ring, DRbObject.new(block)], timeout])
@broadcast_list.each do |it|
soc = UDPSocket.open
begin
soc.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
soc.send(msg, 0, it, @port)
rescue
nil
ensure
soc.close
end
end
sleep(timeout)
end | ruby | def lookup_ring(timeout=5, &block)
return lookup_ring_any(timeout) unless block_given?
msg = Marshal.dump([[:lookup_ring, DRbObject.new(block)], timeout])
@broadcast_list.each do |it|
soc = UDPSocket.open
begin
soc.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
soc.send(msg, 0, it, @port)
rescue
nil
ensure
soc.close
end
end
sleep(timeout)
end | [
"def",
"lookup_ring",
"(",
"timeout",
"=",
"5",
",",
"&",
"block",
")",
"return",
"lookup_ring_any",
"(",
"timeout",
")",
"unless",
"block_given?",
"msg",
"=",
"Marshal",
".",
"dump",
"(",
"[",
"[",
":lookup_ring",
",",
"DRbObject",
".",
"new",
"(",
"block",
")",
"]",
",",
"timeout",
"]",
")",
"@broadcast_list",
".",
"each",
"do",
"|",
"it",
"|",
"soc",
"=",
"UDPSocket",
".",
"open",
"begin",
"soc",
".",
"setsockopt",
"(",
"Socket",
"::",
"SOL_SOCKET",
",",
"Socket",
"::",
"SO_BROADCAST",
",",
"true",
")",
"soc",
".",
"send",
"(",
"msg",
",",
"0",
",",
"it",
",",
"@port",
")",
"rescue",
"nil",
"ensure",
"soc",
".",
"close",
"end",
"end",
"sleep",
"(",
"timeout",
")",
"end"
] | Looks up RingServers waiting +timeout+ seconds. RingServers will be
given +block+ as a callback, which will be called with the remote
TupleSpace. | [
"Looks",
"up",
"RingServers",
"waiting",
"+",
"timeout",
"+",
"seconds",
".",
"RingServers",
"will",
"be",
"given",
"+",
"block",
"+",
"as",
"a",
"callback",
"which",
"will",
"be",
"called",
"with",
"the",
"remote",
"TupleSpace",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rinda/ring.rb#L176-L192 |
1,796 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/chm_generator.rb | Generators.CHMGenerator.create_project_file | def create_project_file
template = TemplatePage.new(RDoc::Page::HPP_FILE)
values = { "title" => @options.title, "opname" => @op_name }
files = []
@files.each do |f|
files << { "html_file_name" => f.path }
end
values['all_html_files'] = files
File.open(@project_name, "w") do |f|
template.write_html_on(f, values)
end
end | ruby | def create_project_file
template = TemplatePage.new(RDoc::Page::HPP_FILE)
values = { "title" => @options.title, "opname" => @op_name }
files = []
@files.each do |f|
files << { "html_file_name" => f.path }
end
values['all_html_files'] = files
File.open(@project_name, "w") do |f|
template.write_html_on(f, values)
end
end | [
"def",
"create_project_file",
"template",
"=",
"TemplatePage",
".",
"new",
"(",
"RDoc",
"::",
"Page",
"::",
"HPP_FILE",
")",
"values",
"=",
"{",
"\"title\"",
"=>",
"@options",
".",
"title",
",",
"\"opname\"",
"=>",
"@op_name",
"}",
"files",
"=",
"[",
"]",
"@files",
".",
"each",
"do",
"|",
"f",
"|",
"files",
"<<",
"{",
"\"html_file_name\"",
"=>",
"f",
".",
"path",
"}",
"end",
"values",
"[",
"'all_html_files'",
"]",
"=",
"files",
"File",
".",
"open",
"(",
"@project_name",
",",
"\"w\"",
")",
"do",
"|",
"f",
"|",
"template",
".",
"write_html_on",
"(",
"f",
",",
"values",
")",
"end",
"end"
] | The project file links together all the various
files that go to make up the help. | [
"The",
"project",
"file",
"links",
"together",
"all",
"the",
"various",
"files",
"that",
"go",
"to",
"make",
"up",
"the",
"help",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/chm_generator.rb#L54-L67 |
1,797 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/chm_generator.rb | Generators.CHMGenerator.create_contents_and_index | def create_contents_and_index
contents = []
index = []
(@files+@classes).sort.each do |entry|
content_entry = { "c_name" => entry.name, "ref" => entry.path }
index << { "name" => entry.name, "aref" => entry.path }
internals = []
methods = entry.build_method_summary_list(entry.path)
content_entry["methods"] = methods unless methods.empty?
contents << content_entry
index.concat methods
end
values = { "contents" => contents }
template = TemplatePage.new(RDoc::Page::CONTENTS)
File.open("contents.hhc", "w") do |f|
template.write_html_on(f, values)
end
values = { "index" => index }
template = TemplatePage.new(RDoc::Page::CHM_INDEX)
File.open("index.hhk", "w") do |f|
template.write_html_on(f, values)
end
end | ruby | def create_contents_and_index
contents = []
index = []
(@files+@classes).sort.each do |entry|
content_entry = { "c_name" => entry.name, "ref" => entry.path }
index << { "name" => entry.name, "aref" => entry.path }
internals = []
methods = entry.build_method_summary_list(entry.path)
content_entry["methods"] = methods unless methods.empty?
contents << content_entry
index.concat methods
end
values = { "contents" => contents }
template = TemplatePage.new(RDoc::Page::CONTENTS)
File.open("contents.hhc", "w") do |f|
template.write_html_on(f, values)
end
values = { "index" => index }
template = TemplatePage.new(RDoc::Page::CHM_INDEX)
File.open("index.hhk", "w") do |f|
template.write_html_on(f, values)
end
end | [
"def",
"create_contents_and_index",
"contents",
"=",
"[",
"]",
"index",
"=",
"[",
"]",
"(",
"@files",
"+",
"@classes",
")",
".",
"sort",
".",
"each",
"do",
"|",
"entry",
"|",
"content_entry",
"=",
"{",
"\"c_name\"",
"=>",
"entry",
".",
"name",
",",
"\"ref\"",
"=>",
"entry",
".",
"path",
"}",
"index",
"<<",
"{",
"\"name\"",
"=>",
"entry",
".",
"name",
",",
"\"aref\"",
"=>",
"entry",
".",
"path",
"}",
"internals",
"=",
"[",
"]",
"methods",
"=",
"entry",
".",
"build_method_summary_list",
"(",
"entry",
".",
"path",
")",
"content_entry",
"[",
"\"methods\"",
"]",
"=",
"methods",
"unless",
"methods",
".",
"empty?",
"contents",
"<<",
"content_entry",
"index",
".",
"concat",
"methods",
"end",
"values",
"=",
"{",
"\"contents\"",
"=>",
"contents",
"}",
"template",
"=",
"TemplatePage",
".",
"new",
"(",
"RDoc",
"::",
"Page",
"::",
"CONTENTS",
")",
"File",
".",
"open",
"(",
"\"contents.hhc\"",
",",
"\"w\"",
")",
"do",
"|",
"f",
"|",
"template",
".",
"write_html_on",
"(",
"f",
",",
"values",
")",
"end",
"values",
"=",
"{",
"\"index\"",
"=>",
"index",
"}",
"template",
"=",
"TemplatePage",
".",
"new",
"(",
"RDoc",
"::",
"Page",
"::",
"CHM_INDEX",
")",
"File",
".",
"open",
"(",
"\"index.hhk\"",
",",
"\"w\"",
")",
"do",
"|",
"f",
"|",
"template",
".",
"write_html_on",
"(",
"f",
",",
"values",
")",
"end",
"end"
] | The contents is a list of all files and modules.
For each we include as sub-entries the list
of methods they contain. As we build the contents
we also build an index file | [
"The",
"contents",
"is",
"a",
"list",
"of",
"all",
"files",
"and",
"modules",
".",
"For",
"each",
"we",
"include",
"as",
"sub",
"-",
"entries",
"the",
"list",
"of",
"methods",
"they",
"contain",
".",
"As",
"we",
"build",
"the",
"contents",
"we",
"also",
"build",
"an",
"index",
"file"
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rdoc/generators/chm_generator.rb#L74-L102 |
1,798 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rinda/tuplespace.rb | Rinda.TupleEntry.get_renewer | def get_renewer(it)
case it
when Numeric, true, nil
return it, nil
else
begin
return it.renew, it
rescue Exception
return it, nil
end
end
end | ruby | def get_renewer(it)
case it
when Numeric, true, nil
return it, nil
else
begin
return it.renew, it
rescue Exception
return it, nil
end
end
end | [
"def",
"get_renewer",
"(",
"it",
")",
"case",
"it",
"when",
"Numeric",
",",
"true",
",",
"nil",
"return",
"it",
",",
"nil",
"else",
"begin",
"return",
"it",
".",
"renew",
",",
"it",
"rescue",
"Exception",
"return",
"it",
",",
"nil",
"end",
"end",
"end"
] | Returns a valid argument to make_expires and the renewer or nil.
Given +true+, +nil+, or Numeric, returns that value and +nil+ (no actual
renewer). Otherwise it returns an expiry value from calling +it.renew+
and the renewer. | [
"Returns",
"a",
"valid",
"argument",
"to",
"make_expires",
"and",
"the",
"renewer",
"or",
"nil",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rinda/tuplespace.rb#L145-L156 |
1,799 | ThoughtWorksStudios/oauth2_provider | tools/jruby-1.5.1/lib/ruby/1.8/rinda/tuplespace.rb | Rinda.TupleBag.push | def push(tuple)
key = bin_key(tuple)
@hash[key] ||= TupleBin.new
@hash[key].add(tuple)
end | ruby | def push(tuple)
key = bin_key(tuple)
@hash[key] ||= TupleBin.new
@hash[key].add(tuple)
end | [
"def",
"push",
"(",
"tuple",
")",
"key",
"=",
"bin_key",
"(",
"tuple",
")",
"@hash",
"[",
"key",
"]",
"||=",
"TupleBin",
".",
"new",
"@hash",
"[",
"key",
"]",
".",
"add",
"(",
"tuple",
")",
"end"
] | Add +tuple+ to the TupleBag. | [
"Add",
"+",
"tuple",
"+",
"to",
"the",
"TupleBag",
"."
] | d54702f194edd05389968cf8947465860abccc5d | https://github.com/ThoughtWorksStudios/oauth2_provider/blob/d54702f194edd05389968cf8947465860abccc5d/tools/jruby-1.5.1/lib/ruby/1.8/rinda/tuplespace.rb#L333-L337 |
Subsets and Splits