chronic 0.1.5 → 0.6.5

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.
Files changed (68) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +5 -0
  3. data/.yardopts +3 -0
  4. data/HISTORY.md +180 -0
  5. data/LICENSE +21 -0
  6. data/README.md +176 -0
  7. data/Rakefile +39 -32
  8. data/chronic.gemspec +17 -0
  9. data/lib/chronic/chronic.rb +294 -208
  10. data/lib/chronic/grabber.rb +22 -17
  11. data/lib/chronic/handler.rb +90 -0
  12. data/lib/chronic/handlers.rb +365 -278
  13. data/lib/chronic/mini_date.rb +38 -0
  14. data/lib/chronic/numerizer.rb +121 -0
  15. data/lib/chronic/ordinal.rb +23 -19
  16. data/lib/chronic/pointer.rb +20 -17
  17. data/lib/chronic/repeater.rb +126 -105
  18. data/lib/chronic/repeaters/repeater_day.rb +49 -43
  19. data/lib/chronic/repeaters/repeater_day_name.rb +48 -42
  20. data/lib/chronic/repeaters/repeater_day_portion.rb +81 -80
  21. data/lib/chronic/repeaters/repeater_fortnight.rb +59 -53
  22. data/lib/chronic/repeaters/repeater_hour.rb +49 -43
  23. data/lib/chronic/repeaters/repeater_minute.rb +55 -39
  24. data/lib/chronic/repeaters/repeater_month.rb +77 -55
  25. data/lib/chronic/repeaters/repeater_month_name.rb +83 -82
  26. data/lib/chronic/repeaters/repeater_season.rb +107 -21
  27. data/lib/chronic/repeaters/repeater_season_name.rb +41 -22
  28. data/lib/chronic/repeaters/repeater_second.rb +39 -33
  29. data/lib/chronic/repeaters/repeater_time.rb +117 -103
  30. data/lib/chronic/repeaters/repeater_week.rb +63 -57
  31. data/lib/chronic/repeaters/repeater_weekday.rb +85 -0
  32. data/lib/chronic/repeaters/repeater_weekend.rb +64 -9
  33. data/lib/chronic/repeaters/repeater_year.rb +70 -51
  34. data/lib/chronic/scalar.rb +64 -29
  35. data/lib/chronic/season.rb +37 -0
  36. data/lib/chronic/separator.rb +50 -38
  37. data/lib/chronic/span.rb +31 -0
  38. data/lib/chronic/tag.rb +42 -0
  39. data/lib/chronic/time_zone.rb +30 -0
  40. data/lib/chronic/token.rb +45 -0
  41. data/lib/chronic.rb +86 -22
  42. data/test/helper.rb +6 -0
  43. data/test/test_Chronic.rb +118 -20
  44. data/test/test_DaylightSavings.rb +118 -0
  45. data/test/test_Handler.rb +36 -42
  46. data/test/test_MiniDate.rb +32 -0
  47. data/test/test_Numerizer.rb +72 -0
  48. data/test/test_RepeaterDayName.rb +15 -16
  49. data/test/test_RepeaterFortnight.rb +16 -17
  50. data/test/test_RepeaterHour.rb +22 -19
  51. data/test/test_RepeaterMinute.rb +34 -0
  52. data/test/test_RepeaterMonth.rb +20 -17
  53. data/test/test_RepeaterMonthName.rb +17 -18
  54. data/test/test_RepeaterSeason.rb +40 -0
  55. data/test/test_RepeaterTime.rb +20 -22
  56. data/test/test_RepeaterWeek.rb +16 -17
  57. data/test/test_RepeaterWeekday.rb +55 -0
  58. data/test/test_RepeaterWeekend.rb +74 -0
  59. data/test/test_RepeaterYear.rb +24 -18
  60. data/test/test_Span.rb +5 -6
  61. data/test/test_Token.rb +5 -6
  62. data/test/test_parsing.rb +743 -338
  63. metadata +81 -54
  64. data/History.txt +0 -29
  65. data/Manifest.txt +0 -43
  66. data/README.txt +0 -149
  67. data/test/parse_numbers.rb +0 -50
  68. data/test/suite.rb +0 -9
