panko_serializer 0.8.4 → 1.0.0

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.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -6
  3. data/lib/panko/array_serializer.rb +55 -16
  4. data/lib/panko/code_gen/active_record/access_classifier.rb +65 -0
  5. data/lib/panko/code_gen/active_record/define_attribute_methods.rb +13 -0
  6. data/lib/panko/code_gen/code_builder.rb +32 -0
  7. data/lib/panko/code_gen/compile_cache.rb +28 -0
  8. data/lib/panko/code_gen/compiler.rb +56 -0
  9. data/lib/panko/code_gen/config.rb +79 -0
  10. data/lib/panko/code_gen/datetime_format.rb +38 -0
  11. data/lib/panko/code_gen/descriptor.rb +136 -0
  12. data/lib/panko/code_gen/descriptor_builder.rb +166 -0
  13. data/lib/panko/code_gen/dump.rb +52 -0
  14. data/lib/panko/code_gen/errors.rb +21 -0
  15. data/lib/panko/code_gen/filter.rb +29 -0
  16. data/lib/panko/code_gen/filter_adapter.rb +44 -0
  17. data/lib/panko/code_gen/filters/indexed.rb +62 -0
  18. data/lib/panko/code_gen/filters/none.rb +19 -0
  19. data/lib/panko/code_gen/generator.rb +23 -0
  20. data/lib/panko/code_gen/generators/banner.rb +27 -0
  21. data/lib/panko/code_gen/generators/class_emitter.rb +120 -0
  22. data/lib/panko/code_gen/generators/cycle_membership.rb +53 -0
  23. data/lib/panko/code_gen/generators/descriptor_walk.rb +22 -0
  24. data/lib/panko/code_gen/generators/fanout.rb +60 -0
  25. data/lib/panko/code_gen/generators/field_index.rb +31 -0
  26. data/lib/panko/code_gen/generators/field_walk.rb +38 -0
  27. data/lib/panko/code_gen/generators/generated_names.rb +73 -0
  28. data/lib/panko/code_gen/generators/hash_sink.rb +217 -0
  29. data/lib/panko/code_gen/generators/json_sink.rb +290 -0
  30. data/lib/panko/code_gen/generators/record_access/generic.rb +92 -0
  31. data/lib/panko/code_gen/generators/record_access/specialized.rb +90 -0
  32. data/lib/panko/code_gen/generators/release.rb +60 -0
  33. data/lib/panko/code_gen/generators/sink.rb +80 -0
  34. data/lib/panko/code_gen/instance_pool.rb +27 -0
  35. data/lib/panko/code_gen/runtime.rb +27 -0
  36. data/lib/panko/code_gen/serializer_cache.rb +242 -0
  37. data/lib/panko/code_gen/validators/callable_arity.rb +42 -0
  38. data/lib/panko/code_gen/validators/name_uniqueness.rb +44 -0
  39. data/lib/panko/code_gen/validators/source_resolution.rb +48 -0
  40. data/lib/panko/code_gen/validators/validator.rb +19 -0
  41. data/lib/panko/code_gen/writers_pool.rb +51 -0
  42. data/lib/panko/code_gen.rb +82 -0
  43. data/lib/panko/compile_all.rb +80 -0
  44. data/lib/panko/compile_all_result.rb +21 -0
  45. data/lib/panko/config.rb +71 -0
  46. data/lib/panko/descriptor.rb +93 -0
  47. data/lib/panko/response.rb +40 -8
  48. data/lib/panko/serializer.rb +175 -91
  49. data/lib/panko/serializer_resolver.rb +2 -8
  50. data/lib/panko/version.rb +1 -1
  51. data/lib/panko_serializer.rb +3 -5
  52. metadata +49 -99
  53. data/.clang-format +0 -3
  54. data/.github/dependabot.yml +0 -6
  55. data/.github/workflows/database_matrix.yml +0 -85
  56. data/.github/workflows/docs.yml +0 -39
  57. data/.github/workflows/lint.yml +0 -30
  58. data/.github/workflows/tests.yml +0 -34
  59. data/.gitignore +0 -20
  60. data/.rspec +0 -2
  61. data/.rubocop.yml +0 -37
  62. data/Appraisals +0 -28
  63. data/Gemfile +0 -37
  64. data/Rakefile +0 -93
  65. data/benchmarks/BENCHMARKS.md +0 -48
  66. data/benchmarks/allocs.rb +0 -23
  67. data/benchmarks/app.rb +0 -11
  68. data/benchmarks/benchmarking_support.rb +0 -44
  69. data/benchmarks/bm_ams_0_10.rb +0 -43
  70. data/benchmarks/bm_object_writer.rb +0 -65
  71. data/benchmarks/bm_panko_json.rb +0 -60
  72. data/benchmarks/bm_panko_object.rb +0 -46
  73. data/benchmarks/bm_plain_object.rb +0 -99
  74. data/benchmarks/bm_serialization_descriptor.rb +0 -76
  75. data/benchmarks/bm_serializer_resolver.rb +0 -22
  76. data/benchmarks/bm_to_object.rb +0 -81
  77. data/benchmarks/profile.rb +0 -86
  78. data/benchmarks/sanity.rb +0 -83
  79. data/benchmarks/setup.rb +0 -56
  80. data/benchmarks/type_casts/bm_active_record.rb +0 -58
  81. data/benchmarks/type_casts/bm_panko.rb +0 -65
  82. data/benchmarks/type_casts/support.rb +0 -27
  83. data/docs/docs/associations.md +0 -107
  84. data/docs/docs/attributes.md +0 -150
  85. data/docs/docs/design-choices.md +0 -127
  86. data/docs/docs/getting-started.md +0 -70
  87. data/docs/docs/introduction.md +0 -13
  88. data/docs/docs/performance.md +0 -32
  89. data/docs/docs/response-bag.md +0 -83
  90. data/docs/docusaurus.config.js +0 -86
  91. data/docs/package-lock.json +0 -17872
  92. data/docs/package.json +0 -18
  93. data/docs/sidebars.json +0 -15
  94. data/docs/src/css/customTheme.css +0 -9
  95. data/docs/static/.DS_Store +0 -0
  96. data/docs/static/CNAME +0 -1
  97. data/docs/static/css/custom.css +0 -51
  98. data/docs/static/img/favicon.ico +0 -0
  99. data/docs/static/img/oss_logo.png +0 -0
  100. data/docs/static/img/undraw_code_review.svg +0 -1
  101. data/docs/static/img/undraw_monitor.svg +0 -1
  102. data/docs/static/img/undraw_note_list.svg +0 -1
  103. data/docs/static/img/undraw_online.svg +0 -1
  104. data/docs/static/img/undraw_open_source.svg +0 -1
  105. data/docs/static/img/undraw_operating_system.svg +0 -1
  106. data/docs/static/img/undraw_react.svg +0 -1
  107. data/docs/static/img/undraw_tweetstorm.svg +0 -1
  108. data/docs/static/img/undraw_youtube_tutorial.svg +0 -1
  109. data/docs/static/index.html +0 -14
  110. data/ext/panko_serializer/attributes_writer/active_record.c +0 -181
  111. data/ext/panko_serializer/attributes_writer/active_record.h +0 -17
  112. data/ext/panko_serializer/attributes_writer/attributes_writer.c +0 -55
  113. data/ext/panko_serializer/attributes_writer/attributes_writer.h +0 -35
  114. data/ext/panko_serializer/attributes_writer/common.c +0 -10
  115. data/ext/panko_serializer/attributes_writer/common.h +0 -9
  116. data/ext/panko_serializer/attributes_writer/hash.c +0 -13
  117. data/ext/panko_serializer/attributes_writer/hash.h +0 -7
  118. data/ext/panko_serializer/attributes_writer/plain.c +0 -13
  119. data/ext/panko_serializer/attributes_writer/plain.h +0 -7
  120. data/ext/panko_serializer/attributes_writer/type_cast/time_conversion.c +0 -156
  121. data/ext/panko_serializer/attributes_writer/type_cast/time_conversion.h +0 -10
  122. data/ext/panko_serializer/attributes_writer/type_cast/type_cast.c +0 -398
  123. data/ext/panko_serializer/attributes_writer/type_cast/type_cast.h +0 -81
  124. data/ext/panko_serializer/common.h +0 -9
  125. data/ext/panko_serializer/extconf.rb +0 -28
  126. data/ext/panko_serializer/panko_serializer.c +0 -181
  127. data/ext/panko_serializer/panko_serializer.h +0 -12
  128. data/ext/panko_serializer/serialization_descriptor/association.c +0 -90
  129. data/ext/panko_serializer/serialization_descriptor/association.h +0 -20
  130. data/ext/panko_serializer/serialization_descriptor/attribute.c +0 -96
  131. data/ext/panko_serializer/serialization_descriptor/attribute.h +0 -27
  132. data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.c +0 -177
  133. data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.h +0 -30
  134. data/gemfiles/7.2.0.gemfile +0 -41
  135. data/gemfiles/7.2.0.gemfile.lock +0 -221
  136. data/gemfiles/8.0.0.gemfile +0 -41
  137. data/gemfiles/8.0.0.gemfile.lock +0 -239
  138. data/gemfiles/8.1.0.gemfile +0 -41
  139. data/gemfiles/8.1.0.gemfile.lock +0 -248
  140. data/lib/panko/association.rb +0 -17
  141. data/lib/panko/attribute.rb +0 -29
  142. data/lib/panko/object_writer.rb +0 -68
  143. data/lib/panko/serialization_descriptor.rb +0 -180
  144. data/panko_serializer.gemspec +0 -36
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panko_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosi Attias
@@ -35,14 +35,14 @@ dependencies:
35
35
  requirements:
