Rails_xss Plugin

I installed the rails_xss plugin, for
the main purpose of seeing what will
break with Rails 3.0 (where the behaviour
of the plugin is the default). I think
I've fixed everything, but let me know if you
see stuff that is HTML-escaped, which
shouldn't be.

As a side benefit, we now use Erubis,
rather than ERB, to render templates.
They tell me it's faster ...
This commit is contained in:
Jacques Distler 2010-05-26 00:27:49 -05:00
parent d6be09e0f0
commit a5e08f7bcc
343 changed files with 43874 additions and 37 deletions

View file

@ -0,0 +1,3 @@
: release 1.0.0 (2006-03-12)
- first release (1.0.0)

View file

@ -0,0 +1,57 @@
= README
revision:: $Rev: 1 $
release:: $Release: 1.0.0 $
copyright:: copyright(c) 2006 kuwata-lab.com all rights reserved.
== Introduction
'abstract.rb' is a library which enable you to define abstract method in Ruby.
The followings are examples:
## example1. (shorter notation)
require 'rubygems' # if installed with 'gem install'
require 'abstract'
class Foo
abstract_method 'arg1, arg2=""', :method1, :method2, :method3
end
## example2. (RDoc friendly notation)
require 'rubygems' # if installed with 'gem install'
require 'abstract'
class Bar
# ... method1 description ...
def method1(arg1, arg2="")
not_implemented
end
# ... method2 description ...
def method2(arg1, arg2="")
not_implemented
end
end
Abstract method makes your code more descriptive.
It is useful even for dynamic language such as Ruby.
== Installation
* Type 'gem install -r abstract' with root account if you have installed RubyGems.
* Or type 'ruby setup.rb' with root account if you can be root account.
* Or copy lib/abstract.rb into proper directory such as '/usr/local/lib/ruby/site_ruby'.
== License
Ruby's
== Copyright
copyright(c) 2006 kuwata-lab.com all rights reserved.

View file

@ -0,0 +1,48 @@
#!/usr/bin/env ruby
###
### RubyGems Specification file for abstract.rb
###
### $Rev: 1 $
### $Release: 1.0.0 $
### copyright(c) 2006 kuwata-lab.com all rights reserved.
###
require 'rubygems'
spec = Gem::Specification.new do |s|
## package information
s.name = 'abstract'
s.author = 'makoto kuwata'
s.version = ("$Release: 1.0.0 $" =~ /[\.\d]+/) && $&
s.platform = Gem::Platform::RUBY
s.homepage = 'http://rubyforge.org/projects/abstract'
s.summary = "a library which enable you to define abstract method in Ruby"
s.description = <<-'END'
'abstract.rb' is a library which enable you to define abstract method in Ruby.
END
## files
files = []
files += Dir.glob('lib/**/*')
files += Dir.glob('test/**/*')
files += %w[README.txt ChangeLog setup.rb abstract.gemspec]
#s.files = files.delete_if { |path| path =~ /\.svn/ }
s.files = files
s.test_file = 'test/test.rb'
end
# Quick fix for Ruby 1.8.3 / YAML bug (thanks to Ross Bamford)
if (RUBY_VERSION == '1.8.3')
def spec.to_yaml
out = super
out = '--- ' + out unless out =~ /^---/
out
end
end
if $0 == __FILE__
Gem::manage_gems
Gem::Builder.new(spec).build
end

