Skip to content

Commit

Permalink
git subrepo pull modules
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "modules"
  merged:   "6b5bebf46e"
upstream:
  origin:   "git@github.com:daisy/pipeline-modules.git"
  branch:   "master"
  commit:   "a22831f219"
git-subrepo:
  version:  "0.3.1"
  origin:   "???"
  commit:   "???"
  • Loading branch information
bertfrees committed Nov 26, 2024
1 parent 4070b5e commit 6bd62d2
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 85 deletions.
2 changes: 1 addition & 1 deletion modules/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
remote = git@github.com:daisy/pipeline-modules.git
branch = master
commit = a22831f2190433aa801f9ff15e78c66eb19a06c0
parent = b83ab46a7e311869be789d3b0754f2a4a0519e1a
parent = 3a2a8a73260f37a841df4e835bd88fb8b08e1870
cmdver = 0.3.1
2 changes: 1 addition & 1 deletion modules/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<dependency>
<groupId>org.daisy.pipeline.modules.braille</groupId>
<artifactId>liblouis-utils</artifactId>
<version>6.2.1</version>
<version>6.2.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.daisy.pipeline.modules.braille</groupId>
Expand Down
24 changes: 23 additions & 1 deletion modules/braille/braille-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
</properties>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<excludes>
<exclude>META-INF/catalog.xml</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.daisy.maven</groupId>
Expand All @@ -119,6 +127,19 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.daisy.pipeline.build</groupId>
<artifactId>modules-build-helper</artifactId>
<executions>
<execution>
<id>process-test-catalog</id>
<phase>generate-test-sources</phase>
<goals>
<goal>process-test-catalog</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.daisy.pipeline.build</groupId>
<artifactId>ds-to-spi-maven-plugin</artifactId>
Expand All @@ -131,7 +152,8 @@
</goals>
<configuration>
<includes>
UppercaseTransform$Provider
UppercaseTransform$Provider,
org.daisy.pipeline.modules.impl.Module_test_module
</includes>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
exclude-result-prefixes="#all">

<xsl:import href="abstract-block-translator.xsl"/>
<xsl:include href="http://www.daisy.org/pipeline/modules/braille/common-utils/library.xsl"/>
<xsl:include href="library.xsl"/>

<xsl:param name="text-transform"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import java.io.File;
import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -7,8 +8,8 @@
import com.xmlcalabash.core.XProcRuntime;
import com.xmlcalabash.runtime.XAtomicStep;

import static org.daisy.common.file.URLs.asURI;

import org.daisy.common.file.URLs;
import org.daisy.common.spi.ActivationException;
import org.daisy.common.xproc.calabash.XProcStep;
import org.daisy.common.xproc.calabash.XProcStepProvider;
import org.daisy.common.xproc.XProcMonitor;
Expand All @@ -19,19 +20,24 @@
import org.daisy.pipeline.braille.common.Query;
import org.daisy.pipeline.braille.common.TransformProvider;
import org.daisy.pipeline.braille.css.CSSStyledText;
import org.daisy.pipeline.modules.Module;
import org.daisy.pipeline.modules.ModuleRegistry;

import org.ops4j.pax.exam.util.PathUtils;

import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;

import org.slf4j.Logger;

