All files / src/files _abstract_file.ts

100% Statements 43/43
83.33% Branches 5/6
100% Functions 5/5
100% Lines 43/43

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 441x 1x 1x 1x 1x 1x 14854x 14854x 1x 1x 103605x 103605x 1x 1x 16012x 16012x 16012x 16012x 16012x 1x 1x 8006x 8006x 8006x 1x 1x 8006x 8006x 8006x 8006x 8006x 8006x 8006x 8006x 8006x 8006x 8006x 8006x 8006x 1x 1x 1x 1x  
import {IFile} from "./_ifile";
 
export abstract class AbstractFile implements IFile {
  private readonly filename: string;
 
  public constructor(filename: string) {
    this.filename = filename;
  }
 
  public getFilename(): string {
    return this.filename;
  }
 
  private baseName(): string {
    const first = this.getFilename().split("\\");
    const base1 = first[ first.length - 1 ];
    const base2 = base1.split("/");
    return base2[ base2.length - 1 ];
  }
 
  public getObjectType(): string | undefined {
    const split = this.baseName().split(".");
    return split[1]?.toUpperCase();
  }
 
  public getObjectName(): string {
    const split = this.baseName().split(".");
// handle url escaped namespace
    split[0] = split[0].replace(/%23/g, "#");
// handle additional escaping
    split[0] = split[0].replace(/%3e/g, ">");
    split[0] = split[0].replace(/%3c/g, "<");
// handle abapGit namespace
    split[0] = split[0].toUpperCase().replace(/#/g, "/");
// handle AFF namespace
    split[0] = split[0].replace("(", "/");
    split[0] = split[0].replace(")", "/");
    return split[0];
  }
 
  public abstract getRaw(): string;
  public abstract getRawRows(): string[];
}