mutils 0.2.37 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 926c4b4de85c53430599d8d3f0bedc06992bba7475f5bfb63c17c0149b9f5e7c
4
- data.tar.gz: 510912f1df040bb65dc4b13d92c7e1e9c3cd976bd29a089dd87449bae7a58813
3
+ metadata.gz: 3bae9a5bf148506da670aefb73cdd40696249e3c4b333730cb9be09f2a1bf175
4
+ data.tar.gz: c54e0b03b2e04278fa5ed591b9143b8e1f18cc25645b602cc7a8e5b92d92da61
5
5
  SHA512:
6
- metadata.gz: 93232e13da63e6c1dd76a44e0bbce37a0fd0ef030bca6b099c47e8529e4ea4522edcf0b5aaca07c19e9aaba9cf0c9febbfceef651544aadbf5170395c444dd64
7
- data.tar.gz: d9fdd7f409e3c7d9dde57ed7a59504aca0145c2dc93f054cd9a6e75b390940f111fb827e352c7510b46864f37175abd266b0f40407b9c4414e6207cdd1baca75
6
+ metadata.gz: 7d345ab04715eeda889499df8e943cb1862db55117cc65000ed67b4a7899ae5ad87218bf3f0f620e6a32871a5ce4036223fe7e9fd10f40a8d26e16248718d9ec
7
+ data.tar.gz: be915ee7e6361dd88226e68aea8c7bbc280f360c23229493611efa561dcd20d0d3be4d578cb62d343d862e773d80cd55da09bfe77765e683fc08e6c0d67e50b1
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
7
+ - package-ecosystem: "npm"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  .rspec_status
12
12
  .idea/*
13
13
  *.gem
14
+ /node_modules
@@ -0,0 +1,7 @@
1
+ {
2
+ "husky": {
3
+ "hooks": {
4
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
5
+ }
6
+ }
7
+ }
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
- --format documentation
2
1
  --color
3
2
  --require spec_helper
@@ -4,5 +4,4 @@ AllCops:
4
4
  TargetRubyVersion: "2.5.0"
5
5
  Exclude:
6
6
  - 'spec/**/*'
7
- - 'test/**/*'
8
- - 'benchmark/benchmark-serializer-json.rb'
7
+ - 'test/**/*'
@@ -37,6 +37,8 @@ Layout/LineLength:
37
37
  Max: 608
38
38
  Metrics/MethodLength:
39
39
  Max: 20
40
+ Metrics/PerceivedComplexity:
41
+ Max: 7
40
42
  Metrics/AbcSize:
41
43
  Max: 22
42
44
  Style/HashEachMethods:
@@ -12,7 +12,18 @@ cache: bundler
12
12
  before_install:
13
13
  - gem install bundler -v 2.0.1
14
14
  - gem install rspec
15
- script: bundle exec rspec
15
+ - nvm use 11
16
+ - npm install
17
+ script: bundle exec rubocop lib && bundle exec rspec
16
18
  branches:
17
19
  only: master
18
- bundler_args: --with=development,test --jobs=3 --retry=3
20
+ bundler_args: --with=development,test --jobs=3 --retry=3
21
+ jobs:
22
+ include:
23
+ - stage: release
24
+ rvm: 2.6.5
25
+ script: npx semantic-release
26
+ stages:
27
+ - test
28
+ - name: release
29
+ if: (NOT type IN (pull_request)) AND (branch = master)
@@ -1,6 +1,45 @@
1
- # Changelog
1
+ ## [1.1.2](https://github.com/Code-Vedas/mutils/compare/v1.1.1...v1.1.2) (2020-10-15)
2
2
 
