alba 3.3.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/alba.gemspec +2 -0
- data/benchmark/Gemfile +24 -0
- data/lib/alba/version.rb +1 -1
- metadata +18 -5
- data/.github/workflows/perf.yml +0 -16
- data/script/perf_check.rb +0 -107
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38b89f99bfe18cf66179ed46c6fdcb5cb25f3d34b8f709fcb9c9de634f7a129b
|
4
|
+
data.tar.gz: b117d86ab11bb7a0b1abe8e2089ae869c8864fd37b066ea544d0ac51ad5082db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b62b63a9a7a4b1d85ba180941752a49d4bec97529794f328092b0bb7bc325daa683f5392a703d277f2c4e0b66e6af13b956706ecef6bfc729695aeff0c43e4d0
|
7
|
+
data.tar.gz: 3336d2097e5e4c78b690c6b3c178fdcef2db47271e1b929c1aeb246fb832632b69c26923abaf5e5e8df1e165d62495da85adce3e66aa8c404b103e65b1a82df1
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [3.3.1] 2024-10-17
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
- Add ostruct as gemspec dependency to be prepared for ruby 3.3.5. [#386](https://github.com/okuramasafumi/alba/pull/386)
|
14
|
+
|
9
15
|
## [3.3.0] 2024-10-09
|
10
16
|
|
11
17
|
### Added
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[![Maintainability](https://api.codeclimate.com/v1/badges/fdab4cc0de0b9addcfe8/maintainability)](https://codeclimate.com/github/okuramasafumi/alba/maintainability)
|
7
7
|
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/okuramasafumi/alba)
|
8
8
|
![GitHub](https://img.shields.io/github/license/okuramasafumi/alba)
|
9
|
-
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](
|
9
|
+
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
|
10
10
|
|
11
11
|
# Alba
|
12
12
|
|
data/alba.gemspec
CHANGED
data/benchmark/Gemfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
|
+
|
6
|
+
gem 'active_model_serializers'
|
7
|
+
gem 'activerecord', '~> 7.1'
|
8
|
+
gem 'alba', path: '../'
|
9
|
+
gem 'benchmark-ips'
|
10
|
+
gem 'benchmark-memory'
|
11
|
+
gem 'blueprinter'
|
12
|
+
gem 'fast_serializer_ruby'
|
13
|
+
gem 'jbuilder'
|
14
|
+
gem 'jserializer'
|
15
|
+
gem 'multi_json'
|
16
|
+
gem 'oj'
|
17
|
+
gem 'oj_serializers'
|
18
|
+
gem 'panko_serializer'
|
19
|
+
gem 'pg'
|
20
|
+
gem 'primalize'
|
21
|
+
gem 'representable'
|
22
|
+
gem 'simple_ams'
|
23
|
+
gem 'sqlite3', '~> 1.4'
|
24
|
+
gem 'turbostreamer'
|
data/lib/alba/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OKURA Masafumi
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2024-10-
|
11
|
-
dependencies:
|
10
|
+
date: 2024-10-17 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: ostruct
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0.6'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0.6'
|
12
26
|
description: Alba is the fastest JSON serializer for Ruby. It focuses on performance,
|
13
27
|
flexibility and usability.
|
14
28
|
email:
|
@@ -25,7 +39,6 @@ files:
|
|
25
39
|
- ".github/workflows/codeql-analysis.yml"
|
26
40
|
- ".github/workflows/lint.yml"
|
27
41
|
- ".github/workflows/main.yml"
|
28
|
-
- ".github/workflows/perf.yml"
|
29
42
|
- ".gitignore"
|
30
43
|
- ".rubocop.yml"
|
31
44
|
- ".yardopts"
|
@@ -39,6 +52,7 @@ files:
|
|
39
52
|
- Rakefile
|
40
53
|
- SECURITY.md
|
41
54
|
- alba.gemspec
|
55
|
+
- benchmark/Gemfile
|
42
56
|
- benchmark/README.md
|
43
57
|
- benchmark/collection.rb
|
44
58
|
- benchmark/prep.rb
|
@@ -68,7 +82,6 @@ files:
|
|
68
82
|
- logo/alba-card.png
|
69
83
|
- logo/alba-sign.png
|
70
84
|
- logo/alba-typography.png
|
71
|
-
- script/perf_check.rb
|
72
85
|
homepage: https://github.com/okuramasafumi/alba
|
73
86
|
licenses:
|
74
87
|
- MIT
|
data/.github/workflows/perf.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
name: Performance Check
|
2
|
-
|
3
|
-
on: [pull_request]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
build:
|
7
|
-
runs-on: ubuntu-latest
|
8
|
-
steps:
|
9
|
-
- uses: actions/checkout@v4
|
10
|
-
- name: Set up Ruby
|
11
|
-
uses: ruby/setup-ruby@v1
|
12
|
-
with:
|
13
|
-
ruby-version: 3.3
|
14
|
-
- name: Run benchmark
|
15
|
-
run: |
|
16
|
-
ruby script/perf_check.rb
|
data/script/perf_check.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
# Benchmark script to run varieties of JSON serializers
|
2
|
-
# Fetch Alba from local, otherwise fetch latest from RubyGems
|
3
|
-
# exit(status)
|
4
|
-
|
5
|
-
require_relative '../benchmark/prep'
|
6
|
-
|
7
|
-
# --- Alba serializers ---
|
8
|
-
|
9
|
-
require "alba"
|
10
|
-
|
11
|
-
class AlbaCommentResource
|
12
|
-
include ::Alba::Resource
|
13
|
-
attributes :id, :body
|
14
|
-
end
|
15
|
-
|
16
|
-
class AlbaPostResource
|
17
|
-
include ::Alba::Resource
|
18
|
-
attributes :id, :body
|
19
|
-
attribute :commenter_names do |post|
|
20
|
-
post.commenters.pluck(:name)
|
21
|
-
end
|
22
|
-
many :comments, resource: AlbaCommentResource
|
23
|
-
end
|
24
|
-
|
25
|
-
# --- Blueprint serializers ---
|
26
|
-
|
27
|
-
require "blueprinter"
|
28
|
-
|
29
|
-
class CommentBlueprint < Blueprinter::Base
|
30
|
-
fields :id, :body
|
31
|
-
end
|
32
|
-
|
33
|
-
class PostBlueprint < Blueprinter::Base
|
34
|
-
fields :id, :body, :commenter_names
|
35
|
-
association :comments, blueprint: CommentBlueprint
|
36
|
-
|
37
|
-
def commenter_names
|
38
|
-
commenters.pluck(:name)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# --- JBuilder serializers ---
|
43
|
-
|
44
|
-
require "jbuilder"
|
45
|
-
|
46
|
-
class Post
|
47
|
-
def to_builder
|
48
|
-
Jbuilder.new do |post|
|
49
|
-
post.call(self, :id, :body, :commenter_names, :comments)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def commenter_names
|
54
|
-
commenters.pluck(:name)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
class Comment
|
59
|
-
def to_builder
|
60
|
-
Jbuilder.new do |comment|
|
61
|
-
comment.call(self, :id, :body)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# --- Test data creation ---
|
67
|
-
|
68
|
-
100.times do |i|
|
69
|
-
post = Post.create!(body: "post#{i}")
|
70
|
-
user1 = User.create!(name: "John#{i}")
|
71
|
-
user2 = User.create!(name: "Jane#{i}")
|
72
|
-
10.times do |n|
|
73
|
-
post.comments.create!(commenter: user1, body: "Comment1_#{i}_#{n}")
|
74
|
-
post.comments.create!(commenter: user2, body: "Comment2_#{i}_#{n}")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
posts = Post.all.to_a
|
79
|
-
|
80
|
-
# --- Store the serializers in procs ---
|
81
|
-
|
82
|
-
alba = Proc.new { AlbaPostResource.new(posts).serialize }
|
83
|
-
blueprinter = Proc.new { PostBlueprint.render(posts) }
|
84
|
-
jbuilder = Proc.new do
|
85
|
-
Jbuilder.new do |json|
|
86
|
-
json.array!(posts) do |post|
|
87
|
-
json.post post.to_builder
|
88
|
-
end
|
89
|
-
end.target!
|
90
|
-
end
|
91
|
-
|
92
|
-
# --- Run the benchmarks ---
|
93
|
-
|
94
|
-
require 'benchmark/ips'
|
95
|
-
result = Benchmark.ips do |x|
|
96
|
-
x.report(:alba, &alba)
|
97
|
-
x.report(:blueprinter, &blueprinter)
|
98
|
-
x.report(:jbuilder, &jbuilder)
|
99
|
-
end
|
100
|
-
|
101
|
-
entries = result.entries.map {|entry| [entry.label, entry.iterations]}
|
102
|
-
alba_ips = entries.find {|e| e.first == :alba }.last
|
103
|
-
blueprinter_ips = entries.find {|e| e.first == :blueprinter }.last
|
104
|
-
jbuidler_ips = entries.find {|e| e.first == :jbuilder }.last
|
105
|
-
# Alba should be as fast as jbuilder and faster than blueprinter
|
106
|
-
alba_is_fast_enough = (alba_ips - jbuidler_ips) > -10.0 && (alba_ips - blueprinter_ips) > 10.0
|
107
|
-
exit(alba_is_fast_enough)
|