metadata CHANGED
@@ -1,41 +1,43 @@
1
- --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
1
+ --- !ruby/object:Gem::Specification
4
2
  name: chronic
5
- version: !ruby/object:Gem::Version
6
- version: 0.1.5
7
- date: 2006-12-21 00:00:00 -08:00
8
- summary: A natural language date parser
9
- require_paths:
10
- - lib
11
- email: ryand-ruby@zenspider.com
12
- homepage: "\thttp://chronic.rubyforge.org/"
13
- rubyforge_project: chronic
14
- description: Chronic is a natural language date/time parser written in pure Ruby. See below for the wide variety of formats Chronic will parse.
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tom Preston-Werner
9
+ - Lee Jarvis
15
10
  autorequire:
16
- default_executable:
17
11
  bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
25
- platform: ruby
26
- signing_key:
27
- cert_chain:
28
- authors:
29
- - Ryan Davis
30
- files:
31
- - History.txt
32
- - Manifest.txt
33
- - README.txt
12
+ cert_chain: []
13
+ date: 2011-11-05 00:00:00.000000000Z
14
+ dependencies: []
15
+ description: Chronic is a natural language date/time parser written in pure Ruby.
16
+ email:
17
+ - tom@mojombo.com
18
+ - lee@jarvis.co
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files:
22
+ - README.md
23
+ - HISTORY.md
24
+ - LICENSE
25
+ files:
26
+ - .gemtest
27
+ - .gitignore
28
+ - .yardopts
29
+ - HISTORY.md
30
+ - LICENSE
31
+ - README.md
34
32
  - Rakefile
33
+ - chronic.gemspec
35
34
  - lib/chronic.rb
36
35
  - lib/chronic/chronic.rb
37
36
  - lib/chronic/grabber.rb
37
+ - lib/chronic/handler.rb
38
38
  - lib/chronic/handlers.rb
39
+ - lib/chronic/mini_date.rb
40
+ - lib/chronic/numerizer.rb
39
41
  - lib/chronic/ordinal.rb
40
42
  - lib/chronic/pointer.rb
41
43
  - lib/chronic/repeater.rb
@@ -52,56 +54,81 @@ files:
52
54
  - lib/chronic/repeaters/repeater_second.rb
53
55
  - lib/chronic/repeaters/repeater_time.rb
54
56
  - lib/chronic/repeaters/repeater_week.rb
57
+ - lib/chronic/repeaters/repeater_weekday.rb
55
58
  - lib/chronic/repeaters/repeater_weekend.rb
56
59
  - lib/chronic/repeaters/repeater_year.rb
57
60
  - lib/chronic/scalar.rb
61
+ - lib/chronic/season.rb
58
62
  - lib/chronic/separator.rb
59
- - test/parse_numbers.rb
60
- - test/suite.rb
63
+ - lib/chronic/span.rb
64
+ - lib/chronic/tag.rb
65
+ - lib/chronic/time_zone.rb
66
+ - lib/chronic/token.rb
67
+ - test/helper.rb
61
68
  - test/test_Chronic.rb
69
+ - test/test_DaylightSavings.rb
62
70
  - test/test_Handler.rb
71
+ - test/test_MiniDate.rb
72
+ - test/test_Numerizer.rb
63
73
  - test/test_RepeaterDayName.rb
64
74
  - test/test_RepeaterFortnight.rb
65
75
  - test/test_RepeaterHour.rb
76
+ - test/test_RepeaterMinute.rb
66
77
  - test/test_RepeaterMonth.rb
67
78
  - test/test_RepeaterMonthName.rb
79
+ - test/test_RepeaterSeason.rb
68
80
  - test/test_RepeaterTime.rb
69
81
  - test/test_RepeaterWeek.rb
82
+ - test/test_RepeaterWeekday.rb
83
+ - test/test_RepeaterWeekend.rb
70
84
  - test/test_RepeaterYear.rb
