eventual 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -20,4 +20,6 @@ rdoc
20
20
  pkg
21
21
  eventual.gemspec
22
22
 
23
- ## PROJECT::SPECIFIC
23
+ ## Bundler
24
+ *.gem
25
+ .bundle
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in inline-style.gemspec
4
+ gemspec
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ eventual (0.5.9)
5
+ treetop
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.2)
11
+ polyglot (0.3.1)
12
+ rspec (2.5.0)
13
+ rspec-core (~> 2.5.0)
14
+ rspec-expectations (~> 2.5.0)
15
+ rspec-mocks (~> 2.5.0)
16
+ rspec-core (2.5.1)
17
+ rspec-expectations (2.5.0)
18
+ diff-lcs (~> 1.1.2)
19
+ rspec-mocks (2.5.0)
20
+ treetop (1.4.9)
21
+ polyglot (>= 0.3.1)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ eventual!
28
+ rspec
29
+ treetop
data/Rakefile CHANGED
@@ -1,46 +1,10 @@
1
1
  require 'rubygems'
2
- require 'rake'
2
+ require 'bundler'
3
+ require "rspec/core/rake_task"
3
4
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "eventual"
8
- gem.summary = %Q{ Reconocimiento de fechas y periodos en lenguaje natural. Natural language date and period parsing, currently only in spanish. }
9
- gem.description = %Q{ Reconocimiento de fechas y periodos en lenguaje natural. Natural language date and period parsing, currently only in spanish. }
10
- gem.email = "macarui@gmail.com"
11
- gem.homepage = "http://github.com/maca/eventual"
12
- gem.authors = ["Macario Ortega"]
13
- gem.post_install_message = %{ \n\n***********************************\nPor favor tenga en cuenta que el API ha cambiado, consulte la página del proyecto: http://github.com/maca/eventual. English implementation is due.\n***********************************\n\n }
14
- gem.add_dependency "treetop", ">= 1.4.5"
15
- gem.add_development_dependency "rspec", ">= 1.2.9"
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
21
-
22
- require 'spec/rake/spectask'
23
- Spec::Rake::SpecTask.new(:spec) do |spec|
24
- spec.libs << 'lib' << 'spec'
25
- spec.spec_files = FileList['spec/**/*_spec.rb']
26
- end
27
-
28
- Spec::Rake::SpecTask.new(:rcov) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.pattern = 'spec/**/*_spec.rb'
31
- spec.rcov = true
32
- end
33
-
34
- task :spec => :check_dependencies
5
+ desc "Run specs"
6
+ RSpec::Core::RakeTask.new(:spec)
35
7
 
36
8
  task :default => :spec
37
9
 
38
- require 'rake/rdoctask'
39
- Rake::RDocTask.new do |rdoc|
40
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
-
42
- rdoc.rdoc_dir = 'rdoc'
43
- rdoc.title = "eventual #{version}"
44
- rdoc.rdoc_files.include('README*')
45
- rdoc.rdoc_files.include('lib/**/*.rb')
46
- end
10
+ Bundler::GemHelper.install_tasks
@@ -1,14 +1,20 @@
1
+ # encoding: UTF-8
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
1
4
  require 'rubygems'
2
5
  require 'treetop'
3
6
  require 'date'
4
7
 
5
- require "#{ File.dirname __FILE__ }/eventual/syntax_nodes"
8
+ require "eventual/syntax_nodes"
9
+
10
+
11
+ Range.send(:alias_method, :cover?, :include?) unless Range.methods.include? :include?
6
12
 
7
13
  autoload :EsDatesParser, 'eventual/es'
8
14
 
9
15
  module Eventual
10
16
  # Parses dates specified in natural language and returns an Eventual::Node object
11
- # Eventual.parse( 'del 5 al 7 de junio del 2009' ).map
17
+ # Eventual.parse( 'del 5 al 7 de junio del 2009' ).to_a
12
18
  # => [#<DateTime: 4909975/2,0,2299161>, #<DateTime: 4909977/2,0,2299161>, #<DateTime: 4909979/2,0,2299161
13
19
  #
14
20
  # Options:
@@ -32,4 +38,4 @@ module Eventual
32
38
  node.year = year if year
33
39
  node
34
40
  end
35
- end
41
+ end
@@ -1,30 +1,30 @@
1
1
  grammar EsDates
2
2
  rule root
3
- compound_date (((space 'y' / ',') space / newline) compound_date)* <Eventual::Node> # ((space 'y' / ',') compound_date)*
3
+ compound_date (((space 'y' / ',') space / newline) compound_date)* <Eventual::Node>
4
4
  end
5
5
 
6
6
  rule compound_date
7
- (same_year_date_list / dates) year? times?
7
+ (date_list / dates) year? times?
8
8
  end
9
9
 
10
10
  rule dates
11
- period / date
11
+ period / single_day
12
12
  end
13
13
 
14
14
  rule period
15
15
  weekday_list_constrain? (range / month)
16
16
  end
17
17
 
18
- rule date
19
- weekday_constrain? day_number month_name?
20
- end
21
-
22
- rule same_year_date_list
18
+ rule date_list
23
19
  dates (',' space dates)* (space 'y' space dates)
24
20
  end
25
21
 
26
22
  rule range
27
- (('del' / 'de' / ',') space)? (month / date) year? space ('al' / 'a') space (month / date) <Eventual::DatePeriod>
23
+ (('del' / 'de' / ',') space)? (month / single_day) year? space ('al' / 'a') space (month / single_day) <Eventual::DatePeriod>
24
+ end
25
+
26
+ rule single_day
27
+ weekday_constrain? day_number month_name? / month
28
28
  end
29
29
 
30
30
  rule month
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  module Eventual
2
4
  Weekdays = %w(domingo lunes martes miércoles jueves viernes sábado).freeze
3
5
  MonthNames = %w(enero febrero marzo abril mayo junio julio agosto septiembre noviembre).unshift(nil).freeze
@@ -28,10 +30,10 @@ module Eventual
28
30
  def value
29
31
  text = wdays_node.text_value.sub('semana', '').sub(/^de\s/, '')
30
32
  days = text.scan(WdayListR).map{ |d| WdaysR.index /#{d}/ }
31
- days += (1..5).map if text.include?('entre')
33
+ days += (1..5).to_a if text.include?('entre')
32
34
  days += [6,0] if text.include?('fines')
33
35
  days.sort!
34
- days = (days.first..days.last).map if text.match /\sal?\s/
36
+ days = (days.first..days.last).to_a if text.match /\sal?\s/
35
37
  days.uniq
36
38
  end
37
39
  end
@@ -58,10 +60,12 @@ module Eventual
58
60
  def last; to_a.last end
59
61
 
60
62
  # Returns last Date or DateTime of the encompassed period
61
- def first; to_a.first end
63
+ def first;
64
+ to_a.first
65
+ end
62
66
 
63
67
  # Returns an array with all the encompassed Dates or DateTimes
64
- def to_a; map end
68
+ def to_a; map{ |e| e } end
65
69
 
66
70
  # Returns true if the weekday (as number) correspons to any allowed weekday
67
71
  def date_within_weekdays? date
@@ -71,15 +75,17 @@ module Eventual
71
75
 
72
76
  # Invokes block once for each Date or DateTime. Creates a new array containing the values returned by the block.
73
77
  def map &block
74
- walk { |elements| elements.map &block }
78
+ walk { |elements| elements.map &block }.compact
75
79
  end
76
80
 
77
81
  # Returns true if the Date or DateTime passed is included in the parsed Dates or DateTimes
78
82
  def include? date
79
83
  result = false
80
- walk { |elements| break result = true if elements.include? date }
81
-
82
- return result if !result or date.class == Date or times.nil?
84
+ walk { |elements|
85
+ break result = true if elements.include? date
86
+ }
87
+
88
+ return result if !result || date.class == Date || times.nil?
83
89
 
84
90
  times.include? date
85
91
  end
@@ -133,7 +139,7 @@ module Eventual
133
139
  dates = make(year, month, text_value.to_i)
134
140
  dates = [dates] unless Array === dates
135
141
  raise WdayMatchError.new(dates.first) unless date_within_weekdays? dates.first
136
- dates.map &block
142
+ dates.map(&block).compact
137
143
  end
138
144
 
139
145
  def include? date
@@ -148,38 +154,34 @@ module Eventual
148
154
 
149
155
  def include? date
150
156
  return false unless date_within_weekdays? date
151
- range.include? date
157
+ range.cover? date
152
158
  end
153
159
 
154
- alias node_map map
155
- private :node_map
156
-
157
160
  def map &block
158
161
  range.map do |date|
159
162
  next unless date_within_weekdays? date
160
- dates = times ? make(date.year, date.month, date.day) : [date]
161
- dates.map &block
162
- end
163
+ (times ? make(date.year, date.month, date.day) : [date]).map(&block)
164
+ end.compact
163
165
  end
164
166
  end
165
167
 
166
168
  class MonthPeriod < Period #:nodoc:
167
169
  def first
168
- Date.civil year, month_name.value
170
+ @first ||= Date.civil year, month_name.value
169
171
  end
170
172
 
171
173
  def last
172
- Date.civil year, month_name.value, -1
174
+ @last ||= Date.civil year, month_name.value, -1
173
175
  end
174
176
  end
175
177
 
176
178
  class DatePeriod < Period #:nodoc:
177
179
  def first
178
- node_map.first
180
+ @first ||= walk { |elements| elements.map{ |e| e } }.first
179
181
  end
180
182
 
181
183
  def last
182
- node_map.last
184
+ @last ||= walk { |elements| elements.map{ |e| e } }.last
183
185
  end
184
186
  end
185
187
 
@@ -0,0 +1,3 @@
1
+ module Eventual
2
+ VERSION = '0.5.9'
3
+ end
@@ -1,4 +1,6 @@
1
- require "#{File.dirname __FILE__}/spec_helper"
1
+ # encoding: UTF-8
2
+
3
+ require "spec_helper"
2
4
  require 'eventual'
3
5
 
4
6
  describe Eventual, 'Es' do
@@ -14,18 +16,18 @@ describe Eventual, 'Es' do
14
16
 
15
17
  shared_examples_for 'correctly parses dates' do
16
18
  it { @result.should_not be_nil }
17
- it { @result.to_a.size.should == @dates.map.size }
19
+ it { @result.to_a.size.should == @dates.to_a.size }
18
20
  it { @result.should map_dates *@dates }
19
21
  end
20
22
 
21
23
  shared_examples_for 'correctly parses time ranges' do
22
24
  it { @result.should_not be_nil }
23
- it { @result.to_a.size.should == @ranges.map.size }
25
+ it { @result.to_a.size.should == @ranges.to_a.size }
24
26
  it { @result.should map_dates *@ranges }
25
27
  end
26
28
 
27
29
  shared_examples_for 'includes corresponding dates' do
28
- it { @dates.map{ |date| @result.should include(date) } }
30
+ it { @dates.each{ |date| @result.should include(date) } }
29
31
  it { @result.should_not include(@dates.first - 1) }
30
32
  it { @result.should_not include(@dates.last + 1) }
31
33
  it { @dates.select{ |d| @result.include? d }.map{ |d| d.to_s }.should == @dates.map{ |r| r.to_s } }
@@ -35,7 +37,7 @@ describe Eventual, 'Es' do
35
37
  describe "month without year parsing 'marzo'" do
36
38
  before do
37
39
  @result = Eventual.parse 'marzo', :lang => 'Es'
38
- @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-31')).map
40
+ @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-31')).to_a
39
41
  end
40
42
  it_should_behave_like 'correctly parses dates'
41
43
  it_should_behave_like 'includes corresponding dates'
@@ -44,7 +46,7 @@ describe Eventual, 'Es' do
44
46
  describe "month without year parsing 'marzo', case insensitive" do
45
47
  before do
46
48
  @result = Eventual.parse 'MarZo', :lang => 'Es'
47
- @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-31')).map
49
+ @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-31')).to_a
48
50
  end
49
51
  it_should_behave_like 'correctly parses dates'
50
52
  it_should_behave_like 'includes corresponding dates'
@@ -54,7 +56,7 @@ describe Eventual, 'Es' do
54
56
  describe "parsing 'marzo de 2009'" do
55
57
  before do
56
58
  @result = Eventual.parse "marzo de 2009"
57
- @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).map
59
+ @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).to_a
58
60
  end
