might 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +19 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -1
- data/Rakefile +1 -0
- data/bin/console +1 -0
- data/lib/might.rb +45 -0
- data/lib/might/fetcher.rb +1 -16
- data/lib/might/fetcher_error.rb +1 -0
- data/lib/might/filter_middleware.rb +1 -4
- data/lib/might/filter_parameter.rb +1 -3
- data/lib/might/filter_parameter_definition.rb +1 -4
- data/lib/might/filter_parameters.rb +1 -3
- data/lib/might/filter_parameters_extractor.rb +1 -5
- data/lib/might/filter_parameters_validator.rb +1 -0
- data/lib/might/filter_predicates.rb +27 -26
- data/lib/might/filter_undefined_parameter.rb +1 -2
- data/lib/might/filter_value_validator.rb +2 -10
- data/lib/might/pagination_middleware.rb +1 -3
- data/lib/might/pagination_parameters_validator.rb +1 -10
- data/lib/might/paginator.rb +1 -2
- data/lib/might/railtie.rb +1 -1
- data/lib/might/ransackable_filter.rb +1 -0
- data/lib/might/ransackable_filter_parameters_adapter.rb +1 -0
- data/lib/might/ransackable_sort.rb +1 -0
- data/lib/might/ransackable_sort_parameters_adapter.rb +1 -0
- data/lib/might/result.rb +1 -0
- data/lib/might/sort_middleware.rb +1 -5
- data/lib/might/sort_parameter.rb +1 -2
- data/lib/might/sort_parameter_definition.rb +1 -2
- data/lib/might/sort_parameters_extractor.rb +1 -3
- data/lib/might/sort_parameters_validator.rb +1 -0
- data/lib/might/sort_undefined_parameter.rb +1 -2
- data/lib/might/sort_value_validator.rb +2 -10
- data/lib/might/version.rb +2 -2
- data/might.gemspec +3 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e4b5f381d33b43a2e2c7cb063cccb64a87c38d1
|
4
|
+
data.tar.gz: 701e845bc0d3722c70c256ae893bb5c6e323fc8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08953e15287d062c199dba58919053966da59e5163eca9a5a6a1e6b7f12065aebc2461e4058b3ca5409ffed17b892654bc5c1bab7c04ba973131cf8edfa041f1
|
7
|
+
data.tar.gz: ba678ffae577804b809fb6c0ee85845a9192e8b5708211c5662c9becf736ca3d13a0b0eab673499663add3d9f50169b1a375ee6c0b7ba6a0e3e6fe3b4c911796
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
engines:
|
3
|
+
duplication:
|
4
|
+
enabled: true
|
5
|
+
config:
|
6
|
+
languages:
|
7
|
+
- ruby
|
8
|
+
fixme:
|
9
|
+
enabled: true
|
10
|
+
rubocop:
|
11
|
+
enabled: true
|
12
|
+
ratings:
|
13
|
+
paths:
|
14
|
+
- "**.rb"
|
15
|
+
exclude_paths:
|
16
|
+
- bin/**/*
|
17
|
+
- config/**/*
|
18
|
+
- gemfiles/**/*
|
19
|
+
- spec/**/*
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/might.rb
CHANGED
@@ -1,4 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'set'
|
3
|
+
require 'forwardable'
|
4
|
+
require 'active_model'
|
5
|
+
require 'active_support'
|
6
|
+
require 'active_support/dependencies/autoload'
|
7
|
+
require 'active_support/core_ext/module/delegation'
|
8
|
+
require 'active_support/core_ext/object/blank'
|
9
|
+
require 'active_support/concern'
|
10
|
+
require 'active_support/callbacks'
|
11
|
+
require 'middleware'
|
12
|
+
require 'uber/inheritable_attr'
|
13
|
+
|
1
14
|
# Top level namespace for mighty fetchers
|
2
15
|
module Might
|
3
16
|
require 'might/version'
|
17
|
+
extend ActiveSupport::Autoload
|
18
|
+
|
19
|
+
autoload :Fetcher
|
20
|
+
autoload :FetcherError
|
21
|
+
autoload :FilterMiddleware
|
22
|
+
autoload :FilterParameter
|
23
|
+
autoload :FilterParameterDefinition
|
24
|
+
autoload :FilterParameters
|
25
|
+
autoload :FilterParametersExtractor
|
26
|
+
autoload :FilterParametersValidator
|
27
|
+
autoload :FilterPredicates
|
28
|
+
autoload :FilterUndefinedParameter
|
29
|
+
autoload :FilterValueValidator
|
30
|
+
autoload :PaginationMiddleware
|
31
|
+
autoload :PaginationParametersValidator
|
32
|
+
autoload :Paginator
|
33
|
+
autoload :RansackableFilter
|
34
|
+
autoload :RansackableFilterParametersAdapter
|
35
|
+
autoload :RansackableSort
|
36
|
+
autoload :RansackableSortParametersAdapter
|
37
|
+
autoload :Result
|
38
|
+
autoload :Failure, 'might/result'
|
39
|
+
autoload :Success, 'might/result'
|
40
|
+
autoload :SortMiddleware
|
41
|
+
autoload :SortParameter
|
42
|
+
autoload :FilterUndefinedParameter
|
43
|
+
autoload :SortParameterDefinition
|
44
|
+
autoload :SortParametersExtractor
|
45
|
+
autoload :SortParametersValidator
|
46
|
+
autoload :SortUndefinedParameter
|
47
|
+
autoload :SortValueValidator
|
48
|
+
autoload :VERSION
|
4
49
|
end
|
data/lib/might/fetcher.rb
CHANGED
@@ -1,19 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'might/sort_parameters_extractor'
|
3
|
-
require 'might/sort_parameters_validator'
|
4
|
-
require 'might/filter_parameters_extractor'
|
5
|
-
require 'might/filter_parameters_validator'
|
6
|
-
require 'might/pagination_parameters_validator'
|
7
|
-
|
8
|
-
require 'might/filter_middleware'
|
9
|
-
require 'might/sort_middleware'
|
10
|
-
require 'might/pagination_middleware'
|
11
|
-
|
12
|
-
require 'might/result'
|
13
|
-
require 'uber/inheritable_attr'
|
14
|
-
require 'middleware'
|
15
|
-
|
16
|
-
#
|
1
|
+
# frozen_string_literal: true
|
17
2
|
module Might
|
18
3
|
# Configure your own fetcher
|
19
4
|
#
|
data/lib/might/fetcher_error.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
require_relative 'filter_undefined_parameter'
|
3
|
-
require_relative 'filter_parameter'
|
4
|
-
require_relative 'filter_parameters'
|
5
|
-
|
1
|
+
# frozen_string_literal: true
|
6
2
|
module Might
|
7
3
|
# User provided filters syntax:
|
8
4
|
# * `{ 'name_eq' => 'Martin' }` - name is equal to Martin
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Might
|
2
3
|
# Contains contains with all supported predicates
|
3
4
|
# You can register your own predicates. Predicates should perform on array or on singular value:
|
@@ -6,32 +7,32 @@ module Might
|
|
6
7
|
# Might::FilterPredicates.register('is_upper_case', on: :value)
|
7
8
|
#
|
8
9
|
module FilterPredicates
|
9
|
-
NOT_EQ = 'not_eq'
|
10
|
-
EQ = 'eq'
|
11
|
-
DOES_NOT_MATCH = 'does_not_match'
|
12
|
-
MATCHES = 'matches'
|
13
|
-
GT = 'gt'
|
14
|
-
LT = 'lt'
|
15
|
-
GTEQ = 'gteq'
|
16
|
-
LTEQ = 'lteq'
|
17
|
-
NOT_CONT = 'not_cont'
|
18
|
-
CONT = 'cont'
|
19
|
-
NOT_START = 'not_start'
|
20
|
-
START = 'start'
|
21
|
-
DOES_NOT_END = 'not_end'
|
22
|
-
ENDS = 'end'
|
23
|
-
NOT_TRUE = 'not_true'
|
24
|
-
TRUE = 'true'
|
25
|
-
NOT_FALSE = 'not_false'
|
26
|
-
FALSE = 'false'
|
27
|
-
BLANK = 'blank'
|
28
|
-
PRESENT = 'present'
|
29
|
-
NOT_NULL = 'not_null'
|
30
|
-
NULL = 'null'
|
31
|
-
NOT_IN = 'not_in'
|
32
|
-
IN = 'in'
|
33
|
-
NOT_CONT_ANY = 'not_cont_any'
|
34
|
-
CONT_ANY = 'cont_any'
|
10
|
+
NOT_EQ = 'not_eq'
|
11
|
+
EQ = 'eq'
|
12
|
+
DOES_NOT_MATCH = 'does_not_match'
|
13
|
+
MATCHES = 'matches'
|
14
|
+
GT = 'gt'
|
15
|
+
LT = 'lt'
|
16
|
+
GTEQ = 'gteq'
|
17
|
+
LTEQ = 'lteq'
|
18
|
+
NOT_CONT = 'not_cont'
|
19
|
+
CONT = 'cont'
|
20
|
+
NOT_START = 'not_start'
|
21
|
+
START = 'start'
|
22
|
+
DOES_NOT_END = 'not_end'
|
23
|
+
ENDS = 'end'
|
24
|
+
NOT_TRUE = 'not_true'
|
25
|
+
TRUE = 'true'
|
26
|
+
NOT_FALSE = 'not_false'
|
27
|
+
FALSE = 'false'
|
28
|
+
BLANK = 'blank'
|
29
|
+
PRESENT = 'present'
|
30
|
+
NOT_NULL = 'not_null'
|
31
|
+
NULL = 'null'
|
32
|
+
NOT_IN = 'not_in'
|
33
|
+
IN = 'in'
|
34
|
+
NOT_CONT_ANY = 'not_cont_any'
|
35
|
+
CONT_ANY = 'cont_any'
|
35
36
|
|
36
37
|
@predicates_on_value = Set.new([
|
37
38
|
NOT_EQ, EQ,
|
@@ -1,12 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'active_support/core_ext/module/delegation'
|
3
|
-
require 'active_model/validator'
|
4
|
-
require 'active_model/validations'
|
5
|
-
require 'active_model/naming'
|
6
|
-
require 'active_model/callbacks'
|
7
|
-
require 'active_model/translation'
|
8
|
-
require 'active_model/errors'
|
9
|
-
|
1
|
+
# frozen_string_literal: true
|
10
2
|
module Might
|
11
3
|
# Build singleton validation class for specified attribute name
|
12
4
|
# @example you need a nice validator for a first_name
|
@@ -30,7 +22,7 @@ module Might
|
|
30
22
|
include ActiveModel::Validations
|
31
23
|
|
32
24
|
validates(definition.as, definition.validations) if definition.validations.present?
|
33
|
-
validates(definition.as,
|
25
|
+
validates(definition.as, 'might/filter_value_validator/defined': true)
|
34
26
|
|
35
27
|
define_method(:undefined?) { definition.undefined? }
|
36
28
|
|
@@ -1,13 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'active_support/core_ext/module/delegation'
|
3
|
-
require 'active_support/callbacks'
|
4
|
-
require 'active_model/naming'
|
5
|
-
require 'active_model/validator'
|
6
|
-
require 'active_model/callbacks'
|
7
|
-
require 'active_model/translation'
|
8
|
-
require 'active_model/errors'
|
9
|
-
require 'active_model/validations'
|
10
|
-
|
1
|
+
# frozen_string_literal: true
|
11
2
|
module Might
|
12
3
|
#
|
13
4
|
class PaginationParametersValidator
|
data/lib/might/paginator.rb
CHANGED
data/lib/might/railtie.rb
CHANGED
data/lib/might/result.rb
CHANGED
data/lib/might/sort_parameter.rb
CHANGED
@@ -1,12 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'active_support/core_ext/module/delegation'
|
3
|
-
require 'active_model/validator'
|
4
|
-
require 'active_model/validations'
|
5
|
-
require 'active_model/callbacks'
|
6
|
-
require 'active_model/naming'
|
7
|
-
require 'active_model/translation'
|
8
|
-
require 'active_model/errors'
|
9
|
-
|
1
|
+
# frozen_string_literal: true
|
10
2
|
module Might
|
11
3
|
# Build singleton validation class for specified attribute name
|
12
4
|
# @example you need a nice validator for a first_name
|
@@ -29,7 +21,7 @@ module Might
|
|
29
21
|
Class.new do
|
30
22
|
include ActiveModel::Validations
|
31
23
|
|
32
|
-
validates(definition.name,
|
24
|
+
validates(definition.name, 'might/sort_value_validator/defined': true)
|
33
25
|
|
34
26
|
define_method(:undefined?) { definition.undefined? }
|
35
27
|
define_method(definition.name) {}
|
data/lib/might/version.rb
CHANGED
data/might.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'might/version'
|
@@ -26,9 +27,10 @@ Gem::Specification.new do |spec|
|
|
26
27
|
spec.add_runtime_dependency 'ransack', '>= 1.6.6'
|
27
28
|
spec.add_development_dependency 'activerecord', '>= 3.2', '< 6.0.0'
|
28
29
|
spec.add_development_dependency 'sqlite3', '~> 1.3.11'
|
29
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.13.7'
|
30
31
|
spec.add_development_dependency 'rake', '~> 11.2.2'
|
31
32
|
spec.add_development_dependency 'rspec', '~> 3.5.0'
|
32
33
|
spec.add_development_dependency 'spbtv_code_style', '1.4.1'
|
33
34
|
spec.add_development_dependency 'appraisal', '2.1.0'
|
35
|
+
spec.add_development_dependency 'rubocop', '0.40.0'
|
34
36
|
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.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tema Bolshakov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -120,14 +120,14 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 1.
|
123
|
+
version: 1.13.7
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 1.
|
130
|
+
version: 1.13.7
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rake
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,6 +184,20 @@ dependencies:
|
|
184
184
|
- - '='
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: 2.1.0
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: rubocop
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - '='
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: 0.40.0
|
194
|
+
type: :development
|
195
|
+
prerelease: false
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - '='
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: 0.40.0
|
187
201
|
description: Mighty resource fetchers build on top of Ransack gem
|
188
202
|
email:
|
189
203
|
- abolshakov@spbtv.com
|
@@ -191,6 +205,7 @@ executables: []
|
|
191
205
|
extensions: []
|
192
206
|
extra_rdoc_files: []
|
193
207
|
files:
|
208
|
+
- ".codeclimate.yml"
|
194
209
|
- ".gitignore"
|
195
210
|
- ".hound.yml"
|
196
211
|
- ".rspec"
|
@@ -264,4 +279,3 @@ signing_key:
|
|
264
279
|
specification_version: 4
|
265
280
|
summary: Mighty resource fetchers
|
266
281
|
test_files: []
|
267
|
-
has_rdoc:
|