tickle 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -0
- data/CHANGES.md +11 -1
- data/README.md +1 -1
- data/lib/tickle.rb +1 -1
- data/lib/tickle/tickle.rb +25 -6
- data/lib/tickle/version.rb +1 -1
- data/test/helper.rb +2 -0
- data/test/test_parsing.rb +15 -6
- data/tickle.gemspec +4 -3
- metadata +39 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c9f24bf840e38c2196e61c1428caa9d84eeb7b5
|
4
|
+
data.tar.gz: 6e8111fb7b6098f3c285d537b2adb529ede9ad36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a13f5b64bd9e49327bca5456bbcb197b7d66b90b0f349ea035f842ffe8aa440a263aefc690d163c5023ac24e13b398b395da9e6d7240e9a89220c7c4ca9433
|
7
|
+
data.tar.gz: 2514f63b04e43ec3610932dc115ad127b29b9a384e9b99fe6c52606982ebb2537cb20ac06beccf2cfcc25630a5c2f7c5021870119ab39395b7fe9f4361af5a1b
|
data/.travis.yml
ADDED
data/CHANGES.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# CH CH CH CH CHANGES! #
|
2
2
|
|
3
|
+
## Friday the 18th of September 2020, v1.2.0
|
4
|
+
|
5
|
+
- Changed the dependency from chronic to gitlab-chronic
|
6
|
+
- Required numerizer explicitly to stop a bug
|
7
|
+
- Formatted the regex for legibility
|
8
|
+
- Fixed bug with "today and" in the tests
|
9
|
+
- Fixed a bug previously fixed on the v2 branch in 2f2a32ce9 with @start
|
10
|
+
- Added Timecop because we're beyond the date chosen in the tests. Tempus fugit!
|
11
|
+
|
12
|
+
----
|
13
|
+
|
3
14
|
## Wednesday the 15th of March 2017, v1.1.1 ##
|
4
15
|
|
5
16
|
* Bit of easier debugging added in.
|
@@ -7,7 +18,6 @@
|
|
7
18
|
|
8
19
|
----
|
9
20
|
|
10
|
-
|
11
21
|
## Wednesday the 22nd of February 2017, v1.1.0 ##
|
12
22
|
|
13
23
|
* Numerizer duplication removed. Thanks to https://github.com/bjonord.
|
data/README.md
CHANGED
data/lib/tickle.rb
CHANGED
data/lib/tickle/tickle.rb
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
+
require 'numerizer'
|
23
|
+
|
22
24
|
module Tickle
|
23
25
|
class << self
|
24
26
|
# == Configuration options
|
@@ -105,9 +107,25 @@ module Tickle
|
|
105
107
|
def scan_expression(text, options)
|
106
108
|
starting = ending = nil
|
107
109
|
|
108
|
-
start_every_regex = /^
|
110
|
+
start_every_regex = /^
|
111
|
+
(start(?:s|ing)?) # 0
|
112
|
+
\s
|
113
|
+
(.*)
|
114
|
+
(\s(?:every|each|\bon\b|repeat) # 1
|
115
|
+
(?:s|ing)?) # 2
|
116
|
+
(.*) # 3
|
117
|
+
/ix
|
109
118
|
every_start_regex = /^(every|each|\bon\b|repeat(?:the)?)\s(.*)(\s(?:start)(?:s|ing)?)(.*)/i
|
110
|
-
start_ending_regex = /^
|
119
|
+
start_ending_regex = /^
|
120
|
+
(start(?:s|ing)?) # 0
|
121
|
+
\s+
|
122
|
+
(.*?)(?:\s+and)? # 1
|
123
|
+
(\s
|
124
|
+
(?:\bend|until)
|
125
|
+
(?:s|ing)?
|
126
|
+
) # 2
|
127
|
+
(.*) # 3
|
128
|
+
/ix
|
111
129
|
if text =~ start_every_regex
|
112
130
|
starting = text.match(start_every_regex)[2].strip
|
113
131
|
text = text.match(start_every_regex)[4].strip
|
@@ -117,8 +135,9 @@ module Tickle
|
|
117
135
|
text = text.match(every_start_regex)[4].strip
|
118
136
|
starting, ending = process_for_ending(text)
|
119
137
|
elsif text =~ start_ending_regex
|
120
|
-
|
121
|
-
|
138
|
+
md = text.match start_ending_regex
|
139
|
+
starting = md.captures[1]
|
140
|
+
ending = md.captures.last.strip
|
122
141
|
event = 'day'
|
123
142
|
else
|
124
143
|
event, ending = process_for_ending(text)
|
@@ -127,6 +146,7 @@ module Tickle
|
|
127
146
|
# they gave a phrase so if we can't interpret then we need to raise an error
|
128
147
|
if starting
|
129
148
|
Tickle.dwrite("starting: #{starting}")
|
149
|
+
@start ||= nil # initialize the variable to quell warnings
|
130
150
|
@start = chronic_parse(pre_filter(starting))
|
131
151
|
if @start
|
132
152
|
@start.to_time
|
@@ -172,8 +192,7 @@ module Tickle
|
|
172
192
|
text.gsub!(/repeat(s|ing)?(\s)?/, '')
|
173
193
|
text.gsub!(/on the(\s)?/, '')
|
174
194
|
text.gsub!(/([^\w\d\s])+/, '')
|
175
|
-
text.downcase.strip
|
176
|
-
text = normalize_us_holidays(text)
|
195
|
+
normalize_us_holidays(text.downcase.strip)
|
177
196
|
end
|
178
197
|
|
179
198
|
# Split the text on spaces and convert each word into
|
data/lib/tickle/version.rb
CHANGED
data/test/helper.rb
CHANGED
data/test/test_parsing.rb
CHANGED
@@ -4,16 +4,22 @@ require 'test/unit'
|
|
4
4
|
|
5
5
|
class TestParsing < Test::Unit::TestCase
|
6
6
|
|
7
|
+
Time_now = Time.parse "2010-05-09 20:57:36 +0000"
|
7
8
|
def setup
|
8
9
|
Tickle.debug = (ARGV.detect {|a| a == '--d'})
|
9
10
|
@verbose = (ARGV.detect {|a| a == '--v'})
|
10
|
-
|
11
|
-
|
12
|
-
p Time.now
|
11
|
+
Timecop.freeze Time_now
|
12
|
+
ENV["TZ"] = "UTC"
|
13
13
|
|
14
14
|
@date = Date.today
|
15
|
+
@tz = ENV["TZ"]
|
15
16
|
end
|
16
17
|
|
18
|
+
def teardown
|
19
|
+
Timecop.return
|
20
|
+
ENV["TZ"] = @tz
|
21
|
+
end
|
22
|
+
|
17
23
|
def test_parse_best_guess_simple
|
18
24
|
start = Date.new(2020, 04, 01)
|
19
25
|
|
@@ -85,11 +91,14 @@ class TestParsing < Test::Unit::TestCase
|
|
85
91
|
assert_date_match(Date.new(2020, 04, 21), 'the twenty first of the month', {:start => start, :now => start})
|
86
92
|
end
|
87
93
|
|
88
|
-
def
|
89
|
-
start = Date.new(2020, 04, 01)
|
90
|
-
|
94
|
+
def test_parse_best_guess_complex_and
|
91
95
|
assert_tickle_match(@date.bump(:day, 1), @date, @date.bump(:week, 1), 'day', 'starting today and ending one week from now') if Time.now.hour < 21 # => demonstrates leaving out the actual time period and implying it as daily
|
92
96
|
assert_tickle_match(@date.bump(:day, 1), @date.bump(:day, 1), @date.bump(:week, 1), 'day','starting tomorrow and ending one week from now') # => demonstrates leaving out the actual time period and implying it as daily.
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def test_parse_best_guess_complex
|
101
|
+
start = Date.new(2020, 04, 01)
|
93
102
|
|
94
103
|
assert_tickle_match(@date.bump(:wday, 'Mon'), @date.bump(:wday, 'Mon'), nil, 'month', 'starting Monday repeat every month')
|
95
104
|
|
data/tickle.gemspec
CHANGED
@@ -20,14 +20,15 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency "chronic", "~> 0.
|
23
|
+
s.add_dependency "gitlab-chronic", "~> 0.10.6"
|
24
|
+
s.add_dependency "numerizer", "~> 0.2.0"
|
24
25
|
s.add_development_dependency "shoulda", "~> 2.10.3"
|
25
26
|
s.add_development_dependency "simplecov"
|
26
27
|
s.add_development_dependency "test-unit"
|
27
|
-
|
28
|
-
s.add_development_dependency "bundler", "~> 1.2"
|
28
|
+
s.add_development_dependency "bundler"
|
29
29
|
s.add_development_dependency "rake"
|
30
30
|
s.add_development_dependency "yard"
|
31
31
|
s.add_development_dependency "maruku"
|
32
|
+
s.add_development_dependency "timecop"
|
32
33
|
end
|
33
34
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tickle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Lippiner
|
@@ -9,22 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: chronic
|
15
|
+
name: gitlab-chronic
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 0.10.6
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
27
|
+
version: 0.10.6
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: numerizer
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.2.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.2.0
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: shoulda
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,16 +85,16 @@ dependencies:
|
|
71
85
|
name: bundler
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
73
87
|
requirements:
|
74
|
-
- - "
|
88
|
+
- - ">="
|
75
89
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
90
|
+
version: '0'
|
77
91
|
type: :development
|
78
92
|
prerelease: false
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
80
94
|
requirements:
|
81
|
-
- - "
|
95
|
+
- - ">="
|
82
96
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
97
|
+
version: '0'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: rake
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +137,20 @@ dependencies:
|
|
123
137
|
- - ">="
|
124
138
|
- !ruby/object:Gem::Version
|
125
139
|
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: timecop
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
126
154
|
description: Tickle is a date/time helper gem to help parse natural language into
|
127
155
|
a recurring pattern. Tickle is designed to be a compliment of Chronic and can interpret
|
128
156
|
things such as "every 2 days, every Sunday, Sundays, Weekly, etc.
|
@@ -133,6 +161,7 @@ extra_rdoc_files: []
|
|
133
161
|
files:
|
134
162
|
- ".document"
|
135
163
|
- ".gitignore"
|
164
|
+
- ".travis.yml"
|
136
165
|
- CHANGES.md
|
137
166
|
- Gemfile
|
138
167
|
- LICENCE
|
@@ -171,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
200
|
version: '0'
|
172
201
|
requirements: []
|
173
202
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
203
|
+
rubygems_version: 2.5.2.3
|
175
204
|
signing_key:
|
176
205
|
specification_version: 4
|
177
206
|
summary: natural language parser for recurring events
|