36
36
  - - ">="
37
37
  - !ruby/object:Gem::Version
38
- version: '0'
38
+ version: '7.2'
39
39
  type: :runtime
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: '0'
45
+ version: '7.2'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: appraisal
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -60,110 +60,60 @@ dependencies:
60
60
  email:
61
61
  - yosy101@gmail.com
62
62
  executables: []
63
- extensions:
64
- - ext/panko_serializer/extconf.rb
63
+ extensions: []
65
64
  extra_rdoc_files: []
66
65
  files:
67
- - ".clang-format"
68
- - ".github/dependabot.yml"
69
- - ".github/workflows/database_matrix.yml"
70
- - ".github/workflows/docs.yml"
71
- - ".github/workflows/lint.yml"
72
- - ".github/workflows/tests.yml"
73
- - ".gitignore"
74
- - ".rspec"
75
- - ".rubocop.yml"
76
- - Appraisals
77
- - Gemfile
78
66
  - LICENSE.txt
79
67
  - README.md
80
- - Rakefile
81
- - benchmarks/BENCHMARKS.md
82
- - benchmarks/allocs.rb
83
- - benchmarks/app.rb
84
- - benchmarks/benchmarking_support.rb
85
- - benchmarks/bm_ams_0_10.rb
86
- - benchmarks/bm_object_writer.rb
87
- - benchmarks/bm_panko_json.rb
88
- - benchmarks/bm_panko_object.rb
89
- - benchmarks/bm_plain_object.rb
90
- - benchmarks/bm_serialization_descriptor.rb
91
- - benchmarks/bm_serializer_resolver.rb
92
- - benchmarks/bm_to_object.rb
93
- - benchmarks/profile.rb
94
- - benchmarks/sanity.rb
95
- - benchmarks/setup.rb
96
- - benchmarks/type_casts/bm_active_record.rb
97
- - benchmarks/type_casts/bm_panko.rb
98
- - benchmarks/type_casts/support.rb
99
- - docs/docs/associations.md
100
- - docs/docs/attributes.md
101
- - docs/docs/design-choices.md
102
- - docs/docs/getting-started.md
103
- - docs/docs/introduction.md
104
- - docs/docs/performance.md
105
- - docs/docs/response-bag.md
106
- - docs/docusaurus.config.js
107
- - docs/package-lock.json
108
- - docs/package.json
109
- - docs/sidebars.json
110
- - docs/src/css/customTheme.css
111
- - docs/static/.DS_Store
112
- - docs/static/CNAME
113
- - docs/static/css/custom.css
114
- - docs/static/img/favicon.ico
115
- - docs/static/img/oss_logo.png
116
- - docs/static/img/undraw_code_review.svg
117
- - docs/static/img/undraw_monitor.svg
118
- - docs/static/img/undraw_note_list.svg
119
- - docs/static/img/undraw_online.svg
120
- - docs/static/img/undraw_open_source.svg
121
- - docs/static/img/undraw_operating_system.svg
122
- - docs/static/img/undraw_react.svg
123
- - docs/static/img/undraw_tweetstorm.svg
124
- - docs/static/img/undraw_youtube_tutorial.svg
125
- - docs/static/index.html
126
- - ext/panko_serializer/attributes_writer/active_record.c
127
- - ext/panko_serializer/attributes_writer/active_record.h
128
- - ext/panko_serializer/attributes_writer/attributes_writer.c
129
- - ext/panko_serializer/attributes_writer/attributes_writer.h
130
- - ext/panko_serializer/attributes_writer/common.c
131
- - ext/panko_serializer/attributes_writer/common.h
132
- - ext/panko_serializer/attributes_writer/hash.c
133
- - ext/panko_serializer/attributes_writer/hash.h
134
- - ext/panko_serializer/attributes_writer/plain.c
135
- - ext/panko_serializer/attributes_writer/plain.h
136
- - ext/panko_serializer/attributes_writer/type_cast/time_conversion.c
137
- - ext/panko_serializer/attributes_writer/type_cast/time_conversion.h
138
- - ext/panko_serializer/attributes_writer/type_cast/type_cast.c
139
- - ext/panko_serializer/attributes_writer/type_cast/type_cast.h
140
- - ext/panko_serializer/common.h
141
- - ext/panko_serializer/extconf.rb
142
- - ext/panko_serializer/panko_serializer.c
143
- - ext/panko_serializer/panko_serializer.h
144
- - ext/panko_serializer/serialization_descriptor/association.c
145
- - ext/panko_serializer/serialization_descriptor/association.h
146
- - ext/panko_serializer/serialization_descriptor/attribute.c
147
- - ext/panko_serializer/serialization_descriptor/attribute.h
148
- - ext/panko_serializer/serialization_descriptor/serialization_descriptor.c
149
- - ext/panko_serializer/serialization_descriptor/serialization_descriptor.h
150
- - gemfiles/7.2.0.gemfile
151
- - gemfiles/7.2.0.gemfile.lock
152
- - gemfiles/8.0.0.gemfile
153
- - gemfiles/8.0.0.gemfile.lock
154
- - gemfiles/8.1.0.gemfile
155
- - gemfiles/8.1.0.gemfile.lock
156
68
  - lib/panko/array_serializer.rb
