chronic 0.4.1 → 0.5.0

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 (46) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +5 -0
  3. data/.yardopts +3 -0
  4. data/HISTORY.md +36 -2
  5. data/Manifest.txt +6 -2
  6. data/README.md +8 -2
  7. data/Rakefile +9 -101
  8. data/chronic.gemspec +12 -78
  9. data/lib/chronic/chronic.rb +225 -91
  10. data/lib/chronic/grabber.rb +12 -3
  11. data/lib/chronic/handlers.rb +94 -198
  12. data/lib/chronic/mini_date.rb +6 -2
  13. data/lib/chronic/ordinal.rb +15 -4
  14. data/lib/chronic/pointer.rb +12 -3
  15. data/lib/chronic/repeater.rb +28 -9
  16. data/lib/chronic/repeaters/repeater_day.rb +0 -1
  17. data/lib/chronic/repeaters/repeater_day_name.rb +0 -1
  18. data/lib/chronic/repeaters/repeater_day_portion.rb +0 -1
  19. data/lib/chronic/repeaters/repeater_fortnight.rb +0 -1
  20. data/lib/chronic/repeaters/repeater_hour.rb +0 -1
  21. data/lib/chronic/repeaters/repeater_minute.rb +0 -1
  22. data/lib/chronic/repeaters/repeater_month.rb +13 -2
  23. data/lib/chronic/repeaters/repeater_month_name.rb +13 -21
  24. data/lib/chronic/repeaters/repeater_season.rb +0 -19
  25. data/lib/chronic/repeaters/repeater_season_name.rb +0 -2
  26. data/lib/chronic/repeaters/repeater_second.rb +0 -1
  27. data/lib/chronic/repeaters/repeater_time.rb +1 -2
  28. data/lib/chronic/repeaters/repeater_week.rb +0 -1
  29. data/lib/chronic/repeaters/repeater_weekday.rb +0 -1
  30. data/lib/chronic/repeaters/repeater_weekend.rb +0 -1
  31. data/lib/chronic/repeaters/repeater_year.rb +19 -8
  32. data/lib/chronic/scalar.rb +29 -1
  33. data/lib/chronic/season.rb +37 -0
  34. data/lib/chronic/separator.rb +24 -7
  35. data/lib/chronic/tag.rb +10 -1
  36. data/lib/chronic/time_zone.rb +12 -3
  37. data/lib/chronic/token.rb +14 -4
  38. data/lib/chronic.rb +62 -49
  39. data/test/test_Chronic.rb +52 -2
  40. data/test/test_RepeaterMonth.rb +4 -0
  41. data/test/test_RepeaterSeason.rb +40 -0
  42. data/test/test_RepeaterYear.rb +7 -0
  43. data/test/test_Time.rb +1 -1
  44. data/test/test_parsing.rb +159 -113
  45. metadata +31 -29
  46. data/benchmark/benchmark.rb +0 -13
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ pkg
2
+ *.rbc
3
+ rdoc
4
+ .yardoc
5
+ doc
data/.yardopts ADDED
@@ -0,0 +1,3 @@
1
+ -m markdown
2
+ --readme README.md
3
+ --title "Chronic - Natural language date/time parsing"
data/HISTORY.md CHANGED
@@ -1,4 +1,38 @@
1
- # 0.4.1
1
+ # TBA
2
+
3
+ * Replace commas with spaces instead of removing the char (Thomas Walpole)
4
+ * Added tests for RepeaterSeason
5
+ * Re-factored tests. Now rather than having a test_parsing method for testing
6
+ all handlers, break them down independent of handler method. For example
7
+ with handler `handle_sm_sd_sy` the subsequent test would be
8
+ `test_handle_sm_sd_sy`
9
+ * Added support for parsing ordinal-dates/month-names/year, ie:
10
+ `2nd of May 1995`
11
+ * Added support for parsing ordinal-dates and month names, ie:
12
+ `22nd of February at 6:30pm`
13
+ * Fix `Time.construct` leap year checking. Instead use `Date.leap?(year)`
14
+
15
+ # 0.4.4 / 2011-06-12
16
+
17
+ * Fix RepeaterYear for fetching past year offsets when the current day is
18
+ later than the last day of the same month in a past year (leap years) ie
19
+ on 29th/feb (leap year) `last year` should (and now does) return 28th/feb
20
+ instead of 1st/march
21
+ * Opt in for gem testing http://test.rubygems.org/
22
+
23
+ # 0.4.3 / 2011-06-08
24
+
25
+ * Fix issue with parsing 1:xxPM -- Ensure 1 is treated as ambiguous, not
26
+ just >1
27
+
28
+ # 0.4.2 / 2011-06-07
29
+
30
+ * Fix MonthRepeater for fetching past month offsets when current day is
31
+ later than the last day of a past month (ie on 29th of March when parsing
32
+ `last month` Chronic would return March instead of February. Now Chronic
33
+ returns the last day of the past month)
34
+
35
+ # 0.4.1 / 2011-06-05
2
36
 
