by_star 2.2.0 → 4.0.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 (66) hide show
  1. checksums.yaml +5 -13
  2. data/.github/workflows/mysql.yml +92 -0
  3. data/.github/workflows/postgresql.yml +99 -0
  4. data/.gitignore +6 -5
  5. data/.travis.yml +92 -35
  6. data/CHANGELOG.md +59 -29
  7. data/Gemfile +18 -25
  8. data/MIT-LICENSE +20 -20
  9. data/README.md +616 -523
  10. data/Rakefile +18 -18
  11. data/UPGRADING +4 -12
  12. data/by_star.gemspec +34 -32
  13. data/cleaner.rb +24 -24
  14. data/lib/by_star/base.rb +69 -68
  15. data/lib/by_star/between.rb +185 -120
  16. data/lib/by_star/directional.rb +35 -21
  17. data/lib/by_star/kernel/date.rb +41 -0
  18. data/lib/by_star/kernel/in_time_zone.rb +20 -0
  19. data/lib/by_star/{kernel.rb → kernel/time.rb} +41 -41
  20. data/lib/by_star/normalization.rb +156 -118
  21. data/lib/by_star/orm/active_record/by_star.rb +75 -59
  22. data/lib/by_star/orm/mongoid/by_star.rb +90 -63
  23. data/lib/by_star/orm/mongoid/reorder.rb +23 -0
  24. data/lib/by_star/version.rb +3 -3
  25. data/lib/by_star.rb +18 -15
  26. data/spec/database.yml +15 -15
  27. data/spec/fixtures/active_record/models.rb +12 -10
  28. data/spec/fixtures/active_record/schema.rb +19 -19
  29. data/spec/fixtures/mongoid/models.rb +31 -29
  30. data/spec/fixtures/shared/seeds.rb +36 -26
  31. data/spec/gemfiles/Gemfile.rails +5 -0
  32. data/spec/gemfiles/Gemfile.rails32 +7 -0
  33. data/spec/gemfiles/Gemfile.rails40 +7 -0
  34. data/spec/gemfiles/Gemfile.rails41 +7 -0
  35. data/spec/gemfiles/Gemfile.rails42 +7 -0
  36. data/spec/gemfiles/Gemfile.rails50 +7 -0
  37. data/spec/gemfiles/Gemfile.rails51 +7 -0
  38. data/spec/gemfiles/Gemfile.rails52 +7 -0
  39. data/spec/gemfiles/Gemfile.rails60 +7 -0
  40. data/spec/gemfiles/Gemfile.rails61 +7 -0
  41. data/spec/integration/active_record/active_record_spec.rb +41 -53
  42. data/spec/integration/mongoid/mongoid_spec.rb +39 -46
  43. data/spec/integration/shared/at_time.rb +53 -0
  44. data/spec/integration/shared/between_dates.rb +99 -0
  45. data/spec/integration/shared/between_times.rb +99 -0
  46. data/spec/integration/shared/by_calendar_month.rb +55 -55
  47. data/spec/integration/shared/by_cweek.rb +54 -0
  48. data/spec/integration/shared/by_day.rb +120 -108
  49. data/spec/integration/shared/by_direction.rb +126 -114
  50. data/spec/integration/shared/by_fortnight.rb +48 -48
  51. data/spec/integration/shared/by_month.rb +50 -50
  52. data/spec/integration/shared/by_quarter.rb +49 -49
  53. data/spec/integration/shared/by_week.rb +54 -54
  54. data/spec/integration/shared/by_weekend.rb +49 -49
  55. data/spec/integration/shared/by_year.rb +48 -48
  56. data/spec/integration/shared/index_scope_parameter.rb +111 -0
  57. data/spec/integration/shared/offset_parameter.rb +32 -31
  58. data/spec/integration/shared/order_parameter.rb +36 -0
  59. data/spec/integration/shared/relative.rb +174 -174
  60. data/spec/spec_helper.rb +33 -29
  61. data/spec/unit/kernel_date_spec.rb +113 -0
  62. data/spec/unit/kernel_time_spec.rb +57 -57
  63. data/spec/unit/normalization_spec.rb +384 -255
  64. data/tmp/.gitignore +1 -1
  65. metadata +82 -68
  66. data/spec/integration/shared/scope_parameter.rb +0 -42
