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 type { MethodArgument } from "../../method";
|
||||
import { getArgumentsList } from "../../method";
|
||||
|
||||
function parseRubyMethodFromPath(path: string): string {
|
||||
const match = path.match(/Method\[([^\]]+)].*/);
|
||||
if (match) {
|
||||
return match[1];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
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}`;
|
||||
}
|
||||
import {
|
||||
parseRubyAccessPath,
|
||||
parseRubyMethodFromPath,
|
||||
rubyMethodPath,
|
||||
rubyMethodSignature,
|
||||
rubyPath,
|
||||
} from "./access-paths";
|
||||
|
||||
export const ruby: ModelsAsDataLanguage = {
|
||||
availableModes: [Mode.Framework],
|
||||
|
||||
Reference in New Issue
Block a user