3
37
  * Fix MiniDate ranges for parsing seasons (Thomas Walpole)
4
38
 
@@ -27,7 +61,7 @@
27
61
  * Fix undefined variable in RepeaterHour (Ryan Garver)
28
62
  * Added support for parsing 'Fourty' as another mis-spelling (Lee Reilly)
29
63
  * Added ordinal format support: ie 'February 14th, 2004' (Jeff Felchner)
30
- * Fix dates when working with daylight saving times Mike Mangino
64
+ * Fix dates when working with daylight saving times (Mike Mangino)
31
65
 
32
66
  # 0.3.0 / 2010-10-22
33
67
 
data/Manifest.txt CHANGED
@@ -1,9 +1,11 @@
1
+ .gemtest
2
+ .gitignore
3
+ .yardopts
1
4
  HISTORY.md
2
5
  LICENSE
3
6
  Manifest.txt
4
7
  README.md
5
8
  Rakefile
6
- benchmark/benchmark.rb
7
9
  chronic.gemspec
8
10
  lib/chronic.rb
9
11
  lib/chronic/chronic.rb
@@ -31,6 +33,7 @@ lib/chronic/repeaters/repeater_weekday.rb
31
33
  lib/chronic/repeaters/repeater_weekend.rb
32
34
  lib/chronic/repeaters/repeater_year.rb
33
35
  lib/chronic/scalar.rb
36
+ lib/chronic/season.rb
34
37
  lib/chronic/separator.rb
35
38
  lib/chronic/span.rb
36
39
  lib/chronic/tag.rb
@@ -48,6 +51,7 @@ test/test_RepeaterHour.rb
48
51
  test/test_RepeaterMinute.rb
49
52
  test/test_RepeaterMonth.rb
50
53
  test/test_RepeaterMonthName.rb
54
+ test/test_RepeaterSeason.rb
51
55
  test/test_RepeaterTime.rb
52
56
  test/test_RepeaterWeek.rb
53
57
  test/test_RepeaterWeekday.rb
@@ -56,4 +60,4 @@ test/test_RepeaterYear.rb
56
60
  test/test_Span.rb
57
61
  test/test_Time.rb
58
62
  test/test_Token.rb
59
- test/test_parsing.rb
63
+ test/test_parsing.rb
data/README.md CHANGED
@@ -98,10 +98,14 @@ Complex
98
98
  * 3rd month next year
99
99
  * 3rd thursday this september
100
100
  * 4th day last week
101
+ * fourteenth of june 2010 at eleven o'clock in the evening
102
+ * may seventh '97 at three in the morning
101
103
 
102
104
  Specific Dates
103
105
 
104
106
  * January 5
107
+ * 22nd of june
108
+ * 5th may 2017
105
109
  * February twenty first
106
110
  * dec 25
107
111
  * may 27th
@@ -125,6 +129,7 @@ Specific Dates
125
129
  Specific Times (many of the above with an added time)
126
130
 
127
131
  * January 5 at 7pm
132
+ * 22nd of june at 8am
128
133
  * 1979-05-27 05:00:00
129
134
  * etc
130
135
 
@@ -133,8 +138,9 @@ Specific Times (many of the above with an added time)
133
138
 
134
139
  Chronic allows you to set which Time class to use when constructing times. By
135
140
  default, the built in Ruby time class creates times in your system's local
136
- time zone. You can set this to something like ActiveSupport's TimeZone class
137
- to get full time zone support.
141
+ time zone. You can set this to something like ActiveSupport's
142
+ [TimeZone](http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html)
143
+ class to get full time zone support.
138
144
 
139
145
  >> Time.zone = "UTC"
140
146
  >> Chronic.time_class = Time.zone
data/Rakefile CHANGED
@@ -1,44 +1,10 @@
1
1
  require 'date'
