Skip to content

Commit

Permalink
parse built field (#1)
Browse files Browse the repository at this point in the history
parse built field
  • Loading branch information
gaborcsardi authored Oct 25, 2019
2 parents bbd043c + d509436 commit 30ec7c8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ function parse_desc_stream(descstream, callback) {
if (rec.key == 'Remotes') {
rec.value = parse_remotes(rec.value);
}
if (rec.key == 'Built') {
rec.value = parse_built(rec.value);
}
desc[ rec.key ] = rec.value;
current = line;
}
Expand All @@ -63,6 +66,16 @@ function parse_remotes(str) {
return str.split(/,[\s]*/);
}

function parse_built(str) {
var built = str.split(/;[\s]*/);
return {
R: built[0].replace(/^R /, ''),
Platform: built[1],
Date: built[2],
OStype: built[3]
};
}

function split_record(str) {
var colon = str.indexOf(":");
return { 'key': str.substr(0, colon).trim(),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rdesc-parser",
"version": "2.0.1",
"version": "2.0.2",
"description": "Parser for R package DESCRIPTION files.",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ test.cb('parse_file, zip file', function(t) {
t.is(err, null);
t.is(d.Package, 'foobar');
t.is(d.RoxygenNote, '6.0.1');
t.is(d.Built.R, '3.4.3');
t.is(d.Built.Platform, '');
t.is(d.Built.Date, '2017-12-25 19:19:13 UTC');
t.is(d.Built.OStype, 'unix');
t.end();
});
});

0 comments on commit 30ec7c8

Please sign in to comment.