Browse Source

Rename `from_address_parser` key to `from_text_parser`

pull/347/head
Julian Simioni 9 years ago
parent
commit
db895c05b7
  1. 6
      helper/types.js
  2. 2
      sanitiser/_text.js
  3. 4
      test/unit/helper/types.js
  4. 2
      test/unit/sanitiser/_text.js

6
helper/types.js

@ -10,7 +10,7 @@ var _ = require('lodash');
*/
module.exports = function calculate_types(clean_types) {
//Check that at least one preference of types is defined
if (!clean_types || !(clean_types.from_layers || clean_types.from_sources || clean_types.from_address_parser)) {
if (!clean_types || !(clean_types.from_layers || clean_types.from_sources || clean_types.from_text_parser)) {
throw new Error('clean_types should not be null or undefined');
}
@ -35,8 +35,8 @@ module.exports = function calculate_types(clean_types) {
* Type restrictions requested by the address parser should only be used
* if both the source and layers parameters are empty, so do this last
*/
if (clean_types.from_address_parser) {
return clean_types.from_address_parser;
if (clean_types.from_text_parser) {
return clean_types.from_text_parser;
}
throw new Error('no types specified');

2
sanitiser/_text.js

@ -26,7 +26,7 @@ function sanitize( raw, clean ){
// try to set layers from query parser results
clean.types = clean.layers || {};
clean.types.from_address_parser = text_parser.get_layers(clean.text);
clean.types.from_text_parser = text_parser.get_layers(clean.text);
}
return messages;

4
test/unit/helper/types.js

@ -33,7 +33,7 @@ module.exports.tests.no_cleaned_types = function(test, common) {
module.exports.tests.address_parser = function(test, common) {
test('address parser specifies only admin layers', function(t) {
var cleaned_types = {
from_address_parser: ['admin0'] // simplified return value from address parser
from_text_parser: ['admin0'] // simplified return value from address parser
};
var actual = types(cleaned_types);
var expected = ['admin0']; // simplified expected value for all admin layers
@ -58,7 +58,7 @@ module.exports.tests.layers_parameter_and_address_parser = function(test, common
test('layers parameter and address parser present', function(t) {
var cleaned_types = {
from_layers: ['geoname'],
from_address_parser: ['admin0'] // simplified return value from address parse
from_text_parser: ['admin0'] // simplified return value from address parse
};
var actual = types(cleaned_types);
var expected = ['geoname'];

2
test/unit/sanitiser/_text.js

@ -15,7 +15,7 @@ module.exports.tests.text_parser = function(test, common) {
t.deepEquals(messages.errors, [], 'no errors');
t.deepEquals(messages.warnings, [], 'no warnings');
t.equal(clean.types.from_address_parser, type_mapping.layer_with_aliases_to_type.coarse, 'coarse layers preferred');
t.equal(clean.types.from_text_parser, type_mapping.layer_with_aliases_to_type.coarse, 'coarse layers preferred');
t.end();
});

Loading…
Cancel
Save