public class UppercaseTransform extends AbstractBrailleTranslator implements BrailleTranslator, XProcStepProvider {

private final XProcStepProvider stepProvider = new CxEvalBasedTransformer(
asURI(new File(new File(PathUtils.getBaseDir()), "target/test-classes/uppercase.xpl")),
null,
null);
private final XProcStepProvider stepProvider;

private UppercaseTransform(XProcStepProvider stepProvider) {
this.stepProvider = stepProvider;
}

public FromStyledTextToBraille fromStyledTextToBraille() {
return fromStyledTextToBraille;
Expand All @@ -55,8 +61,6 @@ public XProcStep newStep(XProcRuntime runtime, XAtomicStep step, XProcMonitor mo

private static final Iterable<UppercaseTransform> empty = Optional.<UppercaseTransform>absent().asSet();

private static final Iterable<UppercaseTransform> instance = Optional.of(new UppercaseTransform()).asSet();

@Component(
name = "UppercaseTransform.Provider",
service = {
Expand All @@ -68,19 +72,70 @@ public static class Provider implements BrailleTranslatorProvider<UppercaseTrans
private Logger logger;
public Provider() {
}
private Provider(Logger context) {
private Provider(Provider from, Logger context) {
logger = context;
stepProvider = from.stepProvider;
}
public Iterable<UppercaseTransform> get(Query query) {
if (query.toString().equals("(uppercase)")) {
Iterable<UppercaseTransform> instance = Optional.of(new UppercaseTransform(stepProvider)).asSet();
if (logger != null)
logger.info("Selecting " + instance);
return instance; }
else
return empty;
}
public TransformProvider<UppercaseTransform> withContext(Logger context) {
return new Provider(context);
return new Provider(this, context);
}

private ModuleRegistry moduleRegistry = null;

@Reference(
name = "ModuleRegistry",
unbind = "-",
service = ModuleRegistry.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.STATIC
)
protected void bindModulesRegistry(ModuleRegistry registry) {
moduleRegistry = registry;
}

private XProcStepProvider stepProvider = null;

@Activate
protected void activate(final Map<?,?> properties) throws RuntimeException {
try {
Module m = moduleRegistry.getModuleByClass(UppercaseTransform.class);

System.err.println(">> " + URLs.asURI(m.getResource("../uppercase-block-translator.xsl")));

stepProvider = new CxEvalBasedTransformer(
URLs.asURI(m.getResource("../uppercase.xpl")),
null,
null);

System.err.println(stepProvider);

} catch (NoSuchFileException e) {
String errorMessage = e.getMessage();
try {
SPIHelper.failToActivate(errorMessage);
} catch (NoClassDefFoundError ee) {
// we are probably in OSGi context
throw new RuntimeException(errorMessage);
}
}
}
}

// FIXME: move to utility class
// static nested class in order to delay class loading
private static class SPIHelper {
private SPIHelper() {}
public static void failToActivate(String message) throws ActivationException {
throw new ActivationException(message);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<!-- internal dependencies of Java code -->
<uri uri="../uppercase.xpl"/> <!-- UppercaseTransform -->
</catalog>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
exclude-result-prefixes="#all"
version="2.0">

<xsl:include href="http://www.daisy.org/pipeline/modules/braille/css-utils/library.xsl"/>
<xsl:include href="library.xsl"/>

<xsl:template match="@*|node()">
<xsl:copy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
exclude-result-prefixes="#all"
version="2.0">

<xsl:include href="http://www.daisy.org/pipeline/modules/braille/css-utils/library.xsl"/>
<xsl:include href="library.xsl"/>

<xsl:param name="property-names" as="xs:string*"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
exclude-result-prefixes="#all"
version="2.0">

<xsl:include href="http://www.daisy.org/pipeline/modules/braille/css-utils/library.xsl"/>
<xsl:include href="library.xsl"/>

<xsl:template match="@*|node()">
<xsl:copy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ private static Iterable<CSSStyledText> cssStyledTextFromTranslatable(String text
String s = attributes != null ? attributes.getDictionaryIdentifier() : null;
if (s != null || parentStyle != null)
style = cssParser.parse(s != null ? s : "", parentStyle);
if (hyphenating && (style == null || style.getProperty("hyphens") == null))
style = HYPHENS_AUTO.inheritFrom(style);
if (hyphenating) {
if (style == null)
style = HYPHENS_AUTO;
else if (style.getProperty("hyphens") == null)
style = HYPHENS_AUTO.inheritFrom(style);
}
}
if (attributes != null && attributes.hasChildren())
return cssStyledTextFromTranslatable(text, attributes.iterator(), language, false, style);
Expand Down Expand Up @@ -306,28 +310,29 @@ private static Iterable<CSSStyledText> cssStyledTextFromTranslatable(List<? exte
List<CSSStyledText> styledText = new ArrayList<>();
for (Object t : precedingOrFollowingText) {
String text;
String locale;
String lang;
boolean hyphenate; {
if (t instanceof PrecedingText) {
text = ((PrecedingText)t).resolve();
locale = ((PrecedingText)t).getLocale().orElse(null);
lang = ((PrecedingText)t).getLocale().orElse(null);
hyphenate = ((PrecedingText)t).shouldHyphenate(); }
else if (t instanceof FollowingText) {
text = ((FollowingText)t).peek();
locale = ((FollowingText)t).getLocale().orElse(null);
lang = ((FollowingText)t).getLocale().orElse(null);
hyphenate = ((FollowingText)t).shouldHyphenate(); }
else
throw new RuntimeException();
}
SimpleInlineStyle style; {
if (hyphenate && (parentStyle == null || parentStyle.getProperty("hyphens") == null))
style = new SimpleInlineStyle("hyphens: auto", parentStyle);
else if (parentStyle == null)
style = null;
Locale locale = lang != null ? parseLocale(lang) : null;
SimpleInlineStyle style = null; {
if (hyphenate && parentStyle == null)
style = HYPHENS_AUTO;
else if (hyphenate && parentStyle.getProperty("hyphens") == null)
style = HYPHENS_AUTO.inheritFrom(parentStyle);
else
style = new SimpleInlineStyle("", parentStyle);
style = parentStyle;
}
styledText.add(new CSSStyledText(text, style, locale != null ? parseLocale(locale) : null));
styledText.add(new CSSStyledText(text, style, locale));
}
return styledText;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uri name="http://www.daisy.org/pipeline/modules/braille/dotify-utils/library.xpl" uri="../xml/library.xpl"/>
<!-- internal dependencies of Java code -->
<uri uri="../xml/transform/dotify-transform.xpl"/> <!-- DotifyCSSStyledDocumentTransform -->
<uri uri="../xml/transform/obfl-to-pef.xpl"/> <!-- DotifyOBFLTransform -->
</catalog>
5 changes: 5 additions & 0 deletions modules/parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.daisy.pipeline</groupId>
<artifactId>ds-to-spi-runtime</artifactId>
<version>1.2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.daisy.pipeline</groupId>
<artifactId>ds-to-spi-runtime</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.List;

import org.daisy.pipeline.css.CounterStyle.AdditiveTuple;
import org.daisy.pipeline.css.CounterStyleImpl.AdditiveTuple;

import org.junit.Assert;
import org.junit.Test;
Expand All @@ -21,31 +21,31 @@ public void testCounterRepresentation() {
symbols.add("f");
symbols.add("g");
symbols.add("h");
Assert.assertEquals("", CounterStyle.counterRepresentationAlphabetic(0, symbols).orElse(""));
Assert.assertEquals("a", CounterStyle.counterRepresentationAlphabetic(1, symbols).orElse(""));
Assert.assertEquals("b", CounterStyle.counterRepresentationAlphabetic(2, symbols).orElse(""));
Assert.assertEquals("add", CounterStyle.counterRepresentationAlphabetic(100, symbols).orElse(""));
Assert.assertEquals("", CounterStyle.counterRepresentationAlphabetic(-1, symbols).orElse(""));
Assert.assertEquals("h", CounterStyle.counterRepresentationCyclic(0, symbols));
Assert.assertEquals("a", CounterStyle.counterRepresentationCyclic(1, symbols));
Assert.assertEquals("b", CounterStyle.counterRepresentationCyclic(2, symbols));
Assert.assertEquals("d", CounterStyle.counterRepresentationCyclic(100, symbols));
Assert.assertEquals("g", CounterStyle.counterRepresentationCyclic(-1, symbols));
Assert.assertEquals("", CounterStyle.counterRepresentationFixed(0, symbols).orElse(""));
Assert.assertEquals("a", CounterStyle.counterRepresentationFixed(1, symbols).orElse(""));
Assert.assertEquals("b", CounterStyle.counterRepresentationFixed(2, symbols).orElse(""));
Assert.assertEquals("", CounterStyle.counterRepresentationFixed(100, symbols).orElse(""));
Assert.assertEquals("", CounterStyle.counterRepresentationFixed(-1, symbols).orElse(""));
Assert.assertEquals("a", CounterStyle.counterRepresentationNumeric(0, symbols, "-"));
Assert.assertEquals("b", CounterStyle.counterRepresentationNumeric(1, symbols, "-"));
Assert.assertEquals("c", CounterStyle.counterRepresentationNumeric(2, symbols, "-"));
Assert.assertEquals("bee", CounterStyle.counterRepresentationNumeric(100, symbols, "-"));
Assert.assertEquals("-b", CounterStyle.counterRepresentationNumeric(-1, symbols, "-"));
Assert.assertEquals("", CounterStyle.counterRepresentationSymbolic(0, symbols).orElse(""));
Assert.assertEquals("a", CounterStyle.counterRepresentationSymbolic(1, symbols).orElse(""));
Assert.assertEquals("b", CounterStyle.counterRepresentationSymbolic(2, symbols).orElse(""));
Assert.assertEquals("ddddddddddddd", CounterStyle.counterRepresentationSymbolic(100, symbols).orElse(""));
Assert.assertEquals("", CounterStyle.counterRepresentationSymbolic(-1, symbols).orElse(""));
Assert.assertEquals("", CounterStyleImpl.counterRepresentationAlphabetic(0, symbols).orElse(""));
Assert.assertEquals("a", CounterStyleImpl.counterRepresentationAlphabetic(1, symbols).orElse(""));
Assert.assertEquals("b", CounterStyleImpl.counterRepresentationAlphabetic(2, symbols).orElse(""));
Assert.assertEquals("add", CounterStyleImpl.counterRepresentationAlphabetic(100, symbols).orElse(""));
Assert.assertEquals("", CounterStyleImpl.counterRepresentationAlphabetic(-1, symbols).orElse(""));
Assert.assertEquals("h", CounterStyleImpl.counterRepresentationCyclic(0, symbols));
Assert.assertEquals("a", CounterStyleImpl.counterRepresentationCyclic(1, symbols));
Assert.assertEquals("b", CounterStyleImpl.counterRepresentationCyclic(2, symbols));
Assert.assertEquals("d", CounterStyleImpl.counterRepresentationCyclic(100, symbols));
Assert.assertEquals("g", CounterStyleImpl.counterRepresentationCyclic(-1, symbols));
Assert.assertEquals("", CounterStyleImpl.counterRepresentationFixed(0, symbols).orElse(""));
Assert.assertEquals("a", CounterStyleImpl.counterRepresentationFixed(1, symbols).orElse(""));
Assert.assertEquals("b", CounterStyleImpl.counterRepresentationFixed(2, symbols).orElse(""));
Assert.assertEquals("", CounterStyleImpl.counterRepresentationFixed(100, symbols).orElse(""));
Assert.assertEquals("", CounterStyleImpl.counterRepresentationFixed(-1, symbols).orElse(""));
Assert.assertEquals("a", CounterStyleImpl.counterRepresentationNumeric(0, symbols, "-"));
Assert.assertEquals("b", CounterStyleImpl.counterRepresentationNumeric(1, symbols, "-"));
Assert.assertEquals("c", CounterStyleImpl.counterRepresentationNumeric(2, symbols, "-"));
Assert.assertEquals("bee", CounterStyleImpl.counterRepresentationNumeric(100, symbols, "-"));
Assert.assertEquals("-b", CounterStyleImpl.counterRepresentationNumeric(-1, symbols, "-"));
Assert.assertEquals("", CounterStyleImpl.counterRepresentationSymbolic(0, symbols).orElse(""));
Assert.assertEquals("a", CounterStyleImpl.counterRepresentationSymbolic(1, symbols).orElse(""));
Assert.assertEquals("b", CounterStyleImpl.counterRepresentationSymbolic(2, symbols).orElse(""));
Assert.assertEquals("ddddddddddddd", CounterStyleImpl.counterRepresentationSymbolic(100, symbols).orElse(""));
Assert.assertEquals("", CounterStyleImpl.counterRepresentationSymbolic(-1, symbols).orElse(""));
}

@Test
Expand All @@ -64,7 +64,7 @@ public void testCounterRepresentationAdditive() {
symbols.add(new AdditiveTuple(5, "⠧"));
symbols.add(new AdditiveTuple(4, "⠊⠧"));
symbols.add(new AdditiveTuple(1, "⠊"));
Assert.assertEquals("⠍⠉⠍⠭⠉⠧⠊⠊⠊", CounterStyle.counterRepresentationAdditive(1998, symbols).orElse(""));
Assert.assertEquals("⠍⠉⠍⠭⠉⠧⠊⠊⠊", CounterStyleImpl.counterRepresentationAdditive(1998, symbols).orElse(""));
}

@Test
Expand Down
Loading

0 comments on commit 6bd62d2

Please sign in to comment.