datetime-scopes 1.0.0.alpha1 → 1.0.0.alpha2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75b2ecf33e5ba50fe1ed72e304e9bec585582159
4
- data.tar.gz: 2b468452b20e581866d4df006b659e72a4110e1e
3
+ metadata.gz: 53e205161e3068b4f9368b2355f85a8c87fc16c2
4
+ data.tar.gz: 3eeffa04759797b6e45efe5cca1fc4df259cb927
5
5
  SHA512:
6
- metadata.gz: a1e4ea76089c638563bb62e7fe0eedca6eb69dd962cf6adc6eafa1908401b76f580d3c4522d024c7fee4fc21fc02c1c352ac59a3f82c9b97f0f84fe9fe925545
7
- data.tar.gz: 51e7f73f17bea88420b2853633ef75b528a71f13d7827d792ec38c988b7652280973cc2b973c732df28c94fc40c4b6567e271e485b9ba59181320b824d27018c
6
+ metadata.gz: 5694ef86f93f49affa201b8cc5b8e8bd7b7bdd633377efd3b80501a87ab3bc1786de391102ed685cb00eed9e58e3d6697c3915e05c1b0fe86c5ae380631134d2
7
+ data.tar.gz: ddd119e486a2bb37a0c24bccbb1584bc165af71b57e12b26cbf7bcb10c88f3ffdfad099f668b59fc91fa1a5f8b8ceb15890a93f80d28e6a6ca40c561a674d210
data/.gitignore CHANGED
@@ -1,16 +1,6 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
1
+ /.bundle
2
+ /pkg
3
+ /log/*
4
+ !/log/.gitkeep
15
5
  .ruby-version
16
6
  .ruby-gemset
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ datetime-scopes (1.0.0.alpha2)
5
+ activerecord (>= 4.0)
6
+ activesupport (>= 4.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (4.2.5.1)
12
+ activesupport (= 4.2.5.1)
13
+ builder (~> 3.1)
14
+ activerecord (4.2.5.1)
15
+ activemodel (= 4.2.5.1)
16
+ activesupport (= 4.2.5.1)
17
+ arel (~> 6.0)
18
+ activesupport (4.2.5.1)
19
+ i18n (~> 0.7)
20
+ json (~> 1.7, >= 1.7.7)
21
+ minitest (~> 5.1)
22
+ thread_safe (~> 0.3, >= 0.3.4)
23
+ tzinfo (~> 1.1)
24
+ arel (6.0.3)
25
+ builder (3.2.2)
26
+ codeclimate-test-reporter (0.4.7)
27
+ simplecov (>= 0.7.1, < 1.0.0)
28
+ database_cleaner (1.4.0)
29
+ diff-lcs (1.2.5)
30
+ docile (1.1.5)
31
+ i18n (0.7.0)
32
+ json (1.8.3)
33
+ minitest (5.8.4)
34
+ multi_json (1.11.0)
35
+ rake (10.4.2)
36
+ rspec (3.4.0)
37
+ rspec-core (~> 3.4.0)
38
+ rspec-expectations (~> 3.4.0)
39
+ rspec-mocks (~> 3.4.0)
40
+ rspec-core (3.4.2)
41
+ rspec-support (~> 3.4.0)
42
+ rspec-expectations (3.4.0)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.4.0)
45
+ rspec-mocks (3.4.1)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.4.0)
48
+ rspec-support (3.4.1)
49
+ simplecov (0.9.2)
50
+ docile (~> 1.1.0)
51
+ multi_json (~> 1.0)
52
+ simplecov-html (~> 0.9.0)
53
+ simplecov-html (0.9.0)
54
+ sqlite3 (1.3.10)
55
+ thread_safe (0.3.5)
56
+ tzinfo (1.2.2)
57
+ thread_safe (~> 0.1)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ bundler (~> 1.11.2)
64
+ codeclimate-test-reporter
65
+ database_cleaner
66
+ datetime-scopes!
67
+ rake (~> 10.4.2)
68
+ rspec (~> 3.4.0)
69
+ sqlite3
70
+
71
+ BUNDLED WITH
72
+ 1.11.2
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Date/time scopes for ActiveRecord models
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/datetime-scopes.svg)](https://badge.fury.io/rb/datetime-scopes)
3
4
  [![Build Status](https://travis-ci.org/907th/datetime-scopes.svg?branch=master)](https://travis-ci.org/907th/datetime-scopes)
4
5
  [![Code Climate](https://codeclimate.com/github/907th/datetime-scopes/badges/gpa.svg)](https://codeclimate.com/github/907th/datetime-scopes)
5
6
  [![Test Coverage](https://codeclimate.com/github/907th/datetime-scopes/badges/coverage.svg)](https://codeclimate.com/github/907th/datetime-scopes/coverage)
@@ -1,7 +1,6 @@
1
1
  module DateTimeScopes
2
2
  class AbstractProxy
3
- def initialize(klass:, attribute:, time_zone:)
4
- @klass = klass
3
+ def initialize(attribute:, time_zone:)
5
4
  @attribute = attribute
6
5
  @time_zone = time_zone
7
6
  end
@@ -10,7 +10,6 @@ module DateTimeScopes
10
10
  module ClassMethods
11
11
  def datetime_scopes(attr, prefix: nil, time_zone: ::Time.zone)
12
12
  proxy = DateTimeProxy.new(
13
- klass: self,
14
13
  attribute: "#{table_name}.#{attr}",
15
14
  time_zone: time_zone
16
15
  )
@@ -20,7 +19,6 @@ module DateTimeScopes
20
19
 
21
20
  def date_scopes(attr, prefix: nil, time_zone: nil)
22
21
  proxy = DateProxy.new(
23
- klass: self,
24
22
  attribute: "#{table_name}.#{attr}",
25
23
  time_zone: time_zone
26
24
  )
@@ -33,7 +31,7 @@ module DateTimeScopes
33
31
  def declare_datetime_scopes(prefix, proxy)
34
32
  proxy.proxy_methods.each do |method_name|
35
33
  scope_name = "#{prefix}_#{method_name}"
36
- scope scope_name, -> (*attrs) { proxy.send method_name, *attrs }
34
+ scope scope_name, -> (*attrs) { proxy.send method_name, self, *attrs }
37
35
  end
38
36
  end
39
37
 
@@ -29,24 +29,26 @@ module DateTimeScopes
29
29
 
30
30
  # Intervals
31
31
 
32
- def within_days(from, to, time_zone: @time_zone)
33
- @klass.where(
34
- "#{@attribute}) >= ? AND #{@attribute} <= ?",
32
+ def within_days(rel, from, to, time_zone: @time_zone)
33
+ rel.where(
34
+ "#{@attribute} >= ? AND #{@attribute} <= ?",
35
35
  from.in_time_zone(time_zone).to_date,
36
36
  to.in_time_zone(time_zone).to_date
37
37
  )
38
38
  end
39
39
 
40
- def within_months(from, to, time_zone: @time_zone)
40
+ def within_months(rel, from, to, time_zone: @time_zone)
41
41
  within_days(
42
+ rel,
42
43
  from.in_time_zone(time_zone).beginning_of_month,
43
44
  to.in_time_zone(time_zone).end_of_month,
44
45
  time_zone: time_zone
45
46
  )
46
47
  end
47
48
 
48
- def within_years(from, to, time_zone: @time_zone)
49
+ def within_years(rel, from, to, time_zone: @time_zone)
49
50
  within_days(
51
+ rel,
50
52
  from.in_time_zone(time_zone).beginning_of_year,
51
53
  to.in_time_zone(time_zone).end_of_year,
52
54
  time_zone: time_zone
@@ -55,28 +57,68 @@ module DateTimeScopes
55
57
 
56
58
  # Specific day/month/year
57
59
 
58
- def on_day(day, time_zone: @time_zone) ; within_days day, day, time_zone: time_zone ; end
59
- def on_month(month, time_zone: @time_zone) ; within_months month, month, time_zone: time_zone ; end
60
- def on_year(year, time_zone: @time_zone) ; within_years year, year, time_zone: time_zone ; end
60
+ def on_day(rel, day, time_zone: @time_zone)
61
+ within_days rel, day, day, time_zone: time_zone
62
+ end
63
+
64
+ def on_month(rel, month, time_zone: @time_zone)
65
+ within_months rel, month, month, time_zone: time_zone
66
+ end
67
+
68
+ def on_year(rel, year, time_zone: @time_zone)
69
+ within_years rel, year, year, time_zone: time_zone
70
+ end
61
71
 
62
72
  # Strict equations
63
73
 
64
- def before_day(day, time_zone: @time_zone) ; @klass.where "#{@attribute} < ?", day.in_time_zone(time_zone).to_date ; end
65
- def before_month(month, time_zone: @time_zone) ; before_day month.in_time_zone(time_zone).beginning_of_month, time_zone: time_zone ; end
66
- def before_year(year, time_zone: @time_zone) ; before_day year.in_time_zone(time_zone).beginning_of_year, time_zone: time_zone ; end
74
+ def before_day(rel, day, time_zone: @time_zone)
75
+ rel.where "#{@attribute} < ?", day.in_time_zone(time_zone).to_date
76
+ end
67
77
 
68
- def after_day(day, time_zone: @time_zone) ; @klass.where "#{@attribute} > ?", day.in_time_zone(time_zone).to_date ; end
69
- def after_month(month, time_zone: @time_zone) ; after_day month.in_time_zone(time_zone).end_of_month, time_zone: time_zone ; end
70
- def after_year(year, time_zone: @time_zone) ; after_day year.in_time_zone(time_zone).end_of_year, time_zone: time_zone ; end
78
+ def before_month(rel, month, time_zone: @time_zone)
79
+ before_day rel, month.in_time_zone(time_zone).beginning_of_month, time_zone: time_zone
80
+ end
81
+
82
+ def before_year(rel, year, time_zone: @time_zone)
83
+ before_day rel, year.in_time_zone(time_zone).beginning_of_year, time_zone: time_zone
84
+ end
85
+
86
+ def after_day(rel, day, time_zone: @time_zone)
87
+ rel.where "#{@attribute} > ?", day.in_time_zone(time_zone).to_date
88
+ end
89
+
90
+ def after_month(rel, month, time_zone: @time_zone)
91
+ after_day rel, month.in_time_zone(time_zone).end_of_month, time_zone: time_zone
92
+ end
93
+
94
+ def after_year(rel, year, time_zone: @time_zone)
95
+ after_day rel, year.in_time_zone(time_zone).end_of_year, time_zone: time_zone
96
+ end
71
97
 
72
98
  # Non-strict equations
73
99
 
74
- def on_or_before_day(day, time_zone: @time_zone) ; @klass.where "#{@attribute} <= ?", day.in_time_zone(time_zone).to_date ; end
75
- def on_or_before_month(month, time_zone: @time_zone) ; on_or_before_day month.in_time_zone(time_zone).end_of_month, time_zone: time_zone ; end
76
- def on_or_before_year(year, time_zone: @time_zone) ; on_or_before_day year.in_time_zone(time_zone).end_of_year, time_zone: time_zone ; end
100
+ def on_or_before_day(rel, day, time_zone: @time_zone)
101
+ rel.where "#{@attribute} <= ?", day.in_time_zone(time_zone).to_date
102
+ end
103
+
104
+ def on_or_before_month(rel, month, time_zone: @time_zone)
105
+ on_or_before_day rel, month.in_time_zone(time_zone).end_of_month, time_zone: time_zone
106
+ end
107
+
108
+ def on_or_before_year(rel, year, time_zone: @time_zone)
109
+ on_or_before_day rel, year.in_time_zone(time_zone).end_of_year, time_zone: time_zone
110
+ end
111
+
112
+ def on_or_after_day(rel, day, time_zone: @time_zone)
113
+ rel.where "#{@attribute} >= ?", day.in_time_zone(time_zone).to_date
114
+ end
77
115
 
78
- def on_or_after_day(day, time_zone: @time_zone) ; @klass.where "#{@attribute} >= ?", day.in_time_zone(time_zone).to_date ; end
79
- def on_or_after_month(month, time_zone: @time_zone) ; on_or_after_day month.in_time_zone(time_zone).beginning_of_month, time_zone: time_zone ; end
80
- def on_or_after_year(year, time_zone: @time_zone) ; on_or_after_day year.in_time_zone(time_zone).beginning_of_year, time_zone: time_zone ; end
116
+ def on_or_after_month(rel, month, time_zone: @time_zone)
117
+ on_or_after_day rel, month.in_time_zone(time_zone).beginning_of_month, time_zone: time_zone
118
+ end
119
+
120
+ def on_or_after_year(rel, year, time_zone: @time_zone)
121
+ on_or_after_day rel, year.in_time_zone(time_zone).beginning_of_year, time_zone: time_zone
122
+ end
81
123
  end
82
124
  end
@@ -34,32 +34,35 @@ module DateTimeScopes
34
34
 
35
35
  # Intervals
36
36
 
37
- def within(from, to, time_zone: @time_zone)
38
- @klass.where(
37
+ def within(rel, from, to, time_zone: @time_zone)
38
+ rel.where(
39
39
  "#{@attribute} >= ? AND #{@attribute} <= ?",
40
40
  from.in_time_zone(time_zone),
41
41
  to.in_time_zone(time_zone)
42
42
  )
43
43
  end
44
44
 
45
- def within_days(from, to, time_zone: @time_zone)
45
+ def within_days(rel, from, to, time_zone: @time_zone)
46
46
  within(
47
+ rel,
47
48
  from.in_time_zone(time_zone).beginning_of_day,
48
49
  to.in_time_zone(time_zone).end_of_day,
49
50
  time_zone: time_zone
50
51
  )
51
52
  end
52
53
 
53
- def within_months(from, to, time_zone: @time_zone)
54
+ def within_months(rel, from, to, time_zone: @time_zone)
54
55
  within(
56
+ rel,
55
57
  from.in_time_zone(time_zone).beginning_of_month,
56
58
  to.in_time_zone(time_zone).end_of_month,
57
59
  time_zone: time_zone
58
60
  )
59
61
  end
60
62
 
61
- def within_years(from, to, time_zone: @time_zone)
63
+ def within_years(rel, from, to, time_zone: @time_zone)
62
64
  within(
65
+ rel,
63
66
  from.in_time_zone(time_zone).beginning_of_year,
64
67
  to.in_time_zone(time_zone).end_of_year,
65
68
  time_zone: time_zone
@@ -68,32 +71,84 @@ module DateTimeScopes
68
71
 
69
72
  # Specific day/month/year
70
73
 
71
- def on_day(day, time_zone: @time_zone) ; within_days day, day, time_zone: time_zone ; end
72
- def on_month(month, time_zone: @time_zone) ; within_months month, month, time_zone: time_zone ; end
73
- def on_year(year, time_zone: @time_zone) ; within_years year, year, time_zone: time_zone ; end
74
+ def on_day(rel, day, time_zone: @time_zone)
75
+ within_days rel, day, day, time_zone: time_zone
76
+ end
77
+
78
+ def on_month(rel, month, time_zone: @time_zone)
79
+ within_months rel, month, month, time_zone: time_zone
80
+ end
81
+
82
+ def on_year(rel, year, time_zone: @time_zone)
83
+ within_years rel, year, year, time_zone: time_zone
84
+ end
74
85
 
75
86
  # Strict equations
76
87
 
77
- def before(time, time_zone: @time_zone) ; @klass.where "#{@attribute} < ?", time.in_time_zone(time_zone) ; end
78
- def before_day(day, time_zone: @time_zone) ; before day.in_time_zone(time_zone).beginning_of_day, time_zone: time_zone ; end
79
- def before_month(month, time_zone: @time_zone) ; before month.in_time_zone(time_zone).beginning_of_month, time_zone: time_zone ; end
80
- def before_year(year, time_zone: @time_zone) ; before year.in_time_zone(time_zone).beginning_of_year, time_zone: time_zone ; end
88
+ def before(rel, time, time_zone: @time_zone)
89
+ rel.where "#{@attribute} < ?", time.in_time_zone(time_zone)
90
+ end
91
+
92
+ def before_day(rel, day, time_zone: @time_zone)
93
+ before rel, day.in_time_zone(time_zone).beginning_of_day, time_zone: time_zone
94
+ end
81
95
 
82
- def after(time, time_zone: @time_zone) ; @klass.where "#{@attribute} > ?", time.in_time_zone(time_zone) ; end
83
- def after_day(day, time_zone: @time_zone) ; after day.in_time_zone(time_zone).end_of_day, time_zone: time_zone ; end
84
- def after_month(month, time_zone: @time_zone) ; after month.in_time_zone(time_zone).end_of_month, time_zone: time_zone ; end
85
- def after_year(year, time_zone: @time_zone) ; after year.in_time_zone(time_zone).end_of_year, time_zone: time_zone ; end
96
+ def before_month(rel, month, time_zone: @time_zone)
97
+ before rel, month.in_time_zone(time_zone).beginning_of_month, time_zone: time_zone
98
+ end
99
+
100
+ def before_year(rel, year, time_zone: @time_zone)
101
+ before rel, year.in_time_zone(time_zone).beginning_of_year, time_zone: time_zone
102
+ end
103
+
104
+ def after(rel, time, time_zone: @time_zone)
105
+ rel.where "#{@attribute} > ?", time.in_time_zone(time_zone)
106
+ end
107
+
108
+ def after_day(rel, day, time_zone: @time_zone)
109
+ after rel, day.in_time_zone(time_zone).end_of_day, time_zone: time_zone
110
+ end
111
+
112
+ def after_month(rel, month, time_zone: @time_zone)
113
+ after rel, month.in_time_zone(time_zone).end_of_month, time_zone: time_zone
114
+ end
115
+
116
+ def after_year(rel, year, time_zone: @time_zone)
117
+ after rel, year.in_time_zone(time_zone).end_of_year, time_zone: time_zone
118
+ end
86
119
 
87
120
  # Non-strict equations
88
121
 
89
- def on_or_before(time, time_zone: @time_zone) ; @klass.where "#{@attribute} <= ?", time.in_time_zone(time_zone) ; end
90
- def on_or_before_day(day, time_zone: @time_zone) ; on_or_before day.in_time_zone(time_zone).end_of_day, time_zone: time_zone ; end
91
- def on_or_before_month(month, time_zone: @time_zone) ; on_or_before month.in_time_zone(time_zone).end_of_month, time_zone: time_zone ; end
92
- def on_or_before_year(year, time_zone: @time_zone) ; on_or_before year.in_time_zone(time_zone).end_of_year, time_zone: time_zone ; end
122
+ def on_or_before(rel, time, time_zone: @time_zone)
123
+ rel.where "#{@attribute} <= ?", time.in_time_zone(time_zone)
124
+ end
125
+
126
+ def on_or_before_day(rel, day, time_zone: @time_zone)
127
+ on_or_before rel, day.in_time_zone(time_zone).end_of_day, time_zone: time_zone
128
+ end
129
+
130
+ def on_or_before_month(rel, month, time_zone: @time_zone)
131
+ on_or_before rel, month.in_time_zone(time_zone).end_of_month, time_zone: time_zone
132
+ end
133
+
134
+ def on_or_before_year(rel, year, time_zone: @time_zone)
135
+ on_or_before rel, year.in_time_zone(time_zone).end_of_year, time_zone: time_zone
136
+ end
137
+
138
+ def on_or_after(rel, time, time_zone: @time_zone)
139
+ rel.where "#{@attribute} >= ?", time.in_time_zone(time_zone)
140
+ end
141
+
142
+ def on_or_after_day(rel, day, time_zone: @time_zone)
143
+ on_or_after rel, day.in_time_zone(time_zone).beginning_of_day, time_zone: time_zone
144
+ end
145
+
146
+ def on_or_after_month(rel, month, time_zone: @time_zone)
147
+ on_or_after rel, month.in_time_zone(time_zone).beginning_of_month, time_zone: time_zone
148
+ end
93
149
 
94
- def on_or_after(time, time_zone: @time_zone) ; @klass.where "#{@attribute} >= ?", time.in_time_zone(time_zone) ; end
95
- def on_or_after_day(day, time_zone: @time_zone) ; on_or_after day.in_time_zone(time_zone).beginning_of_day, time_zone: time_zone ; end
96
- def on_or_after_month(month, time_zone: @time_zone) ; on_or_after month.in_time_zone(time_zone).beginning_of_month, time_zone: time_zone ; end
97
- def on_or_after_year(year, time_zone: @time_zone) ; on_or_after year.in_time_zone(time_zone).beginning_of_year, time_zone: time_zone ; end
150
+ def on_or_after_year(rel, year, time_zone: @time_zone)
151
+ on_or_after rel, year.in_time_zone(time_zone).beginning_of_year, time_zone: time_zone
152
+ end
98
153
  end
99
154
  end
@@ -1,3 +1,3 @@
1
1
  module DateTimeScopes
2
- VERSION = "1.0.0.alpha1"
2
+ VERSION = "1.0.0.alpha2"
3
3
  end
File without changes
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "date_scopes" do
4
+ pending "#within_days"
5
+ pending "#within_months"
6
+ pending "#within_years"
7
+ pending "#on_day"
8
+ pending "#on_month"
9
+ pending "#on_year"
10
+ pending "#before_day"
11
+ pending "#before_month"
12
+ pending "#before_year"
13
+ pending "#after_day"
14
+ pending "#after_month"
15
+ pending "#after_year"
16
+ pending "#on_or_before_day"
17
+ pending "#on_or_before_month"
18
+ pending "#on_or_before_year"
19
+ pending "#on_or_after_day"
20
+ pending "#on_or_after_month"
21
+ pending "#on_or_after_year"
22
+ end
@@ -0,0 +1,73 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "datetime_scopes" do
4
+ def self.test(method_name, params:, matching:, not_matching:)
5
+ describe "##{method_name}" do
6
+ let!(:method_name) { "foo_#{method_name}" }
7
+ let!(:params) { params }
8
+ let!(:matching) { matching }
9
+ let!(:not_matching) { not_matching }
10
+
11
+ before do
12
+ (matching + not_matching).each do |t|
13
+ FooBar.create! foo: t.in_time_zone
14
+ end
15
+ end
16
+
17
+ def perform
18
+ FooBar.send method_name, *params
19
+ end
20
+
21
+ it "includes matching times" do
22
+ ret = perform.to_a.map(&:foo)
23
+ matching.map(&:in_time_zone).each do |t|
24
+ expect(ret).to include(t)
25
+ end
26
+ end
27
+
28
+ it "doesn't include not matching times" do
29
+ ret = perform.to_a.map(&:foo)
30
+ not_matching.map(&:in_time_zone).each do |t|
31
+ expect(ret).not_to include(t)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ test(
38
+ "within",
39
+ params: ["11.01.2015 23:41:35", "12.01.2015 01:00:23"],
40
+ matching: [
41
+ "11.01.2015 23:41:35",
42
+ "12.01.2015 00:40:01",
43
+ "12.01.2015 01:00:23"
44
+ ],
45
+ not_matching: [
46
+ "11.01.2015 23:41:34",
47
+ "12.01.2015 01:00:24"
48
+ ]
49
+ )
50
+
51
+ pending "#within_days"
52
+ pending "#within_months"
53
+ pending "#within_years"
54
+ pending "#on_day"
55
+ pending "#on_month"
56
+ pending "#on_year"
57
+ pending "#before"
58
+ pending "#before_day"
59
+ pending "#before_month"
60
+ pending "#before_year"
61
+ pending "#after"
62
+ pending "#after_day"
63
+ pending "#after_month"
64
+ pending "#after_year"
65
+ pending "#on_or_before"
66
+ pending "#on_or_before_day"
67
+ pending "#on_or_before_month"
68
+ pending "#on_or_before_year"
69
+ pending "#on_or_after"
70
+ pending "#on_or_after_day"
71
+ pending "#on_or_after_month"
72
+ pending "#on_or_after_year"
73
+ end
@@ -1,4 +1,11 @@
1
+ require "logger"
2
+ logger = Logger.new(File.expand_path "../../log/test.log", __FILE__)
3
+ logger.level = Logger::DEBUG
4
+
1
5
  require "codeclimate-test-reporter"
6
+ CodeClimate::TestReporter.configure do |config|
7
+ config.logger = logger
8
+ end
2
9
  CodeClimate::TestReporter.start
3
10
 
4
11
  require "rspec/core"
@@ -6,6 +13,7 @@ require "database_cleaner"
6
13
  require "datetime-scopes"
7
14
 
8
15
  ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
16
+ ActiveRecord::Base.logger = logger
9
17
  DatabaseCleaner.strategy = :truncation
10
18
 
11
19
  RSpec.configure do |c|
@@ -21,7 +29,7 @@ end
21
29
  # Create table and declare AR model
22
30
 
23
31
  ActiveRecord::Migration.verbose = false
24
- ActiveRecord::Migration.create_table :foo_bar do |t|
32
+ ActiveRecord::Migration.create_table :foo_bars do |t|
25
33
  t.datetime :foo
26
34
  t.date :bar
27
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datetime-scopes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha1
4
+ version: 1.0.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Chernenkov
@@ -77,6 +77,7 @@ files:
77
77
  - ".rspec"
78
78
  - ".travis.yml"
79
79
  - Gemfile
80
+ - Gemfile.lock
80
81
  - LICENSE.txt
81
82
  - README.md
82
83
  - Rakefile
@@ -87,9 +88,9 @@ files:
87
88
  - lib/datetime-scopes/date_proxy.rb
88
89
  - lib/datetime-scopes/datetime_proxy.rb
89
90
  - lib/datetime-scopes/version.rb
90
- - spec/datetime-scopes/active_record_extension_spec.rb
91
- - spec/datetime-scopes/date_proxy_spec.rb
92
- - spec/datetime-scopes/datetime_proxy_spec.rb
91
+ - log/.gitkeep
92
+ - spec/datetime-scopes/date_scopes_spec.rb
93
+ - spec/datetime-scopes/datetime_scopes_spec.rb
93
94
  - spec/spec_helper.rb
94
95
  homepage: https://github.com/907th/datetime-scopes
95
96
  licenses:
@@ -116,7 +117,6 @@ signing_key:
116
117
  specification_version: 4
117
118
  summary: Date/time scopes for ActiveRecord models you always missed!
118
119
  test_files:
119
- - spec/datetime-scopes/active_record_extension_spec.rb
120
- - spec/datetime-scopes/date_proxy_spec.rb
121
- - spec/datetime-scopes/datetime_proxy_spec.rb
120
+ - spec/datetime-scopes/date_scopes_spec.rb
121
+ - spec/datetime-scopes/datetime_scopes_spec.rb
122
122
  - spec/spec_helper.rb
@@ -1,43 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe FooBar do
4
- describe "::datetime_scopes" do
5
- let!(:proxy_methods) { DateTimeScopes::DateTimeProxy::PROXY_METHODS }
6
-
7
- it "defines datetime scopes" do
8
- proxy_methods.each do |method_name|
9
- expect(FooBar).to respond_to "foo_#{method_name}"
10
- end
11
- end
12
-
13
- it "delegates a scope call to a proxy" do
14
- proxy_methods.each do |method_name|
15
- dbl = double("result")
16
- expect_any_instance_of(DateTimeScopes::DateTimeProxy).to receive(method_name).with(1, 2, 3).and_return(dbl)
17
- res = FooBar.send("foo_#{method_name}", 1, 2, 3)
18
- expect(res).to eq(dbl)
19
- end
20
- end
21
- end
22
-
23
- describe "::date_scopes" do
24
- def proxy_methods
25
- DateTimeScopes::DateProxy::PROXY_METHODS
26
- end
27
-
28
- it "defines date scopes" do
29
- proxy_methods.each do |method_name|
30
- expect(FooBar).to respond_to "bar_#{method_name}"
31
- end
32
- end
33
-
34
- it "delegates a scope call to a proxy" do
35
- proxy_methods.each do |method_name|
36
- dbl = double("result")
37
- expect_any_instance_of(DateTimeScopes::DateProxy).to receive(method_name).with(1, 2, 3).and_return(dbl)
38
- res = FooBar.send("bar_#{method_name}", 1, 2, 3)
39
- expect(res).to eq(dbl)
40
- end
41
- end
42
- end
43
- end
@@ -1,7 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe DateTimeScopes::DateProxy do
4
- subject { described_class.new klass: FooBar, attribute: "bar", time_zone: "Moscow" }
5
-
6
- pending "TODO"
7
- end
@@ -1,7 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe DateTimeScopes::DateTimeProxy do
4
- subject { described_class.new klass: FooBar, attribute: "foo", time_zone: "Moscow" }
5
-
6
- pending "TODO"
7
- end