alba 1.1.0 → 1.5.0
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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +26 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/dependabot.yml +26 -0
- data/.github/workflows/perf.yml +21 -0
- data/.rubocop.yml +18 -8
- data/.yardopts +2 -0
- data/CHANGELOG.md +40 -0
- data/Gemfile +4 -3
- data/README.md +377 -14
- data/SECURITY.md +12 -0
- data/alba.gemspec +2 -2
- data/benchmark/collection.rb +441 -0
- data/benchmark/{local.rb → single_resource.rb} +120 -15
- data/codecov.yml +3 -0
- data/docs/migrate_from_active_model_serializers.md +359 -0
- data/docs/migrate_from_jbuilder.md +223 -0
- data/gemfiles/all.gemfile +1 -1
- data/gemfiles/without_active_support.gemfile +1 -1
- data/gemfiles/without_oj.gemfile +1 -1
- data/lib/alba/association.rb +14 -17
- data/lib/alba/default_inflector.rb +36 -0
- data/lib/alba/deprecation.rb +14 -0
- data/lib/alba/key_transform_factory.rb +33 -0
- data/lib/alba/many.rb +1 -1
- data/lib/alba/resource.rb +226 -83
- data/lib/alba/typed_attribute.rb +61 -0
- data/lib/alba/version.rb +1 -1
- data/lib/alba.rb +82 -21
- data/script/perf_check.rb +174 -0
- data/sider.yml +2 -4
- metadata +20 -9
- data/lib/alba/key_transformer.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34c441cbc87f959f73c3e7a0175309f780b23ce840add4d53cf5083488390f1f
|
4
|
+
data.tar.gz: f78fb2eea40f502c6f7b3c905317616054bd397d30aa9ce979285003205c81af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 326ac8e731f2b4e0fe4afbb8f690059ecd578ffcb9270b9779bdcb6bb50d57d063ec0a98fc488398915c39ca2978b41e79d53bb1f5a809f9272ad885c383a549
|
7
|
+
data.tar.gz: 2b36eb5d07749505b4ab377b56cc7e564bcd6e86d872e7cb2c45f62ae2cf91a41b2c6e0b70cdcbb8d2a5d802528e4d9bfb113b723a2be7b1bdbc207c0277df45
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
title: ''
|
5
|
+
labels: bug
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
## Describe the bug
|
11
|
+
A clear and concise description of what the bug is.
|
12
|
+
|
13
|
+
## To Reproduce
|
14
|
+
Steps to reproduce the behavior:
|
15
|
+
|
16
|
+
## Expected behavior
|
17
|
+
A clear and concise description of what you expected to happen.
|
18
|
+
|
19
|
+
## Actual behavior
|
20
|
+
A clear and concise description of what actually happened.
|
21
|
+
|
22
|
+
## Environment
|
23
|
+
- Ruby version:
|
24
|
+
|
25
|
+
## Additional context
|
26
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for this project
|
4
|
+
title: ''
|
5
|
+
labels: enhancement
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
## Is your feature request related to a problem? Please describe.
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
12
|
+
|
13
|
+
## Describe the solution you'd like
|
14
|
+
A clear and concise description of what you want to happen.
|
15
|
+
|
16
|
+
## Describe alternatives you've considered
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
18
|
+
|
19
|
+
## Additional context
|
20
|
+
Add any other context or screenshots about the feature request here.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: daily
|
7
|
+
time: "20:00"
|
8
|
+
open-pull-requests-limit: 10
|
9
|
+
ignore:
|
10
|
+
- dependency-name: rubocop
|
11
|
+
versions:
|
12
|
+
- 1.12.0
|
13
|
+
- 1.9.0
|
14
|
+
- dependency-name: rubocop-performance
|
15
|
+
versions:
|
16
|
+
- 1.10.0
|
17
|
+
- 1.10.2
|
18
|
+
- dependency-name: oj
|
19
|
+
versions:
|
20
|
+
- 3.11.3
|
21
|
+
- dependency-name: minitest
|
22
|
+
versions:
|
23
|
+
- 5.14.4
|
24
|
+
- dependency-name: activesupport
|
25
|
+
versions:
|
26
|
+
- 6.1.2
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: Performance Check
|
2
|
+
|
3
|
+
on: [pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
ruby: [2.5, 2.6, 2.7, 3.0]
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
bundler-cache: true
|
19
|
+
- name: Run benchmark
|
20
|
+
run: |
|
21
|
+
ruby script/perf_check.rb
|
data/.rubocop.yml
CHANGED
@@ -13,14 +13,24 @@ AllCops:
|
|
13
13
|
- 'Rakefile'
|
14
14
|
- 'alba.gemspec'
|
15
15
|
- 'benchmark/**/*.rb'
|
16
|
+
- 'script/**/*.rb'
|
16
17
|
NewCops: enable
|
17
18
|
EnabledByDefault: true
|
18
19
|
TargetRubyVersion: 2.5
|
19
20
|
|
20
|
-
#
|
21
|
-
Bundler/
|
21
|
+
# Items in Gemfile is dev dependencies and we don't have to specify versions.
|
22
|
+
Bundler/GemVersion:
|
22
23
|
Enabled: false
|
23
24
|
|
25
|
+
# We'd like to write something like:
|
26
|
+
# assert_equal(
|
27
|
+
# expected,
|
28
|
+
# actual
|
29
|
+
# )
|
30
|
+
Layout/RedundantLineBreak:
|
31
|
+
Exclude:
|
32
|
+
- 'test/**/*'
|
33
|
+
|
24
34
|
Layout/SpaceInsideHashLiteralBraces:
|
25
35
|
EnforcedStyle: no_space
|
26
36
|
|
@@ -35,17 +45,14 @@ Metrics:
|
|
35
45
|
Exclude:
|
36
46
|
- 'test/**/*.rb'
|
37
47
|
|
38
|
-
Metrics/MethodLength:
|
39
|
-
Max: 15
|
40
|
-
|
41
48
|
# `Resource` module is a core module and its length tends to be long...
|
42
49
|
Metrics/ModuleLength:
|
43
|
-
|
50
|
+
Exclude:
|
51
|
+
- 'lib/alba/resource.rb'
|
44
52
|
|
45
53
|
# Resource class includes DSLs, which tend to accept long list of parameters
|
46
54
|
Metrics/ParameterLists:
|
47
55
|
Exclude:
|
48
|
-
- 'lib/alba/resource.rb'
|
49
56
|
- 'test/**/*.rb'
|
50
57
|
|
51
58
|
# We need to eval resource code to test errors on resource classes
|
@@ -71,7 +78,10 @@ Style/InlineComment:
|
|
71
78
|
Enabled: false
|
72
79
|
|
73
80
|
Style/MethodCallWithArgsParentheses:
|
74
|
-
|
81
|
+
IgnoredMethods: ['require', 'require_relative', 'include', 'extend', 'puts', 'p', 'warn', 'raise', 'send', 'public_send']
|
82
|
+
Exclude:
|
83
|
+
# There are so many `attributes` call without parenthese and that's absolutely fine
|
84
|
+
- 'test/**/*.rb'
|
75
85
|
|
76
86
|
# There are so many cases we just want `if` expression!
|
77
87
|
Style/MissingElse:
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.5.0] 2021-11-28
|
10
|
+
|
11
|
+
- [Feat] Add nil handler
|
12
|
+
- [Feat] Implement layout feature
|
13
|
+
- [Improve] if option now works with Symbol
|
14
|
+
- [Improve] Add an alias for serialize
|
15
|
+
- [Improve] Deprecation warning now printed with caller
|
16
|
+
|
17
|
+
## [1.4.0] 2021-06-30
|
18
|
+
|
19
|
+
- [Feat] Add a config method to set encoder directly
|
20
|
+
- [Feat] Implement `meta` method and option for metadata
|
21
|
+
- [Feat] Add `root_key` option to `Resource#serialize`
|
22
|
+
- [Feat] Enable setting key for collection with `root_key`
|
23
|
+
- [Feat] Add `Resource.root_key` and `Resource.root_key!`
|
24
|
+
- [Feat] `Alba.serialize` now infers resource class
|
25
|
+
- [Deprecated] `Resource.key` and `Resource.key!` are deprecated
|
26
|
+
|
27
|
+
## [1.3.0] 2021-05-31
|
28
|
+
|
29
|
+
- [Perf] Improve performance for `many` [641d8f9]
|
30
|
+
- https://github.com/okuramasafumi/alba/pull/125
|
31
|
+
- [Feat] Add custom inflector feature (#126) [ad73291]
|
32
|
+
- https://github.com/okuramasafumi/alba/pull/126
|
33
|
+
- Thank you @wuarmin !
|
34
|
+
- [Feat] Support params in if condition [6e9915e]
|
35
|
+
- https://github.com/okuramasafumi/alba/pull/128
|
36
|
+
- [Fix] fundamentally broken "circular association control" [fbbc9a1]
|
37
|
+
- https://github.com/okuramasafumi/alba/pull/130
|
38
|
+
|
39
|
+
## [1.2.0] 2021-05-09
|
40
|
+
|
41
|
+
- [Fix] multiple word key inference [6c18e73]
|
42
|
+
- https://github.com/okuramasafumi/alba/pull/120
|
43
|
+
- Thank you @alfonsojimenez !
|
44
|
+
- [Feat] Add `Alba.enable_root_key_transformation!` [f172839]
|
45
|
+
- https://github.com/okuramasafumi/alba/pull/121
|
46
|
+
- [Feat] Implement type validation and auto conversion [cbe00c7]
|
47
|
+
- https://github.com/okuramasafumi/alba/pull/122
|
48
|
+
|
9
49
|
## [1.1.0] - 2021-04-23
|
10
50
|
|
11
51
|
- [Feat] Implement circular associations control [71e1543]
|
data/Gemfile
CHANGED
@@ -5,16 +5,17 @@ gemspec
|
|
5
5
|
|
6
6
|
gem 'activesupport', require: false # For backend
|
7
7
|
gem 'ffaker', require: false # For testing
|
8
|
+
gem 'inch', require: false # For inline documents
|
8
9
|
gem 'minitest', '~> 5.14' # For test
|
9
10
|
gem 'rake', '~> 13.0' # For test and automation
|
10
11
|
gem 'rubocop', '>= 0.79.0', require: false # For lint
|
11
|
-
gem 'rubocop-minitest', '~> 0.
|
12
|
-
gem 'rubocop-performance', '~> 1.
|
12
|
+
gem 'rubocop-minitest', '~> 0.17.0', require: false # For lint
|
13
|
+
gem 'rubocop-performance', '~> 1.12.0', require: false # For lint
|
13
14
|
gem 'rubocop-rake', '>= 0.5.1', require: false # For lint
|
14
15
|
gem 'rubocop-sensible', '~> 0.3.0', require: false # For lint
|
15
16
|
gem 'simplecov', '~> 0.21.0', require: false # For test coverage
|
16
17
|
gem 'simplecov-cobertura', require: false # For test coverage
|
17
|
-
gem 'yard', require: false
|
18
|
+
gem 'yard', require: false # For documentation
|
18
19
|
|
19
20
|
platforms :ruby do
|
20
21
|
gem 'oj', '~> 3.11', require: false # For backend
|