data/Rakefile CHANGED
@@ -1,18 +1,18 @@
1
- require 'bundler'
2
- require 'rspec/core/rake_task'
3
-
4
- Bundler::GemHelper.install_tasks
5
- RSpec::Core::RakeTask.new(:spec)
6
-
7
- def orm_test(orm)
8
- RSpec::Core::RakeTask.new(orm) do |task|
9
- task.pattern = "./spec/{unit,integration/#{orm}}/{,/*/**}/*_spec.rb"
10
- end
11
- end
12
-
13
- namespace :spec do
14
- orm_test 'active_record'
15
- orm_test 'mongoid'
16
- end
17
-
18
- task default: :spec
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ def orm_test(orm)
8
+ RSpec::Core::RakeTask.new(orm) do |task|
9
+ task.pattern = "./spec/{unit,integration/#{orm}}/{,/*/**}/*_spec.rb"
10
+ end
11
+ end
12
+
13
+ namespace :spec do
14
+ orm_test 'active_record'
15
+ orm_test 'mongoid'
16
+ end
17
+
18
+ task default: :spec
data/UPGRADING CHANGED
@@ -1,12 +1,4 @@
1
- Upgrading to ByStar 2.2.0
2
- -------------------------
3
-
4
- * ActiveRecord: the `between` method has been deprecated as of version 2.2.0, and will be removed in version 3.3.0.
5
- Please use `between_times` instead.
6
-
7
- * Mongoid: the `between` method has been removed as of version 2.2.0, as it conflicts with the native Mongoid `between`
8
- method. Please use `between_times` instead.
9
-
10
- * Chronic gem (used for time string parsing) has been removed as a hard dependency for ByStar,
11
- however it is still supported. If you would like to use Chronic with ByStar, please explicitly
12
- include `gem chronic` into your Gemfile.
1
+ Upgrading ByStar
2
+ ----------------
3
+
4
+ * As of version 4.0.0, ByStar changes the way it handles `Date` arg to the `#between_times` method. If a `Date` is given as the second (end) arg, the query will use `Date.end_of_day` to include all time values which fall inside that date.
data/by_star.gemspec CHANGED
@@ -1,32 +1,34 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path("../lib/by_star/version", __FILE__)
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "by_star"
6
- s.version = ByStar::VERSION
7
- s.authors = ["Ryan Bigg", "Johnny Shields"]
8
- s.email = ["radarlistener@gmail.com"]
9
- s.homepage = "http://github.com/radar/by_star"
10
- s.summary = "ActiveRecord and Mongoid extension for easier date scopes and time ranges"
11
- s.description = "ActiveRecord and Mongoid extension for easier date scopes and time ranges"
12
-
13
- s.post_install_message = File.read('UPGRADING') if File.exists?('UPGRADING')
14
-
15
- s.add_dependency "activesupport"
16
-
17
- s.add_development_dependency "chronic"
18
- s.add_development_dependency "bundler", ">= 1.0.0"
19
- s.add_development_dependency "sqlite3"
20
- s.add_development_dependency "activerecord"
21
- s.add_development_dependency "mongoid"
22
- s.add_development_dependency "pg"
23
- s.add_development_dependency "mysql2"
24
- s.add_development_dependency "rspec-rails", "~> 2.14"
25
- s.add_development_dependency "timecop", "~> 0.3"
26
- s.add_development_dependency "pry"
27
-
28
- s.files = `git ls-files`.split($/)
29
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
31
- s.require_paths = ['lib']
32
- end
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/by_star/version", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "by_star"
6
+ s.version = ByStar::VERSION
7
+ s.authors = ["Ryan Bigg", "Johnny Shields"]
8
+ s.email = ["radarlistener@gmail.com"]
9
+ s.homepage = "http://github.com/radar/by_star"
10
+ s.summary = "ActiveRecord and Mongoid extension for easier date scopes and time ranges"
11
+ s.description = "ActiveRecord and Mongoid extension for easier date scopes and time ranges"
12
+
13
+ s.required_ruby_version = '>= 2.0.0'
14
+
15
+ s.post_install_message = File.read('UPGRADING') if File.exists?('UPGRADING')
16
+
17
+ s.add_dependency "activesupport", ">= 3.2.0"
18
+
19
+ s.add_development_dependency "chronic"
20
+ s.add_development_dependency "bundler"
21
+ s.add_development_dependency "sqlite3"
22
+ s.add_development_dependency "activerecord"
23
+ s.add_development_dependency "mongoid"
24
+ s.add_development_dependency "pg"
25
+ s.add_development_dependency "mysql2"
26
+ s.add_development_dependency "rspec-rails", "~> 3.1"
27
+ s.add_development_dependency "timecop", "~> 0.3"
28
+ s.add_development_dependency "pry"
29
+
30
+ s.files = `git ls-files`.split($/)
31
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
32
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
33
+ s.require_paths = ['lib']
34
+ end
data/cleaner.rb CHANGED
@@ -1,25 +1,25 @@
1
- files = Dir["**/*"]
2
- ignored_files = [
3
- /log\/.*/,
4
- ]
5
-
6
- files.delete_if do |file|
7
- if File.directory?(file)
8
- true
9
- else
10
- ignored_files.any? do |condition|
11
- if condition.is_a?(String)
12
- file == condition
13
- else
14
- condition.match(file)
15
- end
16
- end || false
17
- end
18
- end
19
-
20
- for file in files - ignored_files
21
- if File.file?(file)
22
- lines = File.readlines(file).map { |line| line.gsub(/^\s+$/, "\n") }
23
- File.open(file, "w+") { |f| f.write(lines.join) }
24
- end
1
+ files = Dir["**/*"]
2
+ ignored_files = [
3
+ /log\/.*/,
4
+ ]
5
+
6
+ files.delete_if do |file|
7
+ if File.directory?(file)
8
+ true
9
+ else
10
+ ignored_files.any? do |condition|
11
+ if condition.is_a?(String)
12
+ file == condition
13
+ else
14
+ condition.match(file)
15
+ end
16
+ end || false
17
+ end
18
+ end
19
+
20
+ for file in files - ignored_files
21
+ if File.file?(file)
22
+ lines = File.readlines(file).map { |line| line.gsub(/^\s+$/, "\n") }
23
+ File.open(file, "w+") { |f| f.write(lines.join) }
24
+ end
25
25
  end