59
61
  it_should_behave_like 'correctly parses dates'
60
62
  it_should_behave_like 'includes corresponding dates'
@@ -63,7 +65,7 @@ describe Eventual, 'Es' do
63
65
  describe "parsing 'marzo del 2009'" do
64
66
  before do
65
67
  @result = Eventual.parse "marzo del 2009"
66
- @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).map
68
+ @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).to_a
67
69
  end
68
70
  it_should_behave_like 'correctly parses dates'
69
71
  it_should_behave_like 'includes corresponding dates'
@@ -72,7 +74,7 @@ describe Eventual, 'Es' do
72
74
  describe "parsing 'marzo 2009'" do
73
75
  before do
74
76
  @result = Eventual.parse "marzo 2009"
75
- @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).map
77
+ @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).to_a
76
78
  end
77
79
  it_should_behave_like 'correctly parses dates'
78
80
  it_should_behave_like 'includes corresponding dates'
@@ -81,7 +83,7 @@ describe Eventual, 'Es' do
81
83
  describe "parsing 'marzo, 2009'" do
82
84
  before do
83
85
  @result = Eventual.parse "marzo, 2009"
84
- @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).map
86
+ @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).to_a
85
87
  end
86
88
  it_should_behave_like 'correctly parses dates'
87
89
  it_should_behave_like 'includes corresponding dates'
