chronic 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.6.1 / 2011-07-21
2
+
3
+ * Ensure Handler definitions are executed in the correct order
4
+
1
5
  # 0.6.0 / 2011-07-19
2
6
 
3
7
  * Attempting to parse strings with days past the last day of a month will
@@ -28,7 +28,7 @@ require 'date'
28
28
  #
29
29
  # @author Tom Preston-Werner, Lee Jarvis
30
30
  module Chronic
31
- VERSION = "0.6.0"
31
+ VERSION = "0.6.1"
32
32
 
33
33
  class << self
34
34
 
@@ -284,23 +284,30 @@ module Chronic
284
284
  def tokens_to_span(tokens, options)
285
285
  definitions = definitions(options)
286
286
 
287
- definitions.each do |type, handlers|
288
- handlers.each do |handler|
289
- next unless handler.match(tokens, definitions)
290
-
291
- good_tokens = case type
292
- when :date, :endian, :anchor
293
- tokens.reject { |o| o.get_tag Separator }
294
- when :arrow
295
- tokens.reject { |o| o.get_tag(SeparatorAt) || o.get_tag(SeparatorSlashOrDash) || o.get_tag(SeparatorComma) }
296
- else
297
- tokens
298
- end
299
-
300
- if handler.handler_method
301
- return handler.invoke(type, good_tokens, options)
302
- end
287
+ (definitions[:date] + definitions[:endian]).each do |handler|
288
+ if handler.match(tokens, definitions)
289
+ good_tokens = tokens.select { |o| !o.get_tag Separator }
290
+ return handler.invoke(:date, good_tokens, options)
291
+ end
292
+ end
293
+
294
+ definitions[:anchor].each do |handler|
295
+ if handler.match(tokens, definitions)
296
+ good_tokens = tokens.select { |o| !o.get_tag Separator }
297
+ return handler.invoke(:anchor, good_tokens, options)
298
+ end
299
+ end
300
+
301
+ definitions[:arrow].each do |handler|
302
+ if handler.match(tokens, definitions)
303
+ good_tokens = tokens.reject { |o| o.get_tag(SeparatorAt) || o.get_tag(SeparatorSlashOrDash) || o.get_tag(SeparatorComma) }
304
+ return handler.invoke(:arrow, good_tokens, options)
305
+ end
306
+ end
303
307
 
308
+ definitions[:narrow].each do |handler|
309
+ if handler.match(tokens, definitions)
310
+ return handler.invoke(:narrow, tokens, options)
304
311
  end
305
312
  end
306
313
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chronic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-07-19 00:00:00.000000000 +01:00
13
+ date: 2011-07-21 00:00:00.000000000 +01:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
  description: Chronic is a natural language date/time parser written in pure Ruby.