data/lib/by_star/base.rb CHANGED
@@ -1,68 +1,69 @@
1
- module ByStar
2
-
3
- module Base
4
-
5
- include ByStar::Between
6
- include ByStar::Directional
7
-
8
- def by_star_field(*args)
9
- options = args.extract_options!
10
- @by_star_start_field ||= args[0]
11
- @by_star_end_field ||= args[1]
12
- @by_star_offset ||= options[:offset]
13
- @by_star_scope ||= options[:scope]
14
- end
15
-
16
- def by_star_offset(options = {})
17
- (options[:offset] || @by_star_offset || 0).seconds
18
- end
19
-
20
- def by_star_start_field(options={})
21
- field = options[:field] ||
22
- options[:start_field] ||
23
- @by_star_start_field ||
24
- by_star_default_field
25
- field.to_s
26
- end
27
-
28
- def by_star_end_field(options={})
29
- field = options[:field] ||
30
- options[:end_field] ||
31
- @by_star_end_field ||
32
- by_star_start_field
33
- field.to_s
34
- end
35
-
36
- def by_star_scope(options={})
37
- scope = options[:scope] || @by_star_scope || self
38
- if scope.is_a?(Proc)
39
- if scope.arity == 0
40
- return instance_exec(&scope)
41
- else
42
- return instance_exec(self, &scope)
43
- end
44
- else
45
- return scope
46
- end
47
- end
48
-
49
- protected
50
-
51
- # Wrapper function which extracts time and options for each by_star query.
52
- # Note the following syntax examples are valid:
53
- #
54
- # Post.by_month # defaults to current time
55
- # Post.by_month(2, :year => 2004) # February, 2004
56
- # Post.by_month(Time.now)
57
- # Post.by_month(Time.now, :field => "published_at")
58
- # Post.by_month(:field => "published_at")
59
- #
60
- def with_by_star_options(*args, &block)
61
- options = args.extract_options!.symbolize_keys!
62
- time = args.first
63
- time ||= Time.zone.local(options[:year]) if options[:year]
64
- time ||= Time.zone.now
65
- block.call(time, options)
66
- end
67
- end
68
- end
1
+ module ByStar
2
+
3
+ module Base
4
+
5
+ include ByStar::Between
6
+ include ByStar::Directional
7
+
8
+ def by_star_field(*args)
9
+ options = args.extract_options!
10
+ @by_star_start_field ||= args[0]
11
+ @by_star_end_field ||= args[1]
12
+ @by_star_offset ||= options[:offset]
13
+ @by_star_scope ||= options[:scope]
14
+ @by_star_index_scope ||= options[:index_scope]
15
+ end
16
+
17
+ def by_star_offset(options = {})
18
+ (options[:offset] || @by_star_offset || 0).seconds
19
+ end
20
+
21
+ def by_star_start_field(options={})
22
+ field = options[:field] ||
23
+ options[:start_field] ||
24
+ @by_star_start_field ||
25
+ by_star_default_field
26
+ field.to_s
27
+ end
28
+
29
+ def by_star_end_field(options={})
30
+ field = options[:field] ||
31
+ options[:end_field] ||
32
+ @by_star_end_field ||
33
+ by_star_start_field
34
+ field.to_s
35
+ end
36
+
37
+ protected
38
+
39
+ # Wrapper function which extracts time and options for each by_star query.
40
+ # Note the following syntax examples are valid:
41
+ #
42
+ # Post.by_month # defaults to current time
43
+ # Post.by_month(2, year: 2004) # February, 2004
44
+ # Post.by_month(Time.now)
45
+ # Post.by_month(Time.now, field: "published_at")
46
+ # Post.by_month(field: "published_at")
47
+ #
48
+ def with_by_star_options(*args, &block)
49
+ options = args.extract_options!.symbolize_keys!
50
+ time = args.first || Time.zone.now
51
+ block.call(time, options)
52
+ end
53
+
54
+ def by_star_eval_index_scope(start_time, end_time, options)
55
+ value = options[:index_scope] || @by_star_index_scope
56
+ value = value.call(start_time, end_time, options) if value.is_a?(Proc)
57
+ case value
58
+ when nil, false then nil
59
+ when Time, DateTime, Date then value.in_time_zone
60
+ when ActiveSupport::Duration then start_time - value
61
+ when Numeric then start_time - value.seconds
62
+ when :beginning_of_day
63
+ offset = options[:offset] || 0
64
+ (start_time - offset).beginning_of_day + offset
65
+ else raise 'ByStar :index_scope option value is not a supported type.'
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,120 +1,185 @@
1
- module ByStar
2
-
3
- module Between
4
-
5
- def between_times(start, finish, options={})
6
- offset = by_star_offset(options)
7
- between_times_query(start + offset, finish + offset, options)
8
- end
9
-
10
- def by_day(*args)
11
- with_by_star_options(*args) do |time, options|
12
- time = ByStar::Normalization.time(time)
13
- between_times(time.beginning_of_day, time.end_of_day, options)
14
- end
15
- end
16
-
17
- def by_week(*args)
18
- with_by_star_options(*args) do |time, options|
19
- time = ByStar::Normalization.week(time, options)
20
- start_day = Array(options[:start_day])
21
- between_times(time.beginning_of_week(*start_day), time.end_of_week(*start_day), options)
22
- end
23
- end
24
-
25
- def by_weekend(*args)
26
- with_by_star_options(*args) do |time, options|
27
- time = ByStar::Normalization.week(time, options)
28
- between_times(time.beginning_of_weekend, time.end_of_weekend, options)
29
- end
30
- end
31
-
32
- def by_fortnight(*args)
33
- with_by_star_options(*args) do |time, options|
34
- time = ByStar::Normalization.fortnight(time, options)
35
- between_times(time.beginning_of_fortnight, time.end_of_fortnight, options)
36
- end
37
- end
38
-
39
- def by_month(*args)
40
- with_by_star_options(*args) do |time, options|
41
- time = ByStar::Normalization.month(time, options)
42
- between_times(time.beginning_of_month, time.end_of_month, options)
43
- end
44
- end
45
-
46
- def by_calendar_month(*args)
47
- with_by_star_options(*args) do |time, options|
48
- time = ByStar::Normalization.month(time, options)
49
- start_day = Array(options[:start_day])
50
- between_times(time.beginning_of_calendar_month(*start_day), time.end_of_calendar_month(*start_day), options)
51
- end
52
- end
53
-
54
- def by_quarter(*args)
55
- with_by_star_options(*args) do |time, options|
56
- time = ByStar::Normalization.quarter(time, options)
57
- between_times(time.beginning_of_quarter, time.end_of_quarter, options)
58
- end
59
- end
60
-
61
- def by_year(*args)
62
- with_by_star_options(*args) do |time, options|
63
- time = ByStar::Normalization.year(time, options)
64
- between_times(time.beginning_of_year, time.end_of_year, options)
65
- end
66
- end
67
-
68
- def today(options={})
69
- by_day(Time.zone.now, options)
70
- end
71
-
72
- def yesterday(options={})
73
- by_day(Time.zone.now.yesterday, options)
74
- end
75
-
76
- def tomorrow(options={})
77
- by_day(Time.zone.now.tomorrow, options)
78
- end
79
-
80
- def past_day(options={})
81
- between_times(Time.zone.now - 1.day, Time.zone.now, options)
82
- end
83
-
84
- def past_week(options={})
85
- between_times(Time.zone.now - 1.week, Time.zone.now, options)
86
- end
87
-
88
- def past_fortnight(options={})
89
- between_times(Time.zone.now - 2.weeks, Time.zone.now, options)
90
- end
91
-
92
- def past_month(options={})
93
- between_times(Time.zone.now - 1.month, Time.zone.now, options)
94
- end
95
-
96
- def past_year(options={})
97
- between_times(Time.zone.now - 1.year, Time.zone.now, options)
98
- end
99
-
100
- def next_day(options={})
101
- between_times(Time.zone.now, Time.zone.now + 1.day, options)
102
- end
103
-
104
- def next_week(options={})
105
- between_times(Time.zone.now, Time.zone.now + 1.week, options)
106
- end
107
-
108
- def next_fortnight(options={})
109
- between_times(Time.zone.now, Time.zone.now + 2.weeks, options)
110
- end
111
-
112
- def next_month(options={})
113
- between_times(Time.zone.now, Time.zone.now + 1.month, options)
114
- end
115
-
116
- def next_year(options={})
117
- between_times(Time.zone.now, Time.zone.now + 1.year, options)
118
- end
119
- end
120
- end
1
+ module ByStar
2
+
3
+ module Between
4
+
5
+ def between_times(*args)
6
+ options = args.extract_options!.symbolize_keys!
7
+
8
+ start_time, end_time = ByStar::Normalization.extract_range(args)
9
+ offset = options[:offset] || 0
10
+
11
+ if start_time.is_a?(Date)
12
+ start_time = ByStar::Normalization.apply_offset_start(start_time.in_time_zone, offset)
13
+ elsif start_time
14
+ start_time += offset.seconds
15
+ end
16
+
17
+ if end_time.is_a?(Date)
18
+ end_time = ByStar::Normalization.apply_offset_end(end_time.in_time_zone, offset)
19
+ elsif end_time
20
+ end_time += offset.seconds
21
+ end
22
+
23
+ start_field = by_star_start_field(options)
24
+ end_field = by_star_end_field(options)
25
+
26
+ scope = self
27
+ scope = if !start_time && !end_time
28
+ scope # do nothing
29
+ elsif !end_time
30
+ by_star_after_query(scope, start_field, start_time)
31
+ elsif !start_time
32
+ by_star_before_query(scope, start_field, end_time)
33
+ elsif start_field == end_field
34
+ by_star_point_query(scope, start_field, start_time, end_time)
35
+ elsif options[:strict]
36
+ by_star_span_strict_query(scope, start_field, end_field, start_time, end_time)
37
+ else
38
+ by_star_span_loose_query(scope, start_field, end_field, start_time, end_time, options)
39
+ end
40
+
41
+ scope = by_star_order(scope, options[:order]) if options[:order]
42
+ scope
43
+ end
44
+
45
+ def between_dates(*args)
46
+ options = args.extract_options!
47
+ start_date, end_date = ByStar::Normalization.extract_range(args)
48
+ start_date = ByStar::Normalization.date(start_date)
49
+ end_date = ByStar::Normalization.date(end_date)
50
+ between_times(start_date, end_date, options)
51
+ end
52
+
53
+ def at_time(*args)
54
+ with_by_star_options(*args) do |time, options|
55
+ start_field = by_star_start_field(options)
56
+ end_field = by_star_end_field(options)
57
+
58
+ scope = self
59
+ scope = if start_field == end_field
60
+ by_star_point_overlap_query(scope, start_field, time)
61
+ else
62
+ by_star_span_overlap_query(scope, start_field, end_field, time, options)
63
+ end
64
+ scope = by_star_order(scope, options[:order]) if options[:order]
65
+ scope
66
+ end
67
+ end
68
+
69
+ def by_day(*args)
70
+ with_by_star_options(*args) do |time, options|
71
+ date = ByStar::Normalization.date(time)
72
+ between_dates(date, date, options)
73
+ end
74
+ end
75
+
76
+ def by_week(*args)
77
+ with_by_star_options(*args) do |time, options|
78
+ date = ByStar::Normalization.week(time, options)
79
+ start_day = Array(options[:start_day])
80
+ between_dates(date.beginning_of_week(*start_day), date.end_of_week(*start_day), options)
81
+ end
82
+ end
83
+
84
+ def by_cweek(*args)
85
+ with_by_star_options(*args) do |time, options|
86
+ by_week(ByStar::Normalization.cweek(time, options), options)
87
+ end
88
+ end
89
+
90
+ def by_weekend(*args)
91
+ with_by_star_options(*args) do |time, options|
92
+ date = ByStar::Normalization.week(time, options)
93
+ between_dates(date.beginning_of_weekend, date.end_of_weekend, options)
94
+ end
95
+ end
96
+
97
+ def by_fortnight(*args)
98
+ with_by_star_options(*args) do |time, options|
99
+ date = ByStar::Normalization.fortnight(time, options)
100
+ between_dates(date.beginning_of_fortnight, date.end_of_fortnight, options)
101
+ end
102
+ end
103
+
104
+ def by_month(*args)
105
+ with_by_star_options(*args) do |time, options|
106
+ date = ByStar::Normalization.month(time, options)
107
+ between_dates(date.beginning_of_month, date.end_of_month, options)
108
+ end
109
+ end
110
+
111
+ def by_calendar_month(*args)
112
+ with_by_star_options(*args) do |time, options|
113
+ date = ByStar::Normalization.month(time, options)
114
+ start_day = Array(options[:start_day])
115
+ between_dates(date.beginning_of_calendar_month(*start_day), date.end_of_calendar_month(*start_day), options)
116
+ end
117
+ end
118
+
119
+ def by_quarter(*args)
120
+ with_by_star_options(*args) do |time, options|
121
+ date = ByStar::Normalization.quarter(time, options)
122
+ between_dates(date.beginning_of_quarter, date.end_of_quarter, options)
123
+ end
124
+ end
125
+
126
+ def by_year(*args)
127
+ with_by_star_options(*args) do |time, options|
128
+ date = ByStar::Normalization.year(time, options)
129
+ between_dates(date.beginning_of_year, date.to_date.end_of_year, options)
130
+ end
131
+ end
132
+
133
+ def today(options = {})
134
+ by_day(Date.current, options)
135
+ end
136
+
137
+ def yesterday(options = {})
138
+ by_day(Date.yesterday, options)
139
+ end
140
+
141
+ def tomorrow(options = {})
142
+ by_day(Date.tomorrow, options)
143
+ end
144
+
145
+ def past_day(options = {})
146
+ between_times(Time.current - 1.day, Time.current, options)
147
+ end
148
+
149
+ def past_week(options = {})
150
+ between_times(Time.current - 1.week, Time.current, options)
151
+ end
152
+
153
+ def past_fortnight(options = {})
154
+ between_times(Time.current - 2.weeks, Time.current, options)
155
+ end
156
+
157
+ def past_month(options = {})
158
+ between_times(Time.current - 1.month, Time.current, options)
159
+ end
160
+
161
+ def past_year(options = {})
162
+ between_times(Time.current - 1.year, Time.current, options)
163
+ end
164
+
165
+ def next_day(options = {})
166
+ between_times(Time.current, Time.current + 1.day, options)
167
+ end
168
+
169
+ def next_week(options = {})
170
+ between_times(Time.current, Time.current + 1.week, options)
171
+ end
172
+
173
+ def next_fortnight(options = {})
174
+ between_times(Time.current, Time.current + 2.weeks, options)
175
+ end
176
+
177
+ def next_month(options = {})
178
+ between_times(Time.current, Time.current + 1.month, options)
179
+ end
180
+
181
+ def next_year(options = {})
182
+ between_times(Time.current, Time.current + 1.year, options)
183
+ end
184
+ end
185
+ end