pragmatic_ql 0.1.0.1 → 0.2

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: abdbb2886a7918395b7cffaedfa8c48a50184f6fe0992499faa69a07577df3bb
4
- data.tar.gz: c726d0febeceff92b9a8c1c7b5ff87c12e3e3f0496435bce65e17d466958a749
3
+ metadata.gz: db43534747874c7bc19d631804a18968be7fce6b5b3cacbc29e27f7e4378d4a0
4
+ data.tar.gz: 21000233f0760251b44b859403e7ab0fe57826bf94062fb46081adac04886f90
5
5
  SHA512:
6
- metadata.gz: e11c3e951b236f2ff1539c3ddae27cb79d61bb24efc19fc49b759a109d3e159d7f13e6e89af2a6e08112bcc2efc6ee30289812d786183ff6a9d7df8791d0ae36
7
- data.tar.gz: c3a3d6911d16e0ac9bc9e82a8e492e0869ace8904c584ba3b80298f4581b266d11137913df16e72f22737abaf7ddd482fe60745a3ffbe45b86013277de843ff1
6
+ metadata.gz: 37ac077510f771f4a1e993dd153d4426459260218fb138cd017a7c0d9755313fbbfa015146e1afd5ec6cf0d56d7e1aa3f0e18581ed1e07153b7e174c7b063068
7
+ data.tar.gz: 8c92696e114c518b725c2f75e06baeb7dc94d0b7d7cec34c7c799c451f9f584b748eebeb15a4eeba5e0517616aff9b8695147274fbfb120819100cc530921f67
data/Gemfile.lock CHANGED
@@ -1,50 +1,49 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pragmatic_ql (0.1.0)
4
+ pragmatic_ql (0.2)
5
5
  activesupport (> 4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.0.0)
10
+ activesupport (6.1.3.2)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
- i18n (>= 0.7, < 2)
13
- minitest (~> 5.1)
14
- tzinfo (~> 1.1)
15
- zeitwerk (~> 2.1, >= 2.1.8)
16
- concurrent-ruby (1.1.5)
17
- diff-lcs (1.3)
18
- i18n (1.6.0)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ zeitwerk (~> 2.3)
16
+ concurrent-ruby (1.1.8)
17
+ diff-lcs (1.4.4)
18
+ i18n (1.8.10)
19
19
  concurrent-ruby (~> 1.0)
20
- minitest (5.11.3)
20
+ minitest (5.14.4)
21
21
  rake (10.5.0)
22
- rspec (3.8.0)
23
- rspec-core (~> 3.8.0)
24
- rspec-expectations (~> 3.8.0)
25
- rspec-mocks (~> 3.8.0)
26
- rspec-core (3.8.2)
27
- rspec-support (~> 3.8.0)
28
- rspec-expectations (3.8.4)
22
+ rspec (3.10.0)
23
+ rspec-core (~> 3.10.0)
24
+ rspec-expectations (~> 3.10.0)
25
+ rspec-mocks (~> 3.10.0)
26
+ rspec-core (3.10.1)
27
+ rspec-support (~> 3.10.0)
28
+ rspec-expectations (3.10.1)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.8.0)
31
- rspec-mocks (3.8.1)
30
+ rspec-support (~> 3.10.0)
31
+ rspec-mocks (3.10.2)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
- rspec-support (~> 3.8.0)
34
- rspec-support (3.8.2)
35
- thread_safe (0.3.6)
36
- tzinfo (1.2.5)
37
- thread_safe (~> 0.1)
38
- zeitwerk (2.1.9)
33
+ rspec-support (~> 3.10.0)
34
+ rspec-support (3.10.2)
35
+ tzinfo (2.0.4)
36
+ concurrent-ruby (~> 1.0)
37
+ zeitwerk (2.4.2)
39
38
 
40
39
  PLATFORMS
41
40
  ruby
42
41
 
43
42
  DEPENDENCIES
44
- bundler (~> 1.17)
43
+ bundler (> 2.0)
45
44
  pragmatic_ql!
46
45
  rake (~> 10.0)
47
46
  rspec (~> 3.0)
48
47
 
49
48
  BUNDLED WITH
