All files / output zcl_abapgit_url.clas.mjs

66.89% Statements 99/148
75.75% Branches 25/33
18.18% Functions 6/33
66.89% Lines 99/148

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 1481x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x             1x       1x     1x 20x 20x 20x 20x 20x 19x 20x 1x     1x                   1x     1x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 3x 3x     3x 18x 2x 2x 2x       2x     2x 16x 18x 1x     1x                 1x     1x 44x 44x 44x 44x 44x 44x 44x 44x 13x 13x 3x   13x 44x 1x     1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x   6x 1x 1x 1x 1x 1x 6x 6x 6x 1x     1x 3x 3x 3x 3x 3x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_url.clas.abap
class zcl_abapgit_url {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_URL';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"REGEX": {"visibility": "I", "parameters": {"IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "EV_HOST": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "EV_PATH": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "EV_NAME": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "VALIDATE": {"visibility": "U", "parameters": {"IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "HOST": {"visibility": "U", "parameters": {"RV_HOST": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "NAME": {"visibility": "U", "parameters": {"RV_NAME": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_VALIDATE": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}}},
  "PATH_NAME": {"visibility": "U", "parameters": {"RV_PATH_NAME": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "IS_ABAPGIT_REPO": {"visibility": "U", "parameters": {"RV_ABAPGIT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}},
  "URL_ADDRESS": {"visibility": "U", "parameters": {"RV_ADRESS": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_URL": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async host(INPUT) {
    return zcl_abapgit_url.host(INPUT);
  }
  static async host(INPUT) {
    let rv_host = new abap.types.String({qualifiedName: "STRING"});
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    await this.regex({iv_url: iv_url, ev_host: rv_host});
    return rv_host;
  }
  async is_abapgit_repo(INPUT) {
    return zcl_abapgit_url.is_abapgit_repo(INPUT);
  }
  static async is_abapgit_repo(INPUT) {
    let rv_abapgit = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    if (abap.compare.cs(iv_url, abap.CharacterFactory.get(10, 'github.com')) && (abap.compare.cp(iv_url, abap.CharacterFactory.get(9, '*/abapGit')) || abap.compare.cp(iv_url, abap.CharacterFactory.get(13, '*/abapGit.git')))) {
      rv_abapgit.set(abap.builtin.abap_true);
    }
    return rv_abapgit;
  }
  async name(INPUT) {
    return zcl_abapgit_url.name(INPUT);
  }
  static async name(INPUT) {
    let rv_name = new abap.types.String({qualifiedName: "STRING"});
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let iv_validate = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    if (INPUT && INPUT.iv_validate) {iv_validate.set(INPUT.iv_validate);}
    if (INPUT === undefined || INPUT.iv_validate === undefined) {iv_validate = abap.builtin.abap_false;}
    let lv_path = new abap.types.String({qualifiedName: "STRING"});
    try {
      await this.regex({iv_url: iv_url, ev_name: rv_name, ev_path: lv_path});
      if (abap.compare.initial(rv_name)) {
        abap.statements.find(lv_path, {regex: abap.CharacterFactory.get(10, '([\\w-]+)/$'), submatches: [rv_name]});
        if (abap.compare.ne(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
          await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: abap.CharacterFactory.get(13, 'Malformed URL')});
        }
      }
    } catch (e) {
      if ((abap.Classes['ZCX_ABAPGIT_EXCEPTION'] && e instanceof abap.Classes['ZCX_ABAPGIT_EXCEPTION'])) {
        if (abap.compare.eq(iv_validate, abap.builtin.abap_true)) {
          await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: abap.CharacterFactory.get(13, 'Malformed URL')});
        } else {
          rv_name.set(abap.CharacterFactory.get(52, 'URL error (fix repo with "Advanced > Change Remote")'));
        }
      } else {
        throw e;
      }
    }
    return rv_name;
  }
  async path_name(INPUT) {
    return zcl_abapgit_url.path_name(INPUT);
  }
  static async path_name(INPUT) {
    let rv_path_name = new abap.types.String({qualifiedName: "STRING"});
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let lv_host = new abap.types.String({qualifiedName: "STRING"});
    abap.statements.find(iv_url, {regex: abap.CharacterFactory.get(16, '(.*://[^/]*)(.*)'), submatches: [lv_host,rv_path_name]});
    return rv_path_name;
  }
  async regex(INPUT) {
    return zcl_abapgit_url.regex(INPUT);
  }
  static async regex(INPUT) {
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let ev_host = INPUT?.ev_host || new abap.types.String({qualifiedName: "STRING"});
    let ev_path = INPUT?.ev_path || new abap.types.String({qualifiedName: "STRING"});
    let ev_name = INPUT?.ev_name || new abap.types.String({qualifiedName: "STRING"});
    abap.statements.find(iv_url, {regex: abap.CharacterFactory.get(32, '^(https?://[^/]*)(.*/)(.*)\\.git$'), submatches: [ev_host,ev_path,ev_name]});
    if (abap.compare.ne(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
      abap.statements.find(iv_url, {regex: abap.CharacterFactory.get(27, '^(https?://[^/]*)(.*/)(.*)$'), submatches: [ev_host,ev_path,ev_name]});
      if (abap.compare.ne(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
        await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: abap.CharacterFactory.get(13, 'Malformed URL')});
      }
    }
  }
  async url_address(INPUT) {
    return zcl_abapgit_url.url_address(INPUT);
  }
  static async url_address(INPUT) {
    let rv_adress = new abap.types.String({qualifiedName: "STRING"});
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let lv_host = new abap.types.String({qualifiedName: "STRING"});
    let lv_path = new abap.types.String({qualifiedName: "STRING"});
    let lv_name = new abap.types.String({qualifiedName: "STRING"});
    let lv_len = new abap.types.Integer({qualifiedName: "I"});
    await this.regex({iv_url: iv_url, ev_host: lv_host, ev_path: lv_path, ev_name: lv_name});
    if (abap.compare.initial(lv_path) && abap.compare.initial(lv_name)) {
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: abap.CharacterFactory.get(13, 'Malformed URL')});
    } else if (abap.compare.initial(lv_name)) {
      lv_len.set(abap.operators.minus(abap.builtin.strlen({val: lv_path}),abap.IntegerFactory.get(1)));
      if (abap.compare.eq(lv_path.getOffset({offset: lv_len, length: 1}), abap.CharacterFactory.get(1, '/'))) {
        lv_path.set(lv_path.getOffset({length: lv_len}));
      }
    }
    rv_adress.set(new abap.types.String().set(`${abap.templateFormatting(lv_host)}${abap.templateFormatting(lv_path)}${abap.templateFormatting(lv_name)}`));
    return rv_adress;
  }
  async validate(INPUT) {
    return zcl_abapgit_url.validate(INPUT);
  }
  static async validate(INPUT) {
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    await this.name({iv_url: iv_url, iv_validate: abap.builtin.abap_true});
  }
}
abap.Classes['ZCL_ABAPGIT_URL'] = zcl_abapgit_url;
export {zcl_abapgit_url};