panko_serializer 0.8.3 → 0.8.5

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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/ext/panko_serializer/attributes_writer/active_record.c +2 -29
  4. data/ext/panko_serializer/attributes_writer/type_cast/type_cast.c +24 -13
  5. data/lib/panko/version.rb +1 -1
  6. metadata +3 -72
  7. data/.clang-format +0 -3
  8. data/.github/dependabot.yml +0 -6
  9. data/.github/workflows/docs.yml +0 -39
  10. data/.github/workflows/lint.yml +0 -30
  11. data/.github/workflows/ruby.yml +0 -51
  12. data/.gitignore +0 -20
  13. data/.rspec +0 -2
  14. data/.rubocop.yml +0 -37
  15. data/Appraisals +0 -29
  16. data/Gemfile +0 -36
  17. data/Rakefile +0 -93
  18. data/benchmarks/BENCHMARKS.md +0 -48
  19. data/benchmarks/allocs.rb +0 -23
  20. data/benchmarks/app.rb +0 -11
  21. data/benchmarks/benchmarking_support.rb +0 -44
  22. data/benchmarks/bm_ams_0_10.rb +0 -43
  23. data/benchmarks/bm_object_writer.rb +0 -65
  24. data/benchmarks/bm_panko_json.rb +0 -60
  25. data/benchmarks/bm_panko_object.rb +0 -46
  26. data/benchmarks/bm_plain_object.rb +0 -99
  27. data/benchmarks/bm_serialization_descriptor.rb +0 -76
  28. data/benchmarks/bm_serializer_resolver.rb +0 -22
  29. data/benchmarks/bm_to_object.rb +0 -81
  30. data/benchmarks/profile.rb +0 -86
  31. data/benchmarks/sanity.rb +0 -83
  32. data/benchmarks/setup.rb +0 -56
  33. data/benchmarks/type_casts/bm_active_record.rb +0 -58
  34. data/benchmarks/type_casts/bm_panko.rb +0 -65
  35. data/benchmarks/type_casts/support.rb +0 -27
  36. data/docs/docs/associations.md +0 -107
  37. data/docs/docs/attributes.md +0 -143
  38. data/docs/docs/design-choices.md +0 -127
  39. data/docs/docs/getting-started.md +0 -70
  40. data/docs/docs/introduction.md +0 -13
  41. data/docs/docs/performance.md +0 -32
  42. data/docs/docs/response-bag.md +0 -83
  43. data/docs/docusaurus.config.js +0 -86
  44. data/docs/package-lock.json +0 -15994
  45. data/docs/package.json +0 -21
  46. data/docs/sidebars.json +0 -15
  47. data/docs/src/css/customTheme.css +0 -9
  48. data/docs/static/.DS_Store +0 -0
  49. data/docs/static/CNAME +0 -1
  50. data/docs/static/css/custom.css +0 -51
  51. data/docs/static/img/favicon.ico +0 -0
  52. data/docs/static/img/oss_logo.png +0 -0
  53. data/docs/static/img/undraw_code_review.svg +0 -1
  54. data/docs/static/img/undraw_monitor.svg +0 -1
  55. data/docs/static/img/undraw_note_list.svg +0 -1
  56. data/docs/static/img/undraw_online.svg +0 -1
  57. data/docs/static/img/undraw_open_source.svg +0 -1
  58. data/docs/static/img/undraw_operating_system.svg +0 -1
  59. data/docs/static/img/undraw_react.svg +0 -1
  60. data/docs/static/img/undraw_tweetstorm.svg +0 -1
  61. data/docs/static/img/undraw_youtube_tutorial.svg +0 -1
  62. data/docs/static/index.html +0 -14
  63. data/gemfiles/7.0.0.gemfile +0 -39
  64. data/gemfiles/7.0.0.gemfile.lock +0 -176
  65. data/gemfiles/7.1.0.gemfile +0 -39
  66. data/gemfiles/7.1.0.gemfile.lock +0 -198
  67. data/gemfiles/7.2.0.gemfile +0 -39
  68. data/gemfiles/7.2.0.gemfile.lock +0 -198
  69. data/gemfiles/8.0.0.gemfile +0 -39
  70. data/gemfiles/8.0.0.gemfile.lock +0 -219
  71. data/panko_serializer.gemspec +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e04b05a5a9a72ce68ad0768dd84b403e4adb6cefa8226f89c30a09d480993481