@@ -90,7 +92,7 @@ describe Eventual, 'Es' do
90
92
  describe "parsing 'marzo '09'" do
91
93
  before do
92
94
  @result = Eventual.parse "marzo '09"
93
- @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).map
95
+ @dates = (Date.parse('2009-3-1')..Date.parse('2009-3-31')).to_a
94
96
  end
95
97
  it_should_behave_like 'correctly parses dates'
96
98
  it_should_behave_like 'includes corresponding dates'
@@ -132,16 +134,15 @@ describe Eventual, 'Es' do
132
134
  it_should_behave_like 'includes corresponding dates'
133
135
  end
134
136
  end
135
-
136
137
  end
137
138
 
138
139
  describe 'day numbers' do
139
140
  describe 'single date' do
140
141
  before do
141
- @dates = [Date.civil 2010, 3, 21]
142
+ @dates = [Date.civil(2010, 3, 21)]
142
143
  end
143
144
 
144
- describe "should single day number for '21 de marzo'" do
145
+ describe "should parse single day number for '21 de marzo'" do
145
146
  before { @result = Eventual.parse("21 de marzo") }
146
147
  it_should_behave_like 'correctly parses dates'
147
148
  it_should_behave_like 'includes corresponding dates'
@@ -153,11 +154,11 @@ describe Eventual, 'Es' do
153
154
  it_should_behave_like 'includes corresponding dates'
