periscope-data_mapper 1.0.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 +21 -14
- data/lib/periscope/adapters/data_mapper.rb +2 -2
- data/lib/periscope-data_mapper.rb +1 -1
- data/periscope-data_mapper.gemspec +10 -17
- metadata +12 -126
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzQxNDZlMmIyZDNhNzc0ZDI4MzIxMjZkM2NiMGYyZGM5NjRhZDAwMA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OGI3ZjEyNTI4ODZjNTc4NGE1MGY5ZWMzMjE5OTE0YTdlZWNkOTk0Ng==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
N2ZmOGRjY2VhNjY2YzE1OWQyNzE1OGVjOTNjZTdhYzgwNzM1NzhlMDRjMGU4
|
10
|
+
NjhhOTUxYzg3MWUzOWQxNGY4YjAzZmQ5ODk4YmE4YTYxYzMzYmQ1MGM1ODg3
|
11
|
+
M2ZjM2E2ZjhmODk5YTZhNThjMWE1YmY4MjcyNTcwNDMyZTAyNTA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2E0N2EwOTM3ZjEwYmVlZDU5ZGQyMjU5NGQ1OTg2Y2Y5ZjQyZjQ2NjlmOTEx
|
14
|
+
NzZmODY3YTBkODk0OGU5OTY5NzgxNTMxNGVkNzU1ZWYwMmJhZDM5M2NkODYw
|
15
|
+
ZTMxOGI3OGQzYjk1Y2NkYjMxZDA3YWFjYzI1NDc0NWRlNmI3MmE=
|
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
|
|
@@ -6,7 +11,7 @@ Periscope provides a simple way to chain scopes on your models and to open those
|
|
6
11
|
|
7
12
|
Periscope sits on top of your favorite ORM. Currently, the following ORMs are supported through individual gems extending Periscope:
|
8
13
|
|
9
|
-
*
|
14
|
+
* Active Record ([periscope-activerecord](https://rubygems.org/gems/periscope-activerecord))
|
10
15
|
* MongoMapper ([periscope-mongo_mapper](https://rubygems.org/gems/periscope-mongo_mapper))
|
11
16
|
* Mongoid ([periscope-mongoid](https://rubygems.org/gems/periscope-mongoid))
|
12
17
|
* DataMapper ([periscope-data_mapper](https://rubygems.org/gems/periscope-data_mapper))
|
@@ -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,19 +129,21 @@ 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
|
```
|
138
143
|
|
139
|
-
## This sucks.
|
144
|
+
## This sucks.
|
145
|
+
|
146
|
+
How can I make it better?
|
140
147
|
|
141
148
|
1. Fork it.
|
142
149
|
2. Make it better.
|
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "periscope/adapters/data_mapper"
|
@@ -1,29 +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-data_mapper"
|
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 DataMapper 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 'dm-sqlite-adapter', '~> 1.0'
|
18
|
-
gem.add_development_dependency 'factory_girl', '>= 2', '< 4'
|
19
|
-
gem.add_development_dependency 'rake', '~> 0.9'
|
20
|
-
gem.add_development_dependency 'rspec', '~> 2.0'
|
21
|
-
gem.add_development_dependency 'sqlite3'
|
13
|
+
gem.add_dependency "dm-core", "~> 1.0"
|
14
|
+
gem.add_dependency "periscope", "~> 2.0"
|
22
15
|
|
23
16
|
gem.files = %w(
|
24
|
-
LICENSE
|
25
17
|
lib/periscope-data_mapper.rb
|
26
18
|
lib/periscope/adapters/data_mapper.rb
|
19
|
+
LICENSE.md
|
27
20
|
periscope-data_mapper.gemspec
|
28
21
|
README.md
|
29
22
|
)
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: periscope-data_mapper
|
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
|
-
name:
|
14
|
+
name: dm-core
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,161 +27,50 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: periscope
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '1.0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '1.0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: database_cleaner
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.8'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.8'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: dm-sqlite-adapter
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '1.0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '1.0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: factory_girl
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '2'
|
86
|
-
- - <
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '4'
|
89
|
-
type: :development
|
90
|
-
prerelease: false
|
91
|
-
version_requirements: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
|
-
requirements:
|
94
|
-
- - ! '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '2'
|
97
|
-
- - <
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: '4'
|
100
|
-
- !ruby/object:Gem::Dependency
|
101
|
-
name: rake
|
102
|
-
requirement: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
|
-
requirements:
|
105
|
-
- - ~>
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: '0.9'
|
108
|
-
type: :development
|
109
|
-
prerelease: false
|
110
|
-
version_requirements: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
|
-
requirements:
|
113
|
-
- - ~>
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: '0.9'
|
116
|
-
- !ruby/object:Gem::Dependency
|
117
|
-
name: rspec
|
118
|
-
requirement: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
30
|
requirements:
|
121
31
|
- - ~>
|
122
32
|
- !ruby/object:Gem::Version
|
123
33
|
version: '2.0'
|
124
|
-
type: :
|
34
|
+
type: :runtime
|
125
35
|
prerelease: false
|
126
36
|
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
37
|
requirements:
|
129
38
|
- - ~>
|
130
39
|
- !ruby/object:Gem::Version
|
131
40
|
version: '2.0'
|
132
|
-
|
133
|
-
|
134
|
-
requirement: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
|
-
requirements:
|
137
|
-
- - ! '>='
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: '0'
|
140
|
-
type: :development
|
141
|
-
prerelease: false
|
142
|
-
version_requirements: !ruby/object:Gem::Requirement
|
143
|
-
none: false
|
144
|
-
requirements:
|
145
|
-
- - ! '>='
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: '0'
|
148
|
-
description: Push your DataMapper models' scopes up to the surface
|
149
|
-
email:
|
150
|
-
- steve.richert@gmail.com
|
41
|
+
description:
|
42
|
+
email: steve.richert@gmail.com
|
151
43
|
executables: []
|
152
44
|
extensions: []
|
153
45
|
extra_rdoc_files: []
|
154
46
|
files:
|
155
|
-
- LICENSE
|
156
47
|
- lib/periscope-data_mapper.rb
|
157
48
|
- lib/periscope/adapters/data_mapper.rb
|
49
|
+
- LICENSE.md
|
158
50
|
- periscope-data_mapper.gemspec
|
159
51
|
- README.md
|
160
52
|
homepage: https://github.com/laserlemon/periscope
|
161
|
-
licenses:
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
162
56
|
post_install_message:
|
163
57
|
rdoc_options: []
|
164
58
|
require_paths:
|
165
59
|
- lib
|
166
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
-
none: false
|
168
61
|
requirements:
|
169
62
|
- - ! '>='
|
170
63
|
- !ruby/object:Gem::Version
|
171
64
|
version: '0'
|
172
|
-
segments:
|
173
|
-
- 0
|
174
|
-
hash: -3628630839409987277
|
175
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
-
none: false
|
177
66
|
requirements:
|
178
67
|
- - ! '>='
|
179
68
|
- !ruby/object:Gem::Version
|
180
69
|
version: '0'
|
181
|
-
segments:
|
182
|
-
- 0
|
183
|
-
hash: -3628630839409987277
|
184
70
|
requirements: []
|
185
71
|
rubyforge_project:
|
186
|
-
rubygems_version:
|
72
|
+
rubygems_version: 2.0.0
|
187
73
|
signing_key:
|
188
|
-
specification_version:
|
74
|
+
specification_version: 4
|
189
75
|
summary: Push your DataMapper models' scopes up to the surface
|
190
76
|
test_files: []
|