attentive 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/attentive/entities/core/date/duration/units.rb +0 -1
- data/lib/attentive/entities/core/time/duration/units.rb +25 -0
- data/lib/attentive/entities/core/time/duration.rb +32 -0
- data/lib/attentive/entities/core/time.rb +31 -0
- data/lib/attentive/entities/core.rb +1 -0
- data/lib/attentive/match.rb +1 -1
- data/lib/attentive/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30975536bce928d23402e0042c837b4632e1736a
|
4
|
+
data.tar.gz: 404d44e02460fe642bda70f08264b51f894f4eaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1a9416baceffca676810f74519fe64bf55d2b1ec6c131aa99defc4941c9f80d34d4a051f918800f0b7cf28258134acd2df9daa613975e86fbe029cf2ee27725
|
7
|
+
data.tar.gz: 7e5ca689fb5554f023eeacb5695e423f4f25e1a568900fe9d2b69a9488f2fa04b2be5de9194aa4cc4074be2b3ed19309338a6ab85d0bc507077ad1bff80b0eac
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "attentive/entity"
|
2
|
+
|
3
|
+
Attentive::Entity.define "core.time.duration.units",
|
4
|
+
"second",
|
5
|
+
"seconds",
|
6
|
+
"s",
|
7
|
+
"minute",
|
8
|
+
"minutes",
|
9
|
+
"min",
|
10
|
+
"m",
|
11
|
+
"hour",
|
12
|
+
"hours",
|
13
|
+
"hr",
|
14
|
+
"hrs",
|
15
|
+
"h",
|
16
|
+
published: false do |match|
|
17
|
+
|
18
|
+
case match.phrase
|
19
|
+
when "second", "seconds", "s" then :seconds
|
20
|
+
when "minute", "minutes", "min", "m" then :minutes
|
21
|
+
when "hour", "hours", "hr", "hrs", "h" then :hours
|
22
|
+
else
|
23
|
+
nomatch!
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "attentive/entity"
|
2
|
+
require "attentive/duration"
|
3
|
+
require "attentive/entities/core/time/duration/units"
|
4
|
+
|
5
|
+
Attentive::Entity.define "core.time.duration.single",
|
6
|
+
"{{n:core.number.integer.positive}} {{unit:core.time.duration.units}}",
|
7
|
+
published: false do |match|
|
8
|
+
|
9
|
+
unit = match["unit"]
|
10
|
+
n = match["n"]
|
11
|
+
Attentive::Duration.new(unit => n)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
Attentive::Entity.define "core.time.duration",
|
16
|
+
%q{(?:(?<hours>\d\d?):(?<minutes>\d\d):(?<seconds>\d\d))},
|
17
|
+
"{{a:core.time.duration.single}} {{b:core.time.duration}}",
|
18
|
+
"{{a:core.time.duration.single}} and {{b:core.time.duration}}",
|
19
|
+
"{{a:core.time.duration.single}}" do |match|
|
20
|
+
|
21
|
+
if match.matched?("hours")
|
22
|
+
return Attentive::Duration.new(
|
23
|
+
hours: match["hours"],
|
24
|
+
minutes: match["minutes"],
|
25
|
+
seconds: match["seconds"])
|
26
|
+
else
|
27
|
+
a = match["a"]
|
28
|
+
a += match["b"] if match.matched?("b")
|
29
|
+
a
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "attentive/entities/core/time/duration"
|
2
|
+
require "date"
|
3
|
+
require "time"
|
4
|
+
|
5
|
+
Attentive::Entity.define "core.time",
|
6
|
+
"noon",
|
7
|
+
"midnight",
|
8
|
+
%q{(?:(?<hours>\d\d?):(?<minutes>\d\d)\s*(?<pm>pm?))},
|
9
|
+
%q{(?:(?<hours>\d\d?)\s*(?:am?|(?<pm>pm?)))},
|
10
|
+
%q{(?:(?<hours>\d\d?):(?<minutes>\d\d))} do |match|
|
11
|
+
|
12
|
+
minutes = 0
|
13
|
+
|
14
|
+
p match
|
15
|
+
if match.matched?("hours")
|
16
|
+
hours = match["hours"].to_i
|
17
|
+
hours += 12 if match.matched?("pm")
|
18
|
+
minutes = match["minutes"].to_i if match.matched?("minutes")
|
19
|
+
else
|
20
|
+
case match.to_s
|
21
|
+
when "noon" then hours = 12
|
22
|
+
when "midnight" then hours = 0
|
23
|
+
else nomatch!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
nomatch! if hours < 0 || hours > 24
|
28
|
+
nomatch! if minutes < 0 || minutes > 60
|
29
|
+
|
30
|
+
today = Date.today; Time.new(today.year, today.month, today.day, hours, minutes)
|
31
|
+
end
|
data/lib/attentive/match.rb
CHANGED
data/lib/attentive/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attentive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_safe
|
@@ -196,6 +196,9 @@ files:
|
|
196
196
|
- lib/attentive/entities/core/number/integer/positive.rb
|
197
197
|
- lib/attentive/entities/core/number/negative.rb
|
198
198
|
- lib/attentive/entities/core/number/positive.rb
|
199
|
+
- lib/attentive/entities/core/time.rb
|
200
|
+
- lib/attentive/entities/core/time/duration.rb
|
201
|
+
- lib/attentive/entities/core/time/duration/units.rb
|
199
202
|
- lib/attentive/entity.rb
|
200
203
|
- lib/attentive/errors.rb
|
201
204
|
- lib/attentive/listener.rb
|