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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c381da1faa5f3165f54a17cddd246bfb5bfffa7ec9114766181556e529ffb4d
4
- data.tar.gz: 27e8bdebcf4be2fc4cbb20771e44946df652447be534c19e68805525ad813356
3
+ metadata.gz: b271c656d2a4022958e729ec3478f6dcb05e74b6f159c2718ca41858bcfe5027
4
+ data.tar.gz: b5f433765febad3256686135bf0a4b925c209c161b166aff1dab75f0714f0c48
5
5
  SHA512:
6
- metadata.gz: 2a22ff71a77c8eaad11f69d9d7d9e1abd46e2727e8bd59576ac6bc5eabba3d32b246f5a6b54aaa4a3fb9aea3d33e3eec323c2df9d58fb92a4550d3f230c93244
7
- data.tar.gz: 20d74b6f9062c88abe29ed3570acc09ae56bdcdffeb2499d85876b31a9a8a9a3076f4073eb7106a2d3ad58f088903f43cf99b232b957b49fa50059322f1b7fcd
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mutils (0.2.27)
4
+ mutils (0.2.28)
5
5
  activesupport (>= 4.2)
6
6
 
7
7
  GEM
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
- #### Usage: Use anywhere by
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
- # or
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
 
@@ -2,7 +2,7 @@ Description:
2
2
  Generates a serializer for the given model.
3
3
 
4
4
  Example:
5
- rails generate serializer User
5
+ rails generate mutils:serializer User
6
6
 
7
7
  This will create:
8
8
  app/serializers/user_serializer.rb
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mutils
4
- VERSION = '0.2.27'
4
+ VERSION = '0.2.28'
5
5
  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: 0.2.27
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-25 00:00:00.000000000 Z
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/serializer/USAGE
143
- - lib/generators/serializer/serializer_generator.rb
144
- - lib/generators/serializer/templates/serializer.rb.tt
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.27
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