<commit_before>%%=============================================================================
%% 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.
%%=============================================================================

%% @private
%% @doc Module containing functions needed by meck to integrate with cover.

-module(meck_cover).

%% Interface exports
-export([compile_beam/2]).
-export([rename_module/2]).
-export([dump_coverdata/1]).

%%=============================================================================
%% Interface exports
%%=============================================================================

%% @doc Enabled cover on `<name>_meck_original'.
compile_beam(OriginalMod, Bin) ->
    CompileBeams = alter_cover(),
    [{ok, _}] = CompileBeams([{OriginalMod, Bin}]).

%% @doc Given a cover file `File' exported by `cover:export' overwrite
%% the module name with `Name'.
rename_module(File, Name) ->
    NewTerms = change_cover_mod_name(read_cover_file(File), Name),
    write_terms(File, NewTerms),
    ok.

%% @doc Dump cover data for `Mod' into a .coverdata file in the current
%% directory. Return the absolute file name.
dump_coverdata(Mod) ->
    {ok, CWD} = file:get_cwd(),
    File = filename:join(CWD, atom_to_list(Mod) ++ ".coverdata"),
    ok = cover:export(File, Mod),
    File.
<commit_msg>Isolate backup *.coverdata from other beam instances<commit_after>%%=============================================================================
%% 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.
%%=============================================================================

%% @private
%% @doc Module containing functions needed by meck to integrate with cover.

-module(meck_cover).

%% Interface exports
-export([compile_beam/2]).
-export([rename_module/2]).
-export([dump_coverdata/1]).

%%=============================================================================
%% Interface exports
%%=============================================================================

%% @doc Enabled cover on `<name>_meck_original'.
compile_beam(OriginalMod, Bin) ->
    CompileBeams = alter_cover(),
    [{ok, _}] = CompileBeams([{OriginalMod, Bin}]).

%% @doc Given a cover file `File' exported by `cover:export' overwrite
%% the module name with `Name'.
rename_module(File, Name) ->
    NewTerms = change_cover_mod_name(read_cover_file(File), Name),
    write_terms(File, NewTerms),
    ok.

%% @doc Dump cover data for `Mod' into a .coverdata file in the current
%% directory. Return the absolute path to the backup file.
dump_coverdata(Mod) ->
    {ok, CWD} = file:get_cwd(),
    File = lists:concat([Mod, ".", os:getpid(), ".coverdata"]),
    Path = filename:join(CWD, File),
    ok = cover:export(Path, Mod),
    Path.

{'fraction_non_alphanumeric': 0.27253333333333335, 'fraction_numerical': 0.0037333333333333333, 'mean_word_length': 5.512152777777778, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7347527', 'n_tokens_mistral': 995, 'n_tokens_neox': 947, 'n_words': 342}