157
- - lib/panko/association.rb
158
- - lib/panko/attribute.rb
159
- - lib/panko/object_writer.rb
69
+ - lib/panko/code_gen.rb
70
+ - lib/panko/code_gen/active_record/access_classifier.rb
71
+ - lib/panko/code_gen/active_record/define_attribute_methods.rb
72
+ - lib/panko/code_gen/code_builder.rb
73
+ - lib/panko/code_gen/compile_cache.rb
74
+ - lib/panko/code_gen/compiler.rb
75
+ - lib/panko/code_gen/config.rb
76
+ - lib/panko/code_gen/datetime_format.rb
77
+ - lib/panko/code_gen/descriptor.rb
78
+ - lib/panko/code_gen/descriptor_builder.rb
79
+ - lib/panko/code_gen/dump.rb
80
+ - lib/panko/code_gen/errors.rb
81
+ - lib/panko/code_gen/filter.rb
82
+ - lib/panko/code_gen/filter_adapter.rb
83
+ - lib/panko/code_gen/filters/indexed.rb
84
+ - lib/panko/code_gen/filters/none.rb
85
+ - lib/panko/code_gen/generator.rb
86
+ - lib/panko/code_gen/generators/banner.rb
87
+ - lib/panko/code_gen/generators/class_emitter.rb
88
+ - lib/panko/code_gen/generators/cycle_membership.rb
89
+ - lib/panko/code_gen/generators/descriptor_walk.rb
90
+ - lib/panko/code_gen/generators/fanout.rb
91
+ - lib/panko/code_gen/generators/field_index.rb
92
+ - lib/panko/code_gen/generators/field_walk.rb
93
+ - lib/panko/code_gen/generators/generated_names.rb
94
+ - lib/panko/code_gen/generators/hash_sink.rb
95
+ - lib/panko/code_gen/generators/json_sink.rb
96
+ - lib/panko/code_gen/generators/record_access/generic.rb
97
+ - lib/panko/code_gen/generators/record_access/specialized.rb
98
+ - lib/panko/code_gen/generators/release.rb
99
+ - lib/panko/code_gen/generators/sink.rb
100
+ - lib/panko/code_gen/instance_pool.rb
101
+ - lib/panko/code_gen/runtime.rb
102
+ - lib/panko/code_gen/serializer_cache.rb
103
+ - lib/panko/code_gen/validators/callable_arity.rb
104
+ - lib/panko/code_gen/validators/name_uniqueness.rb
105
+ - lib/panko/code_gen/validators/source_resolution.rb
106
+ - lib/panko/code_gen/validators/validator.rb
107
+ - lib/panko/code_gen/writers_pool.rb
108
+ - lib/panko/compile_all.rb
109
+ - lib/panko/compile_all_result.rb
110
+ - lib/panko/config.rb
111
+ - lib/panko/descriptor.rb
160
112
  - lib/panko/response.rb
