include_date_scopes 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +61 -1
- data/lib/include_date_scopes/date_scopes.rb +7 -2
- data/lib/include_date_scopes/version.rb +1 -1
- data/spec/lib/date_scopes_spec.rb +12 -0
- data/spec/support/timestamp_scope_examples.rb +0 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4b57e4f256f05cb34e6ea7e11c639b293aa7b87
|
4
|
+
data.tar.gz: 8c35adefc851df2c4e37ad8b05f5ed3d4185aede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 744b30ac18ac870e1c951c03c30990186b95ccadcb6d6d743f6748147d6f4ad5952b8f16be64da240a16f8fcdd5ba671242bebfc6b842109231f27712d21d56e
|
7
|
+
data.tar.gz: cf8c6ad8fc127d2267de4260fd1270765458708a84c1c45c8aa482a10d14e67d578acbfffc319f07ae6df777fe07e5dfd36101cc0069116bd1f692b6d2f9f9b4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
include_date_scopes (0.9.
|
4
|
+
include_date_scopes (0.9.3)
|
5
5
|
activerecord (< 4)
|
6
6
|
railties
|
7
7
|
|
@@ -30,17 +30,61 @@ GEM
|
|
30
30
|
i18n (~> 0.6, >= 0.6.4)
|
31
31
|
multi_json (~> 1.0)
|
32
32
|
arel (3.0.3)
|
33
|
+
better_errors (2.0.0)
|
34
|
+
coderay (>= 1.0.0)
|
35
|
+
erubis (>= 2.6.6)
|
36
|
+
rack (>= 0.9.0)
|
33
37
|
builder (3.0.4)
|
38
|
+
bullet (4.13.2)
|
39
|
+
activesupport (>= 3.0.0)
|
40
|
+
uniform_notifier (>= 1.6.0)
|
41
|
+
byebug (3.4.0)
|
42
|
+
columnize (~> 0.8)
|
43
|
+
debugger-linecache (~> 1.2)
|
44
|
+
slop (~> 3.6)
|
45
|
+
celluloid (0.16.0)
|
46
|
+
timers (~> 4.0.0)
|
47
|
+
coderay (1.1.0)
|
48
|
+
columnize (0.8.9)
|
49
|
+
debugger-linecache (1.2.0)
|
34
50
|
diff-lcs (1.2.5)
|
35
51
|
erubis (2.7.0)
|
52
|
+
ffi (1.9.3)
|
53
|
+
formatador (0.2.5)
|
54
|
+
guard (2.6.1)
|
55
|
+
formatador (>= 0.2.4)
|
56
|
+
listen (~> 2.7)
|
57
|
+
lumberjack (~> 1.0)
|
58
|
+
pry (>= 0.9.12)
|
59
|
+
thor (>= 0.18.1)
|
60
|
+
guard-ctags-bundler (1.1.0)
|
61
|
+
guard (~> 2.0)
|
36
62
|
hike (1.2.3)
|
63
|
+
hitimes (1.2.2)
|
37
64
|
i18n (0.6.9)
|
65
|
+
interactive_editor (0.0.10)
|
66
|
+
spoon (>= 0.0.1)
|
38
67
|
journey (1.0.4)
|
39
68
|
json (1.8.1)
|
69
|
+
listen (2.7.9)
|
70
|
+
celluloid (>= 0.15.2)
|
71
|
+
rb-fsevent (>= 0.9.3)
|
72
|
+
rb-inotify (>= 0.9)
|
73
|
+
lumberjack (1.0.9)
|
74
|
+
method_source (0.8.2)
|
40
75
|
multi_json (1.9.2)
|
76
|
+
pry (0.10.1)
|
77
|
+
coderay (~> 1.1.0)
|
78
|
+
method_source (~> 0.8.1)
|
79
|
+
slop (~> 3.4)
|
80
|
+
pry-byebug (2.0.0)
|
81
|
+
byebug (~> 3.4)
|
82
|
+
pry (~> 0.10)
|
41
83
|
rack (1.4.5)
|
42
84
|
rack-cache (1.2)
|
43
85
|
rack (>= 0.4)
|
86
|
+
rack-mini-profiler (0.9.2)
|
87
|
+
rack (>= 1.1.3)
|
44
88
|
rack-ssl (1.3.4)
|
45
89
|
rack
|
46
90
|
rack-test (0.6.2)
|
@@ -53,6 +97,9 @@ GEM
|
|
53
97
|
rdoc (~> 3.4)
|
54
98
|
thor (>= 0.14.6, < 2.0)
|
55
99
|
rake (10.2.2)
|
100
|
+
rb-fsevent (0.9.4)
|
101
|
+
rb-inotify (0.9.5)
|
102
|
+
ffi (>= 0.5.0)
|
56
103
|
rdoc (3.12.2)
|
57
104
|
json (~> 1.4)
|
58
105
|
rspec-core (2.14.8)
|
@@ -67,6 +114,9 @@ GEM
|
|
67
114
|
rspec-core (~> 2.14.0)
|
68
115
|
rspec-expectations (~> 2.14.0)
|
69
116
|
rspec-mocks (~> 2.14.0)
|
117
|
+
slop (3.6.0)
|
118
|
+
spoon (0.0.4)
|
119
|
+
ffi
|
70
120
|
sprockets (2.2.2)
|
71
121
|
hike (~> 1.2)
|
72
122
|
multi_json (~> 1.0)
|
@@ -76,13 +126,23 @@ GEM
|
|
76
126
|
thor (0.19.1)
|
77
127
|
tilt (1.4.1)
|
78
128
|
timecop (0.7.1)
|
129
|
+
timers (4.0.1)
|
130
|
+
hitimes
|
79
131
|
tzinfo (0.3.39)
|
132
|
+
uniform_notifier (1.6.2)
|
80
133
|
|
81
134
|
PLATFORMS
|
82
135
|
ruby
|
83
136
|
|
84
137
|
DEPENDENCIES
|
138
|
+
better_errors
|
139
|
+
bullet
|
140
|
+
guard-ctags-bundler
|
85
141
|
include_date_scopes!
|
142
|
+
interactive_editor
|
143
|
+
pry
|
144
|
+
pry-byebug
|
145
|
+
rack-mini-profiler
|
86
146
|
rspec-rails
|
87
147
|
sqlite3
|
88
148
|
timecop
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pry'
|
1
2
|
# Add the below date based scopes to a model.
|
2
3
|
#
|
3
4
|
# between(start_date_or_time, stop_date_or_time)
|
@@ -39,13 +40,16 @@ module IncludeDateScopes
|
|
39
40
|
|
40
41
|
def include_date_scopes_for(column,
|
41
42
|
prepend_name = false,
|
42
|
-
column_type =
|
43
|
+
column_type = nil)
|
44
|
+
column_type ||= column_type_for(column)
|
43
45
|
return unless self.table_exists?
|
44
46
|
if column_type == :datetime
|
45
47
|
define_timestamp_scopes_for column, prepend_name
|
46
48
|
elsif column_type == :date
|
47
49
|
define_date_scopes_for column, prepend_name
|
48
50
|
end
|
51
|
+
rescue
|
52
|
+
warn "Not including date scopes for #{column} because of an error: #{$!.message}"
|
49
53
|
end
|
50
54
|
|
51
55
|
def include_named_date_scopes_for(column)
|
@@ -53,7 +57,8 @@ module IncludeDateScopes
|
|
53
57
|
end
|
54
58
|
|
55
59
|
def column_type_for(column)
|
56
|
-
|
60
|
+
# raise "Cannot find column #{column}" unless columns_hash.include? column.to_s
|
61
|
+
columns_hash[column.to_s].type
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end
|
@@ -54,4 +54,16 @@ describe "Post" do
|
|
54
54
|
|
55
55
|
it_behaves_like 'date scopes', :show_at
|
56
56
|
end
|
57
|
+
|
58
|
+
describe 'using column which does not exist yet' do
|
59
|
+
it 'does not raise an error' do
|
60
|
+
previous_stderr, $stderr = $stderr, StringIO.new
|
61
|
+
expect {
|
62
|
+
define_model_class do
|
63
|
+
include_date_scopes_for :does_not_exist
|
64
|
+
end
|
65
|
+
}.to_not raise_error
|
66
|
+
$stderr = previous_stderr
|
67
|
+
end
|
68
|
+
end
|
57
69
|
end
|
@@ -107,15 +107,6 @@ shared_examples "timestamp scopes" do |date_column = :created_at, prefix = '' |
|
|
107
107
|
include_examples 'between time scope','tomorrow'
|
108
108
|
end
|
109
109
|
|
110
|
-
[:second, :minute, :hour, :day, :week, :month, :year].each do |interval|
|
111
|
-
describe ":next_#{interval}" do
|
112
|
-
let(:bottom_threshold) { 1."#{interval}".from_now }
|
113
|
-
let(:top_threshold) { Time.now }
|
114
|
-
let(:arguments) { [] }
|
115
|
-
include_examples 'between time scope',"next_#{interval}"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
110
|
describe ":next_hour" do
|
120
111
|
let(:bottom_threshold) { 1.hour.from_now }
|
121
112
|
let(:top_threshold) { Time.now }
|