Skip to content

Commit a447a83

Browse files
authored
Merge pull request #4 from someth2say/ruby
Added perl, ruby and docker variants
2 parents eb530a5 + 52e79da commit a447a83

8 files changed

+1673
-44
lines changed

.pre-commit-hooks.yaml

+34-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
11
---
2-
3-
- id: xmlformat
4-
name: XML Formatter
2+
- id: xmlformat_docker_perl
3+
name: XML Formatter (perl bash docker)
54
description: >
65
Formats XML files according GLS formating rules
7-
entry: quay.io/someth2say/xmlformat:0.1
6+
entry: quay.io/someth2say/xmlformat:0.2
87
types: [xml]
98
language: docker_image
109
require_serial: true
11-
10+
11+
- id: xmlformat_ruby
12+
name: XML Formatter (ruby)
13+
description: >
14+
Formats XML files according GLS formating rules
15+
entry: xmlformat.rb
16+
#args: ["-i","--config-file","xmlformat.conf"]
17+
args: ["-i"]
18+
language: ruby
19+
require_serial: true
20+
21+
- id: xmlformat_bash_ruby
22+
name: XML Formatter (ruby bash)
23+
description: >
24+
Formats XML files according GLS formating rules
25+
entry: bin/xmlformat.sh
26+
args: ["-l","rb"]
27+
types: [xml]
28+
language: script
29+
require_serial: true
30+
31+
- id: xmlformat_bash_perl
32+
name: XML Formatter (perl bash)
33+
description: >
34+
Formats XML files according GLS formating rules
35+
entry: bin/xmlformat.sh
36+
args: ["-l","pl"]
37+
types: [xml]
38+
language: script
39+
require_serial: true
40+

Dockerfile

+23-18
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,45 @@
1-
FROM registry.access.redhat.com/ubi8/ubi-minimal as perl
1+
FROM registry.access.redhat.com/ubi8/ubi-minimal as ubi8-perl-ruby
22
MAINTAINER Jordi Sola <[email protected]>
33

44
LABEL maintainer="Jordi Sola <[email protected]>" \
5-
name="XMLFormat" \
6-
vcs-ref="TBD" \
5+
name="ubi8-perl-ruby" \
76
version="0.1-SNAPSHOT" \
8-
build-date="TBD" \
7+
description="UBI8 based image containing perl and ruby interpreters" \
8+
summary="UBI8 based image containing perl and ruby interpreters" \
9+
io.k8s.description="UBI8 based image containing perl and ruby interpreters" \
10+
io.k8s.display-name="ubi8-perl-ruby" \
11+
io.openshift.tags="perl ruby"
12+
13+
# Install perl and ruby interpreter
14+
RUN microdnf install -y perl ruby
15+
###
16+
17+
FROM ubi8-perl-ruby
18+
LABEL name="XMLFormat" \
19+
version="0.2-SNAPSHOT" \
920
description="Container image wrapping XML formater by Kitebird (http://www.kitebird.com/software/xmlformat/)" \
1021
summary="Container image wrapping XML formater by Kitebird (http://www.kitebird.com/software/xmlformat/)" \
1122
io.k8s.description="Container image wrapping XML formater by Kitebird (http://www.kitebird.com/software/xmlformat/)" \
1223
io.k8s.display-name="XMLFormat" \
1324
io.openshift.tags="xml format perl"
1425

15-
# Install perl interpreter
16-
RUN microdnf install -y perl
17-
18-
###
19-
20-
FROM perl
21-
2226
# Docker arguments to facilitate image extension
23-
ARG SCRIPTS_DIR="/xmlformat"
24-
ARG EXTRA_ARGS="-i"
25-
ARG CFG_FILE="${SCRIPTS_DIR}/xmlformat.cfg"
27+
ARG SCRIPTS_DIR="/bin"
28+
ARG EXTRA_ARGS=""
29+
ARG CFG_FILE="${SCRIPTS_DIR}/xmlformat.conf"
30+
ARG SCRIPT_LANG="pl"
2631

2732
# Environment to be used by the xmlformat.sh script
2833
ENV PATH=${SCRIPTS_DIR}:$PATH \
29-
XMLFORMAT_CFG_FILE=${CFG_FILE} \
30-
XMLFORMAT_SCRIPTS_DIR=${SCRIPTS_DIR} \
34+
XMLFORMAT_LANG=${SCRIPT_LANG} \
35+
XMLFORMAT_CONF=${CFG_FILE} \
3136
XMLFORMAT_EXTRA_ARGS=${EXTRA_ARGS}
3237

3338
# Copy the root scripts to the scripts folder
34-
ADD scripts ${SCRIPTS_DIR}
39+
ADD bin ${SCRIPTS_DIR}
3540

3641
# Make scripts executable by root group, just in case
3742
RUN chgrp -R 0 ${SCRIPTS_DIR} && \
3843
chmod -R g=u ${SCRIPTS_DIR}
3944

40-
ENTRYPOINT [ "xmlformat.sh" ]
45+
ENTRYPOINT [ "xmlformat.sh" ]
File renamed without changes.

scripts/xmlformat.pl renamed to bin/xmlformat.pl

+6-2
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,12 @@ sub tree_canonize2
10951095
if (!defined ($next_child) && $par_opts->{format} eq "block")
10961096
|| $self->non_normalized_node ($next_child);
10971097
1098+
# After whitespace normalization, split the text into sentences
1099+
# This is done by a simple regexp replacement,
1100+
# looking for period and interrogation symbols and adding a break after them.
1101+
# Note also that the split should also be indented correctly after the break.
10981102
my $indent_str = (" " x ( $indent+$par_opts->{"subindent"}));
1099-
$child->{content} =~ s/([.?]) \s*/$1 \n$indent_str/g;
1103+
$child->{content} =~ s/([.?]) \s*/$1\n$indent_str/g;
11001104
11011105
# If resulting text is empty, discard the node.
11021106
next if $child->{content} =~ /^$/;
@@ -1655,7 +1659,7 @@ package main;
16551659
# are used. (These are set up in new().)
16561660

16571661
my $env_conf_file = $ENV{XMLFORMAT_CONF};
1658-
my $def_conf_file = "./xmlformat.conf";
1662+
my $def_conf_file = "./xmlformat.conf";
16591663

16601664
# If no config file was named, but XMLFORMAT_CONF is set, use its value
16611665
# as the config file name.

0 commit comments

Comments
 (0)