add encoding feature, add support for Travis CI, prepare for release 1.76
Salvador Fandino
10 years ago
0 | 0 |
Revision history for Perl extension Config::Properties.
|
|
1 |
|
|
2 |
1.76 Feb 13, 2014
|
|
3 |
- add encoding feature
|
1 | 4 |
|
2 | 5 |
1.75 Jul 16, 2012
|
3 | 6 |
- add support for order feature
|
9 | 9 |
t/5_save.t
|
10 | 10 |
t/6_sorted.t
|
11 | 11 |
t/7_pods.t
|
|
12 |
t/utf8.t
|
12 | 13 |
META.yml Module meta-data (added by MakeMaker)
|
2 | 2 |
use strict;
|
3 | 3 |
use warnings;
|
4 | 4 |
|
5 | |
our $VERSION = '1.74';
|
|
5 |
our $VERSION = '1.76';
|
6 | 6 |
|
7 | 7 |
use IO::Handle;
|
8 | 8 |
use Carp;
|
|
9 |
use PerlIO;
|
9 | 10 |
|
10 | 11 |
{
|
11 | 12 |
no warnings;
|
|
44 | 45 |
my $o = shift;
|
45 | 46 |
$o =~ /^(?:keep|alpha|none)$/ or
|
46 | 47 |
croak "invalid order";
|
|
48 |
}
|
|
49 |
|
|
50 |
sub _t_encoding ($) {
|
|
51 |
my $e = shift;
|
|
52 |
$e =~ /^[\w\-]+$/ or
|
|
53 |
croak "invalid encoding '$e'";
|
47 | 54 |
}
|
48 | 55 |
}
|
49 | 56 |
|
|
66 | 73 |
$order = 'keep' unless defined $order;
|
67 | 74 |
_t_order($order);
|
68 | 75 |
my $file = delete $opts{file};
|
69 | |
|
|
76 |
my $encoding = delete $opts{encoding} || 'latin1';
|
|
77 |
_t_encoding($encoding);
|
70 | 78 |
|
71 | 79 |
%opts and croak "invalid option(s) '" . join("', '", keys %opts) . "'";
|
72 | 80 |
|
|
90 | 98 |
properties => {},
|
91 | 99 |
next_line_number => 1,
|
92 | 100 |
property_line_numbers => {},
|
93 | |
file => $file };
|
|
101 |
file => $file,
|
|
102 |
encoding => $encoding };
|
94 | 103 |
bless $self, $class;
|
95 | 104 |
|
96 | 105 |
if (defined $file) {
|
|
227 | 236 |
sub load {
|
228 | 237 |
my ($self, $file) = @_;
|
229 | 238 |
_t_file $file;
|
|
239 |
unless (grep /^(?:encoding|utf8)\b/, PerlIO::get_layers($file)) {
|
|
240 |
binmode $file, ":encoding($self->{encoding})"
|
|
241 |
or croak "Unable to set file encoding layer: $!";
|
|
242 |
}
|
230 | 243 |
$self->{properties}={};
|
231 | 244 |
$self->{property_line_numbers}={};
|
232 | 245 |
$self->{next_line_number}=1;
|
|
670 | 683 |
of the properties as added or readed from a file. C<none> returns the
|
671 | 684 |
properties unordered.
|
672 | 685 |
|
|
686 |
=item encoding => $encoding
|
|
687 |
|
|
688 |
IO encoding used to read the configuration file. See L<PerlIO>.
|
|
689 |
|
|
690 |
When C<load> is called the given encoding is used unless the file
|
|
691 |
handler already has a encoding layer applied.
|
|
692 |
|
|
693 |
C<latin1> is used as the default encoding (as specified in the Java
|
|
694 |
properties specification).
|
|
695 |
|
|
696 |
|
673 | 697 |
=back
|
674 | 698 |
|
675 | 699 |
=item Config::Properties-E<gt>new($defaults)
|