periscope-activerecord 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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWEwZjJlOGZiNjhmNzNhM2Y4OTliNGU3MDkwMjczNWZmMjJhYmFmNA==
5
+ data.tar.gz: !binary |-
6
+ N2U2NWRmMDljZWZhMjZhZWY1ZjA2YWZlMjM3MWRkMjIyZWFmNDc2Yg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YmY0ZWIwYTk1YTA2NmZhMWE0NTY5N2MzOWViYzZmYzJiZGI1YWQ1ZDg5MmVj
10
+ ZWM0MjI5NGQ2ZDBjMjhhY2IwMGRlMDEwN2IwYmMzNmRjMTdjYjdlNGYyOTA4
11
+ ZmJhODI5NjUzYzkyMTdiMTliZWVmNjcwZmQzMTYxYjM3MDZiOGY=
12
+ data.tar.gz: !binary |-
13
+ MTQ5YzJkZWZlZDhlODg2ODkzOWQwNWQ1OGEzMTk5MWQ0ODNmNjg0N2E2OTU1
14
+ MzRhOThlNWUyZjU3NmI3MjM0MGIwYTMzZDllOWJhMjMxZTQ5MDQzMDdmMzlm
15
+ YWYzMmY2N2IxMTg4MTZlNGU2OWFiODdhZDc5Mzk3YmVhNDM4MjQ=
File without changes
data/README.md CHANGED
@@ -1,7 +1,23 @@
1
- # Periscope [![Build Status](https://secure.travis-ci.org/laserlemon/periscope.png)](http://travis-ci.org/laserlemon/periscope) [![Dependency Status](https://gemnasium.com/laserlemon/periscope.png)](https://gemnasium.com/laserlemon/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
 
