sherlockjs
Advanced tools
Comparing version 1.3.7 to 1.4.0
{ | ||
"name": "sherlockjs", | ||
"version": "1.3.7", | ||
"version": "1.4.0", | ||
"author": "Neil Gupta", | ||
@@ -5,0 +5,0 @@ "description": "Natural-language event parser for Javascript.", |
@@ -90,6 +90,30 @@ Sherlock | ||
# Testing | ||
You are encouraged to contribute to help improve Sherlock! When doing so, please make sure all tests in `tests.html` still pass. You should also add a test case to cover the situation you're trying to resolve. | ||
`tests.html` is a very simple custom-rolled test framework. You can insert your test anywhere in the list in the following format: | ||
```javascript | ||
(function() { | ||
var start = getNow(); | ||
start.setHours(0, 0, 0, 0); | ||
return test("Use Tabule today!", "Use Tabule", start, null, true); | ||
})(), | ||
``` | ||
You can adjust the setup as needed for your situation, but the `test` method takes the following 5 arguments: | ||
* The input string that is being tested | ||
* The eventTitle we expect Sherlock to spit back | ||
* The startDate we expect back | ||
* The endDate we expect back | ||
* The isAllDay boolean we expect back | ||
# License | ||
The MIT License (MIT) | ||
Copyright (c) 2017 Neil Gupta | ||
Copyright (c) 2018 Neil Gupta | ||
@@ -96,0 +120,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
/*! | ||
* Sherlock | ||
* Copyright (c) 2017 Neil Gupta | ||
* Version 1.3.6 | ||
* Copyright (c) 2018 Neil Gupta | ||
*/ | ||
@@ -37,4 +36,4 @@ | ||
more_than_comparator: /((?:more|greater|older|newer) than|after|before)/i, | ||
less_than_comparator: /((?:less|fewer) than)/i, | ||
more_than_comparator: /((?:more|greater|older|newer) than|after|before) \$(?:DATE|TIME)\$/i, | ||
less_than_comparator: /((?:less|fewer) than) \$(?:DATE|TIME)\$/i, | ||
@@ -69,3 +68,3 @@ // filler words must be preceded with a space to count | ||
strNummed = strNummed.replace(new RegExp(dateMatch), ''); | ||
str = str.replace(new RegExp(helpers.numToStr(dateMatch)), ''); | ||
str = str.replace(new RegExp(helpers.numToStr(dateMatch)), '$DATE$'); | ||
} | ||
@@ -75,3 +74,3 @@ | ||
if (timeMatch = matchTime(strNummed, time, startTime)) | ||
str = str.replace(new RegExp(helpers.numToStr(timeMatch)), ''); | ||
str = str.replace(new RegExp(helpers.numToStr(timeMatch)), '$TIME$'); | ||
@@ -717,3 +716,3 @@ ret.eventTitle = str; | ||
if (result.eventTitle.length > ret.eventTitle.length) | ||
if (result.eventTitle.replace(/\$(?:DATE|TIME)\$/g, '').length > ret.eventTitle.replace(/\$(?:DATE|TIME)\$/g, '').length) | ||
ret.eventTitle = result.eventTitle; | ||
@@ -744,2 +743,3 @@ | ||
if (ret.eventTitle) { | ||
ret.eventTitle = ret.eventTitle.replace(/\$(?:DATE|TIME)\$/g, ''); | ||
var fillerWords = readConfig("disableRanges") ? patterns.fillerWords2 : patterns.fillerWords; | ||
@@ -746,0 +746,0 @@ ret.eventTitle = ret.eventTitle.split(fillerWords)[0].trim(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
124
100287
6
732