71
85
  - test/test_Span.rb
72
86
  - test/test_Token.rb
73
87
  - test/test_parsing.rb
74
- test_files:
88
+ homepage: http://github.com/mojombo/chronic
89
+ licenses: []
90
+ post_install_message:
91
+ rdoc_options:
92
+ - --charset=UTF-8
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project: chronic
109
+ rubygems_version: 1.8.11
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: Natural language date/time parsing.
113
+ test_files:
114
+ - test/helper.rb
75
115
  - test/test_Chronic.rb
116
+ - test/test_DaylightSavings.rb
76
117
  - test/test_Handler.rb
77
- - test/test_parsing.rb
118
+ - test/test_MiniDate.rb
119
+ - test/test_Numerizer.rb
78
120
  - test/test_RepeaterDayName.rb
79
121
  - test/test_RepeaterFortnight.rb
80
122
  - test/test_RepeaterHour.rb
123
+ - test/test_RepeaterMinute.rb
81
124
  - test/test_RepeaterMonth.rb
82
125
  - test/test_RepeaterMonthName.rb
126
+ - test/test_RepeaterSeason.rb
83
127
  - test/test_RepeaterTime.rb
84
128
  - test/test_RepeaterWeek.rb
129
+ - test/test_RepeaterWeekday.rb
130
+ - test/test_RepeaterWeekend.rb
85
131
  - test/test_RepeaterYear.rb
86
132
  - test/test_Span.rb
87
133
  - test/test_Token.rb
