medjool 0.5.2 → 0.5.3

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.
@@ -33,9 +33,13 @@ class Medjool::Parser
33
33
 
34
34
  def parse(text, update_now = true)
35
35
  if Medjool::DATE_MATCHER.match(text)
36
- if /^[0-9]$/.match(text.strip)
36
+ # Let's do an aggressive strip of any whitespace at the start and end, including crazy unicodeness
37
+ # that the standard 'strip' would miss
38
+ text = text.gsub(/^[^a-zA-Z0-9]*/, "").gsub(/[^a-zA-Z0-9]*$/, "")
39
+
40
+ if /^[0-9]$/.match(text)
37
41
  # Handle lone integers
38
- text = "#{text.strip}st"
42
+ text = "#{text}st"
39
43
  end
40
44
 
41
45
  begin
data/lib/medjool.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Medjool
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
3
3
 
4
4
  require 'medjool/parser'
5
5
  require 'medjool/date_range'
data/test/test_medjool.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'helper'
2
4
 
3
5
  class TestMedjool < TestCase
@@ -84,4 +86,9 @@ class TestMedjool < TestCase
84
86
  assert_equal nil, Medjool.parse("Blah")
85
87
  assert_equal nil, Medjool.parse("31st February")
86
88
  end
89
+
90
+ def test_crazy_unicode_junk
91
+ parser = Medjool::Parser.new
92
+ assert parser.parse("3")
93
+ end
87
94
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medjool
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 2
10
- version: 0.5.2
9
+ - 3
10
+ version: 0.5.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Geers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-11-04 00:00:00 Z
18
+ date: 2013-11-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activesupport