alba 2.1.0 → 2.2.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 +1 -1
- data/.rubocop.yml +6 -1
- data/CHANGELOG.md +14 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +3 -2
- data/README.md +12 -2
- data/alba.gemspec +1 -1
- data/lib/alba/layout.rb +2 -2
- data/lib/alba/railtie.rb +8 -0
- data/lib/alba/resource.rb +3 -4
- data/lib/alba/version.rb +1 -1
- data/lib/alba.rb +2 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c68ec07a949642b11dfd36b3bf748249d0d725178ece9dd331e373fc2339cb8a
|
4
|
+
data.tar.gz: 7704431d69f96b88d9632c114dae90cfceae018c8372c8736c091efd2050b65a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98ca1b6fa7c6851f3a69d6d1cb54cd782a3142fccfb33391eb08cbc093ad691496a8fdb9e93e5ce89543032a0003ab8b60022ca8bbbba81c73de249b571a3fa6
|
7
|
+
data.tar.gz: 3756fe21da92358031a722d83b7169ef81e8749ccf6430bef577dfaac7ab4a80e68c07c6e0205497e54692f74b16e66aabad390db6eda09e486a732387541630
|
data/.github/workflows/main.yml
CHANGED
@@ -8,7 +8,7 @@ jobs:
|
|
8
8
|
fail-fast: false
|
9
9
|
matrix:
|
10
10
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
11
|
-
ruby: [2.
|
11
|
+
ruby: [2.7, 3.0, 3.1, 3.2, head, jruby, truffleruby]
|
12
12
|
gemfile: [all, without_active_support, without_oj]
|
13
13
|
exclude:
|
14
14
|
- os: windows-latest
|
data/.rubocop.yml
CHANGED
@@ -16,7 +16,7 @@ AllCops:
|
|
16
16
|
- 'script/**/*.rb'
|
17
17
|
NewCops: enable
|
18
18
|
EnabledByDefault: true
|
19
|
-
TargetRubyVersion: 2.
|
19
|
+
TargetRubyVersion: 2.7
|
20
20
|
|
21
21
|
# Items in Gemfile is dev dependencies and we don't have to specify versions.
|
22
22
|
Bundler/GemVersion:
|
@@ -58,6 +58,11 @@ Metrics/ParameterLists:
|
|
58
58
|
Exclude:
|
59
59
|
- 'test/**/*.rb'
|
60
60
|
|
61
|
+
# Putting extra empty line is not valuable in test
|
62
|
+
# We prefer shorter test code
|
63
|
+
Minitest/EmptyLineBeforeAssertionMethods:
|
64
|
+
Enabled: false
|
65
|
+
|
61
66
|
# We need to eval resource code to test errors on resource classes
|
62
67
|
Security/Eval:
|
63
68
|
Exclude:
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.2.0] 2023-02-17
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Rails integration to set default inflector [#298](https://github.com/okuramasafumi/alba/pull/298)
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Fix cascade not working with association and inheritance [#300](https://github.com/okuramasafumi/alba/pull/300)
|
18
|
+
|
19
|
+
### Removed
|
20
|
+
|
21
|
+
- Drop support of Ruby 2.6
|
22
|
+
|
9
23
|
## [2.1.0] 2022-12-03
|
10
24
|
|
11
25
|
### Added
|
data/CONTRIBUTING.md
CHANGED
@@ -27,4 +27,4 @@ You're more than welcomed to submit a Pull Request! You are expected to follow t
|
|
27
27
|
## Documents
|
28
28
|
|
29
29
|
* [code of conduct](https://github.com/okuramasafumi/alba/blob/master/CODE_OF_CONDUCT.md) for all contributors
|
30
|
-
* [hacking document](https://github.com/okuramasafumi/alba/blob/
|
30
|
+
* [hacking document](https://github.com/okuramasafumi/alba/blob/main/HACKING.md) for those who want to know the internal of Alba
|
data/Gemfile
CHANGED
@@ -7,10 +7,11 @@ gem 'activesupport', require: false # For backend
|
|
7
7
|
gem 'dry-inflector', require: false # For inflection
|
8
8
|
gem 'ffaker', require: false # For testing
|
9
9
|
gem 'minitest', '~> 5.14' # For test
|
10
|
+
gem 'railties', require: false # For Rails integration testing
|
10
11
|
gem 'rake', '~> 13.0' # For test and automation
|
11
12
|
gem 'rubocop', '>= 0.79.0', require: false # For lint
|
12
|
-
gem 'rubocop-minitest', '
|
13
|
-
gem 'rubocop-performance', '
|
13
|
+
gem 'rubocop-minitest', '>= 0.25.0', require: false # For lint
|
14
|
+
gem 'rubocop-performance', '>= 1.15.0', require: false # For lint
|
14
15
|
gem 'rubocop-rake', '>= 0.5.1', require: false # For lint
|
15
16
|
gem 'rubocop-sensible', '~> 0.3.0', require: false # For lint
|
16
17
|
gem 'ruby-lsp', require: false # For language server
|
data/README.md
CHANGED
@@ -23,6 +23,16 @@ If you have feature requests or interesting ideas, join us with [Ideas](https://
|
|
23
23
|
|
24
24
|
If you want to know more about Alba, there's a [screencast](https://hanamimastery.com/episodes/21-serialization-with-alba) created by Sebastian from [Hanami Mastery](https://hanamimastery.com/). It covers basic features of Alba and how to use it in Hanami.
|
25
25
|
|
26
|
+
## What users say about Alba
|
27
|
+
|
28
|
+
> Alba is a well-maintained JSON serialization engine, for Ruby, JRuby, and TruffleRuby implementations, and what I like in this gem - except of its speed, is the easiness of use, no dependencies and the fact it plays well with any Ruby application!
|
29
|
+
|
30
|
+
[Hanami Mastery by Seb Wilgosz](https://hanamimastery.com/episodes/21-serialization-with-alba)
|
31
|
+
|
32
|
+
> Alba is more feature-rich and pretty fast, too
|
33
|
+
|
34
|
+
[Gemfile of dreams by Evil Martians](https://evilmartians.com/chronicles/gemfile-of-dreams-libraries-we-use-to-build-rails-apps)
|
35
|
+
|
26
36
|
## Why Alba?
|
27
37
|
|
28
38
|
Because it's fast, easy and feature rich!
|
@@ -57,7 +67,7 @@ Or install it yourself as:
|
|
57
67
|
|
58
68
|
## Supported Ruby versions
|
59
69
|
|
60
|
-
Alba supports CRuby 2.
|
70
|
+
Alba supports CRuby 2.7 and higher and latest JRuby and TruffleRuby.
|
61
71
|
|
62
72
|
## Documentation
|
63
73
|
|
@@ -1072,7 +1082,7 @@ You can validate and convert input with types.
|
|
1072
1082
|
class User
|
1073
1083
|
attr_reader :id, :name, :age, :bio, :admin, :created_at
|
1074
1084
|
|
1075
|
-
def initialize(id, name, age, bio = '', admin = false)
|
1085
|
+
def initialize(id, name, age, bio = '', admin = false)
|
1076
1086
|
@id = id
|
1077
1087
|
@name = name
|
1078
1088
|
@age = age
|
data/alba.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.description = "Alba is the fastest JSON serializer for Ruby. It focuses on performance, flexibility and usability."
|
11
11
|
spec.homepage = 'https://github.com/okuramasafumi/alba'
|
12
12
|
spec.license = 'MIT'
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
14
14
|
|
15
15
|
spec.metadata = {
|
16
16
|
'bug_tracker_uri' => 'https://github.com/okuramasafumi/issues',
|
data/lib/alba/layout.rb
CHANGED
@@ -8,8 +8,8 @@ module Alba
|
|
8
8
|
|
9
9
|
def_delegators :@resource, :object, :params, :serializable_hash, :to_h
|
10
10
|
|
11
|
-
# @
|
12
|
-
# @
|
11
|
+
# @param file [String] name of the layout file
|
12
|
+
# @param inline [Proc] a proc returning JSON string or a Hash representing JSON
|
13
13
|
def initialize(file:, inline:)
|
14
14
|
if file
|
15
15
|
raise ArgumentError, 'File layout must be a String representing filename' unless file.is_a?(String)
|
data/lib/alba/railtie.rb
ADDED
data/lib/alba/resource.rb
CHANGED
@@ -11,7 +11,7 @@ module Alba
|
|
11
11
|
module Resource
|
12
12
|
# @!parse include InstanceMethods
|
13
13
|
# @!parse extend ClassMethods
|
14
|
-
DSLS = {_attributes: {}, _key: nil, _key_for_collection: nil, _meta: nil, _transform_type: :none, _transforming_root_key: false, _on_error: nil, _on_nil: nil, _layout: nil, _collection_key: nil}.freeze # rubocop:disable Layout/LineLength
|
14
|
+
DSLS = {_attributes: {}, _key: nil, _key_for_collection: nil, _meta: nil, _transform_type: :none, _transforming_root_key: false, _key_transformation_cascade: true, _on_error: nil, _on_nil: nil, _layout: nil, _collection_key: nil}.freeze # rubocop:disable Layout/LineLength
|
15
15
|
private_constant :DSLS
|
16
16
|
|
17
17
|
WITHIN_DEFAULT = Object.new.freeze
|
@@ -78,7 +78,6 @@ module Alba
|
|
78
78
|
#
|
79
79
|
# @param root_key [Symbol, nil, true]
|
80
80
|
# @param meta [Hash] metadata for this seialization
|
81
|
-
# @param symbolize_root_key [Boolean] determines if root key should be symbolized
|
82
81
|
# @return [Hash]
|
83
82
|
def as_json(root_key: nil, meta: {})
|
84
83
|
key = root_key.nil? ? fetch_key : root_key.to_s
|
@@ -442,8 +441,8 @@ module Alba
|
|
442
441
|
|
443
442
|
# Set layout
|
444
443
|
#
|
445
|
-
# @
|
446
|
-
# @
|
444
|
+
# @param file [String] name of the layout file
|
445
|
+
# @param inline [Proc] a proc returning JSON string or a Hash representing JSON
|
447
446
|
def layout(file: nil, inline: nil)
|
448
447
|
@_layout = Layout.new(file: file, inline: inline)
|
449
448
|
end
|
data/lib/alba/version.rb
CHANGED
data/lib/alba.rb
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: 2.
|
4
|
+
version: 2.2.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: 2023-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Alba is the fastest JSON serializer for Ruby. It focuses on performance,
|
14
14
|
flexibility and usability.
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/alba/errors.rb
|
60
60
|
- lib/alba/layout.rb
|
61
61
|
- lib/alba/nested_attribute.rb
|
62
|
+
- lib/alba/railtie.rb
|
62
63
|
- lib/alba/resource.rb
|
63
64
|
- lib/alba/typed_attribute.rb
|
64
65
|
- lib/alba/version.rb
|
@@ -83,14 +84,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
84
|
requirements:
|
84
85
|
- - ">="
|
85
86
|
- !ruby/object:Gem::Version
|
86
|
-
version: 2.
|
87
|
+
version: 2.7.0
|
87
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
89
|
requirements:
|
89
90
|
- - ">="
|
90
91
|
- !ruby/object:Gem::Version
|
91
92
|
version: '0'
|
92
93
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
94
|
+
rubygems_version: 3.4.6
|
94
95
|
signing_key:
|
95
96
|
specification_version: 4
|
96
97
|
summary: Alba is the fastest JSON serializer for Ruby.
|