date_scopes 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -1
- data/Gemfile.lock +13 -11
- data/README.markdown +4 -4
- data/lib/date_scopes/version.rb +1 -1
- data/lib/date_scopes.rb +2 -0
- data/spec/date_scopes_spec.rb +12 -0
- metadata +6 -7
- data/spec/support/test.sqlite3 +0 -0
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm
|
1
|
+
rvm use --create ree@date_scopes
|
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ GIT
|
|
8
8
|
PATH
|
9
9
|
remote: .
|
10
10
|
specs:
|
11
|
-
date_scopes (0.
|
11
|
+
date_scopes (0.1.2)
|
12
12
|
activerecord (~> 3)
|
13
13
|
|
14
14
|
GEM
|
@@ -24,21 +24,23 @@ GEM
|
|
24
24
|
arel (~> 2.0.2)
|
25
25
|
tzinfo (~> 0.3.23)
|
26
26
|
activesupport (3.0.3)
|
27
|
-
arel (2.0.
|
27
|
+
arel (2.0.7)
|
28
28
|
builder (2.1.2)
|
29
29
|
diff-lcs (1.1.2)
|
30
30
|
i18n (0.5.0)
|
31
|
-
rspec (2.
|
32
|
-
rspec-core (~> 2.
|
33
|
-
rspec-expectations (~> 2.
|
34
|
-
rspec-mocks (~> 2.
|
35
|
-
rspec-core (2.
|
36
|
-
rspec-expectations (2.
|
31
|
+
rspec (2.4.0)
|
32
|
+
rspec-core (~> 2.4.0)
|
33
|
+
rspec-expectations (~> 2.4.0)
|
34
|
+
rspec-mocks (~> 2.4.0)
|
35
|
+
rspec-core (2.4.0)
|
36
|
+
rspec-expectations (2.4.0)
|
37
37
|
diff-lcs (~> 1.1.2)
|
38
|
-
rspec-mocks (2.
|
39
|
-
sqlite3
|
38
|
+
rspec-mocks (2.4.0)
|
39
|
+
sqlite3 (1.3.3)
|
40
|
+
sqlite3-ruby (1.3.3)
|
41
|
+
sqlite3 (>= 1.3.3)
|
40
42
|
timecop (0.3.5)
|
41
|
-
tzinfo (0.3.
|
43
|
+
tzinfo (0.3.24)
|
42
44
|
watchr (0.7)
|
43
45
|
|
44
46
|
PLATFORMS
|
data/README.markdown
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
##Description
|
12
12
|
|
13
13
|
|
14
|
-
|
14
|
+
Date\_Scopes is a rubygem that adds a simple macro, {DateScopes::ClassMethods#has\_date\_scopes has\_date\_scopes} to ActiveRecord. When used it adds a number of convinience scopes to your models relating to a whether a particular date field on that model is in the past or future. It also has other handy features.
|
15
15
|
|
16
16
|
Note that it does *not* depend on the whole of Rails, but is a pure ActiveRecord extension. As such it can be used wherever you use ActiveRecord, be it in Sinatra or whatever other mad thing you've cooked up.
|
17
17
|
|
@@ -25,7 +25,7 @@ This gem will neaten up your model code whenever your model instances need to be
|
|
25
25
|
|
26
26
|
###Dynamic Scopes
|
27
27
|
|
28
|
-
Assuming that the model has a datetime field called `published_at`, one can simply call the {DateScopes::ClassMethods#
|
28
|
+
Assuming that the model has a datetime field called `published_at`, one can simply call the {DateScopes::ClassMethods#has\_date\_scopes has\_date\_scopes} method in the model defintion like so:
|
29
29
|
|
30
30
|
class Post < ActiveRecord::Base
|
31
31
|
has_date_scopes
|
@@ -77,8 +77,8 @@ Then the `Order` class would have the following scopes:
|
|
77
77
|
|
78
78
|
unfilled
|
79
79
|
nonfilled
|
80
|
-
|
81
|
-
|
80
|
+
non_filled
|
81
|
+
not_filled
|
82
82
|
|
83
83
|
**NOTE**: The column option actually takes the verb that will form part of the various dynamic methods, and then adds `_at` to that name to find the name of the database column. In future it should be made to accept either but the current interface will not be broken. If the correct database column for the `:column` option is not found, the macro method will raise an exception.
|
84
84
|
|
data/lib/date_scopes/version.rb
CHANGED
data/lib/date_scopes.rb
CHANGED
data/spec/date_scopes_spec.rb
CHANGED
@@ -42,9 +42,21 @@ describe DateScopes do
|
|
42
42
|
it "accepts false to boolean setter and sets column as nil" do
|
43
43
|
post = Post.new
|
44
44
|
post.published_at = Time.now
|
45
|
+
post.save
|
45
46
|
post.published_at.should_not be_nil
|
47
|
+
post.should be_published
|
46
48
|
post.published = false
|
49
|
+
post.save
|
47
50
|
post.published_at.should be_nil
|
51
|
+
post.should_not be_published
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'copes with string passed to boolean setter' do
|
55
|
+
post = Post.new
|
56
|
+
post.published = 'true'
|
57
|
+
post.should be_published
|
58
|
+
post.published = 'False'
|
59
|
+
post.should_not be_published
|
48
60
|
end
|
49
61
|
|
50
62
|
context 'when published_at is in the past' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date_scopes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonathan Davies
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2011-01-27 00:00:00 +00:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -115,7 +115,6 @@ files:
|
|
115
115
|
- spec.watchr
|
116
116
|
- spec/date_scopes_spec.rb
|
117
117
|
- spec/spec_helper.rb
|
118
|
-
- spec/support/test.sqlite3
|
119
118
|
has_rdoc: yard
|
120
119
|
homepage: https://github.com/ThroughTheNet/date_scopes
|
121
120
|
licenses:
|
@@ -148,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
147
|
requirements: []
|
149
148
|
|
150
149
|
rubyforge_project:
|
151
|
-
rubygems_version: 1.
|
150
|
+
rubygems_version: 1.4.2
|
152
151
|
signing_key:
|
153
152
|
specification_version: 3
|
154
153
|
summary: An ActiveRecord extension for automatic date-based scopes
|
data/spec/support/test.sqlite3
DELETED
Binary file
|