Merge pull request #3216 from github/koesie10/move-ruby-access-paths
Move Ruby access paths functions to separate file
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
export function parseRubyMethodFromPath(path: string): string {
|
||||||
|
const match = path.match(/Method\[([^\]]+)].*/);
|
||||||
|
if (match) {
|
||||||
|
return match[1];
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseRubyAccessPath(path: string): {
|
||||||
|
methodName: string;
|
||||||
|
path: string;
|
||||||
|
} {
|
||||||
|
const match = path.match(/Method\[([^\]]+)]\.(.*)/);
|
||||||
|
if (match) {
|
||||||
|
return { methodName: match[1], path: match[2] };
|
||||||
|
} else {
|
||||||
|
return { methodName: "", path: "" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rubyMethodSignature(typeName: string, methodName: string) {
|
||||||
|
return `${typeName}#${methodName}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rubyMethodPath(methodName: string) {
|
||||||
|
if (methodName === "") {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return `Method[${methodName}]`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rubyPath(methodName: string, path: string) {
|
||||||
|
const methodPath = rubyMethodPath(methodName);
|
||||||
|
if (methodPath === "") {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${methodPath}.${path}`;
|
||||||
|
}
|
||||||
@@ -4,48 +4,13 @@ import { Mode } from "../../shared/mode";
|
|||||||
import { parseGenerateModelResults } from "./generate";
|
import { parseGenerateModelResults } from "./generate";
|
||||||
import type { MethodArgument } from "../../method";
|
import type { MethodArgument } from "../../method";
|
||||||
import { getArgumentsList } from "../../method";
|
import { getArgumentsList } from "../../method";
|
||||||
|
import {
|
||||||
function parseRubyMethodFromPath(path: string): string {
|
parseRubyAccessPath,
|
||||||
const match = path.match(/Method\[([^\]]+)].*/);
|
parseRubyMethodFromPath,
|
||||||
if (match) {
|
rubyMethodPath,
|
||||||
return match[1];
|
rubyMethodSignature,
|
||||||
} else {
|
rubyPath,
|
||||||
return "";
|
} from "./access-paths";
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseRubyAccessPath(path: string): {
|
|
||||||
methodName: string;
|
|
||||||
path: string;
|
|
||||||
} {
|
|
||||||
const match = path.match(/Method\[([^\]]+)]\.(.*)/);
|
|
||||||
if (match) {
|
|
||||||
return { methodName: match[1], path: match[2] };
|
|
||||||
} else {
|
|
||||||
return { methodName: "", path: "" };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function rubyMethodSignature(typeName: string, methodName: string) {
|
|
||||||
return `${typeName}#${methodName}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function rubyMethodPath(methodName: string) {
|
|
||||||
if (methodName === "") {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return `Method[${methodName}]`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function rubyPath(methodName: string, path: string) {
|
|
||||||
const methodPath = rubyMethodPath(methodName);
|
|
||||||
if (methodPath === "") {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${methodPath}.${path}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ruby: ModelsAsDataLanguage = {
|
export const ruby: ModelsAsDataLanguage = {
|
||||||
availableModes: [Mode.Framework],
|
availableModes: [Mode.Framework],
|
||||||
|
|||||||
Reference in New Issue
Block a user