mutils 0.2.27 → 0.2.28
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +12 -3
- data/lib/generators/{serializer → mutils}/USAGE +1 -1
- data/lib/generators/mutils/serializer_generator.rb +21 -0
- data/lib/generators/{serializer → mutils}/templates/serializer.rb.tt +0 -0
- data/lib/mutils/version.rb +1 -1
- metadata +6 -6
- data/lib/generators/serializer/serializer_generator.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b271c656d2a4022958e729ec3478f6dcb05e74b6f159c2718ca41858bcfe5027
|
4
|
+
data.tar.gz: b5f433765febad3256686135bf0a4b925c209c161b166aff1dab75f0714f0c48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9388594a4573507149e3a4e6d22ccc9d00adbbbfbeb604df89b13b71647c35279b2ff88ace506c343c85d1cc963f170ffc21315229412b60651193d64eeb5989
|
7
|
+
data.tar.gz: 23b88db0d4e902e85e74dbdffa60ddb95505a3aa9c3377b7ac563c1650a0bb9549c8e072ce4a1301962a98d9598bb63d75505a8ae12cfd2ee7169fdd11354757
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
# Changelog
|
2
|
+
## [v0.2.28](https://github.com/niteshpurohit/mutils/tree/v0.2.28) (2019-11-27)
|
3
|
+
**Changes:**
|
4
|
+
- Serializer scoped into mutils
|
5
|
+
|
6
|
+
[Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.27...v0.2.28)
|
7
|
+
|
2
8
|
## [v0.2.27](https://github.com/niteshpurohit/mutils/tree/v0.2.27) (2019-11-25)
|
3
9
|
|
4
10
|
[Full Changelog](https://github.com/niteshpurohit/mutils/compare/v0.2.26...v0.2.27)
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -34,7 +34,7 @@ JSON Serializer for Active Models
|
|
34
34
|
|
35
35
|
#### Generate Serializer by command
|
36
36
|
```shell script
|
37
|
-
rails g serializer User id first_name last_name email
|
37
|
+
rails g mutils:serializer User id first_name last_name email
|
38
38
|
|
39
39
|
OUTPUT
|
40
40
|
Running via Spring preloader in process xxxxx
|
@@ -127,17 +127,26 @@ class UserSerializer < Mutils::Serialization::BaseSerializer
|
|
127
127
|
end
|
128
128
|
```
|
129
129
|
|
130
|
-
|
130
|
+
## Usage: Use anywhere by
|
131
131
|
|
132
132
|
```ruby
|
133
133
|
user = User.first
|
134
134
|
options = {includes: [:comments,:account]}
|
135
135
|
UserSerializer.new(user,options).to_h
|
136
|
-
|
136
|
+
```
|
137
|
+
###or
|
138
|
+
```ruby
|
137
139
|
users = User.all
|
138
140
|
options = {includes: [:account]}
|
139
141
|
UserSerializer.new(users,options).to_json
|
140
142
|
```
|
143
|
+
###or in controllers
|
144
|
+
```ruby
|
145
|
+
users = User.all
|
146
|
+
options = {includes: [:account]}
|
147
|
+
users_serializer =UserSerializer.new(users,options)
|
148
|
+
render json: users_serializer
|
149
|
+
```
|
141
150
|
|
142
151
|
## Contributing
|
143
152
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/base'
|
4
|
+
|
5
|
+
module Mutils
|
6
|
+
# Class SerializerGenerator
|
7
|
+
class SerializerGenerator < Rails::Generators::NamedBase
|
8
|
+
source_root File.expand_path('templates', __dir__)
|
9
|
+
|
10
|
+
argument :attributes, type: :array, default: [], banner: 'field field'
|
11
|
+
def create_serializer_file
|
12
|
+
template 'serializer.rb.tt', File.join('app', 'serializers', class_path, "#{file_name}_serializer.rb")
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def attributes_names
|
18
|
+
attributes.map { |attribute| attribute.name.to_sym.inspect }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
File without changes
|
data/lib/mutils/version.rb
CHANGED
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: 0.2.
|
4
|
+
version: 0.2.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nitesh Purohit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -139,9 +139,9 @@ files:
|
|
139
139
|
- benchmark/benchmark-serializer-json.rb
|
140
140
|
- bin/console
|
141
141
|
- bin/setup
|
142
|
-
- lib/generators/
|
143
|
-
- lib/generators/
|
144
|
-
- lib/generators/
|
142
|
+
- lib/generators/mutils/USAGE
|
143
|
+
- lib/generators/mutils/serializer_generator.rb
|
144
|
+
- lib/generators/mutils/templates/serializer.rb.tt
|
145
145
|
- lib/mutils.rb
|
146
146
|
- lib/mutils/serialization/base_serializer.rb
|
147
147
|
- lib/mutils/serialization/serialization_includes.rb
|
@@ -154,7 +154,7 @@ licenses:
|
|
154
154
|
- MIT
|
155
155
|
metadata:
|
156
156
|
bug_tracker_uri: https://github.com/niteshpurohit/mutils/issues
|
157
|
-
source_code_uri: https://github.com/niteshpurohit/mutils/tree/v0.2.
|
157
|
+
source_code_uri: https://github.com/niteshpurohit/mutils/tree/v0.2.28
|
158
158
|
post_install_message:
|
159
159
|
rdoc_options: []
|
160
160
|
require_paths:
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails/generators/base'
|
4
|
-
|
5
|
-
# Class SerializerGenerator
|
6
|
-
class SerializerGenerator < Rails::Generators::NamedBase
|
7
|
-
source_root File.expand_path('templates', __dir__)
|
8
|
-
|
9
|
-
argument :attributes, type: :array, default: [], banner: 'field field'
|
10
|
-
def create_serializer_file
|
11
|
-
template 'serializer.rb.tt', File.join('app', 'serializers', class_path, "#{file_name}_serializer.rb")
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def attributes_names
|
17
|
-
attributes.map { |attribute| attribute.name.to_sym.inspect }
|
18
|
-
end
|
19
|
-
end
|