periscope-mongoid 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/{LICENSE → LICENSE.md} +0 -0
- data/README.md +17 -12
- data/lib/periscope-mongoid.rb +1 -1
- data/lib/periscope/adapters/mongoid.rb +3 -3
- data/periscope-mongoid.gemspec +10 -14
- metadata +11 -77
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDY0Yzk3NTUzZDhkNTliODZjNzdkNjIzN2IxYWViOGUzNTYwZWVlNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTA1OTcwMWE3ODlhMTczY2Y5ZDY1ZGNiYjAwM2Q2YzE2M2I0ZTA4NA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzhkOWNhNTE5NzhiMzQ3ZGJiYTU5YjQ3YzUxNTgwNGJhZWJjNjI0NTg0OTY1
|
10
|
+
ZjVkYTI2Mzc0ZmY2ZDFjODkzYmU3MDViZDc0N2FjODYyM2Q4YWE5MDZlYmYy
|
11
|
+
YmM5MzhhMjEzZDliM2Q3NDVhMmFkOTA2ZjRlNWJhN2ViZmNiOGY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTA1MjdhM2ViOWFkMzZmMWZjZjVhMmFlNzFjZDFiYzczYTQwYjAyOWVjZjA0
|
14
|
+
MzM5MDViZDBmNzVhN2UxMjkzYzJiMzI1MTY4MjI4MDYyNGY3MjA3MDVmY2Q1
|
15
|
+
NjJlODYxZDA4OTJlYzgyMzg2MDhmODUyNDkwYjg3NjBiZTFmMGI=
|
data/{LICENSE → LICENSE.md}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
# Periscope
|
1
|
+
# Periscope
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/periscope.png)](http://badge.fury.io/rb/periscope)
|
3
|
+
[![Build Status](https://travis-ci.org/laserlemon/periscope.png?branch=master)](https://travis-ci.org/laserlemon/periscope)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/laserlemon/periscope.png)](https://codeclimate.com/github/laserlemon/periscope)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/laserlemon/periscope/badge.png?branch=master)](https://coveralls.io/r/laserlemon/periscope)
|
6
|
+
[![Dependency Status](https://gemnasium.com/laserlemon/periscope.png)](https://gemnasium.com/laserlemon/periscope)
|
2
7
|
|
3
8
|
Periscope provides a simple way to chain scopes on your models and to open those scopes up to your users.
|
4
9
|
|
@@ -51,8 +56,8 @@ Within your model you can use the `scope_accessible` method to specify which sco
|
|
51
56
|
|
52
57
|
```ruby
|
53
58
|
class User < ActiveRecord::Base
|
54
|
-
scope :gender,
|
55
|
-
scope :makes,
|
59
|
+
scope :gender, proc { |g| where(gender: g) }
|
60
|
+
scope :makes, proc { |s| where("salary >= ?", s) }
|
56
61
|
|
57
62
|
scope_accessible :gender
|
58
63
|
end
|
@@ -82,9 +87,9 @@ Parsers must respond to the `call` method, receiving the raw query parameter and
|
|
82
87
|
|
83
88
|
```ruby
|
84
89
|
class User < ActiveRecord::Base
|
85
|
-
scope :gender,
|
90
|
+
scope :gender, proc { |g| where(gender: g) }
|
86
91
|
|
87
|
-
scope_accessible :gender, parser:
|
92
|
+
scope_accessible :gender, parser: proc { |g| [g.downcase] }
|
88
93
|
end
|
89
94
|
```
|
90
95
|
|
@@ -94,8 +99,8 @@ But not all scopes accept arguments. For scopes that you want to toggle on or of
|
|
94
99
|
|
95
100
|
```ruby
|
96
101
|
class User < ActiveRecord::Base
|
97
|
-
scope :male, where(gender:
|
98
|
-
scope :female, where(gender:
|
102
|
+
scope :male, proc { where(gender: "male") }
|
103
|
+
scope :female, proc { where(gender: "female") }
|
99
104
|
|
100
105
|
scope_accessible :male, :female, boolean: true
|
101
106
|
end
|
@@ -111,11 +116,11 @@ class Project < ActiveRecord::Base
|
|
111
116
|
scope_accessible :end, method: :ends_before
|
112
117
|
|
113
118
|
def self.begins_after(date)
|
114
|
-
where(
|
119
|
+
where("begins_at >= ?", date)
|
115
120
|
end
|
116
121
|
|
117
122
|
def self.ends_before(date)
|
118
|
-
where(
|
123
|
+
where("ends_at <= ?", date)
|
119
124
|
end
|
120
125
|
end
|
121
126
|
```
|
@@ -124,14 +129,14 @@ Alternatively, you can set `:prefix` and/or `:suffix` options, which will be app
|
|
124
129
|
|
125
130
|
```ruby
|
126
131
|
class Project < ActiveRecord::Base
|
127
|
-
scope_accessible :begin, :end, suffix:
|
132
|
+
scope_accessible :begin, :end, suffix: "_date"
|
128
133
|
|
129
134
|
def self.begin_date(date)
|
130
|
-
where(
|
135
|
+
where("begins_at >= ?", date)
|
131
136
|
end
|
132
137
|
|
133
138
|
def self.end_date(date)
|
134
|
-
where(
|
139
|
+
where("ends_at <= ?", date)
|
135
140
|
end
|
136
141
|
end
|
137
142
|
```
|
data/lib/periscope-mongoid.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "periscope/adapters/mongoid"
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "periscope"
|
2
|
+
require "mongoid"
|
3
3
|
|
4
4
|
module Periscope
|
5
5
|
module Adapters
|
@@ -15,4 +15,4 @@ module Periscope
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
Mongoid::Document::ClassMethods.send(:include, Periscope::Adapters::Mongoid)
|
18
|
+
Mongoid::Document::ClassMethods.send(:include, Periscope::Adapters::Mongoid)
|
data/periscope-mongoid.gemspec
CHANGED
@@ -1,26 +1,22 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
|
-
gem.name =
|
5
|
-
gem.version =
|
4
|
+
gem.name = "periscope-mongoid"
|
5
|
+
gem.version = "2.0.0"
|
6
6
|
|
7
|
-
gem.
|
8
|
-
gem.email
|
9
|
-
gem.
|
10
|
-
gem.
|
11
|
-
gem.
|
7
|
+
gem.author = "Steve Richert"
|
8
|
+
gem.email = "steve.richert@gmail.com"
|
9
|
+
gem.summary = "Push your Mongoid models' scopes up to the surface"
|
10
|
+
gem.homepage = "https://github.com/laserlemon/periscope"
|
11
|
+
gem.license = "MIT"
|
12
12
|
|
13
|
-
gem.add_dependency
|
14
|
-
gem.add_dependency
|
15
|
-
|
16
|
-
gem.add_development_dependency 'database_cleaner', '~> 0.8'
|
17
|
-
gem.add_development_dependency 'factory_girl', '>= 2', '< 5'
|
18
|
-
gem.add_development_dependency 'rspec', '~> 2.0'
|
13
|
+
gem.add_dependency "mongoid", ">= 2", "< 4"
|
14
|
+
gem.add_dependency "periscope", "~> 2.0"
|
19
15
|
|
20
16
|
gem.files = %w(
|
21
|
-
LICENSE
|
22
17
|
lib/periscope-mongoid.rb
|
23
18
|
lib/periscope/adapters/mongoid.rb
|
19
|
+
LICENSE.md
|
24
20
|
periscope-mongoid.gemspec
|
25
21
|
README.md
|
26
22
|
)
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: periscope-mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Steve Richert
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-03-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: mongoid
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -25,7 +23,6 @@ dependencies:
|
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
@@ -36,113 +33,50 @@ dependencies:
|
|
36
33
|
- !ruby/object:Gem::Dependency
|
37
34
|
name: periscope
|
38
35
|
requirement: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '1.0'
|
44
|
-
type: :runtime
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
|
-
requirements:
|
49
|
-
- - ~>
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '1.0'
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: database_cleaner
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
|
-
requirements:
|
57
|
-
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '0.8'
|
60
|
-
type: :development
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
|
-
requirements:
|
65
|
-
- - ~>
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0.8'
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: factory_girl
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
|
-
requirements:
|
73
|
-
- - ! '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '2'
|
76
|
-
- - <
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '5'
|
79
|
-
type: :development
|
80
|
-
prerelease: false
|
81
|
-
version_requirements: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
|
-
requirements:
|
84
|
-
- - ! '>='
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: '2'
|
87
|
-
- - <
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '5'
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: rspec
|
92
|
-
requirement: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
36
|
requirements:
|
95
37
|
- - ~>
|
96
38
|
- !ruby/object:Gem::Version
|
97
39
|
version: '2.0'
|
98
|
-
type: :
|
40
|
+
type: :runtime
|
99
41
|
prerelease: false
|
100
42
|
version_requirements: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
43
|
requirements:
|
103
44
|
- - ~>
|
104
45
|
- !ruby/object:Gem::Version
|
105
46
|
version: '2.0'
|
106
|
-
description:
|
107
|
-
email:
|
108
|
-
- steve.richert@gmail.com
|
47
|
+
description:
|
48
|
+
email: steve.richert@gmail.com
|
109
49
|
executables: []
|
110
50
|
extensions: []
|
111
51
|
extra_rdoc_files: []
|
112
52
|
files:
|
113
|
-
- LICENSE
|
114
53
|
- lib/periscope-mongoid.rb
|
115
54
|
- lib/periscope/adapters/mongoid.rb
|
55
|
+
- LICENSE.md
|
116
56
|
- periscope-mongoid.gemspec
|
117
57
|
- README.md
|
118
58
|
homepage: https://github.com/laserlemon/periscope
|
119
|
-
licenses:
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
120
62
|
post_install_message:
|
121
63
|
rdoc_options: []
|
122
64
|
require_paths:
|
123
65
|
- lib
|
124
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
67
|
requirements:
|
127
68
|
- - ! '>='
|
128
69
|
- !ruby/object:Gem::Version
|
129
70
|
version: '0'
|
130
|
-
segments:
|
131
|
-
- 0
|
132
|
-
hash: 665879964349728397
|
133
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
-
none: false
|
135
72
|
requirements:
|
136
73
|
- - ! '>='
|
137
74
|
- !ruby/object:Gem::Version
|
138
75
|
version: '0'
|
139
|
-
segments:
|
140
|
-
- 0
|
141
|
-
hash: 665879964349728397
|
142
76
|
requirements: []
|
143
77
|
rubyforge_project:
|
144
|
-
rubygems_version:
|
78
|
+
rubygems_version: 2.0.0
|
145
79
|
signing_key:
|
146
|
-
specification_version:
|
80
|
+
specification_version: 4
|
147
81
|
summary: Push your Mongoid models' scopes up to the surface
|
148
82
|
test_files: []
|