3
- ## [v0.2.36](https://github.com/code-vedas/mutils/tree/v0.2.36) (2020-04-14)
3
+
4
+ ### Bug Fixes
5
+
6
+ * **coveralls:** gemfile to reduce vulnerabilities ([#64](https://github.com/Code-Vedas/mutils/issues/64)) ([7d4e592](https://github.com/Code-Vedas/mutils/commit/7d4e59214d5c9aced1c4beb1a6b9f929367d84da))
7
+
8
+ ## [1.1.1](https://github.com/Code-Vedas/mutils/compare/v1.1.0...v1.1.1) (2020-10-05)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **params:** always send hash in params ([7d71b6d](https://github.com/Code-Vedas/mutils/commit/7d71b6d2c89f39883745a40e5472c444b5673e8b))
14
+
15
+ # [1.1.0](https://github.com/Code-Vedas/mutils/compare/v1.0.1...v1.1.0) (2020-08-15)
16
+
17
+
18
+ ### Features
19
+
20
+ * **params:** conditional if:Proc get params as second attribute ([55a3b08](https://github.com/Code-Vedas/mutils/commit/55a3b08fee52c0dbef2b22c6e4f468389f8c53a4))
21
+
22
+ ## [1.0.1](https://github.com/Code-Vedas/mutils/compare/v1.0.0...v1.0.1) (2020-07-24)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **semantic-release:** enable semantic-release ([aa9c28f](https://github.com/Code-Vedas/mutils/commit/aa9c28fb8da7fcd1915a189bda22f8421a566eee))
28
+
29
+ ## [1.0.0](https://github.com/code-vedas/mutils/tree/v0.2.36) (2020-04-17)
30
+
31
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.36...v1.0.0)
32
+
33
+ **First Stable release: Features**
34
+ - Performance upto 35i/s under load
35
+ - Observed 35-40 MB of memory usage
36
+ - Fully featured JSON serializer similar to Active Serializer but with more power and speed.
37
+
38
+ **Changes:**
39
+ - Code refactored
40
+ - Using cache for expensive operations
41
+
42
+ ## [0.2.36](https://github.com/code-vedas/mutils/tree/v0.2.36) (2020-04-14)
4
43
 
5
44
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.35...v0.2.36)
6
45
 
@@ -10,7 +49,7 @@
10
49
  - Conditional attributes and relations [\#32](https://github.com/code-vedas/mutils/pull/32) ([niteshpurohit](https://github.com/niteshpurohit))
11
50
  - chore: add more ruby version and os to test [\#31](https://github.com/code-vedas/mutils/pull/31) ([niteshpurohit](https://github.com/niteshpurohit))
12
51
 
13
- ## [v0.2.35](https://github.com/code-vedas/mutils/tree/v0.2.35) (2020-03-30)
52
+ ## [0.2.35](https://github.com/code-vedas/mutils/tree/v0.2.35) (2020-03-30)
14
53
 
15
54
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.34...v0.2.35)
16
55
 
@@ -20,7 +59,7 @@
20
59
  - added custom\_method and attribute example [\#29](https://github.com/code-vedas/mutils/pull/29) ([niteshpurohit](https://github.com/niteshpurohit))
21
60
  - chore: update changelog [\#28](https://github.com/code-vedas/mutils/pull/28) ([niteshpurohit](https://github.com/niteshpurohit))
22
61
 
23
- ## [v0.2.34](https://github.com/code-vedas/mutils/tree/v0.2.34) (2020-03-29)
62
+ ## [0.2.34](https://github.com/code-vedas/mutils/tree/v0.2.34) (2020-03-29)
24
63
 
25
64
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.33...v0.2.34)
26
65
 
@@ -28,7 +67,7 @@
28
67
 
29
68
  - Feature/attribute can be optional [\#27](https://github.com/code-vedas/mutils/pull/27) ([niteshpurohit](https://github.com/niteshpurohit))
30
69
 
31
- ## [v0.2.33](https://github.com/code-vedas/mutils/tree/v0.2.33) (2020-03-29)
70
+ ## [0.2.33](https://github.com/code-vedas/mutils/tree/v0.2.33) (2020-03-29)
32
71
 
33
72
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.32...v0.2.33)
34
73
 
@@ -39,7 +78,7 @@
39
78
  - Create .codeclimate.yml [\#24](https://github.com/code-vedas/mutils/pull/24) ([niteshpurohit](https://github.com/niteshpurohit))
40
79
  - changelog: v0.2.32 [\#22](https://github.com/code-vedas/mutils/pull/22) ([niteshpurohit](https://github.com/niteshpurohit))
41
80
 
42
- ## [v0.2.32](https://github.com/code-vedas/mutils/tree/v0.2.32) (2020-03-18)
81
+ ## [0.2.32](https://github.com/code-vedas/mutils/tree/v0.2.32) (2020-03-18)
43
82
 
44
83
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.31...v0.2.32)
45
84
 
@@ -47,7 +86,7 @@
47
86
 
48
87
  - Feature/improve performance [\#21](https://github.com/code-vedas/mutils/pull/21) ([niteshpurohit](https://github.com/niteshpurohit))
49
88
 
50
- ## [v0.2.31](https://github.com/code-vedas/mutils/tree/v0.2.31) (2020-03-18)
89
+ ## [0.2.31](https://github.com/code-vedas/mutils/tree/v0.2.31) (2020-03-18)
51
90
 
52
91
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.30...v0.2.31)
53
92
 
@@ -56,7 +95,7 @@
56
95
  - Update version.rb [\#20](https://github.com/code-vedas/mutils/pull/20) ([niteshpurohit](https://github.com/niteshpurohit))
57
96
  - Rake 13.0 [\#19](https://github.com/code-vedas/mutils/pull/19) ([niteshpurohit](https://github.com/niteshpurohit))
58
97
 
59
- ## [v0.2.30](https://github.com/code-vedas/mutils/tree/v0.2.30) (2020-03-17)
98
+ ## [0.2.30](https://github.com/code-vedas/mutils/tree/v0.2.30) (2020-03-17)
60
99
 
61
100
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.29...v0.2.30)
62
101
 
@@ -64,7 +103,7 @@
64
103
 
65
104
  - Deps [\#18](https://github.com/code-vedas/mutils/pull/18) ([niteshpurohit](https://github.com/niteshpurohit))
66
105
 
67
- ## [v0.2.29](https://github.com/code-vedas/mutils/tree/v0.2.29) (2019-12-07)
106
+ ## [0.2.29](https://github.com/code-vedas/mutils/tree/v0.2.29) (2019-12-07)
68
107
 
69
108
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.28...v0.2.29)
70
109
 
@@ -72,7 +111,7 @@
72
111
 
73
112
  - Scope Variable bug [\#14](https://github.com/code-vedas/mutils/pull/14) ([niteshpurohit](https://github.com/niteshpurohit))
74
113
 
75
- ## [v0.2.28](https://github.com/code-vedas/mutils/tree/v0.2.28) (2019-11-26)
114
+ ## [0.2.28](https://github.com/code-vedas/mutils/tree/v0.2.28) (2019-11-26)
76
115
 
77
116
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.27...v0.2.28)
78
117
 
@@ -80,7 +119,7 @@
80
119
 
81
120
  - Feature/scoped generator [\#13](https://github.com/code-vedas/mutils/pull/13) ([niteshpurohit](https://github.com/niteshpurohit))
82
121
 
83
- ## [v0.2.27](https://github.com/code-vedas/mutils/tree/v0.2.27) (2019-11-25)
122
+ ## [0.2.27](https://github.com/code-vedas/mutils/tree/v0.2.27) (2019-11-25)
84
123
 
85
124
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.26...v0.2.27)
86
125
 
@@ -97,11 +136,11 @@
97
136
  - Update README.md [\#7](https://github.com/code-vedas/mutils/pull/7) ([niteshpurohit](https://github.com/niteshpurohit))
98
137
  - Update README.md [\#6](https://github.com/code-vedas/mutils/pull/6) ([niteshpurohit](https://github.com/niteshpurohit))
99
138
 
100
- ## [v0.2.26](https://github.com/code-vedas/mutils/tree/v0.2.26) (2019-11-24)
139
+ ## [0.2.26](https://github.com/code-vedas/mutils/tree/v0.2.26) (2019-11-24)
101
140
 
102
141
  [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.25...v0.2.26)
103
142
 
104
- ## [v0.2.25](https://github.com/code-vedas/mutils/tree/v0.2.25) (2019-11-24)
143
+ ## [0.2.25](https://github.com/code-vedas/mutils/tree/v0.2.25) (2019-11-24)
105
144
 
106
145
  [Full Changelog](https://github.com/code-vedas/mutils/compare/885f96959dd3701ac20ed0981b920be753c00db0...v0.2.25)
107
146
 
@@ -109,6 +148,3 @@
109
148
 
110
149
  - Feature/improve concurrency [\#4](https://github.com/code-vedas/mutils/pull/4) ([niteshpurohit](https://github.com/niteshpurohit))
111
150
  - Testing Deploy [\#3](https://github.com/code-vedas/mutils/pull/3) ([niteshpurohit](https://github.com/niteshpurohit))
112
-
113
-
114
- \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile CHANGED
@@ -3,4 +3,10 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in mutils.gemspec
6
+ gem 'coveralls'
7
+ gem 'pre-commit', require: false
8
+ gem 'rspec'
9
+ gem 'rspec-benchmark'
10
+ gem 'rspec-json_expectations'
11
+ gem 'rubocop'
6
12
  gemspec
@@ -1,12 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mutils (0.2.36)
4
+ mutils (1.1.1)
5
5
  dry-inflector
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ ast (2.4.1)
11
+ benchmark-malloc (0.2.0)
12
+ benchmark-perf (0.6.0)
13
+ benchmark-trend (0.4.0)
10
14
  coveralls (0.8.23)
11
15
  json (>= 1.8, < 3)
12
16
  simplecov (~> 0.16.1)
@@ -18,11 +22,25 @@ GEM
18
22
  dry-inflector (0.2.0)
19
23
  json (2.3.0)
20
24
  json (2.3.0-java)
25
+ parallel (1.19.2)
26
+ parser (2.7.1.4)
27
+ ast (~> 2.4.1)
28
+ pluginator (1.5.0)
29
+ pre-commit (0.39.0)
30
+ pluginator (~> 1.5)
31
+ rainbow (3.0.0)
21
32
  rake (13.0.1)
33
+ regexp_parser (1.7.1)
34
+ rexml (3.2.4)
22
35
  rspec (3.9.0)
23
36
  rspec-core (~> 3.9.0)
24
37
  rspec-expectations (~> 3.9.0)
25
38
  rspec-mocks (~> 3.9.0)
39
+ rspec-benchmark (0.6.0)
40
+ benchmark-malloc (~> 0.2)
41
+ benchmark-perf (~> 0.6)
42
+ benchmark-trend (~> 0.4)
43
+ rspec (>= 3.0)
26
44
  rspec-core (3.9.1)
27
45
  rspec-support (~> 3.9.1)
28
46
  rspec-expectations (3.9.1)
@@ -33,6 +51,18 @@ GEM
33
51
  diff-lcs (>= 1.2.0, < 2.0)
34
52
  rspec-support (~> 3.9.0)
35
53
  rspec-support (3.9.2)
54
+ rubocop (0.89.1)
55
+ parallel (~> 1.10)
56
+ parser (>= 2.7.1.1)
57
+ rainbow (>= 2.2.2, < 4.0)
58
+ regexp_parser (>= 1.7)
59
+ rexml
60
+ rubocop-ast (>= 0.3.0, < 1.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (>= 1.4.0, < 2.0)
63
+ rubocop-ast (0.3.0)
64
+ parser (>= 2.7.1.4)
65
+ ruby-progressbar (1.10.1)
36
66
  simplecov (0.16.1)
37
67
  docile (~> 1.1)
38
68
  json (>= 1.8, < 3)
@@ -44,6 +74,7 @@ GEM
44
74
  thor (1.0.1)
45
75
  tins (1.24.1)
46
76
  sync
77
+ unicode-display_width (1.7.0)
47
78
 
48
79
  PLATFORMS
49
80
  java
@@ -53,9 +84,12 @@ DEPENDENCIES
53
84
  bundler (~> 2.0)
54
85
  coveralls
55
86
  mutils!
87
+ pre-commit
56
88
  rake (~> 13.0)
57
89
  rspec
90
+ rspec-benchmark
58
91
  rspec-json_expectations
92
+ rubocop
59
93
 
60
94
  BUNDLED WITH
61
95
  2.1.4
data/README.md CHANGED
@@ -26,7 +26,7 @@ These collection of modules are built by developer for developers :-)
26
26
 
27
27
  ## Features
28
28
  * Simple declaration syntax similar to Active Model Serializer
29
- * Realtionships support `belongs_to', `has_many`, `has_one`
29
+ * Realtionships support `belongs_to`, `has_many`, `has_one`
30
30
  * Block style attributes with params
31
31
 
32
32
  ## Installation
@@ -89,7 +89,7 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
89
89
  attributes :id, :first_name, :last_name, :email
90
90
 
91
91
  belongs_to :company, serializer: CompanySerializer, always_include: true
92
- ##OR
92
+ ## OR
93
93
  belongs_to :company, serializer: CompanySerializer, always_include: true, label: 'organization' ##<== important to give singular name
94
94
 
95
95
  has_many :comments, serializer: CommentSerializer
@@ -101,7 +101,11 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
101
101
  end
102
102
  ```
103
103
  ### Conditional Attributes
104
- Attributes are fields in the model itself. You can reference them by below example
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
- in proc {|scope|}, scope is object which is being serialized
123
+
115
124
  ### Conditional Relations
116
- Attributes are fields in the model itself. You can reference them by below example
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
- in proc {|scope|}, scope is object which is being serialized
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
@@ -209,13 +228,13 @@ user = User.first
209
228
  options = {includes: [:comments,:account]}
210
229
  UserSerializer.new(user,options).to_h
211
230
  ```
212
- ###or
231
+ ### or
213
232
  ```ruby
214
233
  users = User.all
215
234
  options = {includes: [:account]}
216
235
  UserSerializer.new(users,options).to_json
217
236
  ```
218
- ###or in controllers
237
+ ### or in controllers
219
238
  ```ruby
220
239
  users = User.all
221
240
  options = {includes: [:account]}
@@ -234,3 +253,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
234
253
  ## Code of Conduct
235
254
 
236
255
  Everyone interacting in the Mutils project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/code-vedas/mutils/blob/master/CODE_OF_CONDUCT.md).
256
+
257
+ ## Security
258
+
259
+ For security refer to [security](https://github.com/Code-Vedas/mutils/blob/master/SECURITY.md) document.
@@ -0,0 +1,13 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Versions currently being supported with security updates.
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 1.x.x | :white_check_mark: |
10
+
11
+ ## Reporting a Vulnerability
12
+
13
+ Create an issue or email at security@codevedas.com
data/Version ADDED
@@ -0,0 +1 @@
1
+ v1.1.2
@@ -0,0 +1 @@
1
+ module.exports = {extends: ['@commitlint/config-angular']};
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ mkdir -p $HOME/.gem
6
+ touch $HOME/.gem/credentials
7
+ chmod 0600 $HOME/.gem/credentials
8
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
9
+ gem build *.gemspec
10
+ gem push *.gem
@@ -3,6 +3,7 @@
3
3
  require 'dry/inflector'
4
4
  require_relative 'mutils/version'
5
5
  require_relative 'mutils/lib/helper'
6
+ require_relative 'mutils/lib/result_hash'
6
7
  require_relative 'mutils/serialization/serialization_results'
7
8
  require_relative 'mutils/serialization/serialization_includes'
8
9
  require_relative 'mutils/serialization/serialization_methods'