badtaste / extern / meck / .eunit / meck_cover.COVER.html

<html>
<head><title>.eunit/meck_cover.COVER.html</title></head><body bgcolor=white text=black>
<pre>
File generated from /mnt/work/dev/home/kissbang/extern/meck/.eunit/meck_cover.erl by COVER 2012-06-05 at 11:31:44

****************************************************************************

        |  %%==============================================================================
        |  %% Licensed under the Apache License, Version 2.0 (the "License");
        |  %% you may not use this file except in compliance with the License.
        |  %% You may obtain a copy of the License at
        |  %%
        |  %% http://www.apache.org/licenses/LICENSE-2.0
        |  %%
        |  %% Unless required by applicable law or agreed to in writing, software
        |  %% distributed under the License is distributed on an "AS IS" BASIS,
        |  %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        |  %% See the License for the specific language governing permissions and
        |  %% limitations under the License.
        |  %%==============================================================================
        |  
        |  %% @doc Module containing functions needed by meck to integrate with cover.
        |  
        |  -module(meck_cover).
        |  
        |  %% Interface exports
        |  -export([compile_beam/2]).
        |  -export([rename_module/2]).
        |  
        |  %%==============================================================================
        |  %% Interface exports
        |  %%==============================================================================
        |  
        |  %% @doc Enabled cover on `&lt;name&gt;_meck_original'.
        |  compile_beam(OriginalMod, Bin) -&gt;
     7..|      alter_cover(),
     7..|      {ok, _} = cover:compile_beam(OriginalMod, Bin).
        |  
        |  %% @doc Given a cover file `File' exported by `cover:export' overwrite
        |  %% the module name with `Name'.
        |  rename_module(File, Name) -&gt;
     7..|      NewTerms = change_cover_mod_name(read_cover_file(File), Name),
     7..|      write_terms(File, NewTerms),
     7..|      ok.
        |  
        |  %%==============================================================================
        |  %% Internal functions
        |  %%==============================================================================
        |  
        |  %% @private
        |  %%
        |  %% @doc Alter the cover BEAM module to export some of it's private
        |  %% functions.  This is done for two reasons:
        |  %%
        |  %% 1. Meck needs to alter the export analysis data on disk and
        |  %% therefore needs to understand this format.  This is why `get_term'
        |  %% and `write' are exposed.
        |  %%
        |  %% 2. In order to avoid creating temporary files meck needs direct
        |  %% access to `compile_beam/2' which allows passing a binary.
        |  alter_cover() -&gt;
     7..|      case lists:member({compile_beam,2}, cover:module_info(exports)) of
        |          true -&gt;
     6..|              ok;
        |          false -&gt;
     1..|              Beam = meck_mod:beam_file(cover),
     1..|              AbsCode = meck_mod:abstract_code(Beam),
     1..|              Exports = [{compile_beam, 2}, {get_term, 1}, {write, 2}],
     1..|              AbsCode2 = meck_mod:add_exports(Exports, AbsCode),
     1..|              _Bin = meck_mod:compile_and_load_forms(AbsCode2),
     1..|              ok
        |      end.
        |  
        |  change_cover_mod_name(CoverTerms, Name) -&gt;
     7..|      {_, Terms} = lists:foldl(fun change_name_in_term/2, {Name,[]}, CoverTerms),
     7..|      Terms.
        |  
        |  change_name_in_term({file, Mod, File}, {Name, Terms}) -&gt;
     7..|      Term2 = {file, Name, replace_string(File, Mod, Name)},
     7..|      {Name, [Term2|Terms]};
        |  change_name_in_term({Bump={bump,_,_,_,_,_},_}=Term, {Name, Terms}) -&gt;
    20..|      Bump2 = setelement(2, Bump, Name),
    20..|      Term2 = setelement(1, Term, Bump2),
    20..|      {Name, [Term2|Terms]};
        |  change_name_in_term({_Mod,Clauses}, {Name, Terms}) -&gt;
     7..|      Clauses2 = lists:foldl(fun change_name_in_clause/2, {Name, []}, Clauses),
     7..|      Term2 = {Name, Clauses2},
     7..|      {Name, [Term2|Terms]}.
        |  
        |  change_name_in_clause(Clause, {Name, NewClauses}) -&gt;
    20..|      {Name, [setelement(1, Clause, Name)|NewClauses]}.
        |  
        |  replace_string(File, Old, New) -&gt;
     7..|      Old2 = atom_to_list(Old),
     7..|      New2 = atom_to_list(New),
     7..|      re:replace(File, Old2, New2, [{return, list}]).
        |  
        |  read_cover_file(File) -&gt;
     7..|      {ok, Fd} = file:open(File, [read, binary, raw]),
     7..|      Terms = get_terms(Fd, []),
     7..|      ok = file:close(Fd),
     7..|      Terms.
        |  
        |  get_terms(Fd, Terms) -&gt;
    41..|      case cover:get_term(Fd) of
     7..|          eof -&gt; Terms;
    34..|          Term -&gt; get_terms(Fd, [Term|Terms])
        |      end.
        |  
        |  write_terms(File, Terms) -&gt;
     7..|      {ok, Fd} = file:open(File, [write, binary, raw]),
     7..|      lists:foreach(write_term(Fd), Terms),
     7..|      ok.
        |  
        |  write_term(Fd) -&gt;
     7..|      fun(Term) -&gt; cover:write(Term, Fd) end.
        |  
</pre>
</body>
</html>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.