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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d4a557ce1436d0736e986bb84ddc20b6f7d6f3d
4
- data.tar.gz: e8e525c87f55a18a9b26e7001d224dbf2dafeb35
3
+ metadata.gz: b8ad5a2a1fad44b7b91dd8179dcc3befa9b77a92
4
+ data.tar.gz: 7b56ff9fef68c379480c70d779c53a3033b9d34a
5
5
  SHA512:
6
- metadata.gz: 2195b4b20e5616157159c98d319a2cc831f6157b639fd75bc3d2a0381d0b48bf04c3905c3cac94a220e6ed0d497c10c31e49cf433080cd618ab19d8be72b8967
7
- data.tar.gz: 3d5576ded98021422c4c3f73ec11925221cb80252c95113f4c11e1de4f18ef9f8be7221aae6963263f6316713d4f54a14ad7858fcaaf599d8fe89f3e4b02da98
6
+ metadata.gz: f0133660039a13166f4a32a0c87c3496facb8df76c527869c4773a54724a4c6559c1c94feaa18a4a1dab8bddebc4322350955a393845fc84f6998bf009b098b0
7
+ data.tar.gz: fd1b270755e6966c8cbb447ec90959ce6b6415b4fef2dbbe5c29f96eb8c4762bb282a0f20ee3c582a59a2d34ca9153090709ad1fefe65560db291b49da474b41
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
2
  --require spec_helper
3
- --require rspec/legacy_formatters
data/.travis.yml CHANGED
@@ -10,5 +10,5 @@ matrix:
10
10
  fast_finish: true
11
11
  before_install: gem install bundler -v 1.10.6
12
12
  script:
13
- - bundle exec rake
13
+ - bundle exec rake spec
14
14
  - bundle exec rubocop --fail-level C
data/README.md CHANGED
@@ -278,7 +278,7 @@ end
278
278
  To get translated error messages load Rails Railtie
279
279
 
280
280
  ```ruby
281
- require 'might/railtie
281
+ require 'might/railtie'
282
282
  ```
283
283
 
284
284
  ## Development
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
 
4
- RSpec::Core::RakeTask.new(:rspec)
4
+ RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task default: :rspec
6
+ task default: :spec
@@ -2,24 +2,51 @@ module Might
2
2
  # Contains contains with all supported predicates
3
3
  #
4
4
  module FilterPredicates
5
- ON_VALUE = %w(
6
- not_eq eq
7
- does_not_match matches
8
- gt lt
9
- gteq lteq
10
- not_cont cont
11
- not_start start
12
- not_end end
13
- not_true true
14
- not_false false
15
- blank present
16
- not_null null
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
- ON_ARRAY = %w(
20
- not_in in
21
- not_cont_any cont_any
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
- # validate_parameters!(params)
25
- paginated_scope = Paginator.new(pagination_options(params)).paginate(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
@@ -1,4 +1,4 @@
1
1
  #
2
2
  module Might
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
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.0
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-19 00:00:00.000000000 Z
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: