eventual 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.6
1
+ 0.5.7
@@ -12,7 +12,7 @@ grammar EsDates
12
12
  end
13
13
 
14
14
  rule period
15
- weekdays_constrain? (range / month)
15
+ weekday_list_constrain? (range / month)
16
16
  end
17
17
 
18
18
  rule date
@@ -60,7 +60,6 @@ grammar EsDates
60
60
  time_range ((space 'y' / ',') time_range)* <Eventual::TimeRangeList>
61
61
  end
62
62
 
63
- ##########
64
63
  rule month_name
65
64
  (((space 'de') / ',')? space)? ('enero' / 'febrero' / 'marzo' / 'abril' / 'mayo' / 'junio' / 'julio' / 'agosto' / 'septiembre' / 'octubre' / 'noviembre' / 'diciembre') <Eventual::MonthName>
66
65
  end
@@ -69,10 +68,14 @@ grammar EsDates
69
68
  ((space 'de' 'l'?) / ',')? space ([1-9] [0-9] [0-9] [0-9] / "'" [0-9] [0-9]) <Eventual::Year>
70
69
  end
71
70
 
72
- rule weekdays_constrain
73
- wdays_node:(weekday_list / weekdays / weekday) (',' / (space ('del' / 'de' / 'durante todo' / 'durante')))? space <Eventual::WeekdayConstrain>
71
+ rule weekday_list_constrain
72
+ wdays_node:(weekday_period / weekday_list / weekdays / weekday) (',' / (space ('del' / 'de' / 'durante todo' / 'durante')))? space <Eventual::WeekdayConstrain>
74
73
  end
75
74
 
75
+ rule weekday_period
76
+ ('de' space)? weekday space 'a' space weekday
77
+ end
78
+
76
79
  rule weekday_constrain
77
80
  wdays_node:weekday ','? space <Eventual::WeekdayConstrain>
78
81
  end
@@ -26,13 +26,21 @@ module Eventual
26
26
 
27
27
  class WeekdayConstrain < Treetop::Runtime::SyntaxNode #:nodoc:
28
28
  def value
29
- text = wdays_node.text_value.sub('semana', '')
29
+ text = wdays_node.text_value.sub('semana', '').sub(/^de\s/, '')
30
30
  days = text.scan(WdayListR).map{ |d| WdaysR.index /#{d}/ }
31
31
  days += (1..5).map if text.include?('entre')
32
32
  days += [6,0] if text.include?('fines')
33
+ days.sort!
34
+ days = (days.first..days.last).map if text.match /\sal?\s/
33
35
  days.uniq
34
36
  end
35
37
  end
38
+
39
+ class WeekdayPeriodConstrain < WeekdayConstrain #:nodoc:
40
+ def value
41
+ text_value.scan()
42
+ end
43
+ end
36
44
 
37
45
  class MonthName < Treetop::Runtime::SyntaxNode #:nodoc:
38
46
  def value
@@ -236,4 +244,4 @@ module Eventual
236
244
  (first.to_i..last.to_i).include? date.strftime("%H%M").to_i
237
245
  end
238
246
  end
239
- end
247
+ end
@@ -361,6 +361,23 @@ describe Eventual, 'Es' do
361
361
  it_should_behave_like 'includes corresponding dates'
362
362
  end
363
363
  end
364
+
365
+ describe 'wday range' do
366
+ before do
367
+ @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-22')).reject{ |day| not [1,2,3,4,5].include?(day.wday) }
368
+ end
369
+ describe "wdays for 'lunes a viernes del 1 al 22 de marzo del '10" do
370
+ before { @result = Eventual.parse("lunes a viernes del 1 al 22 de marzo del '10") }
371
+ it_should_behave_like 'correctly parses dates'
372
+ it_should_behave_like 'includes corresponding dates'
373
+ end
374
+
375
+ describe "wdays for 'de lunes a viernes del 1 al 22 de marzo del '10" do
376
+ before { @result = Eventual.parse("de lunes a viernes del 1 al 22 de marzo del '10") }
377
+ it_should_behave_like 'correctly parses dates'
378
+ it_should_behave_like 'includes corresponding dates'
379
+ end
380
+ end
364
381
  end
365
382
  end
366
383
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventual
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 5
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 5
8
- - 6
9
- version: 0.5.6
9
+ - 7
10
+ version: 0.5.7
10
11
  platform: ruby
11
12
  authors:
12
13
  - Macario Ortega
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-09-22 00:00:00 -05:00
18
+ date: 2010-10-01 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: treetop
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 13
27
30
  segments:
28
31
  - 1
29
32
  - 4
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: rspec
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 13
41
46
  segments:
42
47
  - 1
43
48
  - 2
@@ -81,26 +86,30 @@ rdoc_options:
81
86
  require_paths:
82
87
  - lib
83
88
  required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
84
90
  requirements:
85
91
  - - ">="
86
92
  - !ruby/object:Gem::Version
93
+ hash: 3
87
94
  segments:
88
95
  - 0
89
96
  version: "0"
90
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
91
99
  requirements:
92
100
  - - ">="
93
101
  - !ruby/object:Gem::Version
102
+ hash: 3
94
103
  segments:
95
104
  - 0
96
105
  version: "0"
97
106
  requirements: []
98
107
 
99
108
  rubyforge_project:
100
- rubygems_version: 1.3.6
109
+ rubygems_version: 1.3.7
101
110
  signing_key:
102
111
  specification_version: 3
103
112
  summary: Reconocimiento de fechas y periodos en lenguaje natural. Natural language date and period parsing, currently only in spanish.
104
113
  test_files:
105
- - spec/es_eventual_spec.rb
106
114
  - spec/spec_helper.rb
115
+ - spec/es_eventual_spec.rb