4
- data.tar.gz: 1d7ff5f7b035a497e4b7d48e9749bfc13c3861cfb067b53b167b54c2ce5c8822
3
+ metadata.gz: f713e7a7ea669bf0f3fa26ed2780c3f84a56a0faa0013f5514f6e732c49c86c3
4
+ data.tar.gz: b3eace69707162028e2ea379687cd7e3ee0d1bf8b2d1e68dda0402df3da9166e
5
5
  SHA512:
6
- metadata.gz: 9bcb10f0e30eb48277dcdc9eea463dd475e892ed6eca37818d0d21eb9978cabeb1d0c7b1b8989ff69c1dc5c9b958fe8d0d073f0861d4b7207054e33677d615e7
7
- data.tar.gz: 98846622471bed88140fe737f12144e9221e8a439c181c45d3e4ae1cd95aef265e640dd5bb4fda1d6beb8f4fc1f6eecc016620d31b9ec2a51fec6cc214683830
6
+ metadata.gz: 0a12aa0fd1d42cd6b19867c87e278f5d0df045b25f2f93580a6c7e939d44d5859f7f3b983655d828cacafd20574e4278b620c89eabbccfdf387f17bc201dfcad
7
+ data.tar.gz: 5f0d4103ab1382af51d22278006a938bc013829878a709bded8e0564d87ee5f2d945ef3d93c5eadf9c9ee8d309adf416d1b6bea90c72ffac729af6a5b62e9ffe
data/README.md CHANGED
@@ -4,20 +4,20 @@
4
4
 
5
5
  Panko is a library which is inspired by ActiveModelSerializers 0.9 for serializing ActiveRecord/Ruby objects to JSON strings, fast.
6
6
 
7
- To achieve its [performance](https://panko.dev/docs/performance/):
7
+ To achieve its [performance](https://panko.dev/performance):
8
8
 
9
9
  * Oj - Panko relies on Oj since it's fast and allows for incremental serialization using `Oj::StringWriter`
10
10
  * Serialization Descriptor - Panko computes most of the metadata ahead of time, to save time later in serialization.
11
11
  * Type casting — Panko does type casting by itself, instead of relying on ActiveRecord.
12
12
 
13
- To dig deeper about the performance choices, read [Design Choices](https://panko.dev/docs/design-choices/).
13
+ To dig deeper about the performance choices, read [Design Choices](https://panko.dev/design-choices).
14
14
 
15
15
 
16
16
  Support
17
17
  -------
18
18
 
19
- - [Documentation](https://panko.dev/docs)
20
- - [Getting Started](https://panko.dev/docs/getting-started/)
19
+ - [Documentation](https://panko.dev/)
20
+ - [Getting Started](https://panko.dev/getting-started)
21
21
 
22
22
  License
23
23
  -------
@@ -11,31 +11,6 @@ static ID type_id;
11
11
 
12
12
  static ID fetch_id;
13
13
 
14
- // ActiveRecord::Result::IndexedRow
15
- static VALUE ar_result_indexed_row = Qundef;
16
- static int fetched_ar_result_indexed_row = 0;
17
-
18
- VALUE fetch_ar_result_indexed_row_type() {
19
- if (fetched_ar_result_indexed_row == 1) {
20
- return ar_result_indexed_row;
21
- }
22
-
23
- fetched_ar_result_indexed_row = 1;
24
-
25
- VALUE ar, ar_result;
26
-
27
- ar = rb_const_get_at(rb_cObject, rb_intern("ActiveRecord"));
28
-
29
- // ActiveRecord::Result
30
- ar_result = rb_const_get_at(ar, rb_intern("Result"));
31
-
32
- if (rb_const_defined_at(ar_result, rb_intern("IndexedRow")) == (int)Qtrue) {
33
- ar_result_indexed_row = rb_const_get_at(ar_result, rb_intern("IndexedRow"));
34
- }
35
-
36
- return ar_result_indexed_row;
37
- }
38
-
39
14
  struct attributes {
40
15
  // Hash
41
16
  VALUE attributes_hash;
@@ -67,13 +42,11 @@ struct attributes init_context(VALUE obj) {
67
42
  .attributes_hash =
68
43
  PANKO_EMPTY_HASH(attributes_hash) ? Qnil : attributes_hash,
69
44
  .attributes_hash_size = 0,
70
-
71
45
  .types = rb_ivar_get(attributes_set, types_id),
72
46
  .additional_types = rb_ivar_get(attributes_set, additional_types_id),
73
47
  .tryToReadFromAdditionalTypes =
74
48
  PANKO_EMPTY_HASH(rb_ivar_get(attributes_set, additional_types_id)) ==
75
49
  false,
76
-
77
50
  .values = rb_ivar_get(attributes_set, values_id),
78
51
  .is_indexed_row = false,
79
52
  .indexed_row_column_indexes = Qnil,
@@ -84,10 +57,10 @@ struct attributes init_context(VALUE obj) {
84
57
  attrs.attributes_hash_size = RHASH_SIZE(attrs.attributes_hash);
85
58
  }
86
59
 
87
- if (CLASS_OF(attrs.values) == fetch_ar_result_indexed_row_type()) {
60
+ if (strcmp(rb_class2name(CLASS_OF(attrs.values)),
61
+ "ActiveRecord::Result::IndexedRow") == 0) {
88
62
  volatile VALUE indexed_row_column_indexes =
89
63
  rb_ivar_get(attrs.values, rb_intern("@column_indexes"));
90
-
91
64
  volatile VALUE indexed_row_row =
92
65
  rb_ivar_get(attrs.values, rb_intern("@row"));
93
66
 
@@ -34,21 +34,22 @@ static int initiailized = 0;
34
34
  VALUE cache_postgres_type_lookup(VALUE ar) {
35
35
  VALUE ar_connection_adapters, ar_postgresql, ar_oid;
36
36
 
37
- ar_connection_adapters = rb_const_get_at(ar, rb_intern("ConnectionAdapters"));
38
- if (ar_connection_adapters == Qundef) {
37
+ if (rb_const_defined_at(ar, rb_intern("ConnectionAdapters")) != (int)Qtrue) {
39
38
  return Qfalse;
40
39
  }
40
+ ar_connection_adapters = rb_const_get_at(ar, rb_intern("ConnectionAdapters"));
41
41
 
42
- ar_postgresql =
43
- rb_const_get_at(ar_connection_adapters, rb_intern("PostgreSQL"));
44
- if (ar_postgresql == Qundef) {
42
+ if (rb_const_defined_at(ar_connection_adapters, rb_intern("PostgreSQL")) !=
43
+ (int)Qtrue) {
45
44
  return Qfalse;
46
45
  }
46
+ ar_postgresql =
47
+ rb_const_get_at(ar_connection_adapters, rb_intern("PostgreSQL"));
47
48
 
48
- ar_oid = rb_const_get_at(ar_postgresql, rb_intern("OID"));
49
- if (ar_oid == Qundef) {
49
+ if (rb_const_defined_at(ar_postgresql, rb_intern("OID")) != (int)Qtrue) {
50
50
  return Qfalse;
51
51
  }
52
+ ar_oid = rb_const_get_at(ar_postgresql, rb_intern("OID"));
52
53
 
53
54
  if (rb_const_defined_at(ar_oid, rb_intern("Float")) == (int)Qtrue) {
54
55
  ar_pg_float_type = rb_const_get_at(ar_oid, rb_intern("Float"));
@@ -85,18 +86,23 @@ VALUE cache_time_zone_type_lookup(VALUE ar) {
85
86
  VALUE ar_attr_methods, ar_time_zone_conversion;
86
87
 
87
88
  // ActiveRecord::AttributeMethods
88
- ar_attr_methods = rb_const_get_at(ar, rb_intern("AttributeMethods"));
89
- if (ar_attr_methods == Qundef) {
89
+ if (rb_const_defined_at(ar, rb_intern("AttributeMethods")) != (int)Qtrue) {
90
90
  return Qfalse;
91
91
  }
92
+ ar_attr_methods = rb_const_get_at(ar, rb_intern("AttributeMethods"));
92
93
 
93
94
  // ActiveRecord::AttributeMethods::TimeZoneConversion
95
+ if (rb_const_defined_at(ar_attr_methods, rb_intern("TimeZoneConversion")) !=
96
+ (int)Qtrue) {
97
+ return Qfalse;
98
+ }
94
99
  ar_time_zone_conversion =
95
100
  rb_const_get_at(ar_attr_methods, rb_intern("TimeZoneConversion"));
96
- if (ar_time_zone_conversion == Qundef) {
101
+
102
+ if (rb_const_defined_at(ar_time_zone_conversion,
103
+ rb_intern("TimeZoneConverter")) != (int)Qtrue) {
97
104
  return Qfalse;
98
105
  }
99
-
100
106
  ar_time_zone_converter =
101
107
  rb_const_get_at(ar_time_zone_conversion, rb_intern("TimeZoneConverter"));
102
108
 
@@ -136,11 +142,16 @@ void cache_type_lookup() {
136
142
  ar_json_type = rb_const_get_at(ar_type, rb_intern("Json"));
137
143
  }
138
144
 
139
- // TODO: if we get error or not, add this to some debug log
140
145
  int isErrored;
141
146
  rb_protect(cache_postgres_type_lookup, ar, &isErrored);
147
+ if (isErrored) {
148
+ rb_set_errinfo(Qnil);
149
+ }
142
150
 
143
151
  rb_protect(cache_time_zone_type_lookup, ar, &isErrored);
152
+ if (isErrored) {
153
+ rb_set_errinfo(Qnil);
154
+ }
144
155
  }
145
156
 
146
157
  bool is_string_or_text_type(VALUE type_klass) {
@@ -288,7 +299,7 @@ VALUE cast_date_time_type(VALUE value) {
288
299
  return Qundef;
289
300
  }
290
301
 
291
- VALUE rescue_func() { return Qfalse; }
302
+ VALUE rescue_func(VALUE _arg, VALUE _data) { return Qfalse; }
292
303
 
293
304
  VALUE parse_json(VALUE value) {
294
305
  return rb_funcall(oj_type, oj_sc_parse_id, 2, rb_cObject, value);
data/lib/panko/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Panko
4
- VERSION = "0.8.3"
4
+ VERSION = "0.8.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panko_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosi Attias
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-15 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: oj
@@ -58,7 +57,6 @@ dependencies:
58
57
  - - ">="
59
58
  - !ruby/object:Gem::Version
60
59
  version: '0'
61
- description:
62
60
  email:
63
61
  - yosy101@gmail.com
64
62
  executables: []
@@ -66,64 +64,8 @@ extensions:
66
64
  - ext/panko_serializer/extconf.rb
67
65
  extra_rdoc_files: []
68
66
  files:
69
- - ".clang-format"
70
- - ".github/dependabot.yml"
71
- - ".github/workflows/docs.yml"
72
- - ".github/workflows/lint.yml"
73
- - ".github/workflows/ruby.yml"
74
- - ".gitignore"
75
- - ".rspec"
76
- - ".rubocop.yml"
77
- - Appraisals
78
- - Gemfile
79
67
  - LICENSE.txt
80
68
  - README.md
81
- - Rakefile
82
- - benchmarks/BENCHMARKS.md
83
- - benchmarks/allocs.rb
84
- - benchmarks/app.rb
85
- - benchmarks/benchmarking_support.rb
86
- - benchmarks/bm_ams_0_10.rb
87
- - benchmarks/bm_object_writer.rb
88
- - benchmarks/bm_panko_json.rb
89
- - benchmarks/bm_panko_object.rb
90
- - benchmarks/bm_plain_object.rb
91
- - benchmarks/bm_serialization_descriptor.rb
92
- - benchmarks/bm_serializer_resolver.rb
93
- - benchmarks/bm_to_object.rb
94
- - benchmarks/profile.rb
95
- - benchmarks/sanity.rb
96
- - benchmarks/setup.rb
97
- - benchmarks/type_casts/bm_active_record.rb
98
- - benchmarks/type_casts/bm_panko.rb
99
- - benchmarks/type_casts/support.rb
100
- - docs/docs/associations.md
101
- - docs/docs/attributes.md
102
- - docs/docs/design-choices.md
103
- - docs/docs/getting-started.md
104
- - docs/docs/introduction.md
105
- - docs/docs/performance.md
106
- - docs/docs/response-bag.md
107
- - docs/docusaurus.config.js
108
- - docs/package-lock.json
109
- - docs/package.json
110
- - docs/sidebars.json
111
- - docs/src/css/customTheme.css
112
- - docs/static/.DS_Store
113
- - docs/static/CNAME
114
- - docs/static/css/custom.css
115
- - docs/static/img/favicon.ico
116
- - docs/static/img/oss_logo.png
117
- - docs/static/img/undraw_code_review.svg
118
- - docs/static/img/undraw_monitor.svg
119
- - docs/static/img/undraw_note_list.svg
120
- - docs/static/img/undraw_online.svg
121
- - docs/static/img/undraw_open_source.svg
122
- - docs/static/img/undraw_operating_system.svg
123
- - docs/static/img/undraw_react.svg
124
- - docs/static/img/undraw_tweetstorm.svg
125
- - docs/static/img/undraw_youtube_tutorial.svg
126
- - docs/static/index.html
127
69
  - ext/panko_serializer/attributes_writer/active_record.c
128
70
  - ext/panko_serializer/attributes_writer/active_record.h
129
71
  - ext/panko_serializer/attributes_writer/attributes_writer.c
@@ -148,14 +90,6 @@ files:
148
90
  - ext/panko_serializer/serialization_descriptor/attribute.h
149
91
  - ext/panko_serializer/serialization_descriptor/serialization_descriptor.c
150
92
  - ext/panko_serializer/serialization_descriptor/serialization_descriptor.h
151
- - gemfiles/7.0.0.gemfile
152
- - gemfiles/7.0.0.gemfile.lock
153
- - gemfiles/7.1.0.gemfile
154
- - gemfiles/7.1.0.gemfile.lock
155
- - gemfiles/7.2.0.gemfile
156
- - gemfiles/7.2.0.gemfile.lock
157
- - gemfiles/8.0.0.gemfile
158
- - gemfiles/8.0.0.gemfile.lock
159
93
  - lib/panko/array_serializer.rb
160
94
  - lib/panko/association.rb
161
95
  - lib/panko/attribute.rb
@@ -166,7 +100,6 @@ files:
166
100
  - lib/panko/serializer_resolver.rb
167
101
  - lib/panko/version.rb
168
102
  - lib/panko_serializer.rb
169
- - panko_serializer.gemspec
170
103
  homepage: https://panko.dev
171
104
  licenses:
172
105
  - MIT
@@ -175,7 +108,6 @@ metadata:
175
108
  source_code_uri: https://github.com/yosiat/panko_serializer
176
109
  documentation_uri: https://panko.dev
177
110
  changelog_uri: https://github.com/yosiat/panko_serializer/releases
178
- post_install_message:
179
111
  rdoc_options: []
180
112
  require_paths:
181
113
  - lib
@@ -190,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
122
  - !ruby/object:Gem::Version
191
123
  version: '0'
192
124
  requirements: []
193
- rubygems_version: 3.5.23
194
- signing_key:
125
+ rubygems_version: 3.7.2
195
126
  specification_version: 4
196
127
  summary: High Performance JSON Serialization for ActiveRecord & Ruby Objects
197
128
  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,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@v4
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
- build:
7
- runs-on: ubuntu-latest
8
-
9
- steps:
10
- - uses: actions/checkout@v4
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.13.0
27
- with:
28
- clang-format-version: "16"
29
- check-path: "ext/panko_serializer"
30
- fallback-style: "Google"
@@ -1,51 +0,0 @@
1
- name: Panko Serializer CI
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- ruby: ["3.1", "3.2", "3.3"]
12
- rails: ["7.0.0", "7.1.0", "7.2.0", "8.0.0"]
13
- exclude:
14
- - ruby: 3.1
15
- rails: 8.0.0
16
-
17
- steps:
18
- - name: Install deps
19
- run: |
20
- sudo apt update -y
21
- sudo apt install -y libsqlite3-dev
22
-
23
- - uses: actions/checkout@v4
24
- - name: Set up Ruby ${{ matrix.ruby }}
25
- uses: ruby/setup-ruby@v1
26
- with:
27
- ruby-version: ${{ matrix.ruby }}
28
-
29
-
30
- - name: Gems Cache
31
- id: gem-cache
32
- uses: actions/cache@v4
33
- with:
34
- path: vendor/bundle
35
- key: ${{ runner.os }}-${{ matrix.ruby }}-${{ matrix.rails }}-gem
36
- restore-keys: |
37
- ${{ runner.os }}-${{ matrix.ruby }}-${{ matrix.rails }}-gem
38
-
39
- - name: Install gems
40
- env:
41
- BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
42
- run: |
43
- gem install bundler
44
- bundle config set path 'vendor/bundle'
45
- bundle check || bundle install --jobs 4 --retry 3
46
-
47
- - name: Compile & test
48
- env:
49
- BUNDLE_GEMFILE: gemfiles/${{ matrix.rails }}.gemfile
50
- run: |
51
- 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,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise "7.0.0" do
4
- gem "sqlite3", "~> 1.4"
5
- gem "activesupport", "~> 7.0.0"
6
- gem "activemodel", "~> 7.0.0"
7
- gem "activerecord", "~> 7.0.0", group: :test
8
- end
9
-
10
- appraise "7.1.0" do
11
- gem "sqlite3", "~> 1.4"
12
- gem "activesupport", "~> 7.1.5"
13
- gem "activemodel", "~> 7.1.5"
14
- gem "activerecord", "~> 7.1.5", group: :test
15
- end
16
-
17
- appraise "7.2.0" do
18
- gem "sqlite3", "~> 1.4"
19
- gem "activesupport", "~> 7.2.0"
20
- gem "activemodel", "~> 7.2.0"
21
- gem "activerecord", "~> 7.2.0", group: :test
22
- end
23
-
24
- appraise "8.0.0" do
25
- gem "sqlite3", ">= 2.1"
26
- gem "activesupport", "~> 8.0.0"
27
- gem "activemodel", "~> 8.0.0"
28
- gem "activerecord", "~> 8.0.0", group: :test
29
- end
data/Gemfile DELETED
@@ -1,36 +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
- end
21
-
22
- group :development do
23
- gem "byebug"
24
- gem "rake"
25
- gem "rspec", "~> 3.0"
26
- gem "rake-compiler"
27
- end
28
-
29
- group :development, :test do
30
- gem "rubocop"
31
-
32
- gem "standard"
33
- gem "standard-performance"
34
- gem "rubocop-performance"
35
- gem "rubocop-rspec"
36
- 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