might 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/.travis.yml +1 -1
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/lib/might/filter_predicates.rb +44 -17
- data/lib/might/pagination_middleware.rb +4 -8
- data/lib/might/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8ad5a2a1fad44b7b91dd8179dcc3befa9b77a92
|
4
|
+
data.tar.gz: 7b56ff9fef68c379480c70d779c53a3033b9d34a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0133660039a13166f4a32a0c87c3496facb8df76c527869c4773a54724a4c6559c1c94feaa18a4a1dab8bddebc4322350955a393845fc84f6998bf009b098b0
|
7
|
+
data.tar.gz: fd1b270755e6966c8cbb447ec90959ce6b6415b4fef2dbbe5c29f96eb8c4762bb282a0f20ee3c582a59a2d34ca9153090709ad1fefe65560db291b49da474b41
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -2,24 +2,51 @@ module Might
|
|
2
2
|
# Contains contains with all supported predicates
|
3
3
|
#
|
4
4
|
module FilterPredicates
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
NOT_EQ = 'not_eq'
|
6
|
+
EQ = 'eq'
|
7
|
+
DOES_NOT_MATCH = 'does_not_match'
|
8
|
+
MATCHES = 'matches'
|
9
|
+
GT = 'gt'
|
10
|
+
LT = 'lt'
|
11
|
+
GTEQ = 'gteq'
|
12
|
+
LTEQ = 'lteq'
|
13
|
+
NOT_CONT = 'not_cont'
|
14
|
+
CONT = 'cont'
|
15
|
+
NOT_START = 'not_start'
|
16
|
+
START = 'start'
|
17
|
+
DOES_NOT_END = 'not_end'
|
18
|
+
ENDS = 'end'
|
19
|
+
NOT_TRUE = 'not_true'
|
20
|
+
TRUE = 'true'
|
21
|
+
NOT_FALSE = 'not_false'
|
22
|
+
FALSE = 'false'
|
23
|
+
BLANK = 'blank'
|
24
|
+
PRESENT = 'present'
|
25
|
+
NOT_NULL = 'not_null'
|
26
|
+
NULL = 'null'
|
27
|
+
NOT_IN = 'not_in'
|
28
|
+
IN = 'in'
|
29
|
+
NOT_CONT_ANY = 'not_cont_any'
|
30
|
+
CONT_ANY = 'cont_any'
|
18
31
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
32
|
+
ON_VALUE = [
|
33
|
+
NOT_EQ, EQ,
|
34
|
+
DOES_NOT_MATCH, MATCHES,
|
35
|
+
GT, LT,
|
36
|
+
GTEQ, LTEQ,
|
37
|
+
NOT_CONT, CONT,
|
38
|
+
NOT_START, START,
|
39
|
+
DOES_NOT_END, ENDS,
|
40
|
+
NOT_TRUE, TRUE,
|
41
|
+
NOT_FALSE, FALSE,
|
42
|
+
BLANK, PRESENT,
|
43
|
+
NOT_NULL, NULL
|
44
|
+
]
|
45
|
+
|
46
|
+
ON_ARRAY = [
|
47
|
+
NOT_IN, IN,
|
48
|
+
NOT_CONT_ANY, CONT_ANY
|
49
|
+
]
|
23
50
|
|
24
51
|
ALL = ON_VALUE + ON_ARRAY
|
25
52
|
end
|
@@ -9,10 +9,11 @@ module Might
|
|
9
9
|
# @param max_per_page [Integer]
|
10
10
|
# @param per_page [Integer]
|
11
11
|
#
|
12
|
-
def initialize(app, max_per_page: false, per_page: 50)
|
12
|
+
def initialize(app, max_per_page: false, per_page: 50, paginator_class: Paginator)
|
13
13
|
@app = app
|
14
14
|
@max_per_page = max_per_page
|
15
15
|
@per_page = per_page
|
16
|
+
@paginator_class = paginator_class
|
16
17
|
end
|
17
18
|
|
18
19
|
# @param [Array(ActiveRecord::Relation, Hash)] env
|
@@ -21,8 +22,8 @@ module Might
|
|
21
22
|
#
|
22
23
|
def call(env)
|
23
24
|
scope, params = env
|
24
|
-
|
25
|
-
paginated_scope =
|
25
|
+
|
26
|
+
paginated_scope = @paginator_class.new(pagination_options(params)).paginate(scope)
|
26
27
|
app.call([paginated_scope, params])
|
27
28
|
end
|
28
29
|
|
@@ -30,11 +31,6 @@ module Might
|
|
30
31
|
|
31
32
|
attr_reader :app
|
32
33
|
|
33
|
-
# def validate_parameters!(params)
|
34
|
-
# validator = Validator.new(params[:page])
|
35
|
-
# fail(PaginationValidationFailed, validator.errors) unless validator.valid?
|
36
|
-
# end
|
37
|
-
|
38
34
|
# @param [Hash] params
|
39
35
|
# @option params [Hash] (nil) :limit
|
40
36
|
# @option params [Hash] (nil) :offset
|
data/lib/might/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: might
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tema Bolshakov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -237,4 +237,3 @@ signing_key:
|
|
237
237
|
specification_version: 4
|
238
238
|
summary: Mighty resource fetchers
|
239
239
|
test_files: []
|
240
|
-
has_rdoc:
|