154
155
  end
155
156
 
156
- # describe "parsing 'marzo 21'" do
157
- # before { @result = Eventual.parse("21 marzo") }
158
- # it_should_behave_like 'correctly parses dates'
159
- # it_should_behave_like 'includes corresponding dates'
160
- # end
157
+ describe "parsing 'marzo 21'" do
158
+ before { @result = Eventual.parse("21 marzo") }
159
+ it_should_behave_like 'correctly parses dates'
160
+ it_should_behave_like 'includes corresponding dates'
161
+ end
161
162
 
162
163
  describe 'date with wday' do
163
164
  describe "parsing 'domingo 21 de marzo'" do
@@ -165,9 +166,8 @@ describe Eventual, 'Es' do
165
166
  it_should_behave_like 'correctly parses dates'
166
167
  it_should_behave_like 'includes corresponding dates'
167
168
  end
168
-
169
169
  it "should raise WdayMatchError if weekday doesn't correspond to date" do
170
- lambda { Eventual.parse("lunes 21 de marzo").map }.should raise_error(Eventual::WdayMatchError)
170
+ lambda { Eventual.parse("lunes 21 de marzo").to_a }.should raise_error(Eventual::WdayMatchError)
171
171
  end
172
172
  end
173
173
 
@@ -179,16 +179,16 @@ describe Eventual, 'Es' do
179
179
  end
