mutils 0.2.36 → 1.1.1

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: 1331c714748c7ecdc92258a4b37ad2ebddb23bff4a5a9858eab6bcc9a08fee0f
4
- data.tar.gz: 6a9850b4e1602f656c90ce2b3fa65bd1dc15639f4aad115e8295668a5ea0f305
3
+ metadata.gz: aa28e1305e1235539317296db74c6b6509c5991c4cbacd731fe64bb70f1e32d3
4
+ data.tar.gz: ef7699f142663ee8a61d69c6f2059e657d35bb16606cf2d0486ec67a981da04d
5
5
  SHA512:
6
- metadata.gz: 2af97f7e2f52f822568edf377dfa135347bd506374c27ece2c86c3b82c96780e6111e6723532192175e979cfcb8885219018d7851acb12f35744a35777513b65
7
- data.tar.gz: ffd8ded7613308b8a736ed8fe6eee83de98c183c34854d22fc30b03f438dc6e1cc71cc42df9f1a3de66d3a2e1d57dde75a01678e0214df9467a3077ca09fd522
6
+ metadata.gz: 2bc5a5ee4df0ee503ff4e574a905dfd7309d30062bba0166e7f795d25378bd916cb2814494c00a64daa40ae1ccd8525031c6b155bb5f51f8f4a09157c45c5d77
7
+ data.tar.gz: e858cc6077fe7cb6cf14f2bd3dffe16acca0e974de7a0158f093a37bcfcf629d9a19f46a97656396b403e191b9d37d5140869b11f4dd32c7f9eaeb6e7ee0ab83
@@ -3,11 +3,11 @@
3
3
  We love pull requests from everyone. By participating in this project, you
4
4
  agree to abide by the [code of conduct].
5
5
 
6
- [code of conduct]: https://github.com/niteshpurohit/mutils/blob/master/CODE_OF_CONDUCT.md
6
+ [code of conduct]: https://github.com/code-vedas/mutils/blob/master/CODE_OF_CONDUCT.md
7
7
 
8
8
  Fork, then clone the repo:
9
9
 
10
- git clone git@github.com:niteshpurohit/mutils.git
10
+ git clone git@github.com:code-vedas/mutils.git
11
11
 
12
12
  Set up your machine:
13
13
 
@@ -23,7 +23,7 @@ Make your change. Add tests for your change. Make the tests pass:
23
23
 
24
24
  Push to your fork and [submit a pull request][pr].
25
25
 
26
- [pr]: https://github.com/niteshpurohit/mutils/compare/
26
+ [pr]: https://github.com/code-vedas/mutils/compare/
27
27
 
28
28
  At this point you're waiting on us. We like to at least comment on pull requests
29
29
  within three business days (and, typically, one business day). We may suggest
@@ -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:
@@ -1,20 +1,29 @@
1
- os:
2
- - linux
3
- - osx
4
1
  rvm:
5
2
  - 2.5
6
3
  - 2.6.3
7
4
  - 2.6.5
8
5
  - 2.7.0
9
6
  - 2.7.1
10
- - jruby-9.2
7
+ - jruby-9.2.5.0
8
+ - jruby-9.2.10.0
11
9
  sudo: false
12
10
  language: ruby
13
11
  cache: bundler
14
- before_install: gem install bundler -v 2.0.1
12
+ before_install:
13
+ - gem install bundler -v 2.0.1
14
+ - gem install rspec
15
+ - nvm use 11
16
+ - npm install
17
+ script: bundle exec rubocop lib && bundle exec rspec
15
18
  branches:
16
19
  only: master
17
- matrix:
18
- allow_failures:
19
- - rvm: jruby-9.2
20
- fast_finish: true
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,95 +1,143 @@
1
- # Changelog
1
+ ## [1.1.1](https://github.com/Code-Vedas/mutils/compare/v1.1.0...v1.1.1) (2020-10-05)
2
2
 
3
- ## [v0.2.34](https://github.com/niteshpurohit/mutils/tree/v0.2.34) (2020-03-29)
4
3
 
