panko_serializer 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/docs.yml +39 -0
- data/.github/workflows/ruby.yml +48 -0
- data/Gemfile +2 -2
- data/README.md +3 -3
- data/docs/core/Footer.js +2 -2
- data/docs/docs/associations.md +2 -2
- data/docs/docs/attributes.md +2 -2
- data/docs/docs/design-choices.md +1 -1
- data/docs/docs/introduction.md +1 -1
- data/docs/docs/response-bag.md +19 -0
- data/docs/package-lock.json +6 -6
- data/docs/siteConfig.js +4 -3
- data/ext/panko_serializer/attributes_writer/active_record.c +52 -11
- data/ext/panko_serializer/attributes_writer/attributes_writer.c +6 -3
- data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.c +7 -10
- data/lib/panko/association.rb +1 -1
- data/lib/panko/response.rb +5 -4
- data/lib/panko/version.rb +1 -1
- data/panko_serializer.gemspec +6 -6
- metadata +15 -15
- data/.travis.yml +0 -37
- data/docs/docs/panko/docpress.json +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cbaf86b0b95041f6f3387c8d82cc8ef1fa272549e50b5d3fdac2d13989f1a29
|
4
|
+
data.tar.gz: 41496c877bee39fa9fe7f136469ea260c1c60feeb25c6f95930b8c13a9055b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c30cbbde27a0ff4cead7b0763c1a76d0d179053e7d913ac81594eedb50defee858792d0893e19a42bd5b5ea71e6c5e4ed2cc3371a2d48d1dce4d53737a4d584
|
7
|
+
data.tar.gz: 0dd1443b07977c1eea6457016f4db43d88fcf857ea607bf9064b72485e4f7d78e0ffcf39fe1f9b83456c0477da3988ee6a392730bfe84565d266816484e01589
|
@@ -0,0 +1,39 @@
|
|
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 ]
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
env:
|
15
|
+
working_directory: 'docs/'
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
20
|
+
uses: actions/setup-node@v1
|
21
|
+
with:
|
22
|
+
node-version: '12.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.2.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=panko-serializer CURRENT_BRANCH=master USE_SSH=true npm run publish-gh-pages
|
39
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
name: Panko Serializer CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
ruby: [ '2.5', '2.6', '2.7']
|
13
|
+
rails: ['5.2.0', '6.0.0', '6.1.0rc1']
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
18
|
+
uses: actions/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
|
22
|
+
- name: Install deps
|
23
|
+
run: |
|
24
|
+
sudo apt update -y
|
25
|
+
sudo apt install -y libsqlite3-dev
|
26
|
+
|
27
|
+
- name: Gems Cache
|
28
|
+
id: gem-cache
|
29
|
+
uses: actions/cache@v1
|
30
|
+
with:
|
31
|
+
path: vendor/bundle
|
32
|
+
key: ${{ runner.os }}-${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
33
|
+
restore-keys: |
|
34
|
+
${{ runner.os }}-${{ matrix.ruby }}-${{ matrix.rails }}-gem
|
35
|
+
|
36
|
+
- name: Install gems
|
37
|
+
env:
|
38
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
39
|
+
run: |
|
40
|
+
gem install bundler
|
41
|
+
bundle config set path 'vendor/bundle'
|
42
|
+
bundle check || bundle install --jobs 4 --retry 3
|
43
|
+
|
44
|
+
- name: Compile & test
|
45
|
+
env:
|
46
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
47
|
+
run: |
|
48
|
+
bundle exec rake
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# Panko
|
2
2
|
|
3
|
-
|
3
|
+
![Build Status](https://github.com/panko-serializer/panko_serializer/workflows/Panko%20Serializer%20CI/badge.svg?branch=github-actions)
|
4
4
|
|
5
5
|
Panko is library which is inspired by ActiveModelSerializers 0.9 for serializing ActiveRecord/Ruby objects to JSON strings, fast.
|
6
6
|
|
7
7
|
To achieve it's [performance](https://panko.dev/docs/performance.html):
|
8
8
|
|
9
|
-
* Oj - Panko relies Oj since it's fast and allow to
|
9
|
+
* Oj - Panko relies Oj since it's fast and allow to serialize incrementally using `Oj::StringWriter`
|
10
10
|
* Serialization Descriptor - Panko computes most of the metadata ahead of time, to save time later in serialization.
|
11
|
-
* Type casting — Panko does type casting by it's self, instead of relying ActiveRecord.
|
11
|
+
* Type casting — Panko does type casting by it's self, instead of relying on ActiveRecord.
|
12
12
|
|
13
13
|
To dig deeper about the performance choices, read [Design Choices](https://panko.dev/docs/design-choices.html).
|
14
14
|
|
data/docs/core/Footer.js
CHANGED
@@ -48,13 +48,13 @@ class Footer extends React.Component {
|
|
48
48
|
</div>
|
49
49
|
<div>
|
50
50
|
<h5>More</h5>
|
51
|
-
<a href="https://github.com/
|
51
|
+
<a href="https://github.com/panko-serializer/panko_serializer">GitHub</a>
|
52
52
|
<a href="https://pankoserializer.herokuapp.com/">Slack</a>
|
53
53
|
<a
|
54
54
|
className="github-button"
|
55
55
|
href={this.props.config.repoUrl}
|
56
56
|
data-icon="octicon-star"
|
57
|
-
data-count-href="/
|
57
|
+
data-count-href="/panko-serializer/panko_serializer/stargazers"
|
58
58
|
data-show-count="true"
|
59
59
|
data-count-aria-label="# stargazers on GitHub"
|
60
60
|
aria-label="Star this project on GitHub">
|
data/docs/docs/associations.md
CHANGED
@@ -70,7 +70,7 @@ Panko::ArraySerializer.new(posts, only: {
|
|
70
70
|
})
|
71
71
|
```
|
72
72
|
|
73
|
-
Let's
|
73
|
+
Let's dissect `only` option we passed -
|
74
74
|
* `instance` - list of attributes (and associations) we want to serializer for current instance of the serializer, in this case - `PostSerializer`.
|
75
75
|
* `author`, `comments` - here we specify the list of attributes we want to serialize for each association.
|
76
76
|
|
@@ -91,4 +91,4 @@ Panko::ArraySerializer.new(posts, only: {
|
|
91
91
|
})
|
92
92
|
```
|
93
93
|
|
94
|
-
As you see now in `comments` the `instance` have
|
94
|
+
As you see now in `comments` the `instance` have different meaning, the `CommentSerializer`.
|
data/docs/docs/attributes.md
CHANGED
@@ -88,7 +88,7 @@ UserSerializer.new(except: [:name]).serialize(User.first)
|
|
88
88
|
> property is not taken into account.
|
89
89
|
> If you have a `has_many :state_transitions, name: :history` association
|
90
90
|
> defined, the key to use in filters is `:state_transitions`
|
91
|
-
> (e.g. `{ except: [:
|
91
|
+
> (e.g. `{ except: [:state_transitions] }`)
|
92
92
|
|
93
93
|
## Filters For
|
94
94
|
|
@@ -110,7 +110,7 @@ end
|
|
110
110
|
UserSerializer.serialize(User.first)
|
111
111
|
```
|
112
112
|
|
113
|
-
> See
|
113
|
+
> See discussion in: https://github.com/panko-serializer/panko_serializer/issues/16
|
114
114
|
|
115
115
|
## Aliases
|
116
116
|
|
data/docs/docs/design-choices.md
CHANGED
data/docs/docs/introduction.md
CHANGED
@@ -6,7 +6,7 @@ sidebar_label: Introduction
|
|
6
6
|
|
7
7
|
Panko is library which is inspired by ActiveModelSerializers 0.9 for serializing ActiveRecord/Ruby objects to JSON strings, fast.
|
8
8
|
|
9
|
-
To achieve it's [performance](https://
|
9
|
+
To achieve it's [performance](https://panko-serializer.github.io/panko_serializer/performance.html):
|
10
10
|
|
11
11
|
* Oj - Panko relies Oj since it's fast and allow to to serialize incrementally using `Oj::StringWriter`
|
12
12
|
* Serialization Descriptor - Panko computes most of the metadata ahead of time, to save time later in serialization.
|
data/docs/docs/response-bag.md
CHANGED
@@ -37,6 +37,25 @@ end
|
|
37
37
|
|
38
38
|
And everything will work as expected!
|
39
39
|
|
40
|
+
For a single object serialization, we need to use a different API (since `Panko::Serializer` don't accept an object in it's constructor):
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
class PostsController < ApplicationController
|
44
|
+
def show
|
45
|
+
post = Post.find(params[:id])
|
46
|
+
|
47
|
+
render(
|
48
|
+
json: Panko::Response.create do |r|
|
49
|
+
{
|
50
|
+
success: true,
|
51
|
+
post: r.serializer(post, PostSerializer)
|
52
|
+
}
|
53
|
+
end
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
40
59
|
## JsonValue
|
41
60
|
|
42
61
|
Let's take the above example further, we serialized the posts and cached it as JSON string in our Cache.
|
data/docs/package-lock.json
CHANGED
@@ -7499,9 +7499,9 @@
|
|
7499
7499
|
"dev": true
|
7500
7500
|
},
|
7501
7501
|
"prismjs": {
|
7502
|
-
"version": "1.
|
7503
|
-
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.
|
7504
|
-
"integrity": "sha512-
|
7502
|
+
"version": "1.21.0",
|
7503
|
+
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.21.0.tgz",
|
7504
|
+
"integrity": "sha512-uGdSIu1nk3kej2iZsLyDoJ7e9bnPzIgY0naW/HdknGj61zScaprVEVGHrPoXqI+M9sP0NDnTK2jpkvmldpuqDw==",
|
7505
7505
|
"dev": true,
|
7506
7506
|
"requires": {
|
7507
7507
|
"clipboard": "^2.0.0"
|
@@ -9530,9 +9530,9 @@
|
|
9530
9530
|
}
|
9531
9531
|
},
|
9532
9532
|
"websocket-extensions": {
|
9533
|
-
"version": "0.1.
|
9534
|
-
"resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.
|
9535
|
-
"integrity": "sha512-
|
9533
|
+
"version": "0.1.4",
|
9534
|
+
"resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz",
|
9535
|
+
"integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==",
|
9536
9536
|
"dev": true
|
9537
9537
|
},
|
9538
9538
|
"whatwg-url": {
|
data/docs/siteConfig.js
CHANGED
@@ -26,15 +26,16 @@ const siteConfig = {
|
|
26
26
|
tagline: 'High Performance JSON Serialization for ActiveRecord & Ruby Objects',
|
27
27
|
url: 'https://panko.dev',
|
28
28
|
baseUrl: '/',
|
29
|
-
repoPath: '
|
29
|
+
repoPath: 'panko-serializer/panko_serializer',
|
30
30
|
// For github.io type URLs, you would set the url and baseUrl like:
|
31
31
|
// url: 'https://facebook.github.io',
|
32
32
|
// baseUrl: '/test-site/',
|
33
33
|
customDocsPath: require('path').basename(__dirname) + '/docs',
|
34
34
|
|
35
|
-
repoUrl: 'https://github.com/
|
35
|
+
repoUrl: 'https://github.com/panko-serializer/panko_serializer',
|
36
36
|
projectName: 'panko_serializer',
|
37
|
-
organizationName: '
|
37
|
+
organizationName: 'panko-serializer',
|
38
|
+
cname: 'panko.dev',
|
38
39
|
|
39
40
|
headerLinks: [
|
40
41
|
{doc: 'index', label: 'Docs'},
|
@@ -9,7 +9,13 @@ static ID delegate_hash_id;
|
|
9
9
|
static ID value_before_type_cast_id;
|
10
10
|
static ID type_id;
|
11
11
|
|
12
|
-
|
12
|
+
static bool type_detection_ran = false;
|
13
|
+
static bool is_lazy_attributes_set_defined = false;
|
14
|
+
|
15
|
+
/***
|
16
|
+
* Returns ActiveModel::LazyAttributeSet or ActiveModel::LazyAttributesHash
|
17
|
+
*/
|
18
|
+
VALUE panko_read_attributes_container(VALUE object) {
|
13
19
|
volatile VALUE attributes_set, lazy_attributes_hash;
|
14
20
|
|
15
21
|
attributes_set = rb_ivar_get(object, attributes_id);
|
@@ -17,6 +23,10 @@ VALUE panko_read_lazy_attributes_hash(VALUE object) {
|
|
17
23
|
return Qnil;
|
18
24
|
}
|
19
25
|
|
26
|
+
if (is_lazy_attributes_set_defined) {
|
27
|
+
return attributes_set;
|
28
|
+
}
|
29
|
+
|
20
30
|
lazy_attributes_hash = rb_ivar_get(attributes_set, attributes_id);
|
21
31
|
return lazy_attributes_hash;
|
22
32
|
}
|
@@ -41,23 +51,32 @@ struct attributes init_context(VALUE obj) {
|
|
41
51
|
|
42
52
|
attributes_ctx.tryToReadFromAdditionalTypes = false;
|
43
53
|
|
44
|
-
volatile VALUE
|
54
|
+
volatile VALUE attributes_container = panko_read_attributes_container(obj);
|
45
55
|
|
46
|
-
if (RB_TYPE_P(
|
47
|
-
attributes_ctx.attributes_hash =
|
56
|
+
if (RB_TYPE_P(attributes_container, T_HASH)) {
|
57
|
+
attributes_ctx.attributes_hash = attributes_container;
|
48
58
|
} else {
|
49
|
-
|
50
|
-
|
59
|
+
if(is_lazy_attributes_set_defined == false) {
|
60
|
+
volatile VALUE delegate_hash =
|
61
|
+
rb_ivar_get(attributes_container, delegate_hash_id);
|
62
|
+
|
63
|
+
if (PANKO_EMPTY_HASH(delegate_hash) == false) {
|
64
|
+
attributes_ctx.attributes_hash = delegate_hash;
|
65
|
+
}
|
66
|
+
} else {
|
67
|
+
volatile VALUE attributes_hash =
|
68
|
+
rb_ivar_get(attributes_container, attributes_id);
|
51
69
|
|
52
|
-
|
53
|
-
|
70
|
+
if (PANKO_EMPTY_HASH(attributes_hash) == false) {
|
71
|
+
attributes_ctx.attributes_hash = attributes_hash;
|
72
|
+
}
|
54
73
|
}
|
55
74
|
|
56
|
-
attributes_ctx.types = rb_ivar_get(
|
57
|
-
attributes_ctx.values = rb_ivar_get(
|
75
|
+
attributes_ctx.types = rb_ivar_get(attributes_container, types_id);
|
76
|
+
attributes_ctx.values = rb_ivar_get(attributes_container, values_id);
|
58
77
|
|
59
78
|
attributes_ctx.additional_types =
|
60
|
-
rb_ivar_get(
|
79
|
+
rb_ivar_get(attributes_container, additional_types_id);
|
61
80
|
attributes_ctx.tryToReadFromAdditionalTypes =
|
62
81
|
PANKO_EMPTY_HASH(attributes_ctx.additional_types) == false;
|
63
82
|
}
|
@@ -107,8 +126,30 @@ VALUE read_attribute(struct attributes attributes_ctx, Attribute attribute, VALU
|
|
107
126
|
return value;
|
108
127
|
}
|
109
128
|
|
129
|
+
VALUE detect_active_model_changes(VALUE v) {
|
130
|
+
if (type_detection_ran == true) {
|
131
|
+
return Qundef;
|
132
|
+
}
|
133
|
+
|
134
|
+
type_detection_ran = true;
|
135
|
+
|
136
|
+
volatile VALUE active_model_type =
|
137
|
+
rb_const_get_at(rb_cObject, rb_intern("ActiveModel"));
|
138
|
+
|
139
|
+
is_lazy_attributes_set_defined =
|
140
|
+
rb_const_defined(active_model_type, rb_intern("LazyAttributeSet")) > 0;
|
141
|
+
|
142
|
+
return Qundef;
|
143
|
+
}
|
144
|
+
|
110
145
|
void active_record_attributes_writer(VALUE obj, VALUE attributes,
|
111
146
|
EachAttributeFunc write_value, VALUE writer) {
|
147
|
+
if (type_detection_ran == false) {
|
148
|
+
// If ActiveModel can't be found it will throw error
|
149
|
+
int isErrored;
|
150
|
+
rb_protect(detect_active_model_changes, Qnil, &isErrored);
|
151
|
+
}
|
152
|
+
|
112
153
|
long i;
|
113
154
|
struct attributes attributes_ctx = init_context(obj);
|
114
155
|
volatile VALUE record_class = CLASS_OF(obj);
|
@@ -13,6 +13,7 @@ VALUE init_types(VALUE v) {
|
|
13
13
|
|
14
14
|
volatile VALUE ar_type =
|
15
15
|
rb_const_get_at(rb_cObject, rb_intern("ActiveRecord"));
|
16
|
+
|
16
17
|
ar_base_type = rb_const_get_at(ar_type, rb_intern("Base"));
|
17
18
|
|
18
19
|
hash_type = rb_const_get_at(rb_cObject, rb_intern("Hash"));
|
@@ -25,11 +26,13 @@ AttributesWriter create_attributes_writer(VALUE object) {
|
|
25
26
|
int isErrored;
|
26
27
|
rb_protect(init_types, Qnil, &isErrored);
|
27
28
|
|
29
|
+
|
28
30
|
if (ar_base_type != Qundef &&
|
29
31
|
rb_obj_is_kind_of(object, ar_base_type) == Qtrue) {
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
|
33
|
+
return (AttributesWriter){
|
34
|
+
.object_type = ActiveRecord,
|
35
|
+
.write_attributes = active_record_attributes_writer};
|
33
36
|
}
|
34
37
|
|
35
38
|
if (rb_obj_is_kind_of(object, hash_type) == Qtrue) {
|
@@ -1,7 +1,5 @@
|
|
1
1
|
#include "serialization_descriptor.h"
|
2
2
|
|
3
|
-
VALUE cSerializationDescriptor;
|
4
|
-
|
5
3
|
static ID object_id;
|
6
4
|
static ID sc_id;
|
7
5
|
|
@@ -10,8 +8,8 @@ static void sd_free(SerializationDescriptor sd) {
|
|
10
8
|
return;
|
11
9
|
}
|
12
10
|
|
13
|
-
sd->serializer_type = Qnil;
|
14
11
|
sd->serializer = Qnil;
|
12
|
+
sd->serializer_type = Qnil;
|
15
13
|
sd->attributes = Qnil;
|
16
14
|
sd->method_fields = Qnil;
|
17
15
|
sd->has_one_associations = Qnil;
|
@@ -21,8 +19,8 @@ static void sd_free(SerializationDescriptor sd) {
|
|
21
19
|
}
|
22
20
|
|
23
21
|
void sd_mark(SerializationDescriptor data) {
|
24
|
-
rb_gc_mark(data->serializer_type);
|
25
22
|
rb_gc_mark(data->serializer);
|
23
|
+
rb_gc_mark(data->serializer_type);
|
26
24
|
rb_gc_mark(data->attributes);
|
27
25
|
rb_gc_mark(data->method_fields);
|
28
26
|
rb_gc_mark(data->has_one_associations);
|
@@ -30,7 +28,7 @@ void sd_mark(SerializationDescriptor data) {
|
|
30
28
|
rb_gc_mark(data->aliases);
|
31
29
|
}
|
32
30
|
|
33
|
-
static VALUE
|
31
|
+
static VALUE sd_alloc(VALUE klass) {
|
34
32
|
SerializationDescriptor sd = ALLOC(struct _SerializationDescriptor);
|
35
33
|
|
36
34
|
sd->serializer = Qnil;
|
@@ -43,7 +41,7 @@ static VALUE sd_new(int argc, VALUE* argv, VALUE self) {
|
|
43
41
|
|
44
42
|
sd->attributes_writer = create_empty_attributes_writer();
|
45
43
|
|
46
|
-
return Data_Wrap_Struct(
|
44
|
+
return Data_Wrap_Struct(klass, sd_mark, sd_free, sd);
|
47
45
|
}
|
48
46
|
|
49
47
|
SerializationDescriptor sd_read(VALUE descriptor) {
|
@@ -122,7 +120,7 @@ VALUE sd_type_set(VALUE self, VALUE type) {
|
|
122
120
|
return Qnil;
|
123
121
|
}
|
124
122
|
|
125
|
-
VALUE sd_type_aref(VALUE self
|
123
|
+
VALUE sd_type_aref(VALUE self) {
|
126
124
|
SerializationDescriptor sd = (SerializationDescriptor)DATA_PTR(self);
|
127
125
|
return sd->serializer_type;
|
128
126
|
}
|
@@ -142,11 +140,10 @@ void panko_init_serialization_descriptor(VALUE mPanko) {
|
|
142
140
|
object_id = rb_intern("@object");
|
143
141
|
sc_id = rb_intern("@sc");
|
144
142
|
|
145
|
-
cSerializationDescriptor =
|
143
|
+
VALUE cSerializationDescriptor =
|
146
144
|
rb_define_class_under(mPanko, "SerializationDescriptor", rb_cObject);
|
147
145
|
|
148
|
-
|
149
|
-
|
146
|
+
rb_define_alloc_func(cSerializationDescriptor, sd_alloc);
|
150
147
|
rb_define_method(cSerializationDescriptor, "serializer=", sd_serializer_set,
|
151
148
|
1);
|
152
149
|
rb_define_method(cSerializationDescriptor, "serializer", sd_serializer_ref,
|
data/lib/panko/association.rb
CHANGED
data/lib/panko/response.rb
CHANGED
@@ -22,12 +22,13 @@ module Panko
|
|
22
22
|
Panko::JsonValue.from(value)
|
23
23
|
end
|
24
24
|
|
25
|
-
def self.array_serializer(data, serializer)
|
26
|
-
|
25
|
+
def self.array_serializer(data, serializer, options = {})
|
26
|
+
merged_options = options.merge(each_serializer: serializer)
|
27
|
+
Panko::ArraySerializer.new(data, merged_options)
|
27
28
|
end
|
28
29
|
|
29
|
-
def self.serializer(data, serializer)
|
30
|
-
json serializer.new.serialize_to_json(data)
|
30
|
+
def self.serializer(data, serializer, options = {})
|
31
|
+
json serializer.new(options).serialize_to_json(data)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
data/lib/panko/version.rb
CHANGED
data/panko_serializer.gemspec
CHANGED
@@ -11,17 +11,17 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ["yosy101@gmail.com"]
|
12
12
|
|
13
13
|
spec.summary = "High Performance JSON Serialization for ActiveRecord & Ruby Objects"
|
14
|
-
spec.homepage = "https://
|
14
|
+
spec.homepage = "https://panko.dev"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.metadata = {
|
18
|
-
"bug_tracker_uri" => "https://github.com/
|
19
|
-
"source_code_uri" => "https://github.com/
|
20
|
-
"documentation_uri" => "https://
|
21
|
-
"changelog_uri" => "https://github.com/
|
18
|
+
"bug_tracker_uri" => "https://github.com/panko-serializer/panko_serializer/issues",
|
19
|
+
"source_code_uri" => "https://github.com/panko-serializer/panko_serializer",
|
20
|
+
"documentation_uri" => "https://panko-serializer.github.io/panko_serializer/",
|
21
|
+
"changelog_uri" => "https://github.com/panko-serializer/panko_serializer/releases"
|
22
22
|
}
|
23
23
|
|
24
|
-
spec.required_ruby_version = ">= 2.
|
24
|
+
spec.required_ruby_version = ">= 2.5.0"
|
25
25
|
|
26
26
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
27
|
f.match(%r{^(test|spec|features)/})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panko_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yosi Attias
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.10.0
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- yosy101@gmail.com
|
30
30
|
executables: []
|
@@ -33,10 +33,11 @@ extensions:
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- ".clang-format"
|
36
|
+
- ".github/workflows/docs.yml"
|
37
|
+
- ".github/workflows/ruby.yml"
|
36
38
|
- ".gitignore"
|
37
39
|
- ".rspec"
|
38
40
|
- ".rubocop.yml"
|
39
|
-
- ".travis.yml"
|
40
41
|
- Gemfile
|
41
42
|
- LICENSE.txt
|
42
43
|
- README.md
|
@@ -67,7 +68,6 @@ files:
|
|
67
68
|
- docs/docs/design-choices.md
|
68
69
|
- docs/docs/getting-started.md
|
69
70
|
- docs/docs/introduction.md
|
70
|
-
- docs/docs/panko/docpress.json
|
71
71
|
- docs/docs/performance.md
|
72
72
|
- docs/docs/response-bag.md
|
73
73
|
- docs/i18n/en.json
|
@@ -124,15 +124,15 @@ files:
|
|
124
124
|
- lib/panko/version.rb
|
125
125
|
- lib/panko_serializer.rb
|
126
126
|
- panko_serializer.gemspec
|
127
|
-
homepage: https://
|
127
|
+
homepage: https://panko.dev
|
128
128
|
licenses:
|
129
129
|
- MIT
|
130
130
|
metadata:
|
131
|
-
bug_tracker_uri: https://github.com/
|
132
|
-
source_code_uri: https://github.com/
|
133
|
-
documentation_uri: https://
|
134
|
-
changelog_uri: https://github.com/
|
135
|
-
post_install_message:
|
131
|
+
bug_tracker_uri: https://github.com/panko-serializer/panko_serializer/issues
|
132
|
+
source_code_uri: https://github.com/panko-serializer/panko_serializer
|
133
|
+
documentation_uri: https://panko-serializer.github.io/panko_serializer/
|
134
|
+
changelog_uri: https://github.com/panko-serializer/panko_serializer/releases
|
135
|
+
post_install_message:
|
136
136
|
rdoc_options: []
|
137
137
|
require_paths:
|
138
138
|
- lib
|
@@ -140,15 +140,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
140
|
requirements:
|
141
141
|
- - ">="
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version: 2.
|
143
|
+
version: 2.5.0
|
144
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
145
|
requirements:
|
146
146
|
- - ">="
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
151
|
-
signing_key:
|
150
|
+
rubygems_version: 3.1.4
|
151
|
+
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: High Performance JSON Serialization for ActiveRecord & Ruby Objects
|
154
154
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
cache: bundler
|
3
|
-
language: ruby
|
4
|
-
rvm:
|
5
|
-
- 2.5.7
|
6
|
-
- 2.6.5
|
7
|
-
- 2.7.0
|
8
|
-
- ruby-head
|
9
|
-
|
10
|
-
env:
|
11
|
-
global:
|
12
|
-
- GIT_NAME: Travis CI
|
13
|
-
- GIT_EMAIL: nobody@nobody.org
|
14
|
-
|
15
|
-
matrix:
|
16
|
-
- "RAILS_VERSION=4.2.0"
|
17
|
-
- "RAILS_VERSION=5.2.0"
|
18
|
-
- "RAILS_VERSION=6.0.0"
|
19
|
-
|
20
|
-
install: bundle install --path=vendor/bundle --retry=3
|
21
|
-
|
22
|
-
before_install:
|
23
|
-
- gem install bundler
|
24
|
-
- nvm install 12
|
25
|
-
|
26
|
-
after_success:
|
27
|
-
- cd docs/ && npm install
|
28
|
-
- if [ -n "$TRAVIS_TAG" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then cd docs/ && npm install && GIT_USER=yosiat CURRENT_BRANCH=news-docs USE_SSH=true npm run publish-gh-pages; fi
|
29
|
-
- bundle exec rake benchmarks
|
30
|
-
|
31
|
-
matrix:
|
32
|
-
exclude:
|
33
|
-
- rvm: 2.7.0
|
34
|
-
env: RAILS_VERSION=4.2.0
|
35
|
-
allow_failures:
|
36
|
-
- rvm: ruby-head
|
37
|
-
fast_finish: true
|