File: 05_Text_BibTeX_File.t

package info (click to toggle)
libdebian-dep12-perl 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 124 kB
  • sloc: perl: 481; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,415 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

eval 'use Text::BibTeX';
plan skip_all => 'Text::BibTeX required' if $@;
plan tests => 1;

use File::Temp;
use Debian::DEP12;

my $tmp = File::Temp->new();
my $fh;
open( $fh, '>', $tmp->filename );
print $fh <<'END';
@Article{Merkys2016,
  author    = {Merkys, Andrius and Vaitkus, Antanas and Butkus, Justas and Okulič-Kazarinas, Mykolas and Kairys, Visvaldas and Gražulis, Saulius},
  journal   = {Journal of Applied Crystallography},
  title     = {{\it COD::CIF::Parser}: an error-correcting {CIF} parser for the {P}erl language},
  year      = {2016},
  month     = {Feb},
  number    = {1},
  pages     = {292--301},
  volume    = {49},
  doi       = {10.1107/S1600576715022396},
  url       = {http://dx.doi.org/10.1107/S1600576715022396},
}
END
close $fh;

my $bibfile = Text::BibTeX::File->new( $tmp->filename );
my $meta = Debian::DEP12->new( $bibfile );
is( $meta->to_YAML, <<'END' );
Reference:
- Author: Merkys, Andrius and Vaitkus, Antanas and Butkus, Justas and Okulič-Kazarinas,
    Mykolas and Kairys, Visvaldas and Gražulis, Saulius
  DOI: 10.1107/S1600576715022396
  Journal: Journal of Applied Crystallography
  Month: Feb
  Number: 1
  Pages: 292--301
  Title: '{\it COD::CIF::Parser}: an error-correcting {CIF} parser for the {P}erl
    language'
  URL: http://dx.doi.org/10.1107/S1600576715022396
  Volume: 49
  Year: 2016
END