Coverage report for Casbin.Adapter.Filesystem.
Generated at 18/02/2019 12:10:19 by DelphiCodeCoverage - an open source tool for Delphi Code Coverage.
Statistics for Casbin.Adapter.Filesystem.pas
| Number of lines covered | 12 |
| Number of lines with code gen | 13 |
| Line coverage | 92% |
| 1 | // Copyright 2018 by John Kouraklis and Contributors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | unit Casbin.Adapter.Filesystem; |
| 15 | |
| 16 | interface |
| 17 | |
| 18 | uses |
| 19 | Casbin.Adapter.Base, Casbin.Core.Base.Types; |
| 20 | |
| 21 | type |
| 22 | TFileAdapter = class(TBaseAdapter) |
| 23 | protected |
| 24 | fFilename: string; //PALOFF |
| 25 | public |
| 26 | constructor Create(const aFilename: string); virtual; |
| 27 | procedure load(const aFilter: TFilterArray); override; |
| 28 | procedure save; override; |
| 29 | end; |
| 30 | |
| 31 | implementation |
| 32 | |
| 33 | uses |
| 34 | System.SysUtils, System.Generics.Collections, System.IOUtils, System.Types; |
| 35 | |
| 36 | constructor TFileAdapter.Create(const aFilename: string); |
| 37 | begin |
| 38 | if not fileExists(aFilename) then |
| 39 | raise Exception.Create('File '+aFilename+' does not exist'); |
| 40 | inherited Create; |
| 41 | fFilename:=aFilename; |
| 42 | end; |
| 43 | |
| 44 | { TFileAdapter } |
| 45 | |
| 46 | procedure TFileAdapter.load(const aFilter: TFilterArray); |
| 47 | begin |
| 48 | inherited; |
| 49 | Clear; |
| 50 | getAssertions.AddRange(TFile.ReadAllLines(fFilename)); |
| 51 | end; |
| 52 | |
| 53 | procedure TFileAdapter.save; |
| 54 | begin |
| 55 | inherited; |
| 56 | end; |
| 57 | |
| 58 | end. |