alba 0.11.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +25 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +12 -5
- data/.yardopts +2 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +7 -4
- data/README.md +264 -29
- data/benchmark/local.rb +198 -0
- data/lib/alba.rb +52 -11
- data/lib/alba/association.rb +28 -3
- data/lib/alba/key_transformer.rb +31 -0
- data/lib/alba/many.rb +12 -4
- data/lib/alba/one.rb +11 -3
- data/lib/alba/resource.rb +176 -58
- data/lib/alba/version.rb +1 -1
- data/sider.yml +1 -0
- metadata +8 -6
- data/.travis.yml +0 -9
- data/Gemfile.lock +0 -89
- data/lib/alba/serializer.rb +0 -59
data/lib/alba/version.rb
CHANGED
data/sider.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OKURA Masafumi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Alba is designed to be a simple, easy to use and fast alternative to
|
14
14
|
existing JSON serializers. Its performance is better than almost all gems which
|
@@ -19,24 +19,26 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
+
- ".github/workflows/main.yml"
|
22
23
|
- ".gitignore"
|
23
24
|
- ".rubocop.yml"
|
24
|
-
- ".
|
25
|
+
- ".yardopts"
|
26
|
+
- CHANGELOG.md
|
25
27
|
- CODE_OF_CONDUCT.md
|
26
28
|
- Gemfile
|
27
|
-
- Gemfile.lock
|
28
29
|
- LICENSE.txt
|
29
30
|
- README.md
|
30
31
|
- Rakefile
|
31
32
|
- alba.gemspec
|
33
|
+
- benchmark/local.rb
|
32
34
|
- bin/console
|
33
35
|
- bin/setup
|
34
36
|
- lib/alba.rb
|
35
37
|
- lib/alba/association.rb
|
38
|
+
- lib/alba/key_transformer.rb
|
36
39
|
- lib/alba/many.rb
|
37
40
|
- lib/alba/one.rb
|
38
41
|
- lib/alba/resource.rb
|
39
|
-
- lib/alba/serializer.rb
|
40
42
|
- lib/alba/version.rb
|
41
43
|
- sider.yml
|
42
44
|
homepage: https://github.com/okuramasafumi/alba
|
@@ -61,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
63
|
- !ruby/object:Gem::Version
|
62
64
|
version: '0'
|
63
65
|
requirements: []
|
64
|
-
rubygems_version: 3.
|
66
|
+
rubygems_version: 3.2.14
|
65
67
|
signing_key:
|
66
68
|
specification_version: 4
|
67
69
|
summary: Alba is the fastest JSON serializer for Ruby.
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
alba (0.11.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (6.0.3.2)
|
10
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
-
i18n (>= 0.7, < 2)
|
12
|
-
minitest (~> 5.1)
|
13
|
-
tzinfo (~> 1.1)
|
14
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
15
|
-
ast (2.4.1)
|
16
|
-
bigdecimal (2.0.0)
|
17
|
-
concurrent-ruby (1.1.6)
|
18
|
-
coveralls (0.8.23)
|
19
|
-
json (>= 1.8, < 3)
|
20
|
-
simplecov (~> 0.16.1)
|
21
|
-
term-ansicolor (~> 1.3)
|
22
|
-
thor (>= 0.19.4, < 2.0)
|
23
|
-
tins (~> 1.6)
|
24
|
-
docile (1.3.2)
|
25
|
-
i18n (1.8.5)
|
26
|
-
concurrent-ruby (~> 1.0)
|
27
|
-
json (2.3.1)
|
28
|
-
minitest (5.14.1)
|
29
|
-
oj (3.10.12)
|
30
|
-
bigdecimal (>= 1.0, < 3)
|
31
|
-
parallel (1.19.2)
|
32
|
-
parser (2.7.1.4)
|
33
|
-
ast (~> 2.4.1)
|
34
|
-
rainbow (3.0.0)
|
35
|
-
rake (13.0.1)
|
36
|
-
regexp_parser (1.7.1)
|
37
|
-
rexml (3.2.4)
|
38
|
-
rubocop (0.89.1)
|
39
|
-
parallel (~> 1.10)
|
40
|
-
parser (>= 2.7.1.1)
|
41
|
-
rainbow (>= 2.2.2, < 4.0)
|
42
|
-
regexp_parser (>= 1.7)
|
43
|
-
rexml
|
44
|
-
rubocop-ast (>= 0.3.0, < 1.0)
|
45
|
-
ruby-progressbar (~> 1.7)
|
46
|
-
unicode-display_width (>= 1.4.0, < 2.0)
|
47
|
-
rubocop-ast (0.3.0)
|
48
|
-
parser (>= 2.7.1.4)
|
49
|
-
rubocop-minitest (0.10.1)
|
50
|
-
rubocop (>= 0.87)
|
51
|
-
rubocop-performance (1.7.1)
|
52
|
-
rubocop (>= 0.82.0)
|
53
|
-
rubocop-sensible (0.3.0)
|
54
|
-
rubocop (>= 0.60.0)
|
55
|
-
ruby-progressbar (1.10.1)
|
56
|
-
simplecov (0.16.1)
|
57
|
-
docile (~> 1.1)
|
58
|
-
json (>= 1.8, < 3)
|
59
|
-
simplecov-html (~> 0.10.0)
|
60
|
-
simplecov-html (0.10.2)
|
61
|
-
sync (0.5.0)
|
62
|
-
term-ansicolor (1.7.1)
|
63
|
-
tins (~> 1.0)
|
64
|
-
thor (1.0.1)
|
65
|
-
thread_safe (0.3.6)
|
66
|
-
tins (1.25.0)
|
67
|
-
sync
|
68
|
-
tzinfo (1.2.7)
|
69
|
-
thread_safe (~> 0.1)
|
70
|
-
unicode-display_width (1.7.0)
|
71
|
-
zeitwerk (2.4.0)
|
72
|
-
|
73
|
-
PLATFORMS
|
74
|
-
ruby
|
75
|
-
|
76
|
-
DEPENDENCIES
|
77
|
-
activesupport
|
78
|
-
alba!
|
79
|
-
coveralls
|
80
|
-
minitest (~> 5.0)
|
81
|
-
oj (~> 3.10)
|
82
|
-
rake (~> 13.0)
|
83
|
-
rubocop (>= 0.79.0)
|
84
|
-
rubocop-minitest (~> 0.10.1)
|
85
|
-
rubocop-performance (~> 1.7.1)
|
86
|
-
rubocop-sensible (~> 0.3.0)
|
87
|
-
|
88
|
-
BUNDLED WITH
|
89
|
-
2.1.4
|
data/lib/alba/serializer.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
module Alba
|
2
|
-
# This module represents how a resource should be serialized.
|
3
|
-
module Serializer
|
4
|
-
def self.included(base)
|
5
|
-
super
|
6
|
-
base.class_eval do
|
7
|
-
@_opts = {} unless instance_variable_defined?('@_opts')
|
8
|
-
@_metadata = {} unless instance_variable_defined?('@_metadata')
|
9
|
-
end
|
10
|
-
base.include InstanceMethods
|
11
|
-
base.extend ClassMethods
|
12
|
-
end
|
13
|
-
|
14
|
-
# Instance methods
|
15
|
-
module InstanceMethods
|
16
|
-
def initialize(resource)
|
17
|
-
@resource = resource
|
18
|
-
@hash = resource.serializable_hash
|
19
|
-
@hash = {key.to_sym => @hash} if key
|
20
|
-
# @hash is either Hash or Array
|
21
|
-
@hash.is_a?(Hash) ? @hash.merge!(metadata.to_h) : @hash << metadata
|
22
|
-
end
|
23
|
-
|
24
|
-
def serialize
|
25
|
-
Alba.encoder.call(@hash)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def key
|
31
|
-
opts = self.class._opts
|
32
|
-
opts[:key] == true ? @resource.key : opts[:key]
|
33
|
-
end
|
34
|
-
|
35
|
-
def metadata
|
36
|
-
metadata = self.class._metadata
|
37
|
-
metadata.transform_values { |block| block.call(@resource.object) }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Class methods
|
42
|
-
module ClassMethods
|
43
|
-
attr_reader :_opts, :_metadata
|
44
|
-
|
45
|
-
def inherited(subclass)
|
46
|
-
super
|
47
|
-
%w[_opts _metadata].each { |name| subclass.instance_variable_set("@#{name}", public_send(name).clone) }
|
48
|
-
end
|
49
|
-
|
50
|
-
def set(key: false)
|
51
|
-
@_opts[:key] = key
|
52
|
-
end
|
53
|
-
|
54
|
-
def metadata(name, &block)
|
55
|
-
@_metadata[name] = block
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|