Skip to content

Commit

Permalink
Define resources
Browse files Browse the repository at this point in the history
  • Loading branch information
macie committed Mar 10, 2019
1 parent 47170c1 commit 9c78cd5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/rules/reservation/resources.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

reservation(Location) :- atom_string(Location, "reservation://").

reservation(Resource, Location) :- % reservation://<resources>/
reservation(Base_uri),
atom_concat(Resource, "/", Resource_uri),
atom_concat(Base_uri, Resource_uri, Location).

reservation_rooms(Location) :- % reservation://rooms/
reservation("rooms", Location).

reservation_rooms(Room, Location) :- % reservation://rooms/<room_name>/
reservation_rooms(Base_uri),
atom_concat(Room, "/", Room_uri),
atom_concat(Base_uri, Room_uri, Location).

reservation_owner(Location) :- % reservation://rooms/owners/
reservation_owner("", Location).

reservation_owner(Room, Location) :- % reservation://rooms/<room_name>/owners/
reservation_rooms(Room, Base_uri),
atom_concat(Base_uri, "owners/", Location).

reservation_free(Location) :- % reservation://rooms/free/
reservation_free("", Location).

reservation_free(Room, Location) :- % reservation://rooms/<room_name>/free/
reservation_rooms(Room, Base_uri),
atom_concat(Base_uri, "free/", Location).

% reservation://users
% reservation://users/<username>/
% reservation://users/<username>/reservations
% ...
15 changes: 15 additions & 0 deletions src/rules/reservation/resources.plt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
:- begin_tests(resources).
:- include(resources).

test(reservation) :- reservation('reservation://').

test(reservation_rooms) :- reservation_rooms('reservation://rooms/').
test(reservation_rooms) :- reservation_rooms(11, 'reservation://rooms/11/').

test(reservation_owner) :- reservation_owner('reservation://rooms/owners/').
test(reservation_owner) :- reservation_owner(5, 'reservation://rooms/5/owners/').

test(reservation_free) :- reservation_free('reservation://rooms/free/').
test(reservation_free) :- reservation_free(3, 'reservation://rooms/3/free/').

:- end_tests(resources).

0 comments on commit 9c78cd5

Please sign in to comment.