Moved Markup into separate module. Replaced Descriptor rendering with Output clause.

This commit is contained in:
Alexander Nozik 2018-05-09 10:05:49 +03:00
parent 52dd70cbdc
commit 291cef68fa
4 changed files with 29 additions and 51 deletions

View File

@ -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"
}
}

View File

@ -144,7 +144,7 @@ public class Main {
options.addOption("h", "home", true,
"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("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("lc", "list-color", false, "List of available actions with ANSI coloring");

View File

@ -15,15 +15,10 @@
*/
package inr.numass;
import hep.dataforge.actions.ActionManager;
import hep.dataforge.context.Context;
import hep.dataforge.context.ContextBuilder;
import hep.dataforge.context.Global;
import hep.dataforge.description.ActionDescriptor;
import hep.dataforge.description.Descriptors;
import hep.dataforge.exceptions.DescriptorException;
import hep.dataforge.markup.markup.MarkupBuilder;
import hep.dataforge.markup.markup.MarkupUtils;
import hep.dataforge.meta.Meta;
/**
@ -44,29 +39,29 @@ public class Numass {
public static void printDescription(Context context) throws DescriptorException {
MarkupBuilder builder = new MarkupBuilder()
.text("***Data description***", "red")
.ln()
.text("\t")
.content(
MarkupUtils.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read"))
)
.ln()
.text("***Allowed actions***", "red")
.ln();
ActionManager am = context.get(ActionManager.class);
am.getAllActions()
.map(name -> am.optAction(name).get())
.map(ActionDescriptor::build).forEach(descriptor ->
builder.text("\t").content(MarkupUtils.markupDescriptor(descriptor))
);
builder.text("***End of actions list***", "red");
context.getIo().getOutput().render(builder.build(), Meta.empty());
// MarkupBuilder builder = new MarkupBuilder()
// .text("***Data description***", "red")
// .ln()
// .text("\t")
// .content(
// MarkupUtils.markupDescriptor(Descriptors.buildDescriptor("method::hep.dataforge.data.DataManager.read"))
// )
// .ln()
// .text("***Allowed actions***", "red")
// .ln();
//
//
// ActionManager am = context.get(ActionManager.class);
//
// am.getAllActions()
// .map(name -> am.optAction(name).get())
// .map(ActionDescriptor::build).forEach(descriptor ->
// builder.text("\t").content(MarkupUtils.markupDescriptor(descriptor))
// );
//
// builder.text("***End of actions list***", "red");
//
//
// context.getIo().getOutput().render(builder.build(), Meta.empty());
}
}

View File

@ -16,6 +16,7 @@
package inr.numass
import hep.dataforge.context.Context
import hep.dataforge.context.Global
import hep.dataforge.data.DataNode
import hep.dataforge.data.DataSet
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.EnvelopeBuilder
import hep.dataforge.io.envelopes.TaglessEnvelopeType
import hep.dataforge.io.markup.Markedup
import hep.dataforge.io.markup.SimpleMarkupRenderer
import hep.dataforge.io.output.StreamOutput
import hep.dataforge.kodex.nullable
import hep.dataforge.meta.Meta
import hep.dataforge.meta.MetaBuilder
@ -93,8 +93,8 @@ object NumassUtils {
return EnvelopeBuilder().setMeta(meta).setData { serializer.invoke(it, obj) }
}
fun wrap(obj: Markedup, meta: Meta = Meta.empty()): EnvelopeBuilder {
return wrap(obj, meta) { SimpleMarkupRenderer(this).render(it.markup(meta)) }
fun wrap(obj: Any, meta: Meta = Meta.empty()): EnvelopeBuilder {
return wrap(obj, meta) { StreamOutput(Global, this).render(it, meta) }
}