Permalink
Browse files

Fix potential module collision

  • Loading branch information...
1 parent 000f57c commit f5855025ba9c19eaeba27af72fb82896aeba0194 @khueue committed Sep 3, 2012
View
@@ -44,7 +44,6 @@
prolongo_configure_load_paths :-
prolog_load_context(directory, Root), % Available only during compilation.
- prolongo_configure_path(Root, 'src/misc', misc),
prolongo_configure_path(Root, 'src', mongo).
prolongo_configure_path(PathPrefix, PathSuffix, Name) :-
@@ -60,7 +59,7 @@
% but I haven't noticed much difference.
% :- use_module(library(apply_macros)).
-:- include(misc(common)).
+:- include(mongo(include/common)).
prolongo_load_project_modules :-
use_module(library(pldoc), []), % Load first to enable comment processing.
File renamed without changes.
View
@@ -1,67 +0,0 @@
-/** <module> Various utility predicates.
- */
-
-:- module(_,
- [
- list_shaped/1,
- ms_since_epoch/1,
- get_arg/3,
- set_arg/4,
- replace_nth1/4,
- atom_contains/2
- ]).
-
-:- include(misc(common)).
-
-%% list_shaped(+Term) is semidet.
-%
-% True if Term looks like a list (no recursive checks).
-
-list_shaped([]).
-list_shaped([_|_]).
-
-%% ms_since_epoch(-Millis) is det.
-%
-% True if Millis is the number of milliseconds elapsed
-% since the Unix epoch.
-
-ms_since_epoch(Millis) :-
- core:get_time(FloatSeconds),
- Millis is floor(FloatSeconds * 1000).
-
-%% get_arg(+Struct, +Index, ?Arg) is semidet.
-%
-% True if Arg is the argument at Index in Struct. Indexing
-% starts at 1.
-
-get_arg(Struct, Index, Arg) :-
- core:arg(Index, Struct, Arg).
-
-%% set_arg(+Struct, +Index, +Arg, ?NewStruct) is semidet.
-%
-% True if NewStruct is Struct with the argument at Index
-% replaced with Arg. Indexing starts at 1.
-%
-% @tbd There must be a better way to do this?
-
-set_arg(Struct, Index, Arg, Struct1) :-
- Struct =.. [Name|Args],
- replace_nth1(Args, Index, Arg, Args1),
- Struct1 =.. [Name|Args1].
-
-%% replace_nth1(+List, +Index, +Value, ?NewList) is semidet.
-%
-% True if NewList is List with the element at Index
-% replaced by Value. Indexing starts at 1.
-
-replace_nth1([_|Xs], 1, Value, [Value|Xs]) :- !.
-replace_nth1([X|Xs], N, Value, [X|Xs1]) :-
- N1 is N - 1,
- replace_nth1(Xs, N1, Value, Xs1).
-
-%% atom_contains(+Atom, +SubAtom) is semidet.
-%
-% True if SubAtom is a subatom of Atom.
-
-atom_contains(Atom, SubAtom) :-
- core:sub_atom(Atom, _, _, _, SubAtom), !.
View
@@ -25,14 +25,13 @@
mongo_command
]).
-:- include(misc(common)).
+:- include(include/common).
% Internal modules.
:- use_module(mongo_socket, []).
:- use_module(mongo_util, []).
:- use_module(mongo_bytes, []).
:- use_module(mongo_test_helper, []).
-:- use_module(misc(util), []).
:- use_module(bson(bson), []).
%% version(?Version) is semidet.
View
@@ -14,7 +14,7 @@
count_bytes_and_set_length/1
]).
-:- include(misc(common)).
+:- include(include/common).
int32s([]) --> [].
int32s([Int|Ints]) -->
View
@@ -10,7 +10,7 @@
collection_connection/2
]).
-:- include(misc(common)).
+:- include(include/common).
%% new_collection(+Database, +CollectionName, -Collection) is det.
%
@@ -28,7 +28,7 @@
% True if Database is a handle to the database that includes Collection.
collection_database(Collection, Database) :-
- util:get_arg(Collection, 1, Database).
+ mongo_util:get_arg(Collection, 1, Database).
%% collection_name(+Collection, -CollectionName) is det.
%
@@ -50,7 +50,7 @@
% True if Namespace is the namespace name for Collection.
collection_namespace(Collection, Namespace) :-
- util:get_arg(Collection, 2, Namespace).
+ mongo_util:get_arg(Collection, 2, Namespace).
%% collection_connection(+Collection, -Connection) is det.
%
View
@@ -13,7 +13,7 @@
get_last_error/2
]).
-:- include(misc(common)).
+:- include(include/common).
command_collection('$cmd').
namespace_collection('system.namespaces').
@@ -123,9 +123,9 @@
repack_collection_names(Pairs, Names).
acceptable_collection([name-Namespace]) :-
- \+ util:atom_contains(Namespace, '$').
+ \+ mongo_util:atom_contains(Namespace, '$').
acceptable_collection([name-Namespace]) :-
- util:atom_contains(Namespace, '.oplog.$').
+ mongo_util:atom_contains(Namespace, '.oplog.$').
repack_collection([name-Namespace], Name) :-
mongo_collection:collection_without_namespace(Namespace, Name).
View
@@ -1,4 +1,4 @@
-:- include(misc(common)).
+:- include(include/common).
:- begin_tests('mongo commands').
View
@@ -11,7 +11,7 @@
read_reply/4
]).
-:- include(misc(common)).
+:- include(include/common).
%% new_connection(-Connection) is det.
%% new_connection(+Host, +Port, -Connection) is det.
@@ -30,7 +30,7 @@
Connection = connection(Socket).
connection_socket(Connection, Socket) :-
- util:get_arg(Connection, 1, Socket).
+ mongo_util:get_arg(Connection, 1, Socket).
%% free_connection(+Connection) is det.
%
View
@@ -10,16 +10,16 @@
cursor_exhaust/2
]).
-:- include(misc(common)).
+:- include(include/common).
new_cursor(Collection, CursorId, Cursor) :-
Cursor = cursor(Collection, CursorId).
cursor_collection(Cursor, Collection) :-
- util:get_arg(Cursor, 1, Collection).
+ mongo_util:get_arg(Cursor, 1, Collection).
cursor_id(Cursor, CursorId) :-
- util:get_arg(Cursor, 2, CursorId).
+ mongo_util:get_arg(Cursor, 2, CursorId).
%% cursor_kill(+Cursor) is det.
%
View
@@ -1,4 +1,4 @@
-:- include(misc(common)).
+:- include(include/common).
:- begin_tests('mongo:cursor_kill/1').
View
@@ -9,7 +9,7 @@
get_collection/3
]).
-:- include(misc(common)).
+:- include(include/common).
%% new_database(+Connection, +DatabaseName, -Database) is det.
%
@@ -25,14 +25,14 @@
% True if Connection is the connection used to access Database.
database_connection(Database, Connection) :-
- util:get_arg(Database, 1, Connection).
+ mongo_util:get_arg(Database, 1, Connection).
%% database_name(+Database, -DatabaseName) is det.
%
% True if DatabaseName is the name of Database.
database_name(Database, DatabaseName) :-
- util:get_arg(Database, 2, DatabaseName).
+ mongo_util:get_arg(Database, 2, DatabaseName).
%% get_collection(+Database, +CollectionName, -Collection) is det.
%
View
@@ -7,7 +7,7 @@
port/1
]).
-:- include(misc(common)).
+:- include(include/common).
%% host(?Host) is semidet.
%
View
@@ -7,7 +7,7 @@
delete/3
]).
-:- include(misc(common)).
+:- include(include/common).
%% delete(+Collection, +Selector) is det.
%
View
@@ -1,4 +1,4 @@
-:- include(misc(common)).
+:- include(include/common).
:- begin_tests('mongo:delete/2').
View
@@ -10,7 +10,7 @@
find/8
]).
-:- include(misc(common)).
+:- include(include/common).
%% find_one(+Collection, +Query, -Doc) is det.
%
View
@@ -1,4 +1,4 @@
-:- include(misc(common)).
+:- include(include/common).
:- begin_tests('mongo:find/7').
View
@@ -7,7 +7,7 @@
insert_batch/3
]).
-:- include(misc(common)).
+:- include(include/common).
%% insert(+Collection, +Doc) is det.
%
View
@@ -1,12 +1,12 @@
-:- include(misc(common)).
+:- include(include/common).
:- begin_tests('mongo:insert/2').
test('insert', [
setup(mongo_test_helper:up(Conn,Coll)),
cleanup(mongo_test_helper:down(Conn))
]) :-
- util:ms_since_epoch(MilliSeconds),
+ mongo_util:ms_since_epoch(MilliSeconds),
Doc =
[
hello - [åäö,5.05],
@@ -23,7 +23,7 @@ test('insert', [
setup(mongo_test_helper:up(Conn,Coll)),
cleanup(mongo_test_helper:down(Conn))
]) :-
- util:ms_since_epoch(MilliSeconds),
+ mongo_util:ms_since_epoch(MilliSeconds),
Doc =
[
hello - world,
View
@@ -9,7 +9,7 @@
receive_n_bytes/3
]).
-:- include(misc(common)).
+:- include(include/common).
%% new_socket(+Host, +Port, -Socket) is det.
%
@@ -30,10 +30,10 @@
throw(mongo_error('could not connect to server', [Exception])).
socket_read(Socket, ReadStream) :-
- util:get_arg(Socket, 1, ReadStream).
+ mongo_util:get_arg(Socket, 1, ReadStream).
socket_write(Socket, WriteStream) :-
- util:get_arg(Socket, 2, WriteStream).
+ mongo_util:get_arg(Socket, 2, WriteStream).
%% free_socket(+Socket) is det.
%
View
@@ -13,7 +13,7 @@
create_n_docs/2
]).
-:- include(misc(common)).
+:- include(include/common).
:- dynamic asserted_database_name/1.
@@ -27,7 +27,7 @@
asserted_database_name(DbName),
!.
database_name(DbName) :-
- util:ms_since_epoch(Millis),
+ mongo_util:ms_since_epoch(Millis),
core:atomic_list_concat([prolongo_test_suite,Millis], '-', DbName),
assert(asserted_database_name(DbName)).
View
@@ -9,7 +9,7 @@
update_all/3
]).
-:- include(misc(common)).
+:- include(include/common).
%% upsert(+Collection, +Selector, +Modifier) is det.
%
View
@@ -1,4 +1,4 @@
-:- include(misc(common)).
+:- include(include/common).
:- begin_tests('mongo:upsert/3').
Oops, something went wrong.

0 comments on commit f585502

Please sign in to comment.