curl_ifrs
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -6,5 +6,5 @@ #!/usr/bin/env node | ||
/** Build downloaded filename from Standard title */ | ||
const buildFilename = title => { | ||
const numMap = new Map([ | ||
/** Build local filename from title of a Standard */ | ||
const buildLocalName = title => { | ||
const conversion = [ | ||
['IFRS ', '1'], | ||
@@ -14,15 +14,12 @@ ['IAS ', '2'], | ||
['SIC-', '4'], | ||
]); | ||
for (const [key, val] of numMap.entries()) { | ||
const pf = title.match(new RegExp(`^${key}(\\d+) .*`)); | ||
if (pf) { | ||
return `${val}${('0' + pf[1]).slice(-2)} ${title}.pdf`; | ||
} | ||
} | ||
return `${title}.pdf`; | ||
]; | ||
return conversion.reduce((prev, [from, to]) => { | ||
const pf = title.match(new RegExp(`^${from}(\\d+) .*`)); | ||
return pf ? to + ('0' + pf[1]).slice(-2) + ' ' + title : prev; | ||
}, title) + '.pdf'; | ||
}; | ||
/** Build download URL from Standard title */ | ||
const buildUrl = (title, baseUrl) => { | ||
const urlMap = new Map([ | ||
/** Build remote filename from title of a Standard */ | ||
const buildRemoteName = title => { | ||
const conversion = [ | ||
['IFRS ', 'IFRS'], | ||
@@ -32,10 +29,7 @@ ['IAS ', 'IAS'], | ||
['SIC-', 'SIC'], | ||
]); | ||
for (const [key, val] of urlMap.entries()) { | ||
const pf = title.match(new RegExp(`^${key}(\\d+) .*`)); | ||
if (pf) { | ||
return `${baseUrl}${val}${pf[1]}.pdf`; | ||
} | ||
} | ||
return `${baseUrl}${title}.pdf`; | ||
]; | ||
return conversion.reduce((prev, [from, to]) => { | ||
const pf = title.match(new RegExp(`^${from}(\\d+) .*`)); | ||
return pf ? to + pf[1] : prev; | ||
}, title) + '.pdf'; | ||
}; | ||
@@ -51,11 +45,13 @@ | ||
const regulars = titles.map(title => [ | ||
baseUrl + buildRemoteName(title), | ||
buildLocalName(title), | ||
]); | ||
const cookie = 'Cookie: JSESSIONID=' + jsessionid; | ||
const printCurl = (url, filename) => { | ||
console.log(`curl -H '${cookie}' '${filename}' > '${url}'`); | ||
const printCurl = ([url, saveas]) => { | ||
console.log(`curl -H '${cookie}' '${url}' > '${saveas}'`); | ||
}; | ||
new Map(titles.map(title => [ | ||
buildUrl(title, baseUrl), | ||
buildFilename(title), | ||
])).forEach(printCurl); | ||
regulars.forEach(printCurl); | ||
irregulars.forEach(printCurl); | ||
@@ -134,3 +130,3 @@ | ||
const irregulars = new Map([ | ||
const irregulars = [ | ||
[baseUrl + 'framework.pdf', '100 Conceptual Framework for Financial Reporting.pdf'], | ||
@@ -140,3 +136,3 @@ [baseUrl + 'SIC07.pdf', '407 SIC-7 Introduction of the Euro.pdf'], | ||
[baseUrl + 'PS02.pdf', '502 Practice Statement 2: Making Materiality Judgements.pdf'], | ||
]); | ||
]; | ||
@@ -143,0 +139,0 @@ |
{ | ||
"name": "curl_ifrs", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Utility to download latest unaccompanied IFRS using curl.", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "build_ifrs_curls \\$JSESSIONID | diff -u test/output.sh -" | ||
}, | ||
@@ -8,0 +8,0 @@ "keywords": [ |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
27465
5
0
120