Moved Markup into separate module. Replaced Descriptor rendering with Output clause.
This commit is contained in:
parent
52dd70cbdc
commit
291cef68fa
@ -1,17 +0,0 @@
|
|||||||
package inr.numass.control.readvac
|
|
||||||
|
|
||||||
import spock.lang.Specification
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by darksnake on 22-May-17.
|
|
||||||
*/
|
|
||||||
class MeradatVacTest extends Specification {
|
|
||||||
def "CalculateLRC"() {
|
|
||||||
given:
|
|
||||||
def str = "020300000002";
|
|
||||||
when:
|
|
||||||
def lrc = MeradatVacDevice.calculateLRC(str).toUpperCase();
|
|
||||||
then:
|
|
||||||
lrc == "F9"
|
|
||||||
}
|
|
||||||
}
|
|
@ -144,7 +144,7 @@ public class Main {
|
|||||||
options.addOption("h", "home", true,
|
options.addOption("h", "home", true,
|
||||||
"Working directory (by default the working directory is the directory where config file is placed)");
|
"Working directory (by default the working directory is the directory where config file is placed)");
|
||||||
options.addOption("d", "data", true, "Data directory (absolute or relative to working directory)");
|
options.addOption("d", "data", true, "Data directory (absolute or relative to working directory)");
|
||||||
options.addOption("o", "onComplete", true, "Output directory (absolute or relative to working directory)");
|
options.addOption("o", "output", true, "Output directory (absolute or relative to working directory)");
|
||||||
options.addOption("l", "list", false, "List of available actions");
|
options.addOption("l", "list", false, "List of available actions");
|
||||||
options.addOption("lc", "list-color", false, "List of available actions with ANSI coloring");
|
options.addOption("lc", "list-color", false, "List of available actions with ANSI coloring");
|
||||||
|
|
||||||
|
@ -15,15 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package inr.numass;
|
package inr.numass;
|
||||||
|
|
||||||
import hep.dataforge.actions.ActionManager;
|
|
||||||
import hep.dataforge.context.Context;
|
import hep.dataforge.context.Context;
|
||||||
import hep.dataforge.context.ContextBuilder;
|
import hep.dataforge.context.ContextBuilder;
|
||||||
import hep.dataforge.context.Global;
|
import hep.dataforge.context.Global;
|
||||||
import hep.dataforge.description.ActionDescriptor;
|
|
||||||
import hep.dataforge.description.Descriptors;
|
|
||||||
import hep.dataforge.exceptions.DescriptorException;
|
import hep.dataforge.exceptions.DescriptorException;
|
||||||
import hep.dataforge.markup.markup.MarkupBuilder;
|
|
||||||
import hep.dataforge.markup.markup.MarkupUtils;
|
|
||||||
import hep.dataforge.meta.Meta;
|
import hep.dataforge.meta.Meta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,29 +39,29 @@ public class Numass {
|
|||||||
|
|
||||||
public static void printDescription(Context context) throws DescriptorException {
|
public static void printDescription(Context context) throws DescriptorException {
|
||||||
|
|
||||||
MarkupBuilder builder = new MarkupBuilder()
|
// MarkupBuilder builder = new MarkupBuilder()
|
||||||
.text("***Data description***", "red")
|
// .text("***Data description***", "red")
|
||||||
.ln()
|
// .ln()
|
||||||
.text("\t")
|
// .text("\t")
|
||||||
.content(
|
// .content(
|
||||||
MarkupUtils.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read"))
|
// MarkupUtils.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read"))
|
||||||
)
|
// )
|
||||||
.ln()
|
// .ln()
|
||||||
.text("***Allowed actions***", "red")
|
// .text("***Allowed actions***", "red")
|
||||||
.ln();
|
// .ln();
|
||||||
|
//
|
||||||
|
//
|
||||||
ActionManager am = context.get(ActionManager.class);
|
// ActionManager am = context.get(ActionManager.class);
|
||||||
|
//
|
||||||
am.getAllActions()
|
// am.getAllActions()
|
||||||
.map(name -> am.optAction(name).get())
|
// .map(name -> am.optAction(name).get())
|
||||||
.map(ActionDescriptor::build).forEach(descriptor ->
|
// .map(ActionDescriptor::build).forEach(descriptor ->
|
||||||
builder.text("\t").content(MarkupUtils.markupDescriptor(descriptor))
|
// builder.text("\t").content(MarkupUtils.markupDescriptor(descriptor))
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
builder.text("***End of actions list***", "red");
|
// builder.text("***End of actions list***", "red");
|
||||||
|
//
|
||||||
|
//
|
||||||
context.getIo().getOutput().render(builder.build(), Meta.empty());
|
// context.getIo().getOutput().render(builder.build(), Meta.empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package inr.numass
|
package inr.numass
|
||||||
|
|
||||||
import hep.dataforge.context.Context
|
import hep.dataforge.context.Context
|
||||||
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.data.DataNode
|
import hep.dataforge.data.DataNode
|
||||||
import hep.dataforge.data.DataSet
|
import hep.dataforge.data.DataSet
|
||||||
import hep.dataforge.data.binary.Binary
|
import hep.dataforge.data.binary.Binary
|
||||||
@ -23,8 +24,7 @@ import hep.dataforge.io.envelopes.DefaultEnvelopeType
|
|||||||
import hep.dataforge.io.envelopes.Envelope
|
import hep.dataforge.io.envelopes.Envelope
|
||||||
import hep.dataforge.io.envelopes.EnvelopeBuilder
|
import hep.dataforge.io.envelopes.EnvelopeBuilder
|
||||||
import hep.dataforge.io.envelopes.TaglessEnvelopeType
|
import hep.dataforge.io.envelopes.TaglessEnvelopeType
|
||||||
import hep.dataforge.io.markup.Markedup
|
import hep.dataforge.io.output.StreamOutput
|
||||||
import hep.dataforge.io.markup.SimpleMarkupRenderer
|
|
||||||
import hep.dataforge.kodex.nullable
|
import hep.dataforge.kodex.nullable
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.meta.MetaBuilder
|
import hep.dataforge.meta.MetaBuilder
|
||||||
@ -93,8 +93,8 @@ object NumassUtils {
|
|||||||
return EnvelopeBuilder().setMeta(meta).setData { serializer.invoke(it, obj) }
|
return EnvelopeBuilder().setMeta(meta).setData { serializer.invoke(it, obj) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun wrap(obj: Markedup, meta: Meta = Meta.empty()): EnvelopeBuilder {
|
fun wrap(obj: Any, meta: Meta = Meta.empty()): EnvelopeBuilder {
|
||||||
return wrap(obj, meta) { SimpleMarkupRenderer(this).render(it.markup(meta)) }
|
return wrap(obj, meta) { StreamOutput(Global, this).render(it, meta) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user