180
180
 
181
181
  it "should raise WdayMatchError if weekday doesn't correspond to date" do
182
- lambda { Eventual.parse("lunes 21 de marzo").map }.should raise_error(Eventual::WdayMatchError)
182
+ lambda { Eventual.parse("lunes 21 de marzo").to_a }.should raise_error(Eventual::WdayMatchError)
183
183
  end
184
184
  end
185
185
  end
186
186
 
187
187
  describe 'day list' do
188
188
  before do
189
- @dates = (1..3).map{ |i| Date.civil( 2010, 3, i) }
189
+ @dates = (1..3).map{ |i| Date.civil(2010, 3, i) }
190
190
  end
191
-
191
+
192
192
  describe "day list for '1, 2 y 3 de marzo'" do
193
193
  before { @result = Eventual.parse("1, 2 y 3 marzo") }
194
194
  it_should_behave_like 'correctly parses dates'
@@ -208,7 +208,7 @@ describe Eventual, 'Es' do
208
208
  end
209
209
 
210
210
  it "should raise WdayMatchError if weekday doesn't correspond to date" do
211
- lambda { Eventual.parse("lunes 2, martes 2 y jueves 3 de marzo").map }.should raise_error(Eventual::WdayMatchError)
211
+ lambda { Eventual.parse("lunes 2, martes 2 y jueves 3 de marzo").to_a }.should raise_error(Eventual::WdayMatchError)
212
212
  end
213
213
  end
214
214
  end
@@ -216,7 +216,7 @@ describe Eventual, 'Es' do
216
216
  describe 'day range' do
217
217
  describe 'period in same month' do
218
218
  before do
219
- @dates = (1..3).map{ |i| Date.civil( 2010, 3, i) }
219
+ @dates = (1..3).map{ |i| Date.civil(2010, 3, i) }
220
220
  end
221
221
 
222
222
  describe "day list for '1 al 3 de marzo" do
@@ -317,7 +317,7 @@ describe Eventual, 'Es' do
317
317
  describe "wdays for 'fines de semana del 1 al 22 de marzo del '10" do
318
318
  before do
319
319
  @result = Eventual.parse "fines de semana del 1 al 22 de marzo del '10"
320
- @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-22')).map.reject{ |day| not [6,0].include?(day.wday) }
320
+ @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-22')).to_a.reject{ |day| not [6,0].include?(day.wday) }
321
321
  end
322
322
  it_should_behave_like 'correctly parses dates'
323
323
  it_should_behave_like 'includes corresponding dates'
@@ -326,7 +326,7 @@ describe Eventual, 'Es' do
326
326
  describe "wdays for 'entre semana del 1 al 22 de marzo del '10" do
327
327
  before do
328
328
  @result = Eventual.parse("entre semana del 1 al 22 de marzo del '10")
329
- @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-22')).map.reject{ |day| not (1..5).map.include?(day.wday) }
329
+ @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-22')).to_a.reject{ |day| not (1..5).map.include?(day.wday) }
330
330
  end
331
331
  it_should_behave_like 'correctly parses dates'
332
332
  it_should_behave_like 'includes corresponding dates'
@@ -385,13 +385,12 @@ describe Eventual, 'Es' do
385
385
  describe 'octubre a diciembre del 2008' do
386
386
  before do
387
387
  @result = Eventual.parse('octubre a diciembre del 2008')
388
- @dates = (Date.parse('2008-10-1')..DateTime.parse('2008-12-31')).map
388
+ @dates = (Date.parse('2008-10-1')..DateTime.parse('2008-12-31')).to_a
389
389
  end
390
390
  it_should_behave_like 'correctly parses dates'
391
391
  it_should_behave_like 'includes corresponding dates'
392
392
  end
393
393
 
394
-
395
394
  describe 'lunes y martes de octubre del 2007 a diciembre del 2008' do
