json_error_serializer 0.3.0 → 0.3.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
  SHA1:
3
- metadata.gz: 8a40011fe62a351236367051a4cde984f071cebf
4
- data.tar.gz: 5d0e1edcccdbda32db52dcc6f340221d0961d361
3
+ metadata.gz: 681c9a5d4493d5d33ed9a89421a8da50f275d01a
4
+ data.tar.gz: 4a2d68f44b3d46a26b3048700ead9195f1644c1e
5
5
  SHA512:
6
- metadata.gz: d02e399738682a2a30386dc44828525e2014da145918d52eaa1505e6cf5e8bb58680b44d0f2b9e56a59f014c05750b546082762f1f79cb39e8040c4291a268c3
7
- data.tar.gz: c8df4dced8fc6883d6657b7e0047f8d852d442587ae9caf79f7756399f13d74003650aa23442431892c533002e63413bad0a2c7e87fd0ccd18d730310cfccf6a
6
+ metadata.gz: f27476f66e53b77544e40e7fcc5e7b04f82691788776ea88ba6a70e6d2b4cb4f65e20005431805d198aa8d159232b7352d4fe18462fb0ef612255047d4a74ac7
7
+ data.tar.gz: d80dbccf480bdb069efbd82bfb1a8d7fdb21305fee6f6bde88545a0f2659ecfc9aa1cbc916a78e9ef7a4b891e175a0e3c92a489cd4660a907d8becb73b003d1a
data/README.md CHANGED
@@ -1,38 +1,57 @@
1
1
  # JsonErrorSerializer
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/JsonErrorSerializer`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This gem provides a simple way to respond API errors messages with correct HTTP responces from Ruby On Rails applications.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'JsonErrorSerializer'
10
+ gem 'json_error_serializer'
11
11
  ```
12
12
 
13
13
  And then execute:
14
14
 
15
- $ bundle
15
+ $ bundle install
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install JsonErrorSerializer
19
+ $ gem install json_error_serializer
20
20
 
21
21
  ## Usage
22
22
 
23
- Description
23
+ In your controller:
24
+ ```ruby
25
+ respond_404
26
+ ```
24
27
 
25
- ## Development
28
+ ```ruby
29
+ respond_404('User not found')
30
+ ```
26
31
 
27
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+ Result:
33
+ HTTP 404 (Not found)
34
+ ```json
35
+ {
36
+ "status": "404",
37
+ "message": "Not found"
38
+ }
39
+ ```
40
+
41
+ ```json
42
+ {
43
+ "status": "404",
44
+ "message": "User not found"
45
+ }
46
+ ```
28
47
 
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+ Available methods refer to the [wiki](https://github.com/Strollager/error_json_serializer/wiki)
30
49
 
31
50
  ## Contributing
32
51
 
33
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/JsonErrorSerializer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Strollager/error_json_serializer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
53
 
35
54
 
36
55
  ## License
37
56
 
38
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
57
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -3,6 +3,10 @@ module JsonErrorSerializer
3
3
 
4
4
  module Controller
5
5
 
6
+ def validate_errors_serialize(errors)
7
+ render json: JsonErrorSerializer::Extenders::Serialize.serialize(errors), status: :conflict
8
+ end
9
+
6
10
  def respond_200(message = nil)
7
11
  render json: JsonErrorSerializer::Extenders::Serialize._200(message), status: :ok
8
12
  end
@@ -1,3 +1,3 @@
1
1
  module JsonErrorSerializer
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_error_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Stroganov