include_date_scopes 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -58
- data/lib/include_date_scopes/define_timestamp_scopes.rb +1 -1
- data/lib/include_date_scopes/version.rb +1 -1
- data/spec/lib/date_scopes_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/support/date_scope_examples.rb +1 -3
- data/spec/support/timestamp_scope_examples.rb +9 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a07a72dd91cec5fcff6b701ced82fd96bde969af
|
4
|
+
data.tar.gz: 969b6a1e1f8264f25667668376f61c6c03626783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8c8c48ee924d3bdbe7a608f890390e1a35279e78249ba726be9bdd5f06ae29e598fd05e3446fdff031268e4e8e4d43230e66fb91e559a47894ce6536f21dfb0
|
7
|
+
data.tar.gz: f17df27bbd23510e5a1614111742d9086a1ff335bf369b9cc56cc07885fee5ec3a9074815ad5f114d52d468fea5c7ef797a966d4fc2c9e0bbcbc7ea40c68ae18
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
include_date_scopes (0.
|
4
|
+
include_date_scopes (0.9.5)
|
5
5
|
activerecord (< 4)
|
6
6
|
railties
|
7
|
-
squeel
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: http://rubygems.org/
|
@@ -31,51 +30,17 @@ GEM
|
|
31
30
|
i18n (~> 0.6, >= 0.6.4)
|
32
31
|
multi_json (~> 1.0)
|
33
32
|
arel (3.0.3)
|
34
|
-
better_errors (1.1.0)
|
35
|
-
coderay (>= 1.0.0)
|
36
|
-
erubis (>= 2.6.6)
|
37
33
|
builder (3.0.4)
|
38
|
-
bullet (4.8.0)
|
39
|
-
activesupport
|
40
|
-
uniform_notifier (>= 1.4.0)
|
41
|
-
coderay (1.1.0)
|
42
|
-
columnize (0.3.6)
|
43
|
-
daemons (1.1.9)
|
44
|
-
debugger (1.6.6)
|
45
|
-
columnize (>= 0.3.1)
|
46
|
-
debugger-linecache (~> 1.2.0)
|
47
|
-
debugger-ruby_core_source (~> 1.3.2)
|
48
|
-
debugger-linecache (1.2.0)
|
49
|
-
debugger-ruby_core_source (1.3.2)
|
50
34
|
diff-lcs (1.2.5)
|
51
35
|
erubis (2.7.0)
|
52
|
-
eventmachine (1.0.3)
|
53
|
-
ffi (1.9.3)
|
54
36
|
hike (1.2.3)
|
55
37
|
i18n (0.6.9)
|
56
|
-
interactive_editor (0.0.10)
|
57
|
-
spoon (>= 0.0.1)
|
58
38
|
journey (1.0.4)
|
59
39
|
json (1.8.1)
|
60
|
-
method_source (0.8.2)
|
61
40
|
multi_json (1.9.2)
|
62
|
-
polyamorous (0.6.4)
|
63
|
-
activerecord (>= 3.0)
|
64
|
-
pry (0.9.12.6)
|
65
|
-
coderay (~> 1.0)
|
66
|
-
method_source (~> 0.8)
|
67
|
-
slop (~> 3.4)
|
68
|
-
pry-debugger (0.2.2)
|
69
|
-
debugger (~> 1.3)
|
70
|
-
pry (~> 0.9.10)
|
71
|
-
pry-doc (0.6.0)
|
72
|
-
pry (~> 0.9)
|
73
|
-
yard (~> 0.8)
|
74
41
|
rack (1.4.5)
|
75
42
|
rack-cache (1.2)
|
76
43
|
rack (>= 0.4)
|
77
|
-
rack-mini-profiler (0.9.1)
|
78
|
-
rack (>= 1.1.3)
|
79
44
|
rack-ssl (1.3.4)
|
80
45
|
rack
|
81
46
|
rack-test (0.6.2)
|
@@ -102,44 +67,22 @@ GEM
|
|
102
67
|
rspec-core (~> 2.14.0)
|
103
68
|
rspec-expectations (~> 2.14.0)
|
104
69
|
rspec-mocks (~> 2.14.0)
|
105
|
-
slop (3.5.0)
|
106
|
-
spoon (0.0.4)
|
107
|
-
ffi
|
108
70
|
sprockets (2.2.2)
|
109
71
|
hike (~> 1.2)
|
110
72
|
multi_json (~> 1.0)
|
111
73
|
rack (~> 1.0)
|
112
74
|
tilt (~> 1.1, != 1.3.0)
|
113
75
|
sqlite3 (1.3.9)
|
114
|
-
squeel (1.1.1)
|
115
|
-
activerecord (>= 3.0)
|
116
|
-
activesupport (>= 3.0)
|
117
|
-
polyamorous (~> 0.6.0)
|
118
|
-
thin (1.6.2)
|
119
|
-
daemons (>= 1.0.9)
|
120
|
-
eventmachine (>= 1.0.0)
|
121
|
-
rack (>= 1.0.0)
|
122
76
|
thor (0.19.1)
|
123
77
|
tilt (1.4.1)
|
124
78
|
timecop (0.7.1)
|
125
79
|
tzinfo (0.3.39)
|
126
|
-
uniform_notifier (1.4.0)
|
127
|
-
yard (0.8.7.4)
|
128
80
|
|
129
81
|
PLATFORMS
|
130
82
|
ruby
|
131
83
|
|
132
84
|
DEPENDENCIES
|
133
|
-
better_errors
|
134
|
-
bullet
|
135
|
-
debugger
|
136
85
|
include_date_scopes!
|
137
|
-
interactive_editor
|
138
|
-
pry
|
139
|
-
pry-debugger
|
140
|
-
pry-doc
|
141
|
-
rack-mini-profiler
|
142
86
|
rspec-rails
|
143
87
|
sqlite3
|
144
|
-
thin
|
145
88
|
timecop
|
@@ -9,7 +9,7 @@ module IncludeDateScopes
|
|
9
9
|
define_singleton_method :"#{prefix}between" do |start_date_or_time, stop_date_or_time|
|
10
10
|
start_time = (start_date_or_time.is_a?(Date) ? start_date_or_time.to_time : start_date_or_time)
|
11
11
|
stop_time = (stop_date_or_time.is_a?(Date) ? stop_date_or_time.to_time + 1.day : stop_date_or_time )
|
12
|
-
where(t[column_name].
|
12
|
+
where(t[column_name].gt(start_time).and(t[column_name].lteq stop_time))
|
13
13
|
end
|
14
14
|
|
15
15
|
define_singleton_method :"#{prefix}on_or_before_date" do |date|
|
data/spec/spec_helper.rb
CHANGED
@@ -22,14 +22,12 @@ shared_examples "between date scope" do |name|
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
shared_examples "date scopes" do |date_column = :
|
25
|
+
shared_examples "date scopes" do |date_column = :show_until, prefix = '' |
|
26
26
|
let(:test_class) { Post }
|
27
27
|
let(:prefix) { prefix }
|
28
28
|
let(:date_column) { date_column }
|
29
29
|
|
30
30
|
describe "date scopes" do
|
31
|
-
before(:all) { Timecop.freeze Time.local(2013,02,15,06,30) }
|
32
|
-
|
33
31
|
describe ":between" do
|
34
32
|
subject { test_class.send("#{prefix}between", 6.days.ago.to_date, 3.day.ago.to_date) }
|
35
33
|
|
@@ -10,7 +10,7 @@ shared_examples "between time scope" do |name, difference = 1.second|
|
|
10
10
|
let(:before_threshold_obj) { test_class.create! date_column => bottom_threshold + difference }
|
11
11
|
|
12
12
|
it { should_not include after_threshold_obj }
|
13
|
-
it {
|
13
|
+
it { should_not include at_top_threshold_obj }
|
14
14
|
it { should include at_bottom_threshold_obj }
|
15
15
|
it { should_not include before_threshold_obj }
|
16
16
|
end
|
@@ -33,8 +33,6 @@ shared_examples "timestamp scopes" do |date_column = :created_at, prefix = '' |
|
|
33
33
|
let(:date_column) { date_column }
|
34
34
|
|
35
35
|
describe "timestamp scopes" do
|
36
|
-
before(:all) { Timecop.freeze Time.local(2013,02,15,06,30) }
|
37
|
-
|
38
36
|
describe ':between' do
|
39
37
|
let(:top_threshold) { 5.minutes.ago }
|
40
38
|
let(:bottom_threshold) { 5.minutes.from_now }
|
@@ -87,21 +85,21 @@ shared_examples "timestamp scopes" do |date_column = :created_at, prefix = '' |
|
|
87
85
|
end
|
88
86
|
|
89
87
|
describe ":today" do
|
90
|
-
let(:top_threshold) { Time.now.beginning_of_day }
|
88
|
+
let(:top_threshold) { Time.now.beginning_of_day - 1.second }
|
91
89
|
let(:bottom_threshold) { Time.now.end_of_day }
|
92
90
|
let(:arguments) { [] }
|
93
91
|
include_examples 'between time scope','today'
|
94
92
|
end
|
95
93
|
|
96
94
|
describe ":yesterday" do
|
97
|
-
let(:top_threshold) { 1.day.ago.beginning_of_day }
|
95
|
+
let(:top_threshold) { 1.day.ago.beginning_of_day - 1.second }
|
98
96
|
let(:bottom_threshold) { 1.day.ago.end_of_day }
|
99
97
|
let(:arguments) { [] }
|
100
98
|
include_examples 'between time scope','yesterday'
|
101
99
|
end
|
102
100
|
|
103
101
|
describe ":tomorrow" do
|
104
|
-
let(:top_threshold) { 1.day.from_now.beginning_of_day }
|
102
|
+
let(:top_threshold) { 1.day.from_now.beginning_of_day - 1.second }
|
105
103
|
let(:bottom_threshold) { 1.day.from_now.end_of_day }
|
106
104
|
let(:arguments) { [] }
|
107
105
|
include_examples 'between time scope','tomorrow'
|
@@ -311,35 +309,35 @@ shared_examples "timestamp scopes" do |date_column = :created_at, prefix = '' |
|
|
311
309
|
end
|
312
310
|
|
313
311
|
describe ":this_hour" do
|
314
|
-
let(:top_threshold) { Time.now.beginning_of_hour }
|
312
|
+
let(:top_threshold) { Time.now.beginning_of_hour - 1.second }
|
315
313
|
let(:bottom_threshold) { Time.now.end_of_hour }
|
316
314
|
let(:arguments) { [] }
|
317
315
|
include_examples 'between time scope','this_hour'
|
318
316
|
end
|
319
317
|
|
320
318
|
describe ":this_day" do
|
321
|
-
let(:top_threshold) { Time.now.beginning_of_day }
|
319
|
+
let(:top_threshold) { Time.now.beginning_of_day - 1.second }
|
322
320
|
let(:bottom_threshold) { Time.now.end_of_day }
|
323
321
|
let(:arguments) { [] }
|
324
322
|
include_examples 'between time scope','this_day'
|
325
323
|
end
|
326
324
|
|
327
325
|
describe ":this_week" do
|
328
|
-
let(:top_threshold) { Time.now.beginning_of_week }
|
326
|
+
let(:top_threshold) { Time.now.beginning_of_week - 1.second }
|
329
327
|
let(:bottom_threshold) { Time.now.end_of_week }
|
330
328
|
let(:arguments) { [] }
|
331
329
|
include_examples 'between time scope','this_week'
|
332
330
|
end
|
333
331
|
|
334
332
|
describe ":this_month" do
|
335
|
-
let(:top_threshold) { Time.now.beginning_of_month }
|
333
|
+
let(:top_threshold) { Time.now.beginning_of_month - 1.second }
|
336
334
|
let(:bottom_threshold) { Time.now.end_of_month }
|
337
335
|
let(:arguments) { [] }
|
338
336
|
include_examples 'between time scope','this_month'
|
339
337
|
end
|
340
338
|
|
341
339
|
describe ":this_year" do
|
342
|
-
let(:top_threshold) { Time.now.beginning_of_year }
|
340
|
+
let(:top_threshold) { Time.now.beginning_of_year - 1.second }
|
343
341
|
let(:bottom_threshold) { Time.now.end_of_year }
|
344
342
|
let(:arguments) { [] }
|
345
343
|
include_examples 'between time scope','this_year'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: include_date_scopes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Todd
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|