libis-format 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/.gitignore +20 -0
- data/.travis.yml +70 -0
- data/Gemfile +0 -10
- data/README.md +2 -2
- data/Rakefile +8 -0
- data/base/Dockerfile +35 -0
- data/base/Dockerfile.alpine +20 -0
- data/base/Dockerfile.rvm +56 -0
- data/base/rework_path +20 -0
- data/data/PDFA_def.ps +3 -3
- data/data/eciRGB_v2.icc +0 -0
- data/data/types.yml +4 -17
- data/docker_cfg.yml +1 -0
- data/lib/libis/format/cli/convert.rb +4 -4
- data/lib/libis/format/cli/prompt_helper.rb +24 -32
- data/lib/libis/format/command_line.rb +3 -2
- data/lib/libis/format/config.rb +22 -20
- data/lib/libis/format/converter/audio_converter.rb +31 -56
- data/lib/libis/format/converter/base.rb +36 -16
- data/lib/libis/format/converter/chain.rb +32 -52
- data/lib/libis/format/converter/fop_pdf_converter.rb +8 -4
- data/lib/libis/format/converter/image_assembler.rb +82 -0
- data/lib/libis/format/converter/image_converter.rb +40 -153
- data/lib/libis/format/converter/image_splitter.rb +80 -0
- data/lib/libis/format/converter/image_watermarker.rb +261 -0
- data/lib/libis/format/converter/jp2_converter.rb +38 -36
- data/lib/libis/format/converter/office_converter.rb +28 -22
- data/lib/libis/format/converter/pdf_assembler.rb +66 -0
- data/lib/libis/format/converter/pdf_converter.rb +50 -111
- data/lib/libis/format/converter/pdf_optimizer.rb +70 -0
- data/lib/libis/format/converter/pdf_splitter.rb +65 -0
- data/lib/libis/format/converter/pdf_watermarker.rb +110 -0
- data/lib/libis/format/converter/repository.rb +13 -7
- data/lib/libis/format/converter/spreadsheet_converter.rb +16 -10
- data/lib/libis/format/converter/video_converter.rb +58 -47
- data/lib/libis/format/converter/xslt_converter.rb +11 -13
- data/lib/libis/format/converter.rb +1 -1
- data/lib/libis/format/identifier.rb +46 -44
- data/lib/libis/format/info.rb +27 -0
- data/lib/libis/format/library.rb +147 -0
- data/lib/libis/format/tool/droid.rb +30 -29
- data/lib/libis/format/tool/extension_identification.rb +26 -24
- data/lib/libis/format/tool/{ff_mpeg.rb → ffmpeg.rb} +10 -17
- data/lib/libis/format/tool/fido.rb +27 -22
- data/lib/libis/format/tool/file_tool.rb +24 -11
- data/lib/libis/format/tool/fop_pdf.rb +14 -25
- data/lib/libis/format/tool/identification_tool.rb +40 -38
- data/lib/libis/format/tool/office_to_pdf.rb +18 -30
- data/lib/libis/format/tool/pdf_copy.rb +15 -24
- data/lib/libis/format/tool/pdf_merge.rb +14 -24
- data/lib/libis/format/tool/pdf_optimizer.rb +17 -24
- data/lib/libis/format/tool/pdf_split.rb +16 -25
- data/lib/libis/format/tool/pdf_to_pdfa.rb +32 -50
- data/lib/libis/format/tool/pdfa_validator.rb +30 -25
- data/lib/libis/format/tool/spreadsheet_to_ods.rb +18 -29
- data/lib/libis/format/tool.rb +3 -4
- data/lib/libis/format/version.rb +1 -3
- data/lib/libis/format/yaml_loader.rb +71 -0
- data/lib/libis/format.rb +7 -5
- data/lib/libis-format.rb +0 -2
- data/libis-format.gemspec +18 -24
- metadata +78 -120
- data/data/AdobeRGB1998.icc +0 -0
- data/lib/libis/format/converter/email_converter.rb +0 -35
- data/lib/libis/format/tool/msg_to_pdf.rb +0 -270
- data/lib/libis/format/type_database.rb +0 -156
- data/lib/libis/format/type_database_impl.rb +0 -153
- data/tools/pdf2pdfa +0 -395
- /data/bin/{droid_tool → droid} +0 -0
- /data/bin/{fido_tool → fido} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f563ad694fd3d0c9e4a9f0da3309c99ac4b103e6027fcc9cda1606f0f67549c2
|
4
|
+
data.tar.gz: 5cee3f4b3bb1e51db492ee14bf919b0ce0fa69e267292380364c32b4eec40b4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 409ea1fac8f8be4d2519f189090207b6a550a1b1ce174a71fa1886c69b667001459d4bdccd850dd55373199ae5553ebd02183e15eebc88a73d0ac3f8093f7d12
|
7
|
+
data.tar.gz: d3e4d77ddcaab1f5050aaf4acb02e74a221566abedb94062254efbc24d18703c8fdd739644b1cd5435b54a4497e77c82bdcbcb218d121bfaf135e483662aca06
|
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
dist: bionic
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
sudo: false
|
5
|
+
rvm:
|
6
|
+
- 2.3
|
7
|
+
- 2.4
|
8
|
+
- 2.5
|
9
|
+
- 2.6
|
10
|
+
- ruby-head
|
11
|
+
- jruby-9.1
|
12
|
+
- jruby-9.2
|
13
|
+
- jruby-head
|
14
|
+
jdk:
|
15
|
+
- openjdk10
|
16
|
+
- openjdk11
|
17
|
+
matrix:
|
18
|
+
exclude:
|
19
|
+
- rvm: 2.3
|
20
|
+
jdk: openjdk10
|
21
|
+
- rvm: 2.4
|
22
|
+
jdk: openjdk10
|
23
|
+
- rvm: 2.5
|
24
|
+
jdk: openjdk10
|
25
|
+
- rvm: 2.6
|
26
|
+
jdk: openjdk10
|
27
|
+
- rvm: ruby-head
|
28
|
+
jdk: openjdk10
|
29
|
+
allow_failures:
|
30
|
+
- rvm: ruby-head
|
31
|
+
- rvm: jruby-head
|
32
|
+
branches:
|
33
|
+
only:
|
34
|
+
- master
|
35
|
+
- v2
|
36
|
+
before_install:
|
37
|
+
- gem update --system
|
38
|
+
- gem --version
|
39
|
+
- sudo add-apt-repository ppa:mc3man/bionic-media -y
|
40
|
+
- sudo apt-get update -y -q
|
41
|
+
- sudo apt-get install
|
42
|
+
- sudo apt-get install -y -q ffmpeg ubuntu-restricted-extras
|
43
|
+
- sudo pip install --upgrade pip
|
44
|
+
- sudo pip install --upgrade --ignore-installed opf-fido six
|
45
|
+
- sudo wget -O droid.zip -q http://www.nationalarchives.gov.uk/documents/information-management/droid-binary-6.4-bin.zip
|
46
|
+
- sudo mkdir -p /opt/droid
|
47
|
+
- sudo unzip droid.zip -d /opt/droid
|
48
|
+
- sudo chmod 755 /opt/droid/droid.sh
|
49
|
+
- sudo locale-gen "en_US.UTF-8"
|
50
|
+
- echo 'Europe/Brussels' | sudo tee /etc/timezone
|
51
|
+
- export TZ=Europe/Brussels
|
52
|
+
- sudo dpkg-reconfigure --frontend noninteractive tzdata
|
53
|
+
- date
|
54
|
+
before_script:
|
55
|
+
- export TZ=Europe/Brussels
|
56
|
+
env:
|
57
|
+
- LC_ALL=en_US.UTF-8
|
58
|
+
- LANG=en_US.UTF-8
|
59
|
+
addons:
|
60
|
+
apt:
|
61
|
+
packages:
|
62
|
+
- python2.7
|
63
|
+
- imagemagick
|
64
|
+
- libreoffice
|
65
|
+
- ghostscript
|
66
|
+
- sox
|
67
|
+
- libsox-dev
|
68
|
+
- libsox-fmt-all
|
69
|
+
- libchromaprint-dev
|
70
|
+
- libchromaprint-tools
|
data/Gemfile
CHANGED
@@ -1,15 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
source 'https://rubygems.org'
|
4
2
|
|
5
3
|
gem 'coveralls', group: :test, require: false
|
6
4
|
|
7
5
|
gemspec name: 'libis-format', development_group: :test
|
8
|
-
|
9
|
-
gem 'gem-release'
|
10
|
-
|
11
|
-
group :development do
|
12
|
-
gem 'byebug'
|
13
|
-
gem 'debug'
|
14
|
-
gem 'standard'
|
15
|
-
end
|
data/README.md
CHANGED
@@ -26,9 +26,9 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
-
### ::Libis::Format::
|
29
|
+
### ::Libis::Format::Library
|
30
30
|
|
31
|
-
The
|
31
|
+
The format database is the core of the format services. It stores information about all the known formats.
|
32
32
|
|
33
33
|
### ::Libis::Format::Identifier
|
34
34
|
|
data/Rakefile
ADDED
data/base/Dockerfile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
FROM ubuntu:18.04
|
2
|
+
RUN apt-get -q update \
|
3
|
+
&& apt-get install -q -y --no-install-recommends \
|
4
|
+
wget \
|
5
|
+
unzip \
|
6
|
+
imagemagick \
|
7
|
+
python2.7 \
|
8
|
+
python-pip \
|
9
|
+
openjdk-8-jre-headless \
|
10
|
+
libreoffice \
|
11
|
+
ghostscript
|
12
|
+
|
13
|
+
RUN apt-get clean \
|
14
|
+
&& rm -rf /var/lib/apt/lists/*
|
15
|
+
|
16
|
+
RUN pip install --upgrade pip && pip install opf-fido
|
17
|
+
|
18
|
+
RUN wget -q -O droid.zip "http://www.nationalarchives.gov.uk/documents/information-management/droid-binary-6.4-bin.zip" \
|
19
|
+
&& mkdir -p /opt/droid \
|
20
|
+
&& unzip -d /opt/droid droid.zip \
|
21
|
+
&& chmod 755 /opt/droid/droid.sh \
|
22
|
+
&& rm droid.zip
|
23
|
+
|
24
|
+
RUN wget -q -O fop.tar.gz "http://www.apache.org/dyn/closer.cgi?filename=/xmlgraphics/fop/binaries/fop-2.3-bin.tar.gz&action=download" \
|
25
|
+
&& mkdir -p /opt/fop \
|
26
|
+
&& tar xzf fop.tar.gz -C /opt/fop --strip-components=2 \
|
27
|
+
&& rm fop.tar.gz
|
28
|
+
|
29
|
+
RUN echo "8\n9\n" | apt-get install tzdata
|
30
|
+
RUN mkdir -p /teneo/format/spec
|
31
|
+
ADD ./tools /teneo/format/tools
|
32
|
+
ADD ./data /teneo/format/data
|
33
|
+
ADD ./spec/data /teneo/format/spec/data
|
34
|
+
ADD ./base/rework_path /teneo/format/rework_path
|
35
|
+
CMD /bin/bash
|
@@ -0,0 +1,20 @@
|
|
1
|
+
FROM alpine:3.8
|
2
|
+
LABEL maintainer="kris.dekeyser@libis.be"
|
3
|
+
RUN apk update -q && apk upgrade -q
|
4
|
+
RUN apk add -q python2 py-pip openjdk8-jre ffmpeg libreoffice ttf-liberation ttf-freefont ttf-opensans sox git wget unzip sudo bash curl tar imagemagick
|
5
|
+
# install fido
|
6
|
+
RUN pip install -q --upgrade pip && pip install -q opf-fido
|
7
|
+
# install droid
|
8
|
+
RUN wget -q -O droid.zip http://www.nationalarchives.gov.uk/documents/information-management/droid-binary-6.4-bin.zip \
|
9
|
+
&& mkdir -p /opt/droid \
|
10
|
+
&& unzip -q -d /opt/droid droid.zip \
|
11
|
+
&& chmod 755 /opt/droid/droid.sh \
|
12
|
+
&& rm droid.zip
|
13
|
+
# install ImageMagick
|
14
|
+
RUN apk add -q imagemagick
|
15
|
+
ADD ../tools /tools
|
16
|
+
ADD ../data /cfg
|
17
|
+
VOLUME /data
|
18
|
+
WORKDIR /data
|
19
|
+
|
20
|
+
CMD ["/bin/bash", "-l"]
|
data/base/Dockerfile.rvm
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
ARG ubuntu_ver=latest
|
2
|
+
ARG ruby_ver=2.5.3
|
3
|
+
ARG node_ver=10.15.0
|
4
|
+
|
5
|
+
FROM ubuntu:${ubuntu_ver}
|
6
|
+
LABEL maintainer="kris.dekeyser@libis.be"
|
7
|
+
|
8
|
+
ENV RUBY_ENV=${ruby_ver}
|
9
|
+
ENV NVM_DIR=/usr/local/nvm
|
10
|
+
ENV NODE_VER=${node_ver}
|
11
|
+
ENV NODE_PATH=$NVM_DIR/v$NODE_VER/lib/node_modules
|
12
|
+
ENV NODE_PATH=$NVM_DIR/versions/node/v$NODE_VER/bin
|
13
|
+
ENV PATH "${PATH}:${NODE_PATH}:${NODE_PATH}/npm"
|
14
|
+
|
15
|
+
RUN echo $RUBY_ENV
|
16
|
+
|
17
|
+
ENV DEBIAN_FRONTEND=noninteractive
|
18
|
+
RUN apt-get update -q \
|
19
|
+
&& apt-get install -y -q --no-install-recommends software-properties-common apt-utils
|
20
|
+
RUN apt-add-repository -y ppa:rael-gc/rvm \
|
21
|
+
&& apt-get update -q
|
22
|
+
RUN apt-get install -y -q --no-install-recommends \
|
23
|
+
build-essential \
|
24
|
+
gnupg2 \
|
25
|
+
git \
|
26
|
+
wget \
|
27
|
+
curl \
|
28
|
+
sudo \
|
29
|
+
unzip \
|
30
|
+
openjdk-8-jre-headless
|
31
|
+
|
32
|
+
ENV BASH_ENV='/etc/profile exec bash'
|
33
|
+
SHELL ["/bin/bash", "-l", "-c"]
|
34
|
+
|
35
|
+
RUN addgroup --gid 2000 teneo \
|
36
|
+
&& adduser --uid 2000 --gid 2000 --disabled-password --gecos "Teneo user" teneo \
|
37
|
+
&& usermod -L -s /bin/bash teneo
|
38
|
+
RUN echo 'teneo ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers
|
39
|
+
|
40
|
+
USER teneo
|
41
|
+
|
42
|
+
RUN gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
|
43
|
+
|
44
|
+
RUN curl -sSL https://get.rvm.io | bash -s stable
|
45
|
+
|
46
|
+
RUN echo 'gem: --no-document' > ${HOME}/.gemrc
|
47
|
+
RUN echo rvm install ${ruby_ver}
|
48
|
+
RUN echo rvm use ${RUBY_ENV}@teneo --create --ruby-version --ruby-gems
|
49
|
+
|
50
|
+
# required due to bug in rubygems (https://github.com/rubygems/rubygems/issues/2483)
|
51
|
+
RUN gem install rdoc bundler
|
52
|
+
RUN gem update --no-document --system
|
53
|
+
RUN rvm info
|
54
|
+
#ADD . /home/libis/libis_format
|
55
|
+
#WORKDIR /home/libis/libis_format
|
56
|
+
#RUN bundle install && bundle exec rake spec
|
data/base/rework_path
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
CMD=$1
|
4
|
+
shift
|
5
|
+
|
6
|
+
readarray -d ',' -t mapping <<< "$VOLUME_MAPPING"
|
7
|
+
|
8
|
+
args=("$@")
|
9
|
+
#echo "args: ${args[@]}"
|
10
|
+
for map in "${mapping[@]}"
|
11
|
+
do
|
12
|
+
map="${map//[$'\t\r\n ']}"
|
13
|
+
readarray -d '=' -t m <<< "$map"
|
14
|
+
src="${m[0]//[$'\t\r\n ']}"
|
15
|
+
tgt="${m[1]//[$'\t\r\n ']}"
|
16
|
+
# echo "$src -> $tgt"
|
17
|
+
args=("${args[@]/$src/$tgt}")
|
18
|
+
# echo "args: ${args[@]}"
|
19
|
+
done
|
20
|
+
${CMD} "${args[@]}"
|
data/data/PDFA_def.ps
CHANGED
@@ -5,10 +5,10 @@
|
|
5
5
|
% unless the user modifies the corresponding line below.
|
6
6
|
|
7
7
|
% Define entries in the document Info dictionary :
|
8
|
-
/ICCProfile ([**ICC profile**])
|
8
|
+
/ICCProfile ([** Fill in ICC profile location **])
|
9
9
|
def
|
10
10
|
|
11
|
-
[
|
11
|
+
[ /Title (Title)
|
12
12
|
/DOCINFO pdfmark
|
13
13
|
|
14
14
|
% Define an ICC profile :
|
@@ -35,6 +35,6 @@ def
|
|
35
35
|
/Type /OutputIntent % Must be so (the standard requires).
|
36
36
|
/S /GTS_PDFA1 % Must be so (the standard requires).
|
37
37
|
/DestOutputProfile {icc_PDFA} % Must be so (see above).
|
38
|
-
/OutputConditionIdentifier ([**ICC reference**])
|
38
|
+
/OutputConditionIdentifier ([** Fill in ICC reference name **])
|
39
39
|
>> /PUT pdfmark
|
40
40
|
[{Catalog} <</OutputIntents [ {OutputIntent_PDFA} ]>> /PUT pdfmark
|
data/data/eciRGB_v2.icc
ADDED
Binary file
|
data/data/types.yml
CHANGED
@@ -96,14 +96,14 @@ AUDIO:
|
|
96
96
|
|
97
97
|
AAC:
|
98
98
|
NAME: Advanced Audio Coding (AAC)
|
99
|
-
MIME: audio/aac
|
99
|
+
MIME: audio/aac
|
100
100
|
EXTENSIONS: aac
|
101
101
|
|
102
102
|
WMA:
|
103
103
|
NAME: Windows Media Audio (WMA)
|
104
104
|
MIME: audio/x-ms-wma
|
105
105
|
PUID: fmt/132
|
106
|
-
EXTENSIONS: wma
|
106
|
+
EXTENSIONS: wma
|
107
107
|
|
108
108
|
ALAC:
|
109
109
|
NAME: Apple Lossless Audio Codec (ALAC)
|
@@ -194,7 +194,7 @@ VIDEO:
|
|
194
194
|
NAME: Windows Media Video (WMV)
|
195
195
|
MIME: video/x-ms-wmv
|
196
196
|
PUID: fmt/133 fmt/441
|
197
|
-
EXTENSIONS: wmv
|
197
|
+
EXTENSIONS: wmv
|
198
198
|
|
199
199
|
DV:
|
200
200
|
NAME: Digital Video (DV)
|
@@ -319,12 +319,6 @@ TEXT:
|
|
319
319
|
|
320
320
|
TABULAR:
|
321
321
|
|
322
|
-
CSV:
|
323
|
-
NAME: Comma Separated Values
|
324
|
-
MIME: text/csv
|
325
|
-
PUID: x-fmt/18
|
326
|
-
EXTENSIONS: csv
|
327
|
-
|
328
322
|
MSXLS:
|
329
323
|
NAME: Microsoft Excel Spreadsheet (XLS)
|
330
324
|
MIME: application/vnd.ms-excel,application/msexcel
|
@@ -357,15 +351,8 @@ TABULAR:
|
|
357
351
|
|
358
352
|
PRESENTATION:
|
359
353
|
|
360
|
-
MSPPS:
|
361
|
-
NAME: Microsoft Powerpoint Presentation Show
|
362
|
-
PUID: x-fmt/87
|
363
|
-
MIME: application/vnd.ms-powerpoint
|
364
|
-
EXTENSIONS: pps
|
365
|
-
|
366
354
|
MSPPT:
|
367
355
|
NAME: Microsoft Powerpoint Presentation (PPT)
|
368
|
-
PUID: fmt/181 fmt/179 fmt/1747 fmt/1748 x-fmt/88 fmt/125 fmt/126
|
369
356
|
MIME: application/vnd.ms-powerpoint,application/mspowerpoint
|
370
357
|
EXTENSIONS: ppt
|
371
358
|
|
@@ -377,7 +364,7 @@ PRESENTATION:
|
|
377
364
|
|
378
365
|
OO_IMPRESS:
|
379
366
|
NAME: OpenDocument Presentation (ODP)
|
380
|
-
|
367
|
+
PUIID: fmt/138 fmt/292 fmt/293
|
381
368
|
MIME: application/vnd.oasis.opendocument.presentation application/vnd.oasis.opendocument.presentation-template
|
382
369
|
EXTENSIONS: odp otp
|
383
370
|
|
data/docker_cfg.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
:fop_jar: '/tools/fop.jar'
|
@@ -67,7 +67,7 @@ module Libis
|
|
67
67
|
arguments that any of the targetted converters support.
|
68
68
|
|
69
69
|
The source file's format will be identified by the Libis::Format::Identifier and the target file's format
|
70
|
-
will be derived from the file's extension. The Libis::Format::
|
70
|
+
will be derived from the file's extension. The Libis::Format::Library is used to relate extensions
|
71
71
|
with formats.
|
72
72
|
|
73
73
|
DESC
|
@@ -89,7 +89,7 @@ module Libis
|
|
89
89
|
A source file name and target file name should be supplied. The source file should exist and be readable.
|
90
90
|
The target file should be writable, but should not exist.
|
91
91
|
|
92
|
-
The target file's format will be derived from the file's extension. The Libis::Format::
|
92
|
+
The target file's format will be derived from the file's extension. The Libis::Format::Library is used
|
93
93
|
to relate extensions with formats.
|
94
94
|
|
95
95
|
DESC
|
@@ -265,11 +265,11 @@ module Libis
|
|
265
265
|
end
|
266
266
|
|
267
267
|
def extname(format)
|
268
|
-
Libis::Format::
|
268
|
+
Libis::Format::Library.get_field(format, :extensions)
|
269
269
|
end
|
270
270
|
|
271
271
|
def get_format(file_name)
|
272
|
-
Libis::Format::
|
272
|
+
Libis::Format::Library.get_field_by(:extension, File.extname(file_name), :format)
|
273
273
|
end
|
274
274
|
|
275
275
|
def format_identifier(file)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'tty-prompt'
|
4
2
|
require 'pastel'
|
5
3
|
|
@@ -7,6 +5,7 @@ module Libis
|
|
7
5
|
module Format
|
8
6
|
module Cli
|
9
7
|
module PromptHelper
|
8
|
+
|
10
9
|
attr_reader :prompt, :pastel
|
11
10
|
|
12
11
|
def initialize(*args)
|
@@ -15,6 +14,8 @@ module Libis
|
|
15
14
|
super
|
16
15
|
end
|
17
16
|
|
17
|
+
protected
|
18
|
+
|
18
19
|
private
|
19
20
|
|
20
21
|
def index_of(list, value)
|
@@ -24,9 +25,7 @@ module Libis
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def ask(question, bool: false, enum: nil, default: nil, mask: false)
|
27
|
-
cmd = :ask
|
28
|
-
args = [question]
|
29
|
-
opts = {}
|
28
|
+
cmd, args, opts = :ask, [question], {}
|
30
29
|
if enum
|
31
30
|
cmd = :select
|
32
31
|
args << enum
|
@@ -39,57 +38,50 @@ module Libis
|
|
39
38
|
prompt.send(cmd, *args, opts)
|
40
39
|
end
|
41
40
|
|
42
|
-
def tree_select(path, question: nil, file: false, page_size: 22, filter: true, cycle: false, create: false,
|
41
|
+
def tree_select(path, question: nil, file: false, page_size: 22, filter: true, cycle: false, create: false,
|
43
42
|
default_choices: nil)
|
44
43
|
path = Pathname.new(path) unless path.is_a? Pathname
|
45
44
|
|
46
45
|
return path unless path.exist?
|
47
|
-
|
48
46
|
path = path.realpath
|
49
47
|
|
50
48
|
dirs = path.children.select(&:directory?).sort
|
51
49
|
files = file ? path.children.select(&:file?).sort : []
|
52
50
|
|
53
51
|
choices = []
|
54
|
-
choices << {
|
52
|
+
choices << {name: "Folder: #{path}", value: path, disabled: file ? '' : false}
|
55
53
|
choices += default_choices if default_choices
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
new_path = path + new_name
|
62
|
-
FileUtils.mkdir(new_path.to_path)
|
63
|
-
new_path
|
64
|
-
}
|
65
|
-
}
|
54
|
+
choices << {name: '-- new directory --', value: -> do
|
55
|
+
new_name = prompt.ask('new directory name:', modify: :trim, required: true)
|
56
|
+
new_path = path + new_name
|
57
|
+
FileUtils.mkdir(new_path.to_path)
|
58
|
+
new_path
|
66
59
|
end
|
60
|
+
} if create
|
67
61
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
new_name = prompt.ask('new file name:', modify: :trim, required: true)
|
72
|
-
path + new_name
|
73
|
-
}
|
74
|
-
}
|
62
|
+
choices << {name: "-- new file --", value: -> do
|
63
|
+
new_name = prompt.ask('new file name:', modify: :trim, required: true)
|
64
|
+
path + new_name
|
75
65
|
end
|
66
|
+
} if file && create
|
76
67
|
|
77
|
-
choices << {
|
68
|
+
choices << {name: '[..]', value: path.parent}
|
78
69
|
|
79
|
-
dirs.each {
|
80
|
-
files.each {
|
70
|
+
dirs.each {|d| choices << {name: "[#{d.basename}]", value: d}}
|
71
|
+
files.each {|f| choices << {name: f.basename.to_path, value: f}}
|
81
72
|
|
82
73
|
question ||= "Select #{'file or ' if files}directory"
|
83
74
|
selection = prompt.select question, choices,
|
84
|
-
per_page: page_size, filter
|
75
|
+
per_page: page_size, filter: filter, cycle: cycle, default: file ? 2 : 1
|
85
76
|
|
86
77
|
return selection unless selection.is_a? Pathname
|
87
78
|
return selection.to_path if selection == path || selection.file?
|
88
79
|
|
89
|
-
tree_select selection, question
|
90
|
-
|
80
|
+
tree_select selection, question: question, file: file, page_size: page_size, filter: filter,
|
81
|
+
cycle: cycle, create: create, default_choices: default_choices
|
91
82
|
end
|
83
|
+
|
92
84
|
end
|
93
85
|
end
|
94
86
|
end
|
95
|
-
end
|
87
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'thor'
|
4
2
|
require 'tty-prompt'
|
5
3
|
require 'tty-config'
|
@@ -9,7 +7,9 @@ require 'libis/format/cli/format'
|
|
9
7
|
|
10
8
|
module Libis
|
11
9
|
module Format
|
10
|
+
|
12
11
|
class CommandLine < Thor
|
12
|
+
|
13
13
|
def self.exit_on_failure?
|
14
14
|
true
|
15
15
|
end
|
@@ -20,5 +20,6 @@ module Libis
|
|
20
20
|
desc 'format', 'perform format identification on a given file or directory'
|
21
21
|
subcommand 'format', Cli::Format
|
22
22
|
end
|
23
|
+
|
23
24
|
end
|
24
25
|
end
|
data/lib/libis/format/config.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# encoding: utf-8
|
3
2
|
require 'os'
|
4
3
|
require 'libis-tools'
|
5
4
|
|
6
5
|
module Libis
|
7
6
|
module Format
|
7
|
+
|
8
|
+
# noinspection RubyConstantNamingConvention
|
8
9
|
Config = ::Libis::Tools::Config
|
9
10
|
|
10
11
|
Config[:converter_chain_max_level] = 8
|
@@ -15,32 +16,33 @@ module Libis
|
|
15
16
|
Config[:ghostscript_cmd] = 'gs'
|
16
17
|
Config[:droid_cmd] = '/opt/droid/droid.sh'
|
17
18
|
Config[:droid_temp_path] = '/tmp'
|
18
|
-
Config[:fido_cmd] = 'fido'
|
19
|
+
Config[:fido_cmd] = '/usr/local/bin/fido'
|
19
20
|
Config[:fop_jar] = File.join(Libis::Format::TOOL_DIR, 'fop', 'build', 'fop.jar')
|
20
21
|
Config[:ffmpeg_cmd] = 'ffmpeg'
|
21
|
-
Config[:fido_formats] = [File.join(Libis::Format::DATA_DIR, 'lias_formats.xml')]
|
22
|
+
Config[:fido_formats] = [(File.join(Libis::Format::DATA_DIR, 'lias_formats.xml'))]
|
22
23
|
Config[:pdf_tool] = File.join(Libis::Format::TOOL_DIR, 'PdfTool.jar')
|
23
24
|
Config[:preflight_jar] = File.join(Libis::Format::TOOL_DIR, 'pdfbox', 'preflight-app-2.0.13.jar')
|
24
|
-
|
25
|
+
# noinspection RubyStringKeysInHashInspection
|
25
26
|
Config[:xml_validations] = [['archive/ead', File.join(Libis::Format::DATA_DIR, 'ead.xsd')]]
|
26
|
-
Config[:
|
27
|
+
Config[:format_library_implementation] = 'Libis::Format::YamlLoader.instance'
|
28
|
+
Config[:format_library_database] = File.join(Libis::Format::DATA_DIR, 'types.yml')
|
27
29
|
Config[:raw_audio_convert_cmd] = 'sox -V1 %s -e signed -b 16 -t wav %s rate %d channels %d'
|
28
30
|
Config[:watermark_font] = '/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf'
|
29
31
|
Config[:timeouts] = {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
pdfa_validator: 5 * 60
|
32
|
+
droid: 20 * 60,
|
33
|
+
ffmpeg: 5 * 60,
|
34
|
+
fido: 20 * 60,
|
35
|
+
file_tool: 5 * 60,
|
36
|
+
fop: 5 * 60,
|
37
|
+
identification_tool: 5 * 60,
|
38
|
+
office_to_pdf: 5 * 60,
|
39
|
+
pdf_copy: 5 * 60,
|
40
|
+
pdf_merge: 5 * 60,
|
41
|
+
pdf_optimizer: 5 * 60,
|
42
|
+
pdf_split: 5 * 60,
|
43
|
+
pdf_to_pdfa: 5 * 60,
|
44
|
+
pdfa_validator: 5 * 60,
|
44
45
|
}
|
46
|
+
|
45
47
|
end
|
46
48
|
end
|