396
395
  before do
397
396
  @result = Eventual.parse('lunes y martes de octubre del 2007 a diciembre del 2008')
@@ -459,9 +458,8 @@ describe Eventual, 'Es' do
459
458
  describe 'single day with time' do
460
459
  before do
461
460
  @result = Eventual.parse('1 de enero del 2010 a las 15:00')
462
- @dates = [DateTime.civil 2010, 1, 1, 15]
461
+ @dates = [DateTime.civil(2010, 1, 1, 15)]
463
462
  end
464
-
465
463
  it_should_behave_like 'correctly parses dates'
466
464
  it_should_behave_like 'includes corresponding dates'
467
465
  it_should_behave_like 'outputs DateTime'
@@ -510,7 +508,7 @@ describe Eventual, 'Es' do
510
508
  describe 'two times for month range' do
511
509
  before do
512
510
  @result = Eventual.parse('lunes y martes de diciembre a las 16:00 y 15:00 horas')
513
- @dates = ((DateTime.parse('2010-12-1T15:00')..DateTime.parse('2010-12-31T15:00')).map + (DateTime.parse('2010-12-1T16:00')..DateTime.parse('2010-12-31T16:00')).map).reject{ |day| not [1,2].include?(day.wday) }
511
+ @dates = ((DateTime.parse('2010-12-1T15:00')..DateTime.parse('2010-12-31T15:00')).to_a + (DateTime.parse('2010-12-1T16:00')..DateTime.parse('2010-12-31T16:00')).to_a).reject{ |day| not [1,2].include?(day.wday) }
514
512
  end
515
513
  it_should_behave_like 'correctly parses dates'
516
514
  it_should_behave_like 'includes corresponding dates'
@@ -525,9 +523,9 @@ describe Eventual, 'Es' do
525
523
  before do
526
524
  @result = Eventual.parse('lunes y martes de diciembre a las 16:00, 17:00 y 15:00 horas')
527
525
  @dates = (
528
- (DateTime.parse('2010-12-1T15:00')..DateTime.parse('2010-12-31T15:00')).map +
529
- (DateTime.parse('2010-12-1T16:00')..DateTime.parse('2010-12-31T16:00')).map +
530
- (DateTime.parse('2010-12-1T17:00')..DateTime.parse('2010-12-31T17:00')).map
526
+ (DateTime.parse('2010-12-1T15:00')..DateTime.parse('2010-12-31T15:00')).to_a +
527
+ (DateTime.parse('2010-12-1T16:00')..DateTime.parse('2010-12-31T16:00')).to_a +
528
+ (DateTime.parse('2010-12-1T17:00')..DateTime.parse('2010-12-31T17:00')).to_a
531
529
  ).reject{ |day| not [1,2].include?(day.wday) }
532
530
  end
533
531
 
@@ -543,7 +541,7 @@ describe Eventual, 'Es' do
543
541
  describe 'range with time as 12 hours am' do
544
542
  before do
545
543
  @result = Eventual.parse('lunes y martes de diciembre a las 3 am')
546
- @dates = ((DateTime.parse('2010-12-1T03:00')..DateTime.parse('2010-12-31T03:00')).map).reject{ |day| not [1,2].include?(day.wday) }
544
+ @dates = ((DateTime.parse('2010-12-1T03:00')..DateTime.parse('2010-12-31T03:00')).to_a).reject{ |day| not [1,2].include?(day.wday) }
547
545
  end
548
546
  it_should_behave_like 'correctly parses dates'
549
547
  it_should_behave_like 'includes corresponding dates'
@@ -557,7 +555,7 @@ describe Eventual, 'Es' do
557
555
  describe 'range with time as 12 hours pm' do
558
556
  before do
559
557
  @result = Eventual.parse('lunes y martes de diciembre a las 3:00 pm')
560
- @dates = ((DateTime.parse('2010-12-1T15:00')..DateTime.parse('2010-12-31T15:00')).map).reject{ |day| not [1,2].include?(day.wday) }
558
+ @dates = ((DateTime.parse('2010-12-1T15:00')..DateTime.parse('2010-12-31T15:00')).to_a).reject{ |day| not [1,2].include?(day.wday) }
561
559
  end
