Open ShakeyDave opened 6 years ago
While working this through I found a way to add the 'dumping' behaviour without having to change the AltmetricRequest class at all - namely create a JSONFileManager class which you pass the JSON data that AltmetricRequest.request() returns to. A JSONFileManager.dump(data) method can then be implemented. Plus the JSONFileManager can have the local directory added to it, too. So no new methods, switches or other bits of logic need to be passed to the AltmetricRequest. This also means that the dumping behaviour can be tested with entirely local resources in the 'Unit' tests directory. It also means this class can have the loading functionality added to it for Issue #44 too.
Then this JSONFileManager only needs to be added to the facade, to intercept responses from the AltmetricRequest, and not pass them to the AltmetricLoader. Or to swerve using the AltmetricRequest and load from a directory's-worth of local resources instead.
Of course one issue here is that DOIs have forward slashes in them... so what are we going to call the files we dump out, eh?
According to the DOI naming rules: "The DOI syntax shall be made up of a DOI prefix and a DOI suffix separated by a forward slash."
For expediency's sake, I'm going to replace the forward slash with three hyphens. This is the sort of arbitrary decision one normally comes to regret later.
Add a behaviour to the AltmetricRequest class to just dump the JSON returned from Altmetric to a specific folder.
For purposes of making bibliometric research conducted with the Altmetric Client repeatable / easier to validate.