View file

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Kernel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Kernel</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../files/lib/abstract_rb.html">
lib/abstract.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000002">not_implemented</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Private Instance methods</h3>
<div id="method-M000002" class="method-detail">
<a name="M000002"></a>
<div class="method-heading">
<a href="Kernel.src/M000002.html" target="Code" class="method-signature"
onclick="popupCode('Kernel.src/M000002.html');return false;">
<span class="method-name">not_implemented</span><span class="method-args">(</span>
</a>
</div>
<div class="method-description">
<p>
raise NotImplementedError
</p>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>not_implemented (Kernel)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
<pre><span class="ruby-comment cmt"># File lib/abstract.rb, line 65</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">not_implemented</span> <span class="ruby-comment cmt">#:doc:</span>
<span class="ruby-identifier">backtrace</span> = <span class="ruby-identifier">caller</span>()
<span class="ruby-identifier">method_name</span> = (<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">shift</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/`(\w+)'$/</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">$1</span>
<span class="ruby-identifier">mesg</span> = <span class="ruby-node">&quot;class #{self.class.name} must implement abstract method '#{method_name}()'.&quot;</span>
<span class="ruby-comment cmt">#mesg = &quot;#{self.class.name}##{method_name}() is not implemented.&quot;</span>
<span class="ruby-identifier">err</span> = <span class="ruby-constant">NotImplementedError</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">mesg</span>
<span class="ruby-identifier">err</span>.<span class="ruby-identifier">set_backtrace</span> <span class="ruby-identifier">backtrace</span>
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">err</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>

View file

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Module</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Module</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../files/lib/abstract_rb.html">
lib/abstract.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000001">abstract_method</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000001" class="method-detail">
<a name="M000001"></a>
<div class="method-heading">
<a href="Module.src/M000001.html" target="Code" class="method-signature"
onclick="popupCode('Module.src/M000001.html');return false;">
<span class="method-name">abstract_method</span><span class="method-args">(args_str, *method_names)</span>
</a>
</div>
<div class="method-description">
<p>
define abstract methods
</p>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>abstract_method (Module)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
<pre><span class="ruby-comment cmt"># File lib/abstract.rb, line 41</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">abstract_method</span> <span class="ruby-identifier">args_str</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">method_names</span>
<span class="ruby-identifier">method_names</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">module_eval</span> <span class="ruby-value str">&quot;def \#{name}(\#{args_str})\nmesg = \&quot;class \\\#{self.class.name} must implement abstract method `\#{self.name}#\#{name}()'.\&quot;\n#mesg = \&quot;\\\#{self.class.name}#\#{name}() is not implemented.\&quot;\nerr = NotImplementedError.new mesg\nerr.set_backtrace caller()\nraise err\nend\n&quot;</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>

View file

@ -0,0 +1 @@
Mon Mar 13 06:08:02 JST 2006

View file

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>File: README.txt</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="fileHeader">
<h1>README.txt</h1>
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
<td>README.txt
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
<td>Mon Mar 13 06:08:02 JST 2006</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<h1>README</h1>
<table>
<tr><td valign="top">revision:</td><td>$Rev: 1 $
</td></tr>
<tr><td valign="top">release:</td><td>$Release: 1.0.0 $
</td></tr>
<tr><td valign="top">copyright:</td><td>copyright&#169; 2006 kuwata-lab.com all rights reserved.
</td></tr>
</table>
<h2>Introduction</h2>
<p>
&#8216;abstract.rb&#8217; is a library which enable you to define abstract
method in Ruby.
</p>
<p>
The followings are examples:
</p>
<pre>
## example1. (shorter notation)
require 'rubygems' # if installed with 'gem install'
require 'abstract'
class Foo
abstract_method 'arg1, arg2=&quot;&quot;', :method1, :method2, :method3
end
## example2. (RDoc friendly notation)
require 'rubygems' # if installed with 'gem install'
require 'abstract'
class Bar
# ... method1 description ...
def method1(arg1, arg2=&quot;&quot;)
not_implemented
end
# ... method2 description ...
def method2(arg1, arg2=&quot;&quot;)
not_implemented
end
end
</pre>
<p>
Abstract method makes your code more descriptive. It is useful even for
dynamic language such as Ruby.
</p>
<h2>Installation</h2>
<ul>
<li>Type &#8216;gem install -r abstract&#8217; with root account if you have
installed RubyGems.
</li>
<li>Or type &#8216;ruby setup.rb&#8217; with root account if you can be root
account.
</li>
<li>Or copy lib/abstract.rb into proper directory such as
&#8217;/usr/local/lib/ruby/site_ruby&#8217;.
</li>
</ul>
<h2>License</h2>
<p>
Ruby&#8217;s
</p>
<h2>Copyright</h2>
<p>
copyright&#169; 2006 kuwata-lab.com all rights reserved.
</p>
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>File: abstract.rb</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="fileHeader">
<h1>abstract.rb</h1>
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Path:</strong></td>
<td>lib/abstract.rb
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
<td>Mon Mar 13 06:08:02 JST 2006</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
$Rev: 1 $ $Release: 1.0.0 $ copyright&#169; 2006 kuwata-lab.com all rights
reserved.
</p>
<p>
helper to define abstract method in Ruby.
</p>
<p>
example1. (shorter notation)
</p>
<pre>
require 'abstract'
class Foo
abstract_method 'arg1, arg2=&quot;&quot;', :method1, :method2, :method3
end
</pre>
<p>
example2. (RDoc friendly notation)
</p>
<pre>
require 'abstract'
class Bar
# ... method1 description ...
def method1(arg1, arg2=&quot;&quot;)
not_implemented
end
# ... method2 description ...
def method2(arg1, arg2=&quot;&quot;)
not_implemented
end
end
</pre>
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Classes
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Classes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
<base target="docwin" />
</head>
<body>
<div id="index">
<h1 class="section-bar">Classes</h1>
<div id="index-entries">
<a href="classes/Kernel.html">Kernel</a><br />
<a href="classes/Module.html">Module</a><br />
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Files
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Files</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
<base target="docwin" />
</head>
<body>
<div id="index">
<h1 class="section-bar">Files</h1>
<div id="index-entries">
<a href="files/README_txt.html">README.txt</a><br />
<a href="files/lib/abstract_rb.html">lib/abstract.rb</a><br />
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Methods
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Methods</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="rdoc-style.css" type="text/css" />
<base target="docwin" />
</head>
<body>
<div id="index">
<h1 class="section-bar">Methods</h1>
<div id="index-entries">
<a href="classes/Module.html#M000001">abstract_method (Module)</a><br />
<a href="classes/Kernel.html#M000002">not_implemented (Kernel)</a><br />
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<!--
abstract.rb documentation
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>abstract.rb documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<frameset rows="20%, 80%">
<frameset cols="25%,35%,45%">
<frame src="fr_file_index.html" title="Files" name="Files" />
<frame src="fr_class_index.html" name="Classes" />
<frame src="fr_method_index.html" name="Methods" />
</frameset>
<frame src="files/README_txt.html" name="docwin" />
</frameset>
</html>

View file

@ -0,0 +1,208 @@
body {
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 90%;
margin: 0;
margin-left: 40px;
padding: 0;
background: white;
}
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
h1 { font-size: 150%; }
h2,h3,h4 { margin-top: 1em; }
a { background: #eef; color: #039; text-decoration: none; }
a:hover { background: #039; color: #eef; }
/* Override the base stylesheet's Anchor inside a table cell */
td > a {
background: transparent;
color: #039;
text-decoration: none;
}
/* and inside a section title */
.section-title > a {
background: transparent;
color: #eee;
text-decoration: none;
}
/* === Structural elements =================================== */
div#index {
margin: 0;
margin-left: -40px;
padding: 0;
font-size: 90%;
}
div#index a {
margin-left: 0.7em;
}
div#index .section-bar {
margin-left: 0px;
padding-left: 0.7em;
background: #ccc;
font-size: small;
}
div#classHeader, div#fileHeader {
width: auto;
color: white;
padding: 0.5em 1.5em 0.5em 1.5em;
margin: 0;
margin-left: -40px;
border-bottom: 3px solid #006;
}
div#classHeader a, div#fileHeader a {
background: inherit;
color: white;
}
div#classHeader td, div#fileHeader td {
background: inherit;
color: white;
}
div#fileHeader {
background: #057;
}
div#classHeader {
background: #048;
}
.class-name-in-header {
font-size: 180%;
font-weight: bold;
}
div#bodyContent {
padding: 0 1.5em 0 1.5em;
}
div#description {
padding: 0.5em 1.5em;
background: #efefef;
border: 1px dotted #999;
}
div#description h1,h2,h3,h4,h5,h6 {
color: #125;;
background: transparent;
}
div#validator-badges {
text-align: center;
}
div#validator-badges img { border: 0; }
div#copyright {
color: #333;
background: #efefef;
font: 0.75em sans-serif;
margin-top: 5em;
margin-bottom: 0;
padding: 0.5em 2em;
}
/* === Classes =================================== */
table.header-table {
color: white;
font-size: small;
}
.type-note {
font-size: small;
color: #DEDEDE;
}
.xxsection-bar {
background: #eee;
color: #333;
padding: 3px;
}
.section-bar {
color: #333;
border-bottom: 1px solid #999;
margin-left: -20px;
}
.section-title {
background: #79a;
color: #eee;
padding: 3px;
margin-top: 2em;
margin-left: -30px;
border: 1px solid #999;
}
.top-aligned-row { vertical-align: top }
.bottom-aligned-row { vertical-align: bottom }
/* --- Context section classes ----------------------- */
.context-row { }
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
.context-item-value { font-size: small; color: #448; }
.context-item-desc { color: #333; padding-left: 2em; }
/* --- Method classes -------------------------- */
.method-detail {
background: #efefef;
padding: 0;
margin-top: 0.5em;
margin-bottom: 1em;
border: 1px dotted #ccc;
}
.method-heading {
color: black;
background: #ccc;
border-bottom: 1px solid #666;
padding: 0.2em 0.5em 0 0.5em;
}
.method-signature { color: black; background: inherit; }
.method-name { font-weight: bold; }
.method-args { font-style: italic; }
.method-description { padding: 0 0.5em 0 0.5em; }
/* --- Source code sections -------------------- */
a.source-toggle { font-size: 90%; }
div.method-source-code {
background: #262626;
color: #ffdead;
margin: 1em;
padding: 0.5em;
border: 1px dashed #999;
overflow: hidden;
}
div.method-source-code pre { color: #ffdead; overflow: hidden; }
/* --- Ruby keyword styles --------------------- */
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
.ruby-constant { color: #7fffd4; background: transparent; }
.ruby-keyword { color: #00ffff; background: transparent; }
.ruby-ivar { color: #eedd82; background: transparent; }
.ruby-operator { color: #00ffee; background: transparent; }
.ruby-identifier { color: #ffdead; background: transparent; }
.ruby-node { color: #ffa07a; background: transparent; }
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
.ruby-regexp { color: #ffa07a; background: transparent; }
.ruby-value { color: #7fffd4; background: transparent; }

View file

@ -0,0 +1,75 @@
##
## $Rev: 1 $
## $Release: 1.0.0 $
## copyright(c) 2006 kuwata-lab.com all rights reserved.
##
##
## helper to define abstract method in Ruby.
##
##
## example1. (shorter notation)
##
## require 'abstract'
## class Foo
## abstract_method 'arg1, arg2=""', :method1, :method2, :method3
## end
##
##
## example2. (RDoc friendly notation)
##
## require 'abstract'
## class Bar
## # ... method1 description ...
## def method1(arg1, arg2="")
## not_implemented
## end
##
## # ... method2 description ...
## def method2(arg1, arg2="")
## not_implemented
## end
## end
##
##
class Module
##
## define abstract methods
##
def abstract_method args_str, *method_names
method_names.each do |name|
module_eval <<-END
def #{name}(#{args_str})
mesg = "class \#{self.class.name} must implement abstract method `#{self.name}##{name}()'."
#mesg = "\#{self.class.name}##{name}() is not implemented."
err = NotImplementedError.new mesg
err.set_backtrace caller()
raise err
end
END
end
end
end
##
module Kernel
##
## raise NotImplementedError
##
def not_implemented #:doc:
backtrace = caller()
method_name = (backtrace.shift =~ /`(\w+)'$/) && $1
mesg = "class #{self.class.name} must implement abstract method '#{method_name}()'."
#mesg = "#{self.class.name}##{method_name}() is not implemented."
err = NotImplementedError.new mesg
err.set_backtrace backtrace
raise err
end
private :not_implemented
end

1331
vendor/plugins/abstract_1.0.0/setup.rb vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,91 @@
##
## $Rev: 1 $
## $Release: 1.0.0 $
## copyright(c) 2006 kuwata-lab.com all rights reserved.
##
testdir = File.dirname(File.expand_path(__FILE__))
libdir = File.dirname(testdir) + "/lib"
$: << libdir
require 'test/unit'
require 'abstract'
class Foo
abstract_method "arg1, arg2=''", :m1, :m2, :m3
end
class Bar
def m1(arg1, arg2='')
not_implemented
end
end
class AbstractTest < Test::Unit::TestCase
def _test(obj)
assert_raise(NotImplementedError) do
begin
obj = Foo.new
obj.m1 'a'
rescue => ex
linenum = (ex.backtrace[0] =~ /:(\d+)/) && $1
raise ex
end
end
end
def test_abstract_method1
obj = Foo.new
assert_raise(NotImplementedError) { obj.m1 'a' }
assert_raise(NotImplementedError) { obj.m2 'a', 'b' }
end
def test_abstract_method2
begin
obj = Foo.new
linenum = __LINE__; obj.m1 'a'
rescue NotImplementedError => ex
actual_linenum = (ex.backtrace[0] =~ /:(\d+)/) && $1.to_i
end
assert_equal linenum, actual_linenum
end
def test_not_implemented1
obj = Bar.new
assert_raise(NotImplementedError) { obj.m1 123 }
end
def test_not_implemented2
begin
obj = Bar.new
linenum = __LINE__; obj.m1 'a'
rescue NotImplementedError => ex
actual_linenum = (ex.backtrace[0] =~ /:(\d+)/) && $1.to_i
end
assert_equal linenum, actual_linenum
end
def test_not_implemented3
begin
obj = Bar.new
obj.not_implemented
rescue Exception => ex
assert_instance_of(NoMethodError, ex)
assert_match(/private method/, ex.message)
end
end
end