mutils 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +5 -6
- data/CHANGELOG.md +20 -14
- data/Gemfile.lock +6 -6
- data/README.md +23 -4
- data/Version +1 -1
- data/lib/mutils/serialization/results/main.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67eb1dec44388d87c512b85b863039ab36f5721ca1f98a5329f55e37b3225372
|
4
|
+
data.tar.gz: 7da273ae6b0d0f19528b6d32c862dd7715032e843e88f92ff117342691527b69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aabe155aa311002e93f842c0194af6d542f082e74fb50def80339eac8cb8d92f9585efcaa3e6ce484b174c4808e3c5921a1b43e0ac1638826de87c58c38cb670
|
7
|
+
data.tar.gz: c9c0998504123722304d254da59596f30504cea2d85582f6c75cfc0cef4c76bb80c09e45f86aba2ca74b3865d58c1ea87d3690254157684b6c1a302dc17c29f4
|
data/.github/dependabot.yml
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
-
# package ecosystems to update and where the package manifests are located.
|
3
|
-
# Please see the documentation for all configuration options:
|
4
|
-
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
-
|
6
1
|
version: 2
|
7
2
|
updates:
|
8
3
|
- package-ecosystem: "bundler"
|
9
|
-
directory: "/"
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: "daily"
|
7
|
+
- package-ecosystem: "npm"
|
8
|
+
directory: "/"
|
10
9
|
schedule:
|
11
10
|
interval: "daily"
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [1.1.0](https://github.com/Code-Vedas/mutils/compare/v1.0.1...v1.1.0) (2020-08-15)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* **params:** conditional if:Proc get params as second attribute ([55a3b08](https://github.com/Code-Vedas/mutils/commit/55a3b08fee52c0dbef2b22c6e4f468389f8c53a4))
|
7
|
+
|
1
8
|
## [1.0.1](https://github.com/Code-Vedas/mutils/compare/v1.0.0...v1.0.1) (2020-07-24)
|
2
9
|
|
3
10
|
|
@@ -5,8 +12,7 @@
|
|
5
12
|
|
6
13
|
* **semantic-release:** enable semantic-release ([aa9c28f](https://github.com/Code-Vedas/mutils/commit/aa9c28fb8da7fcd1915a189bda22f8421a566eee))
|
7
14
|
|
8
|
-
|
9
|
-
## [v1.0.0](https://github.com/code-vedas/mutils/tree/v0.2.36) (2020-04-17)
|
15
|
+
## [1.0.0](https://github.com/code-vedas/mutils/tree/v0.2.36) (2020-04-17)
|
10
16
|
|
11
17
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.36...v1.0.0)
|
12
18
|
|
@@ -19,7 +25,7 @@
|
|
19
25
|
- Code refactored
|
20
26
|
- Using cache for expensive operations
|
21
27
|
|
22
|
-
## [
|
28
|
+
## [0.2.36](https://github.com/code-vedas/mutils/tree/v0.2.36) (2020-04-14)
|
23
29
|
|
24
30
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.35...v0.2.36)
|
25
31
|
|
@@ -29,7 +35,7 @@
|
|
29
35
|
- Conditional attributes and relations [\#32](https://github.com/code-vedas/mutils/pull/32) ([niteshpurohit](https://github.com/niteshpurohit))
|
30
36
|
- chore: add more ruby version and os to test [\#31](https://github.com/code-vedas/mutils/pull/31) ([niteshpurohit](https://github.com/niteshpurohit))
|
31
37
|
|
32
|
-
## [
|
38
|
+
## [0.2.35](https://github.com/code-vedas/mutils/tree/v0.2.35) (2020-03-30)
|
33
39
|
|
34
40
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.34...v0.2.35)
|
35
41
|
|
@@ -39,7 +45,7 @@
|
|
39
45
|
- added custom\_method and attribute example [\#29](https://github.com/code-vedas/mutils/pull/29) ([niteshpurohit](https://github.com/niteshpurohit))
|
40
46
|
- chore: update changelog [\#28](https://github.com/code-vedas/mutils/pull/28) ([niteshpurohit](https://github.com/niteshpurohit))
|
41
47
|
|
42
|
-
## [
|
48
|
+
## [0.2.34](https://github.com/code-vedas/mutils/tree/v0.2.34) (2020-03-29)
|
43
49
|
|
44
50
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.33...v0.2.34)
|
45
51
|
|
@@ -47,7 +53,7 @@
|
|
47
53
|
|
48
54
|
- Feature/attribute can be optional [\#27](https://github.com/code-vedas/mutils/pull/27) ([niteshpurohit](https://github.com/niteshpurohit))
|
49
55
|
|
50
|
-
## [
|
56
|
+
## [0.2.33](https://github.com/code-vedas/mutils/tree/v0.2.33) (2020-03-29)
|
51
57
|
|
52
58
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.32...v0.2.33)
|
53
59
|
|
@@ -58,7 +64,7 @@
|
|
58
64
|
- Create .codeclimate.yml [\#24](https://github.com/code-vedas/mutils/pull/24) ([niteshpurohit](https://github.com/niteshpurohit))
|
59
65
|
- changelog: v0.2.32 [\#22](https://github.com/code-vedas/mutils/pull/22) ([niteshpurohit](https://github.com/niteshpurohit))
|
60
66
|
|
61
|
-
## [
|
67
|
+
## [0.2.32](https://github.com/code-vedas/mutils/tree/v0.2.32) (2020-03-18)
|
62
68
|
|
63
69
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.31...v0.2.32)
|
64
70
|
|
@@ -66,7 +72,7 @@
|
|
66
72
|
|
67
73
|
- Feature/improve performance [\#21](https://github.com/code-vedas/mutils/pull/21) ([niteshpurohit](https://github.com/niteshpurohit))
|
68
74
|
|
69
|
-
## [
|
75
|
+
## [0.2.31](https://github.com/code-vedas/mutils/tree/v0.2.31) (2020-03-18)
|
70
76
|
|
71
77
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.30...v0.2.31)
|
72
78
|
|
@@ -75,7 +81,7 @@
|
|
75
81
|
- Update version.rb [\#20](https://github.com/code-vedas/mutils/pull/20) ([niteshpurohit](https://github.com/niteshpurohit))
|
76
82
|
- Rake 13.0 [\#19](https://github.com/code-vedas/mutils/pull/19) ([niteshpurohit](https://github.com/niteshpurohit))
|
77
83
|
|
78
|
-
## [
|
84
|
+
## [0.2.30](https://github.com/code-vedas/mutils/tree/v0.2.30) (2020-03-17)
|
79
85
|
|
80
86
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.29...v0.2.30)
|
81
87
|
|
@@ -83,7 +89,7 @@
|
|
83
89
|
|
84
90
|
- Deps [\#18](https://github.com/code-vedas/mutils/pull/18) ([niteshpurohit](https://github.com/niteshpurohit))
|
85
91
|
|
86
|
-
## [
|
92
|
+
## [0.2.29](https://github.com/code-vedas/mutils/tree/v0.2.29) (2019-12-07)
|
87
93
|
|
88
94
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.28...v0.2.29)
|
89
95
|
|
@@ -91,7 +97,7 @@
|
|
91
97
|
|
92
98
|
- Scope Variable bug [\#14](https://github.com/code-vedas/mutils/pull/14) ([niteshpurohit](https://github.com/niteshpurohit))
|
93
99
|
|
94
|
-
## [
|
100
|
+
## [0.2.28](https://github.com/code-vedas/mutils/tree/v0.2.28) (2019-11-26)
|
95
101
|
|
96
102
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.27...v0.2.28)
|
97
103
|
|
@@ -99,7 +105,7 @@
|
|
99
105
|
|
100
106
|
- Feature/scoped generator [\#13](https://github.com/code-vedas/mutils/pull/13) ([niteshpurohit](https://github.com/niteshpurohit))
|
101
107
|
|
102
|
-
## [
|
108
|
+
## [0.2.27](https://github.com/code-vedas/mutils/tree/v0.2.27) (2019-11-25)
|
103
109
|
|
104
110
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.26...v0.2.27)
|
105
111
|
|
@@ -116,11 +122,11 @@
|
|
116
122
|
- Update README.md [\#7](https://github.com/code-vedas/mutils/pull/7) ([niteshpurohit](https://github.com/niteshpurohit))
|
117
123
|
- Update README.md [\#6](https://github.com/code-vedas/mutils/pull/6) ([niteshpurohit](https://github.com/niteshpurohit))
|
118
124
|
|
119
|
-
## [
|
125
|
+
## [0.2.26](https://github.com/code-vedas/mutils/tree/v0.2.26) (2019-11-24)
|
120
126
|
|
121
127
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.25...v0.2.26)
|
122
128
|
|
123
|
-
## [
|
129
|
+
## [0.2.25](https://github.com/code-vedas/mutils/tree/v0.2.25) (2019-11-24)
|
124
130
|
|
125
131
|
[Full Changelog](https://github.com/code-vedas/mutils/compare/885f96959dd3701ac20ed0981b920be753c00db0...v0.2.25)
|
126
132
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mutils (1.0.
|
4
|
+
mutils (1.0.1)
|
5
5
|
dry-inflector
|
6
6
|
|
7
7
|
GEM
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
dry-inflector (0.2.0)
|
23
23
|
json (2.3.0)
|
24
24
|
json (2.3.0-java)
|
25
|
-
parallel (1.19.
|
25
|
+
parallel (1.19.2)
|
26
26
|
parser (2.7.1.4)
|
27
27
|
ast (~> 2.4.1)
|
28
28
|
pluginator (1.5.0)
|
@@ -51,17 +51,17 @@ GEM
|
|
51
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
52
|
rspec-support (~> 3.9.0)
|
53
53
|
rspec-support (3.9.2)
|
54
|
-
rubocop (0.
|
54
|
+
rubocop (0.89.1)
|
55
55
|
parallel (~> 1.10)
|
56
56
|
parser (>= 2.7.1.1)
|
57
57
|
rainbow (>= 2.2.2, < 4.0)
|
58
58
|
regexp_parser (>= 1.7)
|
59
59
|
rexml
|
60
|
-
rubocop-ast (>= 0.
|
60
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
61
61
|
ruby-progressbar (~> 1.7)
|
62
62
|
unicode-display_width (>= 1.4.0, < 2.0)
|
63
|
-
rubocop-ast (0.
|
64
|
-
parser (>= 2.7.
|
63
|
+
rubocop-ast (0.3.0)
|
64
|
+
parser (>= 2.7.1.4)
|
65
65
|
ruby-progressbar (1.10.1)
|
66
66
|
simplecov (0.16.1)
|
67
67
|
docile (~> 1.1)
|
data/README.md
CHANGED
@@ -101,7 +101,11 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
|
|
101
101
|
end
|
102
102
|
```
|
103
103
|
### Conditional Attributes
|
104
|
-
|
104
|
+
Serializer can have conditional attributes with `if: Proc`
|
105
|
+
`if: Proc` block can receive `scope` and `params` as arguments
|
106
|
+
|
107
|
+
- __in proc {|scope|}__, scope is object which is being serialized
|
108
|
+
- __in proc {|scope,params|}__, scope is object which is being serialized and params is hash given to Serializer as second arguments in {params:anything}
|
105
109
|
```ruby
|
106
110
|
# frozen_string_literal: true
|
107
111
|
|
@@ -109,11 +113,20 @@ Attributes are fields in the model itself. You can reference them by below examp
|
|
109
113
|
class UserSerializer < Mutils::Serialization::BaseSerializer
|
110
114
|
attributes :id, :first_name, :last_name
|
111
115
|
attribute :email, if: proc { |scope| scope.name == 'mutils' } ## Email will only serialize if user's name is 'mutils'
|
116
|
+
# OR with Params
|
117
|
+
attribute :email, if: proc { |scope,params| params && params[:show_email] == true } ## Email will only serialize if params[:show_email] is true
|
112
118
|
end
|
119
|
+
|
120
|
+
UserSerializer.new(user) # Without params
|
121
|
+
UserSerializer.new(user,{params:{show_email:true}}) # With params
|
113
122
|
```
|
114
|
-
|
123
|
+
|
115
124
|
### Conditional Relations
|
116
|
-
|
125
|
+
Serializer can have conditional relations with `if: Proc`
|
126
|
+
`if: Proc` block can receive `scope` and `params` as arguments
|
127
|
+
|
128
|
+
- __in proc {|scope|}__, scope is object which is being serialized
|
129
|
+
- __in proc {|scope,params|}__, scope is object which is being serialized and params is hash given to Serializer as second arguments in {params:anything}
|
117
130
|
```ruby
|
118
131
|
# frozen_string_literal: true
|
119
132
|
|
@@ -122,9 +135,15 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
|
|
122
135
|
attributes :id, :first_name, :last_name
|
123
136
|
has_many :comments, serializer: CommentSerializer, if: proc { |scope| scope.name == 'mutils' } ## comments will only serialize if user's name is 'mutils'
|
124
137
|
belongs_to :account, serializer: AccountSerializer, if: proc { |scope| scope.name != 'mutils' } ## account will only serialize if user's name is not 'mutils'
|
138
|
+
# OR with Params
|
139
|
+
belongs_to :account, serializer: AccountSerializer, if: proc { |scope,params| params && params[:show_account] == true } ## account will only serialize if params[:show_account] is true
|
125
140
|
end
|
141
|
+
|
142
|
+
UserSerializer.new(user) # Without params
|
143
|
+
UserSerializer.new(user,{params:{show_account:true}}) # With params
|
144
|
+
|
126
145
|
```
|
127
|
-
|
146
|
+
|
128
147
|
### Attributes Blocks
|
129
148
|
While writting attribute a block can be provided for useful transformations like `full_name` as shown below
|
130
149
|
```ruby
|
data/Version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v1.0
|
1
|
+
v1.1.0
|
@@ -29,7 +29,7 @@ module Mutils
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def check_if_included(s_options, key)
|
32
|
-
return s_options[:if].call(scope) unless s_options[:if].nil? || scope_is_collection?
|
32
|
+
return s_options[:if].call(scope, options[:params]) unless s_options[:if].nil? || scope_is_collection?
|
33
33
|
|
34
34
|
s_options[:always_include] || options[:includes]&.include?(key)
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nitesh Purohit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|
@@ -110,7 +110,7 @@ licenses:
|
|
110
110
|
- MIT
|
111
111
|
metadata:
|
112
112
|
bug_tracker_uri: https://github.com/code-vedas/mutils/issues
|
113
|
-
source_code_uri: https://github.com/code-vedas/mutils/tree/v1.0
|
113
|
+
source_code_uri: https://github.com/code-vedas/mutils/tree/v1.1.0
|
114
114
|
post_install_message:
|
115
115
|
rdoc_options: []
|
116
116
|
require_paths:
|