506 lines
27 KiB
HTML
506 lines
27 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>FakeFS::FileSystem</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" />
|
|
<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>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="banner">
|
|
<h1>
|
|
<span class="type">Module</span>
|
|
FakeFS::FileSystem
|
|
|
|
</h1>
|
|
<ul class="files">
|
|
|
|
<li><a href="../../files/lib/fakefs/file_system_rb.html">lib/fakefs/file_system.rb</a></li>
|
|
|
|
</ul>
|
|
</div>
|
|
<div id="bodyContent">
|
|
<div id="content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sectiontitle">Methods</div>
|
|
<dl class="methods">
|
|
|
|
<dt>A</dt>
|
|
<dd>
|
|
<ul>
|
|
|
|
<li><a href="#M000063">add</a></li>
|
|
|
|
</ul>
|
|
</dd>
|
|
|
|
<dt>C</dt>
|
|
<dd>
|
|
<ul>
|
|
|
|
<li><a href="#M000073">chdir</a>,</li>
|
|
|
|
<li><a href="#M000056">clear</a>,</li>
|
|
|
|
<li><a href="#M000064">clone</a>,</li>
|
|
|
|
<li><a href="#M000078">current_dir</a></li>
|
|
|
|
</ul>
|
|
</dd>
|
|
|
|
<dt>D</dt>
|
|
<dd>
|
|
<ul>
|
|
|
|
<li><a href="#M000072">delete</a>,</li>
|
|
|
|
<li><a href="#M000054">dir_levels</a></li>
|
|
|
|
</ul>
|
|
</dd>
|
|
|
|
<dt>F</dt>
|
|
<dd>
|
|
<ul>
|
|
|
|
<li><a href="#M000057">files</a>,</li>
|
|
|
|
<li><a href="#M000058">find</a>,</li>
|
|
|
|
<li><a href="#M000055">fs</a></li>
|
|
|
|
</ul>
|
|
</dd>
|
|
|
|
<dt>N</dt>
|
|
<dd>
|
|
<ul>
|
|
|
|
<li><a href="#M000077">normalize_path</a></li>
|
|
|
|
</ul>
|
|
</dd>
|
|
|
|
<dt>P</dt>
|
|
<dd>
|
|
<ul>
|
|
|
|
<li><a href="#M000074">path_parts</a></li>
|
|
|
|
</ul>
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sectiontitle">Instance Public methods</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000063">
|
|
|
|
<a name="M000063"></a><b>add</b>(path, object=FakeDir.new)
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000063_source')" id="l_M000063_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L35" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000063_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 35</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">object</span>=<span class="ruby-constant">FakeDir</span>.<span class="ruby-identifier">new</span>)
|
|
<span class="ruby-identifier">parts</span> = <span class="ruby-identifier">path_parts</span>(<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">path</span>))
|
|
|
|
<span class="ruby-identifier">d</span> = <span class="ruby-identifier">parts</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">fs</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span>, <span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
|
|
<span class="ruby-identifier">dir</span>[<span class="ruby-identifier">part</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">FakeDir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">part</span>, <span class="ruby-identifier">dir</span>)
|
|
<span class="ruby-keyword kw">end</span>
|
|
|
|
<span class="ruby-identifier">object</span>.<span class="ruby-identifier">name</span> = <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">last</span>
|
|
<span class="ruby-identifier">object</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-identifier">d</span>
|
|
<span class="ruby-identifier">d</span>[<span class="ruby-identifier">parts</span>.<span class="ruby-identifier">last</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">object</span>
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000073">
|
|
|
|
<a name="M000073"></a><b>chdir</b>(dir, &blk)
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000073_source')" id="l_M000073_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L74" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000073_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 74</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chdir</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">blk</span>)
|
|
<span class="ruby-identifier">new_dir</span> = <span class="ruby-identifier">find</span>(<span class="ruby-identifier">dir</span>)
|
|
<span class="ruby-identifier">dir_levels</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">dir</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">blk</span>
|
|
|
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-identifier">dir</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">new_dir</span>
|
|
|
|
<span class="ruby-identifier">dir_levels</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">dir</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">blk</span>
|
|
<span class="ruby-identifier">blk</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">blk</span>
|
|
<span class="ruby-keyword kw">ensure</span>
|
|
<span class="ruby-identifier">dir_levels</span>.<span class="ruby-identifier">pop</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">blk</span>
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000056">
|
|
|
|
<a name="M000056"></a><b>clear</b>()
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000056_source')" id="l_M000056_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L13" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000056_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 13</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear</span>
|
|
<span class="ruby-ivar">@dir_levels</span> = <span class="ruby-keyword kw">nil</span>
|
|
<span class="ruby-ivar">@fs</span> = <span class="ruby-keyword kw">nil</span>
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000064">
|
|
|
|
<a name="M000064"></a><b>clone</b>(path)
|
|
|
|
</div>
|
|
|
|
<div class="description">
|
|
<p>
|
|
copies directories and files from the real filesystem into our fake one
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000064_source')" id="l_M000064_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L49" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000064_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 49</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clone</span>(<span class="ruby-identifier">path</span>)
|
|
<span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>)
|
|
<span class="ruby-identifier">pattern</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value str">'**'</span>, <span class="ruby-value str">'*'</span>)
|
|
<span class="ruby-identifier">files</span> = <span class="ruby-constant">RealFile</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">path</span>) <span class="ruby-operator">?</span> [<span class="ruby-identifier">path</span>] <span class="ruby-operator">:</span> [<span class="ruby-identifier">path</span>] <span class="ruby-operator">+</span> <span class="ruby-constant">RealDir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">pattern</span>, <span class="ruby-constant">RealFile</span><span class="ruby-operator">::</span><span class="ruby-constant">FNM_DOTMATCH</span>)
|
|
|
|
<span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
|
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">RealFile</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">f</span>)
|
|
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">f</span>))
|
|
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">f</span>, <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">WRITE_ONLY</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span>
|
|
<span class="ruby-identifier">g</span>.<span class="ruby-identifier">print</span> <span class="ruby-constant">RealFile</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">f</span>){<span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">read</span> }
|
|
<span class="ruby-keyword kw">end</span>
|
|
<span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">RealFile</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>)
|
|
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-identifier">f</span>)
|
|
<span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">RealFile</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-identifier">f</span>)
|
|
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>()
|
|
<span class="ruby-keyword kw">end</span>
|
|
<span class="ruby-keyword kw">end</span>
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000078">
|
|
|
|
<a name="M000078"></a><b>current_dir</b>()
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000078_source')" id="l_M000078_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L99" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000078_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 99</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">current_dir</span>
|
|
<span class="ruby-identifier">find</span>(<span class="ruby-identifier">normalize_path</span>(<span class="ruby-value str">'.'</span>))
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000072">
|
|
|
|
<a name="M000072"></a><b>delete</b>(path)
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000072_source')" id="l_M000072_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L68" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000072_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 68</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">path</span>)
|
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node</span> = <span class="ruby-constant">FileSystem</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">path</span>)
|
|
<span class="ruby-identifier">node</span>.<span class="ruby-identifier">delete</span>
|
|
<span class="ruby-keyword kw">end</span>
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000054">
|
|
|
|
<a name="M000054"></a><b>dir_levels</b>()
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000054_source')" id="l_M000054_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L5" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000054_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 5</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dir_levels</span>
|
|
<span class="ruby-ivar">@dir_levels</span> <span class="ruby-operator">||=</span> []
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000057">
|
|
|
|
<a name="M000057"></a><b>files</b>()
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000057_source')" id="l_M000057_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L18" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000057_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 18</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">files</span>
|
|
<span class="ruby-identifier">fs</span>.<span class="ruby-identifier">values</span>
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000058">
|
|
|
|
<a name="M000058"></a><b>find</b>(path)
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000058_source')" id="l_M000058_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L22" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000058_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 22</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find</span>(<span class="ruby-identifier">path</span>)
|
|
<span class="ruby-identifier">parts</span> = <span class="ruby-identifier">path_parts</span>(<span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">path</span>))
|
|
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">fs</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-comment cmt"># '/'</span>
|
|
|
|
<span class="ruby-identifier">entries</span> = <span class="ruby-identifier">find_recurser</span>(<span class="ruby-identifier">fs</span>, <span class="ruby-identifier">parts</span>).<span class="ruby-identifier">flatten</span>
|
|
|
|
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">entries</span>.<span class="ruby-identifier">length</span>
|
|
<span class="ruby-keyword kw">when</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span> <span class="ruby-keyword kw">nil</span>
|
|
<span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">entries</span>.<span class="ruby-identifier">first</span>
|
|
<span class="ruby-keyword kw">else</span> <span class="ruby-identifier">entries</span>
|
|
<span class="ruby-keyword kw">end</span>
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000055">
|
|
|
|
<a name="M000055"></a><b>fs</b>()
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000055_source')" id="l_M000055_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L9" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000055_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 9</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fs</span>
|
|
<span class="ruby-ivar">@fs</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">FakeDir</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'.'</span>)
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000077">
|
|
|
|
<a name="M000077"></a><b>normalize_path</b>(path)
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000077_source')" id="l_M000077_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L90" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000077_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 90</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">path</span>)
|
|
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">Pathname</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">absolute?</span>
|
|
<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>)
|
|
<span class="ruby-keyword kw">else</span>
|
|
<span class="ruby-identifier">parts</span> = <span class="ruby-identifier">dir_levels</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">path</span>]
|
|
<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">parts</span>))
|
|
<span class="ruby-keyword kw">end</span>
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="method">
|
|
<div class="title" id="M000074">
|
|
|
|
<a name="M000074"></a><b>path_parts</b>(path)
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
<p class="source-link">
|
|
Source: <a href="javascript:toggleSource('M000074_source')" id="l_M000074_source">show</a>
|
|
|
|
| <a href="http://github.com/defunkt/fakefs/blob/25c3b4e632aa9b7e6c46a56a1d3acd0ac5f892ad/lib/fakefs/file_system.rb#L86" target="_blank" class="github_url">on GitHub</a>
|
|
|
|
</p>
|
|
<div id="M000074_source" class="dyn-source">
|
|
<pre><span class="ruby-comment cmt"># File lib/fakefs/file_system.rb, line 86</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">path_parts</span>(<span class="ruby-identifier">path</span>)
|
|
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>).<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span> <span class="ruby-identifier">part</span>.<span class="ruby-identifier">empty?</span> }
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |