panko_serializer 0.8.4 → 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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/ext/panko_serializer/attributes_writer/type_cast/type_cast.c +23 -12
  4. data/lib/panko/version.rb +1 -1
  5. metadata +1 -65
  6. data/.clang-format +0 -3
  7. data/.github/dependabot.yml +0 -6
  8. data/.github/workflows/database_matrix.yml +0 -85
  9. data/.github/workflows/docs.yml +0 -39
  10. data/.github/workflows/lint.yml +0 -30
  11. data/.github/workflows/tests.yml +0 -34
  12. data/.gitignore +0 -20
  13. data/.rspec +0 -2
  14. data/.rubocop.yml +0 -37
  15. data/Appraisals +0 -28
  16. data/Gemfile +0 -37
  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 -150
  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 -17872
  45. data/docs/package.json +0 -18
  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.2.0.gemfile +0 -41
  64. data/gemfiles/7.2.0.gemfile.lock +0 -221
  65. data/gemfiles/8.0.0.gemfile +0 -41
  66. data/gemfiles/8.0.0.gemfile.lock +0 -239
  67. data/gemfiles/8.1.0.gemfile +0 -41
  68. data/gemfiles/8.1.0.gemfile.lock +0 -248
  69. data/panko_serializer.gemspec +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b4397a54b1f806131ee07ccaaa4062bba8eb5490c3810e5c6c3cc405b7167ec
4
- data.tar.gz: 8f3127a38fe93844c3a82aa8e2a30ea82312ef1b0ebdf66f86bcd4761c392749
3
+ metadata.gz: f713e7a7ea669bf0f3fa26ed2780c3f84a56a0faa0013f5514f6e732c49c86c3
4
+ data.tar.gz: b3eace69707162028e2ea379687cd7e3ee0d1bf8b2d1e68dda0402df3da9166e
5
5
  SHA512:
6
- metadata.gz: 626bf9689a4be25a166a7ee3fe3b2274cfcc9b7bb17d57398d87301aca1c8039835d02ef37de647d62d3fa5c102cc22f752b2400e10240fa992d2007eaf9344c
7
- data.tar.gz: 9a0048188abc83c9a064a0bb7721cc94a7f3965338f62a84fe4382a7b98f52941c1a1914f25dfee3bc7ed80168a1bb47f7def51954b9b1250029e4784f6f0a5d
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/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/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
19
  - [Documentation](https://panko.dev/)
20
- - [Getting Started](https://panko.dev/getting-started/)
20
+ - [Getting Started](https://panko.dev/getting-started)
21
21
 
22
22
  License
23
23
  -------
@@ -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) {
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.4"
4
+ VERSION = "0.8.5"
5
5
  end
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: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosi Attias
@@ -64,65 +64,8 @@ extensions:
64
64
  - ext/panko_serializer/extconf.rb
65
65
  extra_rdoc_files: []
66
66
  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
67
  - LICENSE.txt
79
68
  - 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
69
  - ext/panko_serializer/attributes_writer/active_record.c
127
70
  - ext/panko_serializer/attributes_writer/active_record.h
128
71
  - ext/panko_serializer/attributes_writer/attributes_writer.c
@@ -147,12 +90,6 @@ files:
147
90
  - ext/panko_serializer/serialization_descriptor/attribute.h
148
91
  - ext/panko_serializer/serialization_descriptor/serialization_descriptor.c
149
92
  - 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
93
  - lib/panko/array_serializer.rb
157
94
  - lib/panko/association.rb
158
95
  - lib/panko/attribute.rb
@@ -163,7 +100,6 @@ files:
163
100
  - lib/panko/serializer_resolver.rb
164
101
  - lib/panko/version.rb
165
102
  - lib/panko_serializer.rb
166
- - panko_serializer.gemspec
167
103
  homepage: https://panko.dev
168
104
  licenses:
169
105
  - MIT
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