cmess 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +68 -81
- data/ChangeLog +28 -0
- data/README +23 -21
- data/Rakefile +15 -16
- data/bin/bconv +30 -47
- data/bin/cinderella +51 -68
- data/bin/decode_entities +28 -36
- data/bin/guess_encoding +53 -81
- data/lib/cmess.rb +35 -26
- data/lib/cmess/bconv.rb +23 -25
- data/lib/cmess/cinderella.rb +21 -20
- data/lib/cmess/cli.rb +27 -17
- data/lib/cmess/decode_entities.rb +19 -20
- data/lib/cmess/guess_encoding.rb +20 -18
- data/lib/cmess/guess_encoding/automatic.rb +151 -125
- data/lib/cmess/guess_encoding/encoding.rb +16 -18
- data/lib/cmess/guess_encoding/manual.rb +26 -31
- data/lib/cmess/version.rb +2 -2
- metadata +25 -28
data/COPYING
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= License for cmess
|
2
|
-
|
3
|
-
GNU GENERAL PUBLIC LICENSE
|
4
|
-
Version 3,
|
2
|
+
|
3
|
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
4
|
+
Version 3, 19 November 2007
|
5
5
|
|
6
6
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
7
7
|
Everyone is permitted to copy and distribute verbatim copies
|
@@ -9,17 +9,15 @@
|
|
9
9
|
|
10
10
|
Preamble
|
11
11
|
|
12
|
-
The GNU General Public License is a free, copyleft license for
|
13
|
-
software and other kinds of works
|
12
|
+
The GNU Affero General Public License is a free, copyleft license for
|
13
|
+
software and other kinds of works, specifically designed to ensure
|
14
|
+
cooperation with the community in the case of network server software.
|
14
15
|
|
15
16
|
The licenses for most software and other practical works are designed
|
16
17
|
to take away your freedom to share and change the works. By contrast,
|
17
|
-
|
18
|
+
our General Public Licenses are intended to guarantee your freedom to
|
18
19
|
share and change all versions of a program--to make sure it remains free
|
19
|
-
software for all its users.
|
20
|
-
GNU General Public License for most of our software; it applies also to
|
21
|
-
any other work released this way by its authors. You can apply it to
|
22
|
-
your programs, too.
|
20
|
+
software for all its users.
|
23
21
|
|
24
22
|
When we speak of free software, we are referring to freedom, not
|
25
23
|
price. Our General Public Licenses are designed to make sure that you
|
@@ -28,44 +26,34 @@
|
|
28
26
|
want it, that you can change the software or use pieces of it in new
|
29
27
|
free programs, and that you know you can do these things.
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
that
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
products. If such problems arise substantially in other domains, we
|
60
|
-
stand ready to extend this provision to those domains in future versions
|
61
|
-
of the GPL, as needed to protect the freedom of users.
|
62
|
-
|
63
|
-
Finally, every program is threatened constantly by software patents.
|
64
|
-
States should not allow patents to restrict development and use of
|
65
|
-
software on general-purpose computers, but in those that do, we wish to
|
66
|
-
avoid the special danger that patents applied to a free program could
|
67
|
-
make it effectively proprietary. To prevent this, the GPL assures that
|
68
|
-
patents cannot be used to render the program non-free.
|
29
|
+
Developers that use our General Public Licenses protect your rights
|
30
|
+
with two steps: (1) assert copyright on the software, and (2) offer
|
31
|
+
you this License which gives you legal permission to copy, distribute
|
32
|
+
and/or modify the software.
|
33
|
+
|
34
|
+
A secondary benefit of defending all users' freedom is that
|
35
|
+
improvements made in alternate versions of the program, if they
|
36
|
+
receive widespread use, become available for other developers to
|
37
|
+
incorporate. Many developers of free software are heartened and
|
38
|
+
encouraged by the resulting cooperation. However, in the case of
|
39
|
+
software used on network servers, this result may fail to come about.
|
40
|
+
The GNU General Public License permits making a modified version and
|
41
|
+
letting the public access it on a server without ever releasing its
|
42
|
+
source code to the public.
|
43
|
+
|
44
|
+
The GNU Affero General Public License is designed specifically to
|
45
|
+
ensure that, in such cases, the modified source code becomes available
|
46
|
+
to the community. It requires the operator of a network server to
|
47
|
+
provide the source code of the modified version running there to the
|
48
|
+
users of that server. Therefore, public use of a modified version, on
|
49
|
+
a publicly accessible server, gives the public access to the source
|
50
|
+
code of the modified version.
|
51
|
+
|
52
|
+
An older license, called the Affero General Public License and
|
53
|
+
published by Affero, was designed to accomplish similar goals. This is
|
54
|
+
a different license, not a version of the Affero GPL, but Affero has
|
55
|
+
released a new version of the Affero GPL which permits relicensing under
|
56
|
+
this license.
|
69
57
|
|
70
58
|
The precise terms and conditions for copying, distribution and
|
71
59
|
modification follow.
|
@@ -74,7 +62,7 @@
|
|
74
62
|
|
75
63
|
0. Definitions.
|
76
64
|
|
77
|
-
"This License" refers to version 3 of the GNU General Public License.
|
65
|
+
"This License" refers to version 3 of the GNU Affero General Public License.
|
78
66
|
|
79
67
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
80
68
|
works, such as semiconductor masks.
|
@@ -551,35 +539,45 @@
|
|
551
539
|
the Program, the only way you could satisfy both those terms and this
|
552
540
|
License would be to refrain entirely from conveying the Program.
|
553
541
|
|
554
|
-
13. Use with the GNU
|
542
|
+
13. Remote Network Interaction; Use with the GNU General Public License.
|
543
|
+
|
544
|
+
Notwithstanding any other provision of this License, if you modify the
|
545
|
+
Program, your modified version must prominently offer all users
|
546
|
+
interacting with it remotely through a computer network (if your version
|
547
|
+
supports such interaction) an opportunity to receive the Corresponding
|
548
|
+
Source of your version by providing access to the Corresponding Source
|
549
|
+
from a network server at no charge, through some standard or customary
|
550
|
+
means of facilitating copying of software. This Corresponding Source
|
551
|
+
shall include the Corresponding Source for any work covered by version 3
|
552
|
+
of the GNU General Public License that is incorporated pursuant to the
|
553
|
+
following paragraph.
|
555
554
|
|
556
555
|
Notwithstanding any other provision of this License, you have
|
557
556
|
permission to link or combine any covered work with a work licensed
|
558
|
-
under version 3 of the GNU
|
557
|
+
under version 3 of the GNU General Public License into a single
|
559
558
|
combined work, and to convey the resulting work. The terms of this
|
560
559
|
License will continue to apply to the part which is the covered work,
|
561
|
-
but the
|
562
|
-
|
563
|
-
combination as such.
|
560
|
+
but the work with which it is combined will remain governed by version
|
561
|
+
3 of the GNU General Public License.
|
564
562
|
|
565
563
|
14. Revised Versions of this License.
|
566
564
|
|
567
565
|
The Free Software Foundation may publish revised and/or new versions of
|
568
|
-
the GNU General Public License from time to time. Such new versions
|
569
|
-
be similar in spirit to the present version, but may differ in detail to
|
566
|
+
the GNU Affero General Public License from time to time. Such new versions
|
567
|
+
will be similar in spirit to the present version, but may differ in detail to
|
570
568
|
address new problems or concerns.
|
571
569
|
|
572
570
|
Each version is given a distinguishing version number. If the
|
573
|
-
Program specifies that a certain numbered version of the GNU General
|
571
|
+
Program specifies that a certain numbered version of the GNU Affero General
|
574
572
|
Public License "or any later version" applies to it, you have the
|
575
573
|
option of following the terms and conditions either of that numbered
|
576
574
|
version or of any later version published by the Free Software
|
577
575
|
Foundation. If the Program does not specify a version number of the
|
578
|
-
GNU General Public License, you may choose any version ever published
|
576
|
+
GNU Affero General Public License, you may choose any version ever published
|
579
577
|
by the Free Software Foundation.
|
580
578
|
|
581
579
|
If the Program specifies that a proxy can decide which future
|
582
|
-
versions of the GNU General Public License can be used, that proxy's
|
580
|
+
versions of the GNU Affero General Public License can be used, that proxy's
|
583
581
|
public statement of acceptance of a version permanently authorizes you
|
584
582
|
to choose that version for the Program.
|
585
583
|
|
@@ -637,40 +635,29 @@
|
|
637
635
|
Copyright (C) <year> <name of author>
|
638
636
|
|
639
637
|
This program is free software: you can redistribute it and/or modify
|
640
|
-
it under the terms of the GNU General Public License as published by
|
638
|
+
it under the terms of the GNU Affero General Public License as published by
|
641
639
|
the Free Software Foundation, either version 3 of the License, or
|
642
640
|
(at your option) any later version.
|
643
641
|
|
644
642
|
This program is distributed in the hope that it will be useful,
|
645
643
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
646
644
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
647
|
-
GNU General Public License for more details.
|
645
|
+
GNU Affero General Public License for more details.
|
648
646
|
|
649
|
-
You should have received a copy of the GNU General Public License
|
647
|
+
You should have received a copy of the GNU Affero General Public License
|
650
648
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
651
649
|
|
652
650
|
Also add information on how to contact you by electronic and paper mail.
|
653
651
|
|
654
|
-
If
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
The hypothetical commands `show w' and `show c' should show the appropriate
|
663
|
-
parts of the General Public License. Of course, your program's commands
|
664
|
-
might be different; for a GUI interface, you would use an "about box".
|
652
|
+
If your software can interact with users remotely through a computer
|
653
|
+
network, you should also make sure that it provides a way for users to
|
654
|
+
get its source. For example, if your program is a web application, its
|
655
|
+
interface could display a "Source" link that leads users to an archive
|
656
|
+
of the code. There are many ways you could offer source, and different
|
657
|
+
solutions will be better for different programs; see section 13 for the
|
658
|
+
specific requirements.
|
665
659
|
|
666
660
|
You should also get your employer (if you work as a programmer) or school,
|
667
661
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
668
|
-
For more information on this, and how to apply and follow the GNU
|
662
|
+
For more information on this, and how to apply and follow the GNU AGPL, see
|
669
663
|
<http://www.gnu.org/licenses/>.
|
670
|
-
|
671
|
-
The GNU General Public License does not permit incorporating your program
|
672
|
-
into proprietary programs. If your program is a subroutine library, you
|
673
|
-
may consider it more useful to permit linking proprietary applications with
|
674
|
-
the library. If this is what you want to do, use the GNU Lesser General
|
675
|
-
Public License instead of this License. But first, please read
|
676
|
-
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
data/ChangeLog
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
= Revision history for cmess
|
2
2
|
|
3
|
+
== 0.3.0 [2011-07-25]
|
4
|
+
|
5
|
+
* Extensive refactoring
|
6
|
+
* Some more Ruby 1.9 compatibility fixes (thx to @Omer)
|
7
|
+
|
8
|
+
== 0.2.5 [2011-04-29]
|
9
|
+
|
10
|
+
* Switched license to Affero GPL
|
11
|
+
|
12
|
+
== 0.2.4 [2010-07-13]
|
13
|
+
|
14
|
+
* decode_entities: Added flavour 'xml-safe' for HTMLEntities decoder
|
15
|
+
and made it the new default
|
16
|
+
|
17
|
+
== 0.2.3 [2010-04-23]
|
18
|
+
|
19
|
+
* guess_encoding: Conveniently test common encodings
|
20
|
+
* cinderella: Ignore illegal sequences in char pool
|
21
|
+
* Housekeeping
|
22
|
+
|
23
|
+
== 0.2.2 [2009-10-24]
|
24
|
+
|
25
|
+
* guess_encoding: More encodings from the ISO 8859 family
|
26
|
+
|
27
|
+
== 0.2.1 [2009-09-24]
|
28
|
+
|
29
|
+
* decode_entities: Fixes for current HTMLEntities
|
30
|
+
|
3
31
|
== 0.2.0 [2009-05-08]
|
4
32
|
|
5
33
|
* Ruby 1.9 compatibility (Syntax, at least)
|
data/README
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== VERSION
|
4
4
|
|
5
|
-
This documentation refers to cmess version 0.
|
5
|
+
This documentation refers to cmess version 0.3.0
|
6
6
|
|
7
7
|
|
8
8
|
== DESCRIPTION
|
@@ -11,15 +11,16 @@ CMess bundles several tools under its hood that aim at dealing with various
|
|
11
11
|
problems occurring in the context of character sets and encodings. Currently,
|
12
12
|
there are:
|
13
13
|
|
14
|
-
guess_encoding
|
15
|
-
|
16
|
-
|
17
|
-
cinderella
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
bconv
|
22
|
-
|
14
|
+
+guess_encoding+:: Simple helper to identify the encoding of a given string.
|
15
|
+
Includes the ability to automatically detect the encoding
|
16
|
+
of an input. (see CMess::GuessEncoding)
|
17
|
+
+cinderella+:: When characters are "double encoded", you can't easily
|
18
|
+
convert them back -- this is where cinderella comes in,
|
19
|
+
sorting the good ones into the pot and the (potentially)
|
20
|
+
bad ones into the crop... (see CMess::Cinderella)
|
21
|
+
+bconv+:: Convert between bibliographic (and other) encodings.
|
22
|
+
(see CMess::BConv)
|
23
|
+
+decode_entities+:: Decode HTML entities in a string. (see CMess::DecodeEntities)
|
23
24
|
|
24
25
|
TODO: well, more of the description... ;-)
|
25
26
|
|
@@ -27,10 +28,10 @@ TODO: well, more of the description... ;-)
|
|
27
28
|
== LINKS
|
28
29
|
|
29
30
|
<b></b>
|
30
|
-
Documentation::
|
31
|
-
Source code
|
32
|
-
|
33
|
-
|
31
|
+
Documentation:: http://prometheus.rubyforge.org/cmess
|
32
|
+
Source code:: http://github.com/blackwinter/cmess
|
33
|
+
RubyForge project:: http://rubyforge.org/projects/prometheus
|
34
|
+
RubyGem:: http://rubygems.org/gems/cmess
|
34
35
|
|
35
36
|
|
36
37
|
== AUTHORS
|
@@ -47,17 +48,18 @@ Rubyforge project:: <http://rubyforge.org/projects/prometheus>
|
|
47
48
|
|
48
49
|
== LICENSE AND COPYRIGHT
|
49
50
|
|
50
|
-
Copyright (C) 2007-
|
51
|
+
Copyright (C) 2007-2011 University of Cologne,
|
51
52
|
Albertus-Magnus-Platz, 50923 Cologne, Germany
|
52
53
|
|
53
54
|
cmess is free software: you can redistribute it and/or modify it under the
|
54
|
-
terms of the GNU General Public License as published by the Free
|
55
|
-
Foundation, either version 3 of the License, or (at your option)
|
56
|
-
version.
|
55
|
+
terms of the GNU Affero General Public License as published by the Free
|
56
|
+
Software Foundation, either version 3 of the License, or (at your option)
|
57
|
+
any later version.
|
57
58
|
|
58
59
|
cmess is distributed in the hope that it will be useful, but WITHOUT ANY
|
59
60
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
60
|
-
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
61
|
+
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
62
|
+
more details.
|
61
63
|
|
62
|
-
You should have received a copy of the GNU General Public License
|
63
|
-
cmess. If not, see <http://www.gnu.org/licenses/>.
|
64
|
+
You should have received a copy of the GNU Affero General Public License
|
65
|
+
along with cmess. If not, see <http://www.gnu.org/licenses/>.
|
data/Rakefile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
$:.unshift(File.expand_path('../lib', __FILE__))
|
2
|
+
|
3
|
+
require 'cmess'
|
2
4
|
|
3
5
|
begin
|
4
6
|
require 'hen'
|
@@ -15,37 +17,34 @@ begin
|
|
15
17
|
Assist with handling messed up encodings (Currently includes the
|
16
18
|
following tools: #{Dir['bin/*'].map { |e| File.basename(e) }.sort.join(', ')})
|
17
19
|
},
|
18
|
-
:
|
19
|
-
:
|
20
|
+
:author => %q{Jens Wille},
|
21
|
+
:email => %q{jens.wille@uni-koeln.de},
|
22
|
+
:extra_files => FileList['data/**/*'].to_a,
|
20
23
|
:dependencies => [['ruby-nuggets', '>= 0.3.3'], 'htmlentities']
|
21
24
|
}
|
22
25
|
}}
|
23
|
-
rescue LoadError
|
24
|
-
|
26
|
+
rescue LoadError => err
|
27
|
+
warn "Please install the `hen' gem. (#{err})"
|
25
28
|
end
|
26
29
|
|
27
30
|
namespace :guess_encoding do
|
28
31
|
|
29
32
|
desc "Compare actual encoding and automatic guess of example files"
|
30
33
|
task :check_examples do
|
31
|
-
require 'lib/cmess/guess_encoding'
|
32
|
-
|
33
34
|
E = CMess::GuessEncoding::Encoding
|
34
35
|
|
35
36
|
Dir[File.join(File.dirname(__FILE__), 'example', 'guess_encoding', '??.*.txt')].sort.each { |example|
|
36
37
|
language, encoding = File.basename(example, '.txt').split('.')
|
37
38
|
encoding.upcase!
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
match = case guessed
|
42
|
-
when E::UNKNOWN: '?'
|
43
|
-
when E::ASCII: '#'
|
44
|
-
when encoding: '+'
|
45
|
-
else '-'
|
46
|
-
end
|
40
|
+
result = CMess::GuessEncoding::Automatic.guess(File.open(example))
|
47
41
|
|
48
|
-
puts '%s %s/%-11s => %s' % [
|
42
|
+
puts '%s %s/%-11s => %s' % [case result
|
43
|
+
when E::UNKNOWN then '?'
|
44
|
+
when E::ASCII then '#'
|
45
|
+
when encoding then '+'
|
46
|
+
else '-'
|
47
|
+
end, language, encoding, result]
|
49
48
|
}
|
50
49
|
end
|
51
50
|
|
data/bin/bconv
CHANGED
@@ -6,43 +6,32 @@
|
|
6
6
|
# bconv -- Convert between bibliographic (and other) encodings #
|
7
7
|
# [A component of cmess, the encoding tool-box] #
|
8
8
|
# #
|
9
|
-
# Copyright (C) 2008 University of Cologne,
|
10
|
-
#
|
11
|
-
#
|
9
|
+
# Copyright (C) 2008-2011 University of Cologne, #
|
10
|
+
# Albertus-Magnus-Platz, #
|
11
|
+
# 50923 Cologne, Germany #
|
12
12
|
# #
|
13
13
|
# Authors: #
|
14
14
|
# Jens Wille <jens.wille@uni-koeln.de> #
|
15
15
|
# #
|
16
16
|
# cmess is free software; you can redistribute it and/or modify it under the #
|
17
|
-
# terms of the GNU General Public License as published by the Free
|
18
|
-
# Foundation; either version 3 of the License, or (at your option)
|
19
|
-
# version.
|
17
|
+
# terms of the GNU Affero General Public License as published by the Free #
|
18
|
+
# Software Foundation; either version 3 of the License, or (at your option) #
|
19
|
+
# any later version. #
|
20
20
|
# #
|
21
21
|
# cmess is distributed in the hope that it will be useful, but WITHOUT ANY #
|
22
22
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
23
|
-
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
24
|
-
# details.
|
23
|
+
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for #
|
24
|
+
# more details. #
|
25
25
|
# #
|
26
|
-
# You should have received a copy of the GNU General Public License
|
27
|
-
# with cmess. If not, see <http://www.gnu.org/licenses/>.
|
26
|
+
# You should have received a copy of the GNU Affero General Public License #
|
27
|
+
# along with cmess. If not, see <http://www.gnu.org/licenses/>. #
|
28
28
|
# #
|
29
29
|
###############################################################################
|
30
30
|
#++
|
31
31
|
|
32
|
-
require 'optparse'
|
33
|
-
|
34
|
-
require 'rubygems'
|
35
|
-
require 'nuggets/string/word_wrap'
|
36
|
-
|
37
|
-
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
38
|
-
|
39
32
|
require 'cmess/bconv'
|
40
|
-
require 'cmess/cli'
|
41
|
-
|
42
33
|
include CMess::CLI
|
43
34
|
|
44
|
-
PROGNAME = File.basename($0)
|
45
|
-
|
46
35
|
options = {
|
47
36
|
:input => STDIN,
|
48
37
|
:output => STDOUT,
|
@@ -51,62 +40,62 @@ options = {
|
|
51
40
|
:chartab_file => CMess::BConv::DEFAULT_CHARTAB_FILE
|
52
41
|
}
|
53
42
|
|
54
|
-
|
43
|
+
parse_options { |opts|
|
55
44
|
opts.banner = "Usage: #{$0} [options] [FILE...]"
|
56
45
|
|
57
46
|
opts.separator ''
|
58
47
|
opts.separator 'Options:'
|
59
48
|
|
60
|
-
opts.on('-i', '--input FILE',
|
61
|
-
options[:input] = open_file_or_std(
|
49
|
+
opts.on('-i', '--input FILE', 'Input file to read from [Default: STDIN]') { |input|
|
50
|
+
options[:input] = open_file_or_std(input)
|
62
51
|
options[:input_set] = true
|
63
52
|
}
|
64
53
|
|
65
|
-
opts.on('-o', '--output FILE',
|
66
|
-
options[:output] = open_file_or_std(
|
54
|
+
opts.on('-o', '--output FILE', 'Output file to write to [Default: STDOUT]') { |output|
|
55
|
+
options[:output] = open_file_or_std(output, 'w')
|
67
56
|
}
|
68
57
|
|
69
|
-
opts.on('-I', '--in-place FILE', "Modify file in-place; sets '-i' and '-o'") { |
|
70
|
-
options[:input], options[:output] = open_file_in_place(
|
58
|
+
opts.on('-I', '--in-place FILE', "Modify file in-place; sets '-i' and '-o'") { |file|
|
59
|
+
options[:input], options[:output] = open_file_in_place(file)
|
71
60
|
options[:input_set] = true
|
72
61
|
}
|
73
62
|
|
74
63
|
opts.separator ''
|
75
64
|
|
76
|
-
opts.on('-e', '--source-encoding ENCODING', "Encoding of input file [Default: #{options[:source_encoding]}]") { |
|
77
|
-
options[:source_encoding] =
|
65
|
+
opts.on('-e', '--source-encoding ENCODING', "Encoding of input file [Default: #{options[:source_encoding]}]") { |encoding|
|
66
|
+
options[:source_encoding] = encoding.downcase
|
78
67
|
}
|
79
68
|
|
80
|
-
opts.on('-t', '--target-encoding ENCODING', "Desired encoding for output file [Default: #{options[:target_encoding]}]") { |
|
81
|
-
options[:target_encoding] =
|
69
|
+
opts.on('-t', '--target-encoding ENCODING', "Desired encoding for output file [Default: #{options[:target_encoding]}]") { |encoding|
|
70
|
+
options[:target_encoding] = encoding.downcase
|
82
71
|
}
|
83
72
|
|
84
73
|
opts.separator ''
|
85
74
|
|
86
|
-
opts.on('-c', '--chartab YAML_FILE',
|
87
|
-
options[:chartab_file] =
|
75
|
+
opts.on('-c', '--chartab YAML_FILE', 'File containing character mappings, in YAML format.', "[Default: #{options[:chartab_file]}]") { |chartab|
|
76
|
+
options[:chartab_file] = chartab
|
88
77
|
}
|
89
78
|
|
90
|
-
opts.on('-l', '--list-encodings',
|
79
|
+
opts.on('-l', '--list-encodings', 'Print a list of all available bibliographic encodings', "and exit; depends on <chartab>, see '-c'") {
|
91
80
|
options[:list_encodings] = true
|
92
81
|
}
|
93
82
|
|
94
83
|
opts.separator ''
|
95
84
|
opts.separator 'Generic options:'
|
96
85
|
|
97
|
-
opts.on('-h', '--help',
|
86
|
+
opts.on('-h', '--help', 'Print this help message and exit') {
|
98
87
|
puts opts
|
99
88
|
exit
|
100
89
|
}
|
101
90
|
|
102
|
-
opts.on('--version',
|
103
|
-
puts "#{
|
91
|
+
opts.on('--version', 'Print program version and exit') {
|
92
|
+
puts "#{File.basename($0)} v#{CMess::BConv::VERSION} (part of cmess v#{CMess::VERSION})"
|
104
93
|
exit
|
105
94
|
}
|
106
95
|
|
107
96
|
opts.separator ''
|
108
|
-
opts.separator
|
109
|
-
}
|
97
|
+
opts.separator 'When FILE is -, either STDIN or STDOUT is used (as appropriate).'
|
98
|
+
}
|
110
99
|
|
111
100
|
cli do
|
112
101
|
if options[:list_encodings]
|
@@ -120,11 +109,5 @@ cli do
|
|
120
109
|
|
121
110
|
trailing_args_as_input(options)
|
122
111
|
|
123
|
-
CMess::BConv.convert(
|
124
|
-
options[:input],
|
125
|
-
options[:output],
|
126
|
-
options[:source_encoding],
|
127
|
-
options[:target_encoding],
|
128
|
-
options[:chartab_file]
|
129
|
-
)
|
112
|
+
CMess::BConv.convert(options)
|
130
113
|
end
|