50
- 1.17.2
49
+ 2.2.17
@@ -0,0 +1,116 @@
1
+ ## Philosophy
2
+
3
+ Most critical part is how to implement the tool not the tool itself.
4
+ Incrorectly implemented solution can do more harm so pls read this.
5
+
6
+
7
+ ### By default return only ID
8
+
9
+
10
+ When you don't include anythnig you will get only the ID back
11
+
12
+
13
+ `GET /v3/students`
14
+
15
+ ```json
16
+ [
17
+ { "id": 123 },
18
+ { "id": 234 },
19
+ { "id": 456 }
20
+ ]
21
+ ```
22
+
23
+
24
+ `GET /v3/student/123`
25
+
26
+ ```json
27
+ {
28
+ "id": 123
29
+ }
30
+ ```
31
+
32
+ Even if you require nested associations without any definition you will
33
+ get just their IDs
34
+
35
+ ```json
36
+ {
37
+ "id": 123,
38
+ "work_list": [
39
+ { "id": 111 },
40
+ { "id": 222 },
41
+ ]
42
+ }
43
+ ```
44
+
45
+ This is design intention. You want to provide FE with minimum
46
+ information as possible. If FE need more than just `id` FE will ask
47
+ for it.
48
+
49
+
50
+
51
+ ### Associations are seperate includes
52
+
53
+
54
+ `?include=student.work_list`
55
+
56
+ ```json
57
+ {
58
+ "id": 123,
59
+ "work_list": [
60
+ { "id": 111 },
61
+ { "id": 222 },
62
+ ]
63
+ }
64
+ ```
65
+
66
+
67
+ `?include=student.comment_list`
68
+
69
+ ```json
70
+ {
71
+ "id": 123,
72
+ "comment_list": [
73
+ { "id": 999 },
74
+ { "id": 888 },
75
+ ]
76
+ }
77
+ ```
78
+
79
+ If frontend needs multiple it will ask for it:
80
+
81
+ `?include=student.comment_list,student.work_list`
82
+
83
+ ```json
84
+ {
85
+ "id": 123,
86
+ "comment_list": [
87
+ { "id": 999 },
88
+ { "id": 888 },
89
+ ],
90
+ "work_list": [
91
+ { "id": 111 },
92
+ { "id": 222 },
93
+ ]
94
+ }
95
+ ```
96
+
97
+ **DON'T** wrap muliple associations into one key
98
+
99
+
100
+ `?include=student.stuff` DON'T
101
+
102
+ ```json
103
+ {
104
+ "id": 123,
105
+ "comment_list": [
106
+ { "id": 999 },
107
+ { "id": 888 },
108
+ ],
109
+ "work_list": [
110
+ { "id": 111 },
111
+ { "id": 222 },
112
+ ]
113
+ }
114
+ ```
115
+
116
+
@@ -27,9 +27,9 @@ class StudentsController < ApplicationController
27
27
  resp.merge!({
28
28
  first_name: student.first_name,
29
29
  last_name: student.last_name
30
- }) if student_im.include?(:names)
30
+ }) if student_im.inclusive_of(:names)
31
31
 
32
- resp.merge!(date_of_birth: student.first_name) if student_im.include?(:dob)
32
+ resp.merge!(date_of_birth: student.first_name) if student_im.include(:dob)
33
33
 
34
34
  render json: resp
35
35
  end
@@ -23,7 +23,7 @@ end
23
23
 
24
24
  ```ruby
25
25
  # app/model/image.rb
26
- class image < ApplicationRecord
26
+ class Image < ApplicationRecord
27
27
  # model has fields: "id", "priority", "work_id"
28
28
 
29
29
  belongs_to :work
@@ -82,7 +82,7 @@ class StudentSerializer
82
82
 
83
83
  private
84
84
 
85
- # feel free to group multiple fields uder one include key
85
+ # feel free to group multiple fields uder one include key as long as they make Domain and performance sense
86
86
  def name_hash
87
87
  {
88
88
  first_name: student.first_name,
@@ -306,3 +306,4 @@ When you query `/students/123?include=student.name,student.work_list,student.wor
306
306
  ]
307
307
  }
308
308
  ```
309
+
@@ -1,3 +1,3 @@
1
1
  module PragmaticQL
2
- VERSION = "0.1.0.1"
2
+ VERSION = "0.2"
3
3
  end
data/pragmatic_ql.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_dependency "activesupport", "> 4" # I use goodies like .try?() .blank?()
27
- spec.add_development_dependency "bundler", "~> 1.17"
27
+ spec.add_development_dependency "bundler", "> 2.0"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pragmatic_ql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.1
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Valent
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: exe
15
15
  cert_chain: []
16
- date: 2019-09-12 00:00:00.000000000 Z
16
+ date: 2021-05-25 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activesupport
@@ -33,16 +33,16 @@ dependencies:
33
33
  name: bundler
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
- - - "~>"
36
+ - - ">"
37
37
  - !ruby/object:Gem::Version
38
- version: '1.17'
38
+ version: '2.0'
39
39
  type: :development
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
42
42
  requirements:
43
- - - "~>"
43
+ - - ">"
44
44
  - !ruby/object:Gem::Version
45
- version: '1.17'
45
+ version: '2.0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +90,7 @@ files:
90
90
  - Rakefile
91
91
  - bin/console
92
92
  - bin/setup
93
+ - docs/00_philosophy.md
93
94
  - docs/01_stupid_simple_implementation.md
94
95
  - docs/02_serializer_example.md
95
96
  - lib/pragmatic_ql.rb
@@ -118,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  - !ruby/object:Gem::Version
119
120
  version: '0'
120
121
  requirements: []
121
- rubygems_version: 3.0.3
122
+ rubygems_version: 3.2.17
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: Simple query language for JSON based APIs