gitlabhq/doc/code/classes/TreeDecorator.html
2012-12-30 14:43:00 +02:00

281 lines
11 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!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>TreeDecorator</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="banner">
<h1>
<span class="type">Class</span>
TreeDecorator
<span class="parent">&lt;
<a href="ApplicationDecorator.html">ApplicationDecorator</a>
</span>
</h1>
<ul class="files">
<li><a href="../files/app/decorators/tree_decorator_rb.html">app/decorators/tree_decorator.rb</a></li>
</ul>
</div>
<div id="bodyContent">
<div id="content">
<!-- Method ref -->
<div class="sectiontitle">Methods</div>
<dl class="methods">
<dt>B</dt>
<dd>
<ul>
<li>
<a href="#method-i-breadcrumbs">breadcrumbs</a>
</li>
</ul>
</dd>
<dt>R</dt>
<dd>
<ul>
<li>
<a href="#method-i-readme">readme</a>
</li>
</ul>
</dd>
<dt>U</dt>
<dd>
<ul>
<li>
<a href="#method-i-up_dir-3F">up_dir?</a>,
</li>
<li>
<a href="#method-i-up_dir_path">up_dir_path</a>
</li>
</ul>
</dd>
</dl>
<!-- Methods -->
<div class="sectiontitle">Instance Public methods</div>
<div class="method">
<div class="title method-title" id="method-i-breadcrumbs">
<b>breadcrumbs</b>(max_links = 2)
<a href="../classes/TreeDecorator.html#method-i-breadcrumbs" name="method-i-breadcrumbs" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-breadcrumbs_source')" id="l_method-i-breadcrumbs_source">show</a>
</p>
<div id="method-i-breadcrumbs_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/decorators/tree_decorator.rb, line 4</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">breadcrumbs</span>(<span class="ruby-identifier">max_links</span> = <span class="ruby-number">2</span>)
<span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span>
<span class="ruby-identifier">part_path</span> = <span class="ruby-string">&quot;&quot;</span>
<span class="ruby-identifier">parts</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;\/&quot;</span>)
<span class="ruby-comment">#parts = parts[0...-1] if is_blob?</span>
<span class="ruby-keyword">yield</span>(<span class="ruby-identifier">h</span>.<span class="ruby-identifier">link_to</span>(<span class="ruby-string">&quot;..&quot;</span>, <span class="ruby-node">&quot;#&quot;</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">max_links</span>
<span class="ruby-identifier">parts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">part_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">part_path</span>, <span class="ruby-identifier">part</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">part_path</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-identifier">part_path</span> = <span class="ruby-identifier">part</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">part_path</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">last</span>(<span class="ruby-number">2</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">part</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">max_links</span>
<span class="ruby-keyword">yield</span>(<span class="ruby-identifier">h</span>.<span class="ruby-identifier">link_to</span>(<span class="ruby-identifier">h</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-identifier">part</span>, <span class="ruby-identifier">length</span><span class="ruby-operator">:</span> <span class="ruby-number">40</span>), <span class="ruby-identifier">h</span>.<span class="ruby-identifier">project_tree_path</span>(<span class="ruby-identifier">project</span>, <span class="ruby-identifier">h</span>.<span class="ruby-identifier">tree_join</span>(<span class="ruby-identifier">ref</span>, <span class="ruby-identifier">part_path</span>))))
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-readme">
<b>readme</b>()
<a href="../classes/TreeDecorator.html#method-i-readme" name="method-i-readme" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-readme_source')" id="l_method-i-readme_source">show</a>
</p>
<div id="method-i-readme_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/decorators/tree_decorator.rb, line 32</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">readme</span>
<span class="ruby-ivar">@readme</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">contents</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Grit</span><span class="ruby-operator">::</span><span class="ruby-constant">Blob</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%r^readme/</span> }
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-up_dir-3F">
<b>up_dir?</b>()
<a href="../classes/TreeDecorator.html#method-i-up_dir-3F" name="method-i-up_dir-3F" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-up_dir-3F_source')" id="l_method-i-up_dir-3F_source">show</a>
</p>
<div id="method-i-up_dir-3F_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/decorators/tree_decorator.rb, line 23</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">up_dir?</span>
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">present?</span>
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
<div class="method">
<div class="title method-title" id="method-i-up_dir_path">
<b>up_dir_path</b>()
<a href="../classes/TreeDecorator.html#method-i-up_dir_path" name="method-i-up_dir_path" class="permalink">Link</a>
</div>
<div class="description">
</div>
<div class="sourcecode">
<p class="source-link">
Source:
<a href="javascript:toggleSource('method-i-up_dir_path_source')" id="l_method-i-up_dir_path_source">show</a>
</p>
<div id="method-i-up_dir_path_source" class="dyn-source">
<pre><span class="ruby-comment"># File app/decorators/tree_decorator.rb, line 27</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">up_dir_path</span>
<span class="ruby-identifier">file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">path</span>, <span class="ruby-string">&quot;..&quot;</span>)
<span class="ruby-identifier">h</span>.<span class="ruby-identifier">project_tree_path</span>(<span class="ruby-identifier">project</span>, <span class="ruby-identifier">h</span>.<span class="ruby-identifier">tree_join</span>(<span class="ruby-identifier">ref</span>, <span class="ruby-identifier">file</span>))
<span class="ruby-keyword">end</span></pre>
</div>
</div>
</div>
</div>
</div>
</body>
</html>