periscope 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTAyZmQ5NjEyMGU2NmQxZTJhM2JjMjQ1MTBiZGY2MmIxOTdmOTMzNQ==
5
+ data.tar.gz: !binary |-
6
+ NjMzNTRhN2IxMjNlZGFhNWFmMTU1YmJhMzYxOGYyOGRhZTBmNzc0Ng==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MDZmYjQyZTcyMTdiMzg1Yzg1NmJhYjNiZTI3YmE1ZjJjNDZiNzNkNDFjYWQ4
10
+ ZmFkM2I0YTE1NjYwMjg2YmFiMjNkZDEwNGFlZTc1ZWEyNjEwY2E5M2FiYjEw
11
+ NWU2ZjlmOWMzYTM2NGVjYmU3MzkzYmUxYTgzYzlkOThlZjMwNWE=
12
+ data.tar.gz: !binary |-
13
+ Y2Y1MjMzZTcyNDBhYzZlYWZiYmQ3MTE2Njg1NjAwMmViZGQ2OTRlMjQzNGNj
14
+ ZjQxZTE2MGMyMWM1YTUyZWQwNGVhMWRhMWVjZmUwZjVlOGJmZWM0OGIyYTc5
15
+ MGQ5NjQ4ZDk5MzdhYzVlOGM3Y2E3MDhmMjc1MTQ0YTgxNjU1MzA=
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,7 +1,7 @@
1
1
  module Periscope
2
2
  def scope_accessible(*scopes)
3
3
  options = scopes.last.is_a?(Hash) ? scopes.pop : {}
4
- scopes.each{|s| periscope_options[s.to_s] = options }
4
+ scopes.each { |s| periscope_options[s.to_s] = options }
5
5
  end
6
6
 
7
7
  def periscope(params = {})
@@ -1,21 +1,18 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.name = 'periscope'
5
- gem.version = '1.0.0'
4
+ gem.name = "periscope"
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 models' scopes up to the surface)
10
- gem.summary = gem.description
11
- gem.homepage = 'https://github.com/laserlemon/periscope'
12
-
13
- gem.add_development_dependency 'rake', '~> 0.9'
14
- gem.add_development_dependency 'rspec', '~> 2.0'
7
+ gem.author = "Steve Richert"
8
+ gem.email = "steve.richert@gmail.com"
9
+ gem.summary = "Push your models' scopes up to the surface"
10
+ gem.homepage = "https://github.com/laserlemon/periscope"
11
+ gem.license = "MIT"
15
12
 
16
13
  gem.files = %w(
17
- LICENSE
18
14
  lib/periscope.rb
15
+ LICENSE.md
19
16
  periscope.gemspec
20
17
  README.md
21
18
  )
metadata CHANGED
@@ -1,87 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: periscope
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
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rake
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '0.9'
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: '0.9'
30
- - !ruby/object:Gem::Dependency
31
- name: rspec
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '2.0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '2.0'
46
- description: Push your models' scopes up to the surface
47
- email:
48
- - steve.richert@gmail.com
11
+ date: 2013-03-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: steve.richert@gmail.com
49
15
  executables: []
50
16
  extensions: []
51
17
  extra_rdoc_files: []
52
18
  files:
53
- - LICENSE
54
19
  - lib/periscope.rb
20
+ - LICENSE.md
55
21
  - periscope.gemspec
56
22
  - README.md
57
23
  homepage: https://github.com/laserlemon/periscope
58
- licenses: []
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
59
27
  post_install_message:
60
28
  rdoc_options: []
61
29
  require_paths:
62
30
  - lib
63
31
  required_ruby_version: !ruby/object:Gem::Requirement
64
- none: false
65
32
  requirements:
66
33
  - - ! '>='
67
34
  - !ruby/object:Gem::Version
68
35
  version: '0'
69
- segments:
70
- - 0
71
- hash: -4385253506114328427
72
36
  required_rubygems_version: !ruby/object:Gem::Requirement
73
- none: false
74
37
  requirements:
75
38
  - - ! '>='
76
39
  - !ruby/object:Gem::Version
77
40
  version: '0'
78
- segments:
79
- - 0
80
- hash: -4385253506114328427
81
41
  requirements: []
82
42
  rubyforge_project:
83
- rubygems_version: 1.8.24
43
+ rubygems_version: 2.0.0
84
44
  signing_key:
85
- specification_version: 3
45
+ specification_version: 4
86
46
  summary: Push your models' scopes up to the surface
87
47
  test_files: []