2009-10-07 04:44:05 +00:00
|
|
|
<?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>
|
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000067">add</a></li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>C</dt>
|
|
|
|
<dd>
|
|
|
|
<ul>
|
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000076">chdir</a>,</li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000059">clear</a>,</li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000073">clone</a>,</li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000084">current_dir</a></li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>D</dt>
|
|
|
|
<dd>
|
|
|
|
<ul>
|
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000075">delete</a>,</li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000057">dir_levels</a></li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>F</dt>
|
|
|
|
<dd>
|
|
|
|
<ul>
|
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000060">files</a>,</li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000061">find</a>,</li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000058">fs</a></li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>N</dt>
|
|
|
|
<dd>
|
|
|
|
<ul>
|
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000078">normalize_path</a></li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>P</dt>
|
|
|
|
<dd>
|
|
|
|
<ul>
|
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<li><a href="#M000077">path_parts</a></li>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sectiontitle">Instance Public methods</div>
|
|
|
|
|
|
|
|
<div class="method">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000067">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000067"></a><b>add</b>(path, object=FakeDir.new)
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
Source: <a href="javascript:toggleSource('M000067_source')" id="l_M000067_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>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000067_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000076">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000076"></a><b>chdir</b>(dir, &blk)
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
Source: <a href="javascript:toggleSource('M000076_source')" id="l_M000076_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>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000076_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000059">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000059"></a><b>clear</b>()
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
Source: <a href="javascript:toggleSource('M000059_source')" id="l_M000059_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>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000059_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000073">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000073"></a><b>clone</b>(path)
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</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">
|
2010-12-18 19:14:23 +00:00
|
|
|
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#L49" target="_blank" class="github_url">on GitHub</a>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000073_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000084">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000084"></a><b>current_dir</b>()
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
Source: <a href="javascript:toggleSource('M000084_source')" id="l_M000084_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>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000084_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000075">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000075"></a><b>delete</b>(path)
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
Source: <a href="javascript:toggleSource('M000075_source')" id="l_M000075_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>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000075_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000057">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000057"></a><b>dir_levels</b>()
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
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#L5" target="_blank" class="github_url">on GitHub</a>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000057_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000060">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000060"></a><b>files</b>()
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
Source: <a href="javascript:toggleSource('M000060_source')" id="l_M000060_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>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000060_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000061">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000061"></a><b>find</b>(path)
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
Source: <a href="javascript:toggleSource('M000061_source')" id="l_M000061_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>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000061_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000058">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000058"></a><b>fs</b>()
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
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#L9" target="_blank" class="github_url">on GitHub</a>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000058_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000078">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000078"></a><b>normalize_path</b>(path)
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
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#L90" target="_blank" class="github_url">on GitHub</a>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000078_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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">
|
2010-12-18 19:14:23 +00:00
|
|
|
<div class="title" id="M000077">
|
2009-10-07 04:44:05 +00:00
|
|
|
|
2010-12-18 19:14:23 +00:00
|
|
|
<a name="M000077"></a><b>path_parts</b>(path)
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="sourcecode">
|
|
|
|
<p class="source-link">
|
2010-12-18 19:14:23 +00:00
|
|
|
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#L86" target="_blank" class="github_url">on GitHub</a>
|
2009-10-07 04:44:05 +00:00
|
|
|
|
|
|
|
</p>
|
2010-12-18 19:14:23 +00:00
|
|
|
<div id="M000077_source" class="dyn-source">
|
2009-10-07 04:44:05 +00:00
|
|
|
<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>
|