562
560
  it_should_behave_like 'correctly parses dates'
563
561
  it_should_behave_like 'includes corresponding dates'
@@ -584,7 +582,7 @@ describe Eventual, 'Es' do
584
582
  before do
585
583
  @result = Eventual.parse('1 de enero del 2010 de las 15:00 a las 16:00')
586
584
  @ranges = [(DateTime.civil 2010, 1, 1, 15)..(DateTime.civil 2010, 1, 1, 16)]
587
- @dates = @ranges.map{ |range| range.map }.flatten
585
+ @dates = @ranges.map{ |range| range.to_a }.flatten
588
586
  end
589
587
 
590
588
  it_should_behave_like 'correctly parses time ranges'
@@ -595,7 +593,7 @@ describe Eventual, 'Es' do
595
593
  before do
596
594
  @result = Eventual.parse('1 de enero del 2010 de las 15:00 a las 16:00 y de las 17:00 a las 19:00')
597
595
  @ranges = [(DateTime.civil 2010, 1, 1, 15)..(DateTime.civil 2010, 1, 1, 16), (DateTime.civil 2010, 1, 1, 17)..(DateTime.civil 2010, 1, 1, 19)]
598
- @dates = @ranges.map{ |range| range.map }.flatten
596
+ @dates = @ranges.map{ |range| range.to_a }.flatten
599
597
  end
600
598
 
601
599
  it_should_behave_like 'correctly parses time ranges'
@@ -606,7 +604,7 @@ describe Eventual, 'Es' do
606
604
  before do
607
605
  @result = Eventual.parse('1 de enero del 2010 de las 15:00 a las 16:00, de las 17:00 a las 19:00 y de las 21:00 a las 22:00')
608
606
  @ranges = [(DateTime.civil 2010, 1, 1, 15)..(DateTime.civil 2010, 1, 1, 16), (DateTime.civil 2010, 1, 1, 17)..(DateTime.civil 2010, 1, 1, 19), (DateTime.civil 2010, 1, 1, 21)..(DateTime.civil 2010, 1, 1, 22)]
609
- @dates = @ranges.map{ |range| range.map }.flatten
607
+ @dates = @ranges.map{ |range| range.to_a }.flatten
610
608
  end
611
609
 
612
610
  it_should_behave_like 'correctly parses time ranges'
@@ -614,12 +612,11 @@ describe Eventual, 'Es' do
614
612
  end
615
613
  end
616
614
 
617
-
618
615
  describe 'Marshal dump' do
619
616
  describe "month without year parsing 'marzo'" do
620
617
  before do
621
618
  @result = Marshal.load Marshal.dump(Eventual.parse('marzo')).gsub('NaturalDates::', 'NaturalDates::Eventual::Es::')
622
- @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-31')).map
619
+ @dates = (Date.parse('2010-3-1')..Date.parse('2010-3-31')).to_a
623
620
  end
624
621
  it_should_behave_like 'correctly parses dates'
625
622
  it_should_behave_like 'includes corresponding dates'
@@ -630,7 +627,7 @@ describe Eventual, 'Es' do
630
627
  describe "month without year parsing 'marzo'" do
631
628
  before do
632
629
  @result = Eventual.parse('marzo', :default_year => 2007)
633
- @dates = (Date.parse('2007-3-1')..Date.parse('2007-3-31')).map
630
+ @dates = (Date.parse('2007-3-1')..Date.parse('2007-3-31')).to_a
634
631
  end
635
632
  it_should_behave_like 'correctly parses dates'
636
633
  it_should_behave_like 'includes corresponding dates'
@@ -2,9 +2,8 @@ $LOAD_PATH.unshift File.dirname(__FILE__)
2
2
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
3
 
4
4
  require 'rubygems'
5
- require 'spec'
6
- require 'spec/autorun'
7
- require 'date/performance'
5
+ require 'rspec'
6
+ require 'rspec/autorun'
8
7
 
9
8
  class MapDates
10
9
  def description
@@ -32,4 +31,4 @@ end
32
31
 
