render_json_rails 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 567856bf688b4a87ee7a035fc524dd787207586ad4d0d4ca1f68fd744f4d46a6
4
- data.tar.gz: 5bb5f2432aacbf4fc845a047ed908bd51f6baabd8955d35e8956561358bf7520
3
+ metadata.gz: 90cc1574d9f07dd9306bb4416625ad680c8a2777bd62de9529b7a110576d6928
4
+ data.tar.gz: be85fbe2ca6984d1efe32ad8531b6913d755761259c9cbb143b007663fb59340
5
5
  SHA512:
6
- metadata.gz: b074eec3f1814117676089f1358b90326740ca3549d9d63acc955da4cfec7dc40561077ae3a6c5e1755b1ce29af906750cfdf2b005bdfc353c5182eb48ea87da
7
- data.tar.gz: ea6691bdbbc4a007e781dc79c85d9b4e20c508eb3035cf37589da840c9d186444a04148f20a74301875a6ae460901317190d2215021c626afda08c76b1da96a5
6
+ metadata.gz: b533b034543b5bbce37a7d8d1a039fb94d8c64557c8635a998c7459499868c70cfdd2d593110ca2389d9724dd7f436cfc14d506287e01967e7a9ab0fa3f2347d
7
+ data.tar.gz: b9ca7bd1f3221de4739824db73dfb5a868bd5725d3528103eee5ff368825d7477eb7700398aef46804d64efccdc749d75da2806d4d01b1150d42c0f255a6fbd6
data/README.md CHANGED
@@ -1,45 +1,102 @@
1
1
  # RenderJsonRails
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/render_json_rails`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ RenderJsonRails pozwala w łatwy sposób dodać możliwość renderowania JSON z ActiveRecord-ów z zależnościami (has_many itp).
4
+ Dzięki temu łatwo jest stworzyć backend Json API np. do pracy z Reactem lub Vue.js
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ ## Przykład
6
7
 
7
- ## Installation
8
+ ```ruby
8
9
 
9
- Add this line to your application's Gemfile:
10
+ class Team < ActiveRecord::Base
11
+ has_many :users
12
+
13
+ include RenderJsonRails::Concern
14
+
15
+ render_json_config name: :team,
16
+ includes: {
17
+ users: User
18
+ }
19
+ end
20
+
21
+ class User < ActiveRecord::Base
22
+ belongs_to :team
23
+
24
+ include RenderJsonRails::Concern
25
+
26
+ render_json_config name: :user,
27
+ includes: {
28
+ team: Team
29
+ }
30
+ end
31
+ ```
32
+
33
+ Dodajemy też w kontrolerze ```teams_controller.rb```
10
34
 
11
35
  ```ruby
12
- gem 'render_json_rails', git: 'https://github.com/intum/render_json_rails'
36
+ include RenderJsonRails::Helper
37
+
38
+ def index
39
+ @team = Team.all
40
+ respond_to do |format|
41
+ format.html
42
+ format.json { render_json @team }
43
+ end
44
+ end
45
+ ```
46
+
47
+ i możemy już otrzymać JSON team-u wraz z userami
48
+
49
+ ```html
50
+ http://example.test/teams/1.json?include=users
51
+ ```
13
52
 
14
- # or
53
+ możemy też określić jakie pola mają być w json
15
54
 
16
- source "https://rubygems.pkg.github.com/intum" do
17
- gem "render_json_rails"
18
- end
55
+ ```html
56
+ http://example.test/teams/1.json?fields[team]=name,description
19
57
  ```
20
58
 
21
- And then execute:
59
+ i możemy łączyć to z include
22
60
 
23
- $ bundle install
61
+ ```html
62
+ http://example.text/teams/1.json?fields[team]=name,description&fields[user]=email,name&include=users
63
+ ```
24
64
 
25
- Or install it yourself as:
65
+ ## Pełny opis ```render_json_config```
26
66
 
27
- $ gem install render_json_rails
67
+ ```ruby
68
+ render_json_config name: :team,
69
+ except: [:account_id, :config], # tych pól nie będzie w json-ie
70
+ methods: [:image], # te metody zostaną dołączone
71
+ allowed_methods: [:members], # te metody mogą być dodane przez parametr fileds np: fields[team]=id,members
72
+ includes: { # to mozna dołączać za pomoca parametru include np include=users,category
73
+ users: Users,
74
+ cateogry: Category
75
+ }
76
+ ```
28
77
 
29
- ## Usage
78
+ ## Installation
30
79
 
31
- TODO: Write usage instructions here
80
+ Add this line to your application's Gemfile:
32
81
 
33
- ## Development
82
+ ```ruby
83
+ gem 'render_json_rails', git: 'https://github.com/intum/render_json_rails'
84
+ ```
34
85
 
35
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
86
+ And then execute:
87
+
88
+ $ bundle install
36
89
 
37
- 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).
90
+ Or install it yourself as:
91
+
92
+ $ gem install render_json_rails
38
93
 
39
94
  ## Contributing
40
95
 
41
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/render_json_rails.
96
+ Bug reports and pull requests are welcome on GitHub at https://github.com/intum/render_json_rails.
97
+
42
98
 
99
+ ## TMP
43
100
 
44
101
  Tworzenie gema
45
102
 
@@ -1,3 +1,3 @@
1
1
  module RenderJsonRails
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
 
10
10
  spec.summary = "Simle JSON API render like JonApi"
11
11
  spec.description = "render json with 'includes' and 'fields' with simple config"
12
- spec.homepage = "https://radgost.com/gems/render_json_rails"
12
+ spec.homepage = "https://github.com/intum/render_json_rails"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
14
 
15
15
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_json_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin
@@ -29,7 +29,7 @@ files:
29
29
  - lib/render_json_rails/helper.rb
30
30
  - lib/render_json_rails/version.rb
31
31
  - render_json_rails.gemspec
32
- homepage: https://radgost.com/gems/render_json_rails
32
+ homepage: https://github.com/intum/render_json_rails
33
33
  licenses:
34
34
  - MIT
35
35
  metadata: {}