2
2
 
3
- #############################################################################
4
- #
5
- # Helper functions
6
- #
7
- #############################################################################
8
-
9
- def name
10
- @name ||= Dir['*.gemspec'].first.split('.').first
11
- end
12
-
13
3
  def version
14
- line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
15
- line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
16
- end
17
-
18
- def rubyforge_project
19
- name
20
- end
21
-
22
- def gemspec_file
23
- "#{name}.gemspec"
4
+ contents = File.read File.expand_path('../lib/chronic.rb', __FILE__)
5
+ contents[/VERSION = "([^"]+)"/, 1]
24
6
  end
25
7
 
26
- def gem_file
27
- "#{name}-#{version}.gem"
28
- end
29
-
30
- def replace_header(head, header_name)
31
- head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
32
- end
33
-
34
- #############################################################################
35
- #
36
- # Standard tasks
37
- #
38
- #############################################################################
39
-
40
- task :default => :test
41
-
42
8
  require 'rake/testtask'
43
9
  Rake::TestTask.new(:test) do |test|
44
10
  test.libs << 'lib' << 'test'
@@ -54,33 +20,12 @@ task :coverage do
54
20
  sh "open coverage/index.html"
55
21
  end
56
22
 
57
- require 'rake/rdoctask'
58
- Rake::RDocTask.new do |rdoc|
59
- rdoc.rdoc_dir = 'rdoc'
60
- rdoc.title = "#{name} #{version}"
61
- rdoc.rdoc_files.include('README*')
62
- rdoc.rdoc_files.include('lib/**/*.rb')
63
- end
64
-
65
23
  desc "Open an irb session preloaded with this library"
66
24
  task :console do
67
25
  sh "irb -Ilib -rchronic"
68
26
  end
69
27
 
70
- #############################################################################
71
- #
72
- # Custom tasks (add your own tasks here)
73
- #
74
- #############################################################################
75
-
76
-
77
-
78
- #############################################################################
79
- #
80
- # Packaging tasks
81
- #
82
- #############################################################################
83
-
28
+ desc "Release Chronic version #{version}"
84
29
  task :release => :build do
85
30
  unless `git branch` =~ /^\* master$/
86
31
  puts "You must be on the master branch to release!"
@@ -90,51 +35,14 @@ task :release => :build do
90
35
  sh "git tag v#{version}"
91
36
  sh "git push origin master"
92
37
  sh "git push origin v#{version}"
93
- sh "gem push pkg/#{name}-#{version}.gem"
38
+ sh "gem push pkg/chronic-#{version}.gem"
94
39
  end
95
40
 
96
- task :build => :gemspec do
41
+ desc "Build a gem from the gemspec"
42
+ task :build do
97
43
  sh "mkdir -p pkg"
98
- sh "gem build #{gemspec_file}"
99
- sh "mv #{gem_file} pkg"
100
- end
101
-
102
- task :gemspec => :validate do
103
- # read spec file and split out manifest section
104
- spec = File.read(gemspec_file)
105
- head, manifest, tail = spec.split(" # = MANIFEST =\n")
106
-
107
- # replace name version and date
108
- replace_header(head, :name)
109
- replace_header(head, :version)
110
-
111
- #comment this out if your rubyforge_project has a different name
112
- replace_header(head, :rubyforge_project)
113
-
114
- # determine file list from git ls-files
115
- files = `git ls-files`.
116
- split("\n").
117
- sort.
118
- reject { |file| file =~ /^\./ }.
119
- reject { |file| file =~ /^(rdoc|pkg)/ }.
120
- map { |file| " #{file}" }.
121
- join("\n")
122
-
123
- # piece file back together and write
124
- manifest = " s.files = %w[\n#{files}\n ]\n"
125
- spec = [head, manifest, tail].join(" # = MANIFEST =\n")
126
- File.open(gemspec_file, 'w') { |io| io.write(spec) }
127
- puts "Updated #{gemspec_file}"
44
+ sh "gem build chronic.gemspec"
45
+ sh "mv chronic-#{version}.gem pkg"
128
46
  end
129
47
 