161
- - lib/panko/serialization_descriptor.rb
162
113
  - lib/panko/serializer.rb
163
114
  - lib/panko/serializer_resolver.rb
164
115
  - lib/panko/version.rb
165
116
  - lib/panko_serializer.rb
166
- - panko_serializer.gemspec
167
117
  homepage: https://panko.dev
168
118
  licenses:
169
119
  - MIT
@@ -179,14 +129,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
129
  requirements:
180
130
  - - ">="
181
131
  - !ruby/object:Gem::Version
182
- version: 3.1.0
132
+ version: '3.4'
183
133
  required_rubygems_version: !ruby/object:Gem::Requirement
184
134
  requirements:
185
135
  - - ">="
186
136
  - !ruby/object:Gem::Version
187
137
  version: '0'
188
138
  requirements: []
189
- rubygems_version: 3.7.2
139
+ rubygems_version: 4.0.20
190
140
  specification_version: 4
191
141
  summary: High Performance JSON Serialization for ActiveRecord & Ruby Objects
192
142
  test_files: []
data/.clang-format DELETED
@@ -1,3 +0,0 @@
1
- ---
2
- Language: Cpp
3
- BasedOnStyle: Google
@@ -1,6 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: "github-actions"
4
- directory: "/"
5
- schedule:
6
- interval: "monthly"
@@ -1,85 +0,0 @@
1
- name: Database Tests
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- database-matrix:
7
- runs-on: ubuntu-latest
8
-
9
- strategy:
10
- fail-fast: false
11
- matrix:
12
- ruby: ["3.4"]
13
- rails: ["7.2.0", "8.0.0"]
14
- database: ["sqlite", "postgresql", "mysql"]
15
-
16
- services:
17
- postgres:
18
- image: postgres:17
19
- env:
20
- POSTGRES_DB: panko_test
21
- POSTGRES_USER: postgres
22
- POSTGRES_PASSWORD: password
23
- options: >-
24
- --health-cmd pg_isready
25
- --health-interval 10s
26
- --health-timeout 5s
27
- --health-retries 5
28
- ports:
29
- - 5432:5432
30
-
31
- mysql:
32
- image: mysql:8.0
33
- env:
34
- MYSQL_DATABASE: panko_test
35
- MYSQL_ROOT_PASSWORD: password
36
- options: >-
37
- --health-cmd="mysqladmin ping"
38
- --health-interval=10s
39
- --health-timeout=5s
40
- --health-retries=3
41
- ports:
42
- - 3306:3306
43
-
44
- steps:
45
- - name: Install system dependencies
46
- run: |
47
- sudo apt update -y
48
- sudo apt install -y libsqlite3-dev libpq-dev libmysqlclient-dev
49
-
50
- - uses: actions/checkout@v5
51
-
52
- - name: Configure MySQL authentication
53
- if: matrix.database == 'mysql'
54
- run: |
55
- # Configure MySQL to use mysql_native_password for Trilogy compatibility
56
- mysql -h 127.0.0.1 -P 3306 -u root -ppassword -e "
57
- ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
58
- ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
59
- FLUSH PRIVILEGES;
60
- "
61
-
62
- - name: Set up Ruby ${{ matrix.ruby }}
63
- uses: ruby/setup-ruby@v1
64
- with:
65
- ruby-version: ${{ matrix.ruby }}
66
- bundler-cache: true
67
- working-directory: .
68
- env:
69
- BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
70
- DB: ${{ matrix.database }}
71
-
72
- - name: Compile & test
73
- env:
74
- BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
75
- DB: ${{ matrix.database }}
76
- POSTGRES_HOST: localhost
77
- POSTGRES_USER: postgres
78
- POSTGRES_PASSWORD: password
79
- POSTGRES_PORT: 5432
80
- MYSQL_HOST: localhost
81
- MYSQL_USER: root
82
- MYSQL_PASSWORD: password
83
- MYSQL_PORT: 3306
84
- run: |
85
- bundle exec rake
@@ -1,39 +0,0 @@
1
- # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2
- # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
-
4
- name: Docs Publishing
5
-
6
- on:
7
- push:
8
- branches: [ master, docup ]
9
-
10
- jobs:
11
- build:
12
-
13
- runs-on: ubuntu-latest
14
- env:
15
- working_directory: 'docs/'
16
-
17
- steps:
18
- - uses: actions/checkout@v5
19
- - name: Use Node.js ${{ matrix.node-version }}
20
- uses: actions/setup-node@v4
21
- with:
22
- node-version: '20.x'
23
-
24
- - name: Install Dependencies
25
- working-directory: ${{ env.working_directory }}
26
- run: npm install
27
-
28
- - name: Install SSH Client 🔑
29
- uses: webfactory/ssh-agent@v0.6.0
30
- with:
31
- ssh-private-key: ${{ secrets.DEPLOY_KEY }}
32
-
33
- - name: Publish
34
- working-directory: ${{ env.working_directory }}
35
- run: |
36
- git config --global user.email "action@github.com"
37
- git config --global user.name "GitHub Action"
38
- GIT_USER=yosiat CURRENT_BRANCH=master USE_SSH=true npm run deploy
39
-
@@ -1,30 +0,0 @@
1
- name: Lint
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- lint:
7
- runs-on: ubuntu-latest
8
-
9
- steps:
10
- - uses: actions/checkout@v5
11
-
12
- - name: Install deps
13
- run: |
14
- sudo apt update -y
15
- sudo apt install -y libsqlite3-dev
16
-
17
- - name: Lint Ruby code
18
- uses: ruby/setup-ruby@v1
19
- with:
20
- ruby-version: 3
21
- bundler-cache: true
22
- - run: |
23
- bundle exec rake rubocop
24
-
25
- - name: Lint C
26
- uses: jidicula/clang-format-action@v4.16.0
27
- with:
28
- clang-format-version: "16"
29
- check-path: "ext/panko_serializer"
30
- fallback-style: "Google"
@@ -1,34 +0,0 @@
1
- name: Panko Serializer CI
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- tests:
7
- runs-on: ubuntu-latest
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: ["3.2", "3.3", "3.4"]
12
- rails: ["7.2.0", "8.0.0", "8.1.0"]
13
-
14
- steps:
15
- - name: Install deps
16
- run: |
17
- sudo apt update -y
18
- sudo apt install -y libsqlite3-dev
19
-
20
- - uses: actions/checkout@v5
21
- - name: Set up Ruby ${{ matrix.ruby }}
22
- uses: ruby/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- bundler-cache: true
26
- working-directory: .
27
- env:
28
- BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
29
-
30
- - name: Compile & test
31
- env:
32
- BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
33
- run: |
34
- bundle exec rake
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /vendor/bundle/
11
- .byebug_history
12
- *.bundle
13
-
14
- # rspec failure tracking
15
- .rspec_status
16
- node_modules
17
-
18
- /docs/build/
19
- .cache/
20
- .docusaurus/
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.rubocop.yml DELETED
@@ -1,37 +0,0 @@
1
- # We want Exclude directives from different
2
- # config files to get merged, not overwritten
3
- inherit_mode:
4
- merge:
5
- - Exclude
6
-
7
- require:
8
- - standard
9
- - rubocop-performance
10
- - standard-performance
11
- - rubocop-rspec
12
-
13
- inherit_gem:
14
- standard: config/base.yml
15
- standard-performance: config/base.yml
16
-
17
- AllCops:
18
- TargetRubyVersion: 3.1
19
- SuggestExtensions: false
20
- NewCops: disable
21
- Exclude:
22
- - ext/**/*
23
- - gemfiles/**/*
24
-
25
-
26
- Style/FrozenStringLiteralComment:
27
- Enabled: true
28
- EnforcedStyle: always
29
- SafeAutoCorrect: true
30
-
31
- # TODO: need to work on specs.
32
- RSpec:
33
- Enabled: false
34
-
35
- Lint/ConstantDefinitionInBlock:
36
- Exclude:
37
- - spec/**/*
data/Appraisals DELETED
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise "7.2.0" do
4
- gem "activesupport", "~> 7.2.0"
5
- gem "activemodel", "~> 7.2.0"
6
- gem "activerecord", "~> 7.2.0", group: :test
7
-
8
- gem "trilogy"
9
- gem "sqlite3", "~> 1.4"
10
- end
11
-
12
- appraise "8.0.0" do
13
- gem "activesupport", "~> 8.0.0"
14
- gem "activemodel", "~> 8.0.0"
15
- gem "activerecord", "~> 8.0.0", group: :test
16
-
17
- gem "trilogy"
18
- gem "sqlite3", ">= 2.1"
19
- end
20
-
21
- appraise "8.1.0" do
22
- gem "activesupport", "~> 8.1.0"
23
- gem "activemodel", "~> 8.1.0"
24
- gem "activerecord", "~> 8.1.0", group: :test
25
-
26
- gem "trilogy"
27
- gem "sqlite3", ">= 2.1"
28
- end
data/Gemfile DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec
6
-
7
- group :benchmarks do
8
- gem "vernier"
9
- gem "stackprof"
10
- gem "pg"
11
-
12
- gem "benchmark-ips"
13
- gem "active_model_serializers", "~> 0.10"
14
- gem "terminal-table"
15
- gem "memory_profiler"
16
- end
17
-
18
- group :test do
19
- gem "faker"
20
- gem "temping"
21
- end
22
-
23
- group :development do
24
- gem "byebug"
25
- gem "rake"
26
- gem "rspec", "~> 3.0"
27
- gem "rake-compiler"
28
- end
29
-
30
- group :development, :test do
31
- gem "rubocop"
32
-
33
- gem "standard"
34
- gem "standard-performance"
35
- gem "rubocop-performance"
36
- gem "rubocop-rspec"
37
- end
data/Rakefile DELETED
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
- require "json"
6
- require "terminal-table"
7
- require "rake/extensiontask"
8
- require "pty"
9
- require "rubocop/rake_task"
10
-
11
- gem = Gem::Specification.load(File.dirname(__FILE__) + "/panko_serializer.gemspec")
12
-
13
- Rake::ExtensionTask.new("panko_serializer", gem) do |ext|
14
- ext.lib_dir = "lib/panko"
15
- end
16
-
17
- Gem::PackageTask.new(gem) do |pkg|
18
- pkg.need_zip = pkg.need_tar = false
19
- end
20
-
21
- RSpec::Core::RakeTask.new(:spec)
22
- Rake::Task[:spec].prerequisites << :compile
23
- Rake::Task[:compile].prerequisites << :clean
24
-
25
- task default: :spec
26
-
27
- RuboCop::RakeTask.new
28
-
29
- def print_and_flush(str)
30
- print str
31
- $stdout.flush
32
- end
33
-
34
- def run_process(cmd)
35
- puts "> Running #{cmd}"
36
- lines = []
37
- _stderr_reader, stderr_writer = IO.pipe
38
- PTY.spawn(cmd, err: stderr_writer.fileno) do |stdout, stdin, pid|
39
- stdout.each do |line|
40
- print_and_flush "."
41
- lines << line
42
- end
43
- rescue Errno::EIO
44
- # ignore this
45
- end
46
-
47
- lines
48
- rescue PTY::ChildExited
49
- puts "The child process exited! - #{cmd}"
50
- []
51
- end
52
-
53
- def run_benchmarks(files, items_count: 2_300)
54
- headings = ["Benchmark", "ip/s", "allocs/retained"]
55
- files.each do |benchmark_file|
56
- lines = run_process "ITEMS_COUNT=#{items_count} RAILS_ENV=production ruby #{benchmark_file}"
57
- rows = lines.map do |line|
58
- row = JSON.parse(line)
59
- row.values
60
- rescue JSON::ParserError
61
- puts "> [ERROR] Failed running #{benchmark_file} - #{lines.join}"
62
- end
63
-
64
- puts "\n\n"
65
- title = File.basename(benchmark_file, ".rb")
66
- table = Terminal::Table.new title: title, headings: headings, rows: rows
67
- puts table
68
- end
69
- end
70
-
71
- namespace :benchmarks do
72
- desc "All"
73
- task :all do
74
- run_benchmarks Dir[File.join(__dir__, "benchmarks", "**", "bm_*")]
75
- end
76
-
77
- desc "Type Casts"
78
- task :type_casts do
79
- run_benchmarks Dir[File.join(__dir__, "benchmarks", "type_casts", "bm_*")], items_count: 0
80
- end
81
-
82
- desc "Sanity"
83
- task :sanity do
84
- puts Time.now.strftime("%d/%m %H:%M:%S")
85
- puts "=========================="
86
-
87
- run_benchmarks [
88
- File.join(__dir__, "benchmarks", "sanity.rb")
89
- ], items_count: 2300
90
-
91
- puts "\n\n"
92
- end
93
- end
@@ -1,48 +0,0 @@
1
- ## Initial state
2
- ```
3
- Native_Posts_2300 57 ip/s 13802 allocs/op
4
- Native_Posts_50 2956 ip/s 302 allocs/op
5
-
6
- AMS_Simple_Posts_2300 21 ip/s 94309 allocs/op
7
- AMS_Simple_Posts_50 1008 ip/s 2059 allocs/op
8
- AMS_HasOne_Posts_2300 9 ip/s 147209 allocs/op
9
- AMS_HasOne_Posts_50 451 ip/s 3209 allocs/op
10
-
11
- Panko_HasOne_Posts_2300 164 ip/s 2372 allocs/op
12
- Panko_HasOne_Posts_50 6118 ip/s 122 allocs/op
13
- Panko_Reused_HasOne_Posts_2300 178 ip/s 2303 allocs/op
14
- Panko_Reused_HasOne_Posts_50 8203 ip/s 53 allocs/op
15
-
16
- Panko_Simple_Posts_2300 150 ip/s 2372 allocs/op
17
- Panko_Simple_Posts_50 5639 ip/s 122 allocs/op
18
- Panko_Reused_Simple_Posts_2300 180 ip/s 2303 allocs/op
19
- Panko_Reused_Simple_Posts_50 8388 ip/s 53 allocs/op
20
- ```
21
-
22
- ## Refactorings, method call support, combining
23
-
24
- ### class eval
25
- ```
26
- Panko_HasOne_Posts_2300 64 ip/s 9477 allocs/op
27
- Panko_HasOne_Posts_50 2397 ip/s 477 allocs/op
28
- Panko_Reused_HasOne_Posts_2300 70 ip/s 9423 allocs/op
29
- Panko_Reused_HasOne_Posts_50 2596 ip/s 423 allocs/op
30
-
31
- Panko_Simple_Posts_2300 191 ip/s 2472 allocs/op
32
- Panko_Simple_Posts_50 5128 ip/s 222 allocs/op
33
- Panko_Reused_Simple_Posts_2300 180 ip/s 2418 allocs/op
34
- Panko_Reused_Simple_Posts_50 5534 ip/s 168 allocs/op
35
- ```
36
-
37
- ### instance eval
38
- ```
39
- Panko_HasOne_Posts_2300 60 ip/s 9473 allocs/op
40
- Panko_HasOne_Posts_50 2399 ip/s 473 allocs/op
41
- Panko_Reused_HasOne_Posts_2300 66 ip/s 9419 allocs/op
42
- Panko_Reused_HasOne_Posts_50 2582 ip/s 419 allocs/op
43
-
44
- Panko_Simple_Posts_2300 195 ip/s 2470 allocs/op
45
- Panko_Simple_Posts_50 4838 ip/s 220 allocs/op
46
- Panko_Reused_Simple_Posts_2300 196 ip/s 2416 allocs/op
47
- Panko_Reused_Simple_Posts_50 6241 ip/s 166 allocs/op
48
- ```