33
32
  def map_dates *times
34
33
  MapDates.new times, Date
35
- end
34
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventual
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 5
9
- - 8
10
- version: 0.5.8
8
+ - 9
9
+ version: 0.5.9
11
10
  platform: ruby
12
11
  authors:
13
12
  - Macario Ortega
@@ -15,61 +14,58 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-10-01 00:00:00 -05:00
17
+ date: 2011-03-05 00:00:00 -06:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: treetop
21
+ name: rspec
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 13
30
28
  segments:
31
- - 1
32
- - 4
33
- - 5
34
- version: 1.4.5
35
- type: :runtime
29
+ - 0
30
+ version: "0"
31
+ type: :development
36
32
  version_requirements: *id001
37
33
  - !ruby/object:Gem::Dependency
38
- name: rspec
34
+ name: treetop
39
35
  prerelease: false
40
36
  requirement: &id002 !ruby/object:Gem::Requirement
41
37
  none: false
42
38
  requirements:
43
39
  - - ">="
44
40
  - !ruby/object:Gem::Version
45
- hash: 13
46
41
  segments:
47
- - 1
48
- - 2
49
- - 9
50
- version: 1.2.9
51
- type: :development
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
52
45
  version_requirements: *id002
53
- description: " Reconocimiento de fechas y periodos en lenguaje natural. Natural language date and period parsing, currently only in spanish. "
54
- email: macarui@gmail.com
46
+ description: Reconocimiento de fechas y periodos en lenguaje natural. Natural language date and period parsing in spanish.
47
+ email:
48
+ - macarui@gmail.com
55
49
  executables: []
56
50
 
57
51
  extensions: []
58
52
 
59
- extra_rdoc_files:
60
- - LICENSE
61
- - README.rdoc
53
+ extra_rdoc_files: []
54
+
62
55
  files:
63
56
  - .document
64
57
  - .gitignore
58
+ - .rspec
59
+ - Gemfile
60
+ - Gemfile.lock
65
61
  - LICENSE
66
62
  - README.rdoc
67
63
  - Rakefile
68
- - VERSION
69
64
  - lib/eventual.rb
70
65
  - lib/eventual/es.rb
71
66
  - lib/eventual/es/event_parser.treetop
72
67
  - lib/eventual/syntax_nodes.rb
68
+ - lib/eventual/version.rb
73
69
  - spec/es_eventual_spec.rb
74
70
  - spec/spec.opts
75
71
  - spec/spec_helper.rb
@@ -77,12 +73,9 @@ has_rdoc: true
77
73
  homepage: http://github.com/maca/eventual
78
74
  licenses: []
79
75
 
80
- post_install_message: " \n\n\
81
- ***********************************\n\
82
- Por favor tenga en cuenta que el API ha cambiado, consulte la p\xC3\xA1gina del proyecto: http://github.com/maca/eventual. English implementation is due.\n\
83
- ***********************************\n\n "
84
- rdoc_options:
85
- - --charset=UTF-8
76
+ post_install_message:
77
+ rdoc_options: []
78
+
86
79
  require_paths:
87
80
  - lib
88
81
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -90,7 +83,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
83
  requirements:
91
84
  - - ">="
92
85
  - !ruby/object:Gem::Version
93
- hash: 3
94
86
  segments:
95
87
  - 0
96
88
  version: "0"
@@ -99,7 +91,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
91
  requirements:
100
92
  - - ">="
101
93
  - !ruby/object:Gem::Version
102
- hash: 3
103
94
  segments:
104
95
  - 0
105
96
  version: "0"
@@ -109,7 +100,6 @@ rubyforge_project:
109
100
  rubygems_version: 1.3.7
110
101
  signing_key:
111
102
  specification_version: 3
112
- summary: Reconocimiento de fechas y periodos en lenguaje natural. Natural language date and period parsing, currently only in spanish.
113
- test_files:
114
- - spec/spec_helper.rb
115
- - spec/es_eventual_spec.rb
103
+ summary: Reconocimiento de fechas y periodos en lenguaje natural. Natural language date and period parsing in spanish.
104
+ test_files: []
105
+
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.5.8