88
- rdoc_options: []
89
-
90
- extra_rdoc_files: []
91
-
92
- executables: []
93
-
94
- extensions: []
95
-
96
- requirements: []
97
-
98
- dependencies:
99
- - !ruby/object:Gem::Dependency
100
- name: hoe
101
- version_requirement:
102
- version_requirements: !ruby/object:Gem::Version::Requirement
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: 1.1.6
107
- version:
134
+ - test/test_parsing.rb
data/History.txt DELETED
@@ -1,29 +0,0 @@
1
- = 0.1.5 2006-12-20
2
-
3
- * fixed 'aug 20' returning next year if current month is august
4
- * modified behavior of 'from now'
5
- * added support for seconds on times, and thus db timestamp format: "2006-12-20 18:04:23"
6
- * made Hoe compliant
7
-
8
- = 0.1.4
9
-
10
- * removed verbose error checking code. oops. :-/
11
-
12
- = 0.1.3
13
-
14
- * improved regexes for word variations (Josh Goebel)
15
- * fixed a bug that caused "today at 3am" to return nil if current time is after 3am
16
-
17
- = 0.1.2
18
-
19
- * removed Date dependency (now works on windows properly without fiddling)
20
-
21
- = 0.1.1
22
-
23
- * run to_s on incoming object
24
- * fixed loop loading of repeaters files (out of order on some machines)
25
- * fixed find_within to use this instead of next (was breaking "today at 6pm")
26
-
27
- = 0.1.0
28
-
29
- * initial release
data/Manifest.txt DELETED
@@ -1,43 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- lib/chronic.rb
6
- lib/chronic/chronic.rb
7
- lib/chronic/grabber.rb
8
- lib/chronic/handlers.rb
9
- lib/chronic/ordinal.rb
10
- lib/chronic/pointer.rb
11
- lib/chronic/repeater.rb
12
- lib/chronic/repeaters/repeater_day.rb
13
- lib/chronic/repeaters/repeater_day_name.rb
14
- lib/chronic/repeaters/repeater_day_portion.rb
15
- lib/chronic/repeaters/repeater_fortnight.rb
16
- lib/chronic/repeaters/repeater_hour.rb
17
- lib/chronic/repeaters/repeater_minute.rb
18
- lib/chronic/repeaters/repeater_month.rb
19
- lib/chronic/repeaters/repeater_month_name.rb
20
- lib/chronic/repeaters/repeater_season.rb
21
- lib/chronic/repeaters/repeater_season_name.rb
22
- lib/chronic/repeaters/repeater_second.rb
23
- lib/chronic/repeaters/repeater_time.rb
24
- lib/chronic/repeaters/repeater_week.rb
25
- lib/chronic/repeaters/repeater_weekend.rb
26
- lib/chronic/repeaters/repeater_year.rb
27
- lib/chronic/scalar.rb
28
- lib/chronic/separator.rb
29
- test/parse_numbers.rb
30
- test/suite.rb
31
- test/test_Chronic.rb
32
- test/test_Handler.rb
33
- test/test_RepeaterDayName.rb
34
- test/test_RepeaterFortnight.rb
35
- test/test_RepeaterHour.rb
36
- test/test_RepeaterMonth.rb
37
- test/test_RepeaterMonthName.rb
38
- test/test_RepeaterTime.rb
39
- test/test_RepeaterWeek.rb
40
- test/test_RepeaterYear.rb
41
- test/test_Span.rb
42
- test/test_Token.rb
43
- test/test_parsing.rb
data/README.txt DELETED
@@ -1,149 +0,0 @@
1
- Chronic
2
- http://chronic.rubyforge.org/
3
- by Tom Preston-Werner
4
-
5
- == DESCRIPTION:
6
-
7
- Chronic is a natural language date/time parser written in pure Ruby. See below for the wide variety of formats Chronic will parse.
8
-
9
- == INSTALLATION:
10
-
11
- Chronic can be installed via RubyGems:
12
-
13
- $ sudo gem install chronic
14
-
15
- == USAGE:
16
-
17
- You can parse strings containing a natural language date using the Chronic.parse method.
18
-
19
- require 'rubygems'
20
- require 'chronic'
21
-
22
- Time.now #=> Sun Aug 27 23:18:25 PDT 2006
23
-
24
- #---
25
-
26
- Chronic.parse('tomorrow')
27
- #=> Mon Aug 28 12:00:00 PDT 2006
28
-
29
- Chronic.parse('monday', :context => :past)
30
- #=> Mon Aug 21 12:00:00 PDT 2006
31
-
32
- Chronic.parse('this tuesday 5:00')
33
- #=> Tue Aug 29 17:00:00 PDT 2006
34
-
35
- Chronic.parse('this tuesday 5:00', :ambiguous_time_range => :none)
36
- #=> Tue Aug 29 05:00:00 PDT 2006
37
-
38
- Chronic.parse('may 27th', :now => Time.local(2000, 1, 1))
39
- #=> Sat May 27 12:00:00 PDT 2000
40
-
41
- Chronic.parse('may 27th', :guess => false)
42
- #=> Sun May 27 00:00:00 PDT 2007..Mon May 28 00:00:00 PDT 2007
43
-
44
- See Chronic.parse for detailed usage instructions.
45
-
46
- == EXAMPLES:
47
-
48
- Chronic can parse a huge variety of date and time formats. Following is a small sample of strings that will be properly parsed. Parsing is case insensitive and will handle common abbreviations and misspellings.
49
-
50
- Simple
51
-
52
- thursday
53
- november
54
- summer
55
- friday 13:00
56
- mon 2:35
57
- 4pm
58
- 6 in the morning
59
- friday 1pm
60
- sat 7 in the evening
61
- yesterday
62
- today
63
- tomorrow
64
- this tuesday
65
- next month
66
- last winter
67
- this morning
68
- last night
69
- this second
70
- yesterday at 4:00
71
- last friday at 20:00
72
- last week tuesday
73
- tomorrow at 6:45pm
74
- afternoon yesterday
75
- thursday last week
76
-
77
- Complex
78
-
79
- 3 years ago
80
- 5 months before now
81
- 7 hours ago
82
- 7 days from now
83
- 1 week hence
84
- in 3 hours
85
- 1 year ago tomorrow
86
- 3 months ago saturday at 5:00 pm
87
- 7 hours before tomorrow at noon
88
- 3rd wednesday in november
89
- 3rd month next year
90
- 3rd thursday this september
91
- 4th day last week
92
-
93
- Specific Dates
94
-
95
- January 5
96
- dec 25
97
- may 27th
98
- October 2006
99
- oct 06
100
- jan 3 2010
101
- february 14, 2004
102
- 3 jan 2000
103
- 17 april 85
104
- 5/27/1979
105
- 27/5/1979
106
- 05/06
107
- 1979-05-27
108
- Friday
109
- 5
110
- 4:00
111
- 17:00
112
- 0800
113
-
114
- Specific Times (many of the above with an added time)
115
-
116
- January 5 at 7pm
117
- 1979-05-27 05:00:00
118
- etc
119
-
120
- == LIMITATIONS:
121
-
122
- Chronic uses Ruby's built in Time class for all time storage and computation. Because of this, only times that the Time class can handle will be properly parsed. Parsing for times outside of this range will simply return nil. Support for a wider range of times is planned for a future release.
123
-
124
- Time zones other than the local one are not currently supported. Support for other time zones is planned for a future release.
125
-
126
- == LICENSE:
127
-
128
- (The MIT License)
129
-
130
- Copyright (c) 2006 Ryan Davis, Zen Spider Software
131
-
132
- Permission is hereby granted, free of charge, to any person obtaining
133
- a copy of this software and associated documentation files (the
134
- "Software"), to deal in the Software without restriction, including
135
- without limitation the rights to use, copy, modify, merge, publish,
136
- distribute, sublicense, and/or sell copies of the Software, and to
137
- permit persons to whom the Software is furnished to do so, subject to
138
- the following conditions:
139
-
140
- The above copyright notice and this permission notice shall be
141
- included in all copies or substantial portions of the Software.
142
-
143
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
144
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
145
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
146
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
147
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
148
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
149
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,50 +0,0 @@
1
- __END__
2
-
3
- require 'test/unit'
4
-
5
- class ParseNumbersTest < Test::Unit::TestCase
6
-
7
- def test_parse
8
- strings = {1 => 'one',
9
- 5 => 'five',
10
- 10 => 'ten',
11
- 11 => 'eleven',
12
- 12 => 'twelve',
13
- 13 => 'thirteen',
14
- 14 => 'fourteen',
15
- 15 => 'fifteen',
16
- 16 => 'sixteen',
17
- 17 => 'seventeen',
18
- 18 => 'eighteen',
19
- 19 => 'nineteen',
20
- 20 => 'twenty',
21
- 27 => 'twenty seven',
22
- 31 => 'thirty-one',
23
- 59 => 'fifty nine',
24
- 100 => 'a hundred',
25
- 100 => 'one hundred',
26
- 150 => 'one hundred and fifty',
27
- 150 => 'one fifty',
28
- 200 => 'two-hundred',
29
- 500 => '5 hundred',
30
- 999 => 'nine hundred and ninety nine',
31
- 1_000 => 'one thousand',
32
- 1_200 => 'twelve hundred',
33
- 1_200 => 'one thousand two hundred',
34
- 17_000 => 'seventeen thousand',
35
- 21_473 => 'twentyone-thousand-four-hundred-and-seventy-three',
36
- 74_002 => 'seventy four thousand and two',
37
- 99_999 => 'ninety nine thousand nine hundred ninety nine',
38
- 100_000 => '100 thousand',
39
- 250_000 => 'two hundred fifty thousand',
40
- 1_000_000 => 'one million',
41
- 1_250_007 => 'one million two hundred fifty thousand and seven',
42
- 1_000_000_000 => 'one billion',
43
- 1_000_000_001 => 'one billion and one'}
44
-
45
- strings.keys.sort.each do |key|
46
- assert_equal key, JW::NumberMagick.convert(strings[key])
47
- end
48
- end
49
-
50
- end
data/test/suite.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'test/unit'
2
-
3
- tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"]
4
- tests.delete_if { |o| o =~ /test_parsing/ }
5
- tests.each do |file|
6
- require file
7
- end
8
-
9
- require File.dirname(__FILE__) + '/test_parsing.rb'