130
- task :validate do
131
- libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
132
- unless libfiles.empty?
133
- puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
134
- exit!
135
- end
136
- unless Dir['VERSION*'].empty?
137
- puts "A `VERSION` file at root level violates Gem best practices."
138
- exit!
139
- end
140
- end
48
+ task :default => :test
data/chronic.gemspec CHANGED
@@ -1,83 +1,17 @@
1
+ $:.unshift File.expand_path('../lib', __FILE__)
2
+ require 'chronic'
3
+
1
4
  Gem::Specification.new do |s|
2
- s.name = 'chronic'
3
- s.version = '0.4.1'
5
+ s.name = 'chronic'
6
+ s.version = Chronic::VERSION
4
7
  s.rubyforge_project = 'chronic'
5
-
6
- s.summary = "Natural language date/time parsing."
7
- s.description = "Chronic is a natural language date/time parser written in pure Ruby."
8
-
9
- s.authors = ["Tom Preston-Werner", "Lee Jarvis"]
8
+ s.summary = 'Natural language date/time parsing.'
9
+ s.description = 'Chronic is a natural language date/time parser written in pure Ruby.'
10
+ s.authors = ['Tom Preston-Werner', 'Lee Jarvis']
10
11
  s.email = ['tom@mojombo.com', 'lee@jarvis.co']
11
12
  s.homepage = 'http://github.com/mojombo/chronic'
12
-
13
- s.rdoc_options = ["--charset=UTF-8"]
13
+ s.rdoc_options = ['--charset=UTF-8']
14
14
  s.extra_rdoc_files = %w[README.md HISTORY.md LICENSE]
15
-
16
- # = MANIFEST =
17
- s.files = %w[
18
- HISTORY.md
19
- LICENSE
20
- Manifest.txt
21
- README.md
22
- Rakefile
23
- benchmark/benchmark.rb
24
- chronic.gemspec
25
- lib/chronic.rb
26
- lib/chronic/chronic.rb
27
- lib/chronic/grabber.rb
28
- lib/chronic/handlers.rb
29
- lib/chronic/mini_date.rb
30
- lib/chronic/numerizer.rb
31
- lib/chronic/ordinal.rb
32
- lib/chronic/pointer.rb
33
- lib/chronic/repeater.rb
34
- lib/chronic/repeaters/repeater_day.rb
35
- lib/chronic/repeaters/repeater_day_name.rb
36
- lib/chronic/repeaters/repeater_day_portion.rb
37
- lib/chronic/repeaters/repeater_fortnight.rb
38
- lib/chronic/repeaters/repeater_hour.rb
39
- lib/chronic/repeaters/repeater_minute.rb
40
- lib/chronic/repeaters/repeater_month.rb
41
- lib/chronic/repeaters/repeater_month_name.rb
42
- lib/chronic/repeaters/repeater_season.rb
43
- lib/chronic/repeaters/repeater_season_name.rb
44
- lib/chronic/repeaters/repeater_second.rb
45
- lib/chronic/repeaters/repeater_time.rb
46
- lib/chronic/repeaters/repeater_week.rb
47
- lib/chronic/repeaters/repeater_weekday.rb
48
- lib/chronic/repeaters/repeater_weekend.rb
49
- lib/chronic/repeaters/repeater_year.rb
50
- lib/chronic/scalar.rb
51
- lib/chronic/separator.rb
52
- lib/chronic/span.rb
53
- lib/chronic/tag.rb
54
- lib/chronic/time_zone.rb
55
- lib/chronic/token.rb
56
- test/helper.rb
57
- test/test_Chronic.rb
58
- test/test_DaylightSavings.rb
59
- test/test_Handler.rb
60
- test/test_MiniDate.rb
61
- test/test_Numerizer.rb
62
- test/test_RepeaterDayName.rb
63
- test/test_RepeaterFortnight.rb
64
- test/test_RepeaterHour.rb
65
- test/test_RepeaterMinute.rb
66
- test/test_RepeaterMonth.rb
67
- test/test_RepeaterMonthName.rb
68
- test/test_RepeaterTime.rb
69
- test/test_RepeaterWeek.rb
70
- test/test_RepeaterWeekday.rb
71
- test/test_RepeaterWeekend.rb
72
- test/test_RepeaterYear.rb
73
- test/test_Span.rb
74
- test/test_Time.rb
75
- test/test_Token.rb
76
- test/test_parsing.rb
77
- ]
78
- # = MANIFEST =
79
-
80
- ## Test files will be grabbed from the file list. Make sure the path glob
81
- ## matches what you actually use.
82
- s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
83
- end
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- test`.split("\n")
17
+ end