10
+ ## Installation
11
+
12
+ Periscope sits on top of your favorite ORM. Currently, the following ORMs are supported through individual gems extending Periscope:
13
+
14
+ * Active Record ([periscope-activerecord](https://rubygems.org/gems/periscope-activerecord))
15
+ * MongoMapper ([periscope-mongo_mapper](https://rubygems.org/gems/periscope-mongo_mapper))
16
+ * Mongoid ([periscope-mongoid](https://rubygems.org/gems/periscope-mongoid))
17
+ * DataMapper ([periscope-data_mapper](https://rubygems.org/gems/periscope-data_mapper))
18
+
19
+ Simply add the gem to your bundle and you're off!
20
+
5
21
  ## The Problem
6
22
 
7
23
  More often than not, the index action in a RESTful Rails controller is expected to do a lot more than simply return all the records for a given model. We ask it to do all sorts of stuff like filtering, sorting and paginating results. Of course, this is typically done using _scopes_.
@@ -40,8 +56,8 @@ Within your model you can use the `scope_accessible` method to specify which sco
40
56
 
41
57
  ```ruby
42
58
  class User < ActiveRecord::Base
43
- scope :gender, lambda{|g| where(gender: g) }
44
- scope :makes, lambda{|s| where('salary >= ?', s) }
59
+ scope :gender, proc { |g| where(gender: g) }
60
+ scope :makes, proc { |s| where("salary >= ?", s) }
45
61
 
46
62
  scope_accessible :gender
47
63
  end
@@ -71,9 +87,9 @@ Parsers must respond to the `call` method, receiving the raw query parameter and
71
87
 
72
88
  ```ruby
73
89
  class User < ActiveRecord::Base
74
- scope :gender, lambda{|g| where(gender: g) }
90
+ scope :gender, proc { |g| where(gender: g) }
75
91
 
76
- scope_accessible :gender, parser: lambda{|g| [g.downcase] }
92
+ scope_accessible :gender, parser: proc { |g| [g.downcase] }
77
93
  end
78
94
  ```
79
95
 
@@ -83,8 +99,8 @@ But not all scopes accept arguments. For scopes that you want to toggle on or of
83
99
 
84
100
  ```ruby
85
101
  class User < ActiveRecord::Base
86
- scope :male, where(gender: 'male')
87
- scope :female, where(gender: 'female')
102
+ scope :male, proc { where(gender: "male") }
103
+ scope :female, proc { where(gender: "female") }
88
104
 
89
105
  scope_accessible :male, :female, boolean: true
90
106
  end
@@ -100,11 +116,11 @@ class Project < ActiveRecord::Base
100
116
  scope_accessible :end, method: :ends_before
101
117
 
102
118
  def self.begins_after(date)
103
- where('begins_at >= ?', date)
119
+ where("begins_at >= ?", date)
104
120
  end
105
121
 
106
122
  def self.ends_before(date)
107
- where('ends_at <= ?', date)
123
+ where("ends_at <= ?", date)
108
124
  end
109
125
  end
110
126
  ```
@@ -113,19 +129,21 @@ Alternatively, you can set `:prefix` and/or `:suffix` options, which will be app
113
129
 
114
130
  ```ruby
115
131
  class Project < ActiveRecord::Base
116
- scope_accessible :begin, :end, suffix: '_date'
132
+ scope_accessible :begin, :end, suffix: "_date"
117
133
 
118
134
  def self.begin_date(date)
119
- where('begins_at >= ?', date)
135
+ where("begins_at >= ?", date)
120
136
  end
121
137
 
122
138
  def self.end_date(date)
123
- where('ends_at <= ?', date)
139
+ where("ends_at <= ?", date)
124
140
  end
125
141
  end
126
142
  ```
127
143
 
128
- ## This sucks. How can I make it better?
144
+ ## This sucks.
145
+
146
+ How can I make it better?
129
147
 
130
148
  1. Fork it.
131
149
  2. Make it better.
@@ -1 +1 @@
1
- require 'periscope/adapters/active_record'
1
+ require "periscope/adapters/active_record"
@@ -1,5 +1,5 @@
1
- require 'periscope'
2
- require 'active_record'
1
+ require "periscope"
2
+ require "active_record"
3
3
 
4
4
  module Periscope
5
5
  module Adapters
@@ -9,7 +9,7 @@ module Periscope
9
9
  private
10
10
 
11
11
  def periscope_default_scope
12
- scoped
12
+ ::ActiveRecord::VERSION::MAJOR == 4 ? all : scoped
13
13
  end
14
14
  end
15
15
  end
@@ -1,28 +1,22 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.name = 'periscope-activerecord'
5
- gem.version = '1.0.0'
4
+ gem.name = "periscope-activerecord"
5
+ gem.version = "2.0.0"
6
6
 
7
- gem.authors = ['Steve Richert']
8
- gem.email = ['steve.richert@gmail.com']
9
- gem.description = %(Push your ActiveRecord models' scopes up to the surface)
10
- gem.summary = gem.description
11
- gem.homepage = 'https://github.com/laserlemon/periscope'
7
+ gem.author = "Steve Richert"
8
+ gem.email = "steve.richert@gmail.com"
9
+ gem.summary = "Push your Active Record models' scopes up to the surface"
10
+ gem.homepage = "https://github.com/laserlemon/periscope"
11
+ gem.license = "MIT"
12
12
 
13
- gem.add_dependency 'activerecord', '~> 3.0'
14
- gem.add_dependency 'periscope', '~> 1.0'
15
-
16
- gem.add_development_dependency 'database_cleaner', '~> 0.8'
17
- gem.add_development_dependency 'factory_girl', '>= 2', '< 4'
18
- gem.add_development_dependency 'rake', '~> 0.9'
19
- gem.add_development_dependency 'rspec', '~> 2.0'
20
- gem.add_development_dependency 'sqlite3'
13
+ gem.add_dependency "activerecord", ">= 3", "< 5"
14
+ gem.add_dependency "periscope", "~> 2.0"
21
15
 
22
16
  gem.files = %w(
23
- LICENSE
24
17
  lib/periscope-activerecord.rb
25
18
  lib/periscope/adapters/active_record.rb
19
+ LICENSE.md
26
20
  periscope-activerecord.gemspec
27
21
  README.md
28
22
  )
metadata CHANGED
@@ -1,174 +1,82 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: periscope-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
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: 2012-06-29 00:00:00.000000000 Z
11
+ date: 2013-03-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '3.0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: '3.0'
30
- - !ruby/object:Gem::Dependency
31
- name: periscope
32
- 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: factory_girl
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
16
  requirements:
67
17
  - - ! '>='
68
18
  - !ruby/object:Gem::Version
69
- version: '2'
19
+ version: '3'
70
20
  - - <
71
21
  - !ruby/object:Gem::Version
72
- version: '4'
73
- type: :development
22
+ version: '5'
23
+ type: :runtime
74
24
  prerelease: false
75
25
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
26
  requirements:
78
27
  - - ! '>='
79
28
  - !ruby/object:Gem::Version
80
- version: '2'
29
+ version: '3'
81
30
  - - <
82
31
  - !ruby/object:Gem::Version
83
- version: '4'
84
- - !ruby/object:Gem::Dependency
85
- name: rake
86
- requirement: !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ~>
90
- - !ruby/object:Gem::Version
91
- version: '0.9'
92
- type: :development
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ~>
98
- - !ruby/object:Gem::Version
99
- version: '0.9'
32
+ version: '5'
100
33
  - !ruby/object:Gem::Dependency
101
- name: rspec
34
+ name: periscope
102
35
  requirement: !ruby/object:Gem::Requirement
103
- none: false
104
36
  requirements:
105
37
  - - ~>
106
38
  - !ruby/object:Gem::Version
107
39
  version: '2.0'
108
- type: :development
40
+ type: :runtime
109
41
  prerelease: false
110
42
  version_requirements: !ruby/object:Gem::Requirement
111
- none: false
112
43
  requirements:
113
44
  - - ~>
114
45
  - !ruby/object:Gem::Version
115
46
  version: '2.0'
116
- - !ruby/object:Gem::Dependency
117
- name: sqlite3
118
- requirement: !ruby/object:Gem::Requirement
119
- none: false
120
- requirements:
121
- - - ! '>='
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
129
- - - ! '>='
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- description: Push your ActiveRecord models' scopes up to the surface
133
- email:
134
- - steve.richert@gmail.com
47
+ description:
48
+ email: steve.richert@gmail.com
135
49
  executables: []
136
50
  extensions: []
137
51
  extra_rdoc_files: []
138
52
  files:
139
- - LICENSE
140
53
  - lib/periscope-activerecord.rb
141
54
  - lib/periscope/adapters/active_record.rb
55
+ - LICENSE.md
142
56
  - periscope-activerecord.gemspec
143
57
  - README.md
144
58
  homepage: https://github.com/laserlemon/periscope
145
- licenses: []
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
146
62
  post_install_message:
147
63
  rdoc_options: []
148
64
  require_paths:
149
65
  - lib
150
66
  required_ruby_version: !ruby/object:Gem::Requirement
151
- none: false
152
67
  requirements:
153
68
  - - ! '>='
154
69
  - !ruby/object:Gem::Version
155
70
  version: '0'
156
- segments:
157
- - 0
158
- hash: 2923427527483607329
159
71
  required_rubygems_version: !ruby/object:Gem::Requirement
160
- none: false
161
72
  requirements:
162
73
  - - ! '>='
163
74
  - !ruby/object:Gem::Version
164
75
  version: '0'
165
- segments:
166
- - 0
167
- hash: 2923427527483607329
168
76
  requirements: []
169
77
  rubyforge_project:
170
- rubygems_version: 1.8.24
78
+ rubygems_version: 2.0.0
171
79
  signing_key:
172
- specification_version: 3
173
- summary: Push your ActiveRecord models' scopes up to the surface
80
+ specification_version: 4
81
+ summary: Push your Active Record models' scopes up to the surface
174
82
  test_files: []