5
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.33...v0.2.34)
4
+ ### Bug Fixes
5
+
6
+ * **params:** always send hash in params ([7d71b6d](https://github.com/Code-Vedas/mutils/commit/7d71b6d2c89f39883745a40e5472c444b5673e8b))
7
+
8
+ # [1.1.0](https://github.com/Code-Vedas/mutils/compare/v1.0.1...v1.1.0) (2020-08-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * **params:** conditional if:Proc get params as second attribute ([55a3b08](https://github.com/Code-Vedas/mutils/commit/55a3b08fee52c0dbef2b22c6e4f468389f8c53a4))
14
+
15
+ ## [1.0.1](https://github.com/Code-Vedas/mutils/compare/v1.0.0...v1.0.1) (2020-07-24)
6
16
 
7
- **Merged pull requests:**
8
17
 
9
- - Feature/attribute can be optional [\#27](https://github.com/niteshpurohit/mutils/pull/27) ([niteshpurohit](https://github.com/niteshpurohit))
18
+ ### Bug Fixes
10
19
 
11
- ## [v0.2.33](https://github.com/niteshpurohit/mutils/tree/v0.2.33) (2020-03-29)
20
+ * **semantic-release:** enable semantic-release ([aa9c28f](https://github.com/Code-Vedas/mutils/commit/aa9c28fb8da7fcd1915a189bda22f8421a566eee))
12
21
 
13
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.32...v0.2.33)
22
+ ## [1.0.0](https://github.com/code-vedas/mutils/tree/v0.2.36) (2020-04-17)
23
+
24
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.36...v1.0.0)
25
+
26
+ **First Stable release: Features**
27
+ - Performance upto 35i/s under load
28
+ - Observed 35-40 MB of memory usage
29
+ - Fully featured JSON serializer similar to Active Serializer but with more power and speed.
30
+
31
+ **Changes:**
32
+ - Code refactored
33
+ - Using cache for expensive operations
34
+
35
+ ## [0.2.36](https://github.com/code-vedas/mutils/tree/v0.2.36) (2020-04-14)
36
+
37
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.35...v0.2.36)
14
38
 
15
39
  **Merged pull requests:**
16
40
 
17
- - Added new custom\_method in serializer to control if include method [\#26](https://github.com/niteshpurohit/mutils/pull/26) ([niteshpurohit](https://github.com/niteshpurohit))
18
- - Update CHANGELOG.md [\#25](https://github.com/niteshpurohit/mutils/pull/25) ([niteshpurohit](https://github.com/niteshpurohit))
19
- - Create .codeclimate.yml [\#24](https://github.com/niteshpurohit/mutils/pull/24) ([niteshpurohit](https://github.com/niteshpurohit))
20
- - changelog: v0.2.32 [\#22](https://github.com/niteshpurohit/mutils/pull/22) ([niteshpurohit](https://github.com/niteshpurohit))
41
+ - Remove active support dep [\#34](https://github.com/code-vedas/mutils/pull/34) ([niteshpurohit](https://github.com/niteshpurohit))
42
+ - Conditional attributes and relations [\#32](https://github.com/code-vedas/mutils/pull/32) ([niteshpurohit](https://github.com/niteshpurohit))
43
+ - chore: add more ruby version and os to test [\#31](https://github.com/code-vedas/mutils/pull/31) ([niteshpurohit](https://github.com/niteshpurohit))
21
44
 
22
- ## [v0.2.32](https://github.com/niteshpurohit/mutils/tree/v0.2.32) (2020-03-18)
45
+ ## [0.2.35](https://github.com/code-vedas/mutils/tree/v0.2.35) (2020-03-30)
23
46
 
24
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.31...v0.2.32)
47
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.34...v0.2.35)
25
48
 
26
49
  **Merged pull requests:**
27
50
 
28
- - Feature/improve performance [\#21](https://github.com/niteshpurohit/mutils/pull/21) ([niteshpurohit](https://github.com/niteshpurohit))
51
+ - new option 'label' for relations [\#30](https://github.com/code-vedas/mutils/pull/30) ([niteshpurohit](https://github.com/niteshpurohit))
52
+ - added custom\_method and attribute example [\#29](https://github.com/code-vedas/mutils/pull/29) ([niteshpurohit](https://github.com/niteshpurohit))
53
+ - chore: update changelog [\#28](https://github.com/code-vedas/mutils/pull/28) ([niteshpurohit](https://github.com/niteshpurohit))
29
54
 
30
- ## [v0.2.31](https://github.com/niteshpurohit/mutils/tree/v0.2.31) (2020-03-18)
55
+ ## [0.2.34](https://github.com/code-vedas/mutils/tree/v0.2.34) (2020-03-29)
31
56
 
32
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.30...v0.2.31)
57
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.33...v0.2.34)
33
58
 
34
59
  **Merged pull requests:**
35
60
 
36
- - Update version.rb [\#20](https://github.com/niteshpurohit/mutils/pull/20) ([niteshpurohit](https://github.com/niteshpurohit))
37
- - Rake 13.0 [\#19](https://github.com/niteshpurohit/mutils/pull/19) ([niteshpurohit](https://github.com/niteshpurohit))
61
+ - Feature/attribute can be optional [\#27](https://github.com/code-vedas/mutils/pull/27) ([niteshpurohit](https://github.com/niteshpurohit))
38
62
 
39
- ## [v0.2.30](https://github.com/niteshpurohit/mutils/tree/v0.2.30) (2020-03-17)
63
+ ## [0.2.33](https://github.com/code-vedas/mutils/tree/v0.2.33) (2020-03-29)
40
64
 
41
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.29...v0.2.30)
65
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.32...v0.2.33)
42
66
 
43
67
  **Merged pull requests:**
44
68
 
45
- - Deps [\#18](https://github.com/niteshpurohit/mutils/pull/18) ([niteshpurohit](https://github.com/niteshpurohit))
69
+ - Added new custom\_method in serializer to control if include method [\#26](https://github.com/code-vedas/mutils/pull/26) ([niteshpurohit](https://github.com/niteshpurohit))
70
+ - Update CHANGELOG.md [\#25](https://github.com/code-vedas/mutils/pull/25) ([niteshpurohit](https://github.com/niteshpurohit))
71
+ - Create .codeclimate.yml [\#24](https://github.com/code-vedas/mutils/pull/24) ([niteshpurohit](https://github.com/niteshpurohit))
72
+ - changelog: v0.2.32 [\#22](https://github.com/code-vedas/mutils/pull/22) ([niteshpurohit](https://github.com/niteshpurohit))
46
73
 
47
- ## [v0.2.29](https://github.com/niteshpurohit/mutils/tree/v0.2.29) (2019-12-07)
74
+ ## [0.2.32](https://github.com/code-vedas/mutils/tree/v0.2.32) (2020-03-18)
48
75
 
49
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.28...v0.2.29)
76
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.31...v0.2.32)
50
77
 
51
78
  **Merged pull requests:**
52
79
 
53
- - Scope Variable bug [\#14](https://github.com/niteshpurohit/mutils/pull/14) ([niteshpurohit](https://github.com/niteshpurohit))
80
+ - Feature/improve performance [\#21](https://github.com/code-vedas/mutils/pull/21) ([niteshpurohit](https://github.com/niteshpurohit))
54
81
 
55
- ## [v0.2.28](https://github.com/niteshpurohit/mutils/tree/v0.2.28) (2019-11-26)
82
+ ## [0.2.31](https://github.com/code-vedas/mutils/tree/v0.2.31) (2020-03-18)
56
83
 
57
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.27...v0.2.28)
84
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.30...v0.2.31)
58
85
 
59
- **Implemented enhancements:**
86
+ **Merged pull requests:**
60
87
 
61
- - Feature/scoped generator [\#13](https://github.com/niteshpurohit/mutils/pull/13) ([niteshpurohit](https://github.com/niteshpurohit))
88
+ - Update version.rb [\#20](https://github.com/code-vedas/mutils/pull/20) ([niteshpurohit](https://github.com/niteshpurohit))
89
+ - Rake 13.0 [\#19](https://github.com/code-vedas/mutils/pull/19) ([niteshpurohit](https://github.com/niteshpurohit))
62
90
 
63
- ## [v0.2.27](https://github.com/niteshpurohit/mutils/tree/v0.2.27) (2019-11-25)
91
+ ## [0.2.30](https://github.com/code-vedas/mutils/tree/v0.2.30) (2020-03-17)
64
92
 
65
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.26...v0.2.27)
93
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.29...v0.2.30)
66
94
 
67
- **Implemented enhancements:**
95
+ **Merged pull requests:**
96
+
97
+ - Deps [\#18](https://github.com/code-vedas/mutils/pull/18) ([niteshpurohit](https://github.com/niteshpurohit))
68
98
 
69
- - feat: coveralls added [\#5](https://github.com/niteshpurohit/mutils/pull/5) ([niteshpurohit](https://github.com/niteshpurohit))
99
+ ## [0.2.29](https://github.com/code-vedas/mutils/tree/v0.2.29) (2019-12-07)
100
+
101
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.28...v0.2.29)
70
102
 
71
103
  **Merged pull requests:**
72
104
 
73
- - Update CHANGELOG.md [\#12](https://github.com/niteshpurohit/mutils/pull/12) ([niteshpurohit](https://github.com/niteshpurohit))
74
- - Update version.rb [\#11](https://github.com/niteshpurohit/mutils/pull/11) ([niteshpurohit](https://github.com/niteshpurohit))
75
- - Removing code smells [\#9](https://github.com/niteshpurohit/mutils/pull/9) ([niteshpurohit](https://github.com/niteshpurohit))
76
- - Update README.md [\#8](https://github.com/niteshpurohit/mutils/pull/8) ([niteshpurohit](https://github.com/niteshpurohit))
77
- - Update README.md [\#7](https://github.com/niteshpurohit/mutils/pull/7) ([niteshpurohit](https://github.com/niteshpurohit))
78
- - Update README.md [\#6](https://github.com/niteshpurohit/mutils/pull/6) ([niteshpurohit](https://github.com/niteshpurohit))
105
+ - Scope Variable bug [\#14](https://github.com/code-vedas/mutils/pull/14) ([niteshpurohit](https://github.com/niteshpurohit))
79
106
 
80
- ## [v0.2.26](https://github.com/niteshpurohit/mutils/tree/v0.2.26) (2019-11-24)
107
+ ## [0.2.28](https://github.com/code-vedas/mutils/tree/v0.2.28) (2019-11-26)
81
108
 
82
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.25...v0.2.26)
109
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.27...v0.2.28)
83
110
 
84
- ## [v0.2.25](https://github.com/niteshpurohit/mutils/tree/v0.2.25) (2019-11-24)
111
+ **Implemented enhancements:**
85
112
 
86
- [Full Changelog](https://github.com/niteshpurohit/mutils/compare/885f96959dd3701ac20ed0981b920be753c00db0...v0.2.25)
113
+ - Feature/scoped generator [\#13](https://github.com/code-vedas/mutils/pull/13) ([niteshpurohit](https://github.com/niteshpurohit))
114
+
115
+ ## [0.2.27](https://github.com/code-vedas/mutils/tree/v0.2.27) (2019-11-25)
116
+
117
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.26...v0.2.27)
118
+
119
+ **Implemented enhancements:**
120
+
121
+ - feat: coveralls added [\#5](https://github.com/code-vedas/mutils/pull/5) ([niteshpurohit](https://github.com/niteshpurohit))
87
122
 
88
123
  **Merged pull requests:**
89
124
 
90
- - Feature/improve concurrency [\#4](https://github.com/niteshpurohit/mutils/pull/4) ([niteshpurohit](https://github.com/niteshpurohit))
91
- - Testing Deploy [\#3](https://github.com/niteshpurohit/mutils/pull/3) ([niteshpurohit](https://github.com/niteshpurohit))
125
+ - Update CHANGELOG.md [\#12](https://github.com/code-vedas/mutils/pull/12) ([niteshpurohit](https://github.com/niteshpurohit))
126
+ - Update version.rb [\#11](https://github.com/code-vedas/mutils/pull/11) ([niteshpurohit](https://github.com/niteshpurohit))
127
+ - Removing code smells [\#9](https://github.com/code-vedas/mutils/pull/9) ([niteshpurohit](https://github.com/niteshpurohit))
128
+ - Update README.md [\#8](https://github.com/code-vedas/mutils/pull/8) ([niteshpurohit](https://github.com/niteshpurohit))
129
+ - Update README.md [\#7](https://github.com/code-vedas/mutils/pull/7) ([niteshpurohit](https://github.com/niteshpurohit))
130
+ - Update README.md [\#6](https://github.com/code-vedas/mutils/pull/6) ([niteshpurohit](https://github.com/niteshpurohit))
131
+
132
+ ## [0.2.26](https://github.com/code-vedas/mutils/tree/v0.2.26) (2019-11-24)
92
133
 
134
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/v0.2.25...v0.2.26)
93
135
 
136
+ ## [0.2.25](https://github.com/code-vedas/mutils/tree/v0.2.25) (2019-11-24)
137
+
138
+ [Full Changelog](https://github.com/code-vedas/mutils/compare/885f96959dd3701ac20ed0981b920be753c00db0...v0.2.25)
139
+
140
+ **Merged pull requests:**
94
141
 
95
- \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
142
+ - Feature/improve concurrency [\#4](https://github.com/code-vedas/mutils/pull/4) ([niteshpurohit](https://github.com/niteshpurohit))
143
+ - Testing Deploy [\#3](https://github.com/code-vedas/mutils/pull/3) ([niteshpurohit](https://github.com/niteshpurohit))
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 'pre-commit', require: false
7
+ gem 'rubocop'
8
+ gem 'coveralls'
9
+ gem 'rspec'
10
+ gem 'rspec-benchmark'
11
+ gem 'rspec-json_expectations'
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.0)
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)
@@ -17,11 +21,26 @@ GEM
17
21
  docile (1.3.2)
18
22
  dry-inflector (0.2.0)
19
23
  json (2.3.0)
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)
20
32
  rake (13.0.1)
33
+ regexp_parser (1.7.1)
34
+ rexml (3.2.4)
21
35
  rspec (3.9.0)
22
36
  rspec-core (~> 3.9.0)
23
37
  rspec-expectations (~> 3.9.0)
24
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)
25
44
  rspec-core (3.9.1)
26
45
  rspec-support (~> 3.9.1)
27
46
  rspec-expectations (3.9.1)
@@ -32,6 +51,18 @@ GEM
32
51
  diff-lcs (>= 1.2.0, < 2.0)
33
52
  rspec-support (~> 3.9.0)
34
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)
35
66
  simplecov (0.16.1)
36
67
  docile (~> 1.1)
37
68
  json (>= 1.8, < 3)
@@ -43,17 +74,22 @@ GEM
43
74
  thor (1.0.1)
44
75
  tins (1.24.1)
45
76
  sync
77
+ unicode-display_width (1.7.0)
46
78
 
47
79
  PLATFORMS
80
+ java
48
81
  ruby
49
82
 
50
83
  DEPENDENCIES
51
84
  bundler (~> 2.0)
52
85
  coveralls
53
86
  mutils!
87
+ pre-commit
54
88
  rake (~> 13.0)
55
89
  rspec
90
+ rspec-benchmark
56
91
  rspec-json_expectations
92
+ rubocop
57
93
 
58
94
  BUNDLED WITH
59
95
  2.1.4
data/README.md CHANGED
@@ -1,13 +1,34 @@
1
- [![Maintainability](https://api.codeclimate.com/v1/badges/2c937dd6d25937ec41bd/maintainability)](https://codeclimate.com/github/niteshpurohit/mutils/maintainability)
1
+ [![Maintainability](https://api.codeclimate.com/v1/badges/42e8a34f839ca0c5ec45/maintainability)](https://codeclimate.com/github/code-vedas/mutils/maintainability)
2
2
  ![](https://ruby-gem-downloads-badge.herokuapp.com/mutils?type=total&color=brightgreen)
3
3
  [![Gem Version](https://badge.fury.io/rb/mutils.svg)](https://badge.fury.io/rb/mutils)
4
- [![Coverage Status](https://coveralls.io/repos/github/niteshpurohit/mutils/badge.svg?branch=feature/coverall)](https://coveralls.io/github/niteshpurohit/mutils?branch=feature/coverall)
5
- [![Build Status](https://travis-ci.com/niteshpurohit/mutils.svg?branch=master)](https://travis-ci.com/niteshpurohit/mutils)
4
+ [![Coverage Status](https://coveralls.io/repos/github/Code-Vedas/mutils/badge.svg?branch=master)](https://coveralls.io/github/Code-Vedas/mutils?branch=master)
5
+ [![Build Status](https://travis-ci.com/code-vedas/mutils.svg?branch=master)](https://travis-ci.com/code-vedas/mutils)
6
6
  # Mutils
7
7
  ## Introduction
8
8
  `mutils` is collection of useful modules for `ruby on rails` which is tested and benchmarked against high load.
9
9
 
10
10
  These collection of modules are built by developer for developers :-)
11
+ # Table of Contents
12
+
13
+ * [Features](#features)
14
+ * [Installation](#installation)
15
+ * [Usage](#usage)
16
+ * [Rails Generator](#rails-generator)
17
+ * [Attributes](#attributes)
18
+ * [Relations](#relations)
19
+ * [Conditional Attributes](#conditional-attributes)
20
+ * [Conditional Relations](#conditional-relations)
21
+ * [Attributes Block](#attributes-blocks)
22
+ * [Attributes Block with Params](#attributes-blocks-with-params)
23
+ * [Custom Methods](#custom-methods)
24
+ * [Name Tag](#name-tag)
25
+ * [Sample Usage](#sample-usage)
26
+
27
+ ## Features
28
+ * Simple declaration syntax similar to Active Model Serializer
29
+ * Realtionships support `belongs_to`, `has_many`, `has_one`
30
+ * Block style attributes with params
31
+
11
32
  ## Installation
12
33
 
13
34
  Add this line to your application's Gemfile:
@@ -22,16 +43,9 @@ Or install it yourself as:
22
43
 
23
44
  $ gem install mutils
24
45
 
25
- ## Modules
26
- | Sno | Name | Status |
27
- |:---: |:-----------------: |:------: |
28
- | 1 | Serializer - JSON | Done |
46
+ ## Usage
29
47
 
30
- ## Usage
31
- ### Serializer - JSON
32
- JSON Serializer for Active Models
33
-
34
- #### Generate Serializer by command
48
+ ### Rails Generator
35
49
  ```shell script
36
50
  rails g mutils:serializer User id first_name last_name email
37
51
 
@@ -49,15 +63,7 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
49
63
  end
50
64
  ```
51
65
 
52
- #### Decorations Available
53
- 1. Attributes
54
- 2. Relations
55
- 3. Conditional Attributes
56
- 4. Conditional Relations
57
- 5. Custom Methods
58
- 6. name_tag
59
-
60
- ##### Attributes
66
+ ### Attributes
61
67
  Attributes are fields in the model itself. You can reference them by below example
62
68
  ```ruby
63
69
  # frozen_string_literal: true
@@ -69,7 +75,7 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
69
75
  attribute :email, {always_include: true} ## this will allow to selectively include email
70
76
  end
71
77
  ```
72
- ##### Relations
78
+ ### Relations
73
79
  Relations such as `has_many`, `belongs_to`, `has_one` can be used as follows
74
80
  1. Every relation must be provided with their own serializer
75
81
  2. `always_include` option can be used to instruct `Serializer` to always include this relation
@@ -83,7 +89,7 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
83
89
  attributes :id, :first_name, :last_name, :email
84
90
 
85
91
  belongs_to :company, serializer: CompanySerializer, always_include: true
86
- ##OR
92
+ ## OR
87
93
  belongs_to :company, serializer: CompanySerializer, always_include: true, label: 'organization' ##<== important to give singular name
88
94
 
89
95
  has_many :comments, serializer: CommentSerializer
@@ -94,8 +100,12 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
94
100
  end
95
101
  end
96
102
  ```
97
- ##### Conditional Attributes
98
- Attributes are fields in the model itself. You can reference them by below example
103
+ ### Conditional Attributes
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}
99
109
  ```ruby
100
110
  # frozen_string_literal: true
101
111
 
@@ -103,11 +113,20 @@ Attributes are fields in the model itself. You can reference them by below examp
103
113
  class UserSerializer < Mutils::Serialization::BaseSerializer
104
114
  attributes :id, :first_name, :last_name
105
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
106
118
  end
119
+
120
+ UserSerializer.new(user) # Without params
121
+ UserSerializer.new(user,{params:{show_email:true}}) # With params
107
122
  ```
108
- in proc {|scope|}, scope is object which is being serialized
109
- ##### Conditional Relations
110
- Attributes are fields in the model itself. You can reference them by below example
123
+
124
+ ### Conditional Relations
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}
111
130
  ```ruby
112
131
  # frozen_string_literal: true
113
132
 
@@ -116,10 +135,49 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
116
135
  attributes :id, :first_name, :last_name
117
136
  has_many :comments, serializer: CommentSerializer, if: proc { |scope| scope.name == 'mutils' } ## comments will only serialize if user's name is 'mutils'
118
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
119
140
  end
141
+
142
+ UserSerializer.new(user) # Without params
143
+ UserSerializer.new(user,{params:{show_account:true}}) # With params
144
+
120
145
  ```
121
- in proc {|scope|}, scope is object which is being serialized
122
- ##### Custom Methods
146
+
147
+ ### Attributes Blocks
148
+ While writting attribute a block can be provided for useful transformations like `full_name` as shown below
149
+ ```ruby
150
+ # frozen_string_literal: true
151
+
152
+ # User Serializer
153
+ class UserSerializer < Mutils::Serialization::BaseSerializer
154
+ attributes :id, :first_name, :last_name, :email
155
+ attribute :full_name do |object|
156
+ "#{object.first_name} #{object.last_name}"
157
+ end
158
+ end
159
+ ```
160
+ ### Attributes Blocks with Params
161
+ While writting attribute a block can be provided for useful transformations like `full_name` as shown below
162
+ ```ruby
163
+ # frozen_string_literal: true
164
+
165
+ # User Serializer
166
+ class UserSerializer < Mutils::Serialization::BaseSerializer
167
+ attributes :id, :first_name, :last_name, :email
168
+ attribute :is_owner do |object,params|
169
+ params[:owner].id == object.id ? true:false
170
+ end
171
+ end
172
+ ```
173
+ ```ruby
174
+ # in controller
175
+
176
+ user = current_user
177
+ owner = owner_user
178
+ render json: UserSerializer.new(user,{params:{owner:owner}})
179
+ ```
180
+ ### Custom Methods
123
181
  Custom methods used in Serializer can be useful for cases as below.
124
182
  `scope` will be available to reference object in Serializer in below case its `user`
125
183
 
@@ -140,7 +198,7 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
140
198
  end
141
199
  end
142
200
  ```
143
- ##### name_tag
201
+ ### Name Tag
144
202
  name_tag is used to provide custom name to serializer output keys for json
145
203
 
146
204
  **Options**
@@ -163,20 +221,20 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
163
221
  end
164
222
  ```
165
223
 
166
- ## Usage: Use anywhere by
224
+ ### Sample Usage
167
225
 
168
226
  ```ruby
169
227
  user = User.first
170
228
  options = {includes: [:comments,:account]}
171
229
  UserSerializer.new(user,options).to_h
172
230
  ```
173
- ###or
231
+ ### or
174
232
  ```ruby
175
233
  users = User.all
176
234
  options = {includes: [:account]}
177
235
  UserSerializer.new(users,options).to_json
178
236
  ```
179
- ###or in controllers
237
+ ### or in controllers
180
238
  ```ruby
181
239
  users = User.all
182
240
  options = {includes: [:account]}
@@ -194,4 +252,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
194
252
 
195
253
  ## Code of Conduct
196
254
 
197
- 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/niteshpurohit/mutils/blob/master/CODE_OF_CONDUCT.md).
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.