alba 3.5.0 → 3.7.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/CHANGELOG.md +27 -0
- data/README.md +96 -40
- data/lib/alba/association.rb +4 -1
- data/lib/alba/conditional_attribute.rb +11 -14
- data/lib/alba/layout.rb +8 -6
- data/lib/alba/railtie.rb +2 -2
- data/lib/alba/resource.rb +90 -17
- data/lib/alba/typed_attribute.rb +2 -0
- data/lib/alba/version.rb +1 -1
- data/lib/alba.rb +51 -32
- metadata +5 -53
- data/.codeclimate.yml +0 -12
- data/.editorconfig +0 -10
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -26
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/dependabot.yml +0 -12
- data/.github/workflows/codeql-analysis.yml +0 -70
- data/.github/workflows/lint.yml +0 -17
- data/.github/workflows/main.yml +0 -41
- data/.gitignore +0 -11
- data/.rubocop.yml +0 -156
- data/.yardopts +0 -4
- data/CODE_OF_CONDUCT.md +0 -132
- data/CONTRIBUTING.md +0 -30
- data/Gemfile +0 -39
- data/HACKING.md +0 -42
- data/Rakefile +0 -17
- data/SECURITY.md +0 -12
- data/alba.gemspec +0 -33
- data/benchmark/Gemfile +0 -26
- data/benchmark/README.md +0 -137
- data/benchmark/collection.rb +0 -297
- data/benchmark/prep.rb +0 -56
- data/benchmark/single_resource.rb +0 -300
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/codecov.yml +0 -8
- data/docs/migrate_from_active_model_serializers.md +0 -359
- data/docs/migrate_from_jbuilder.md +0 -237
- data/docs/rails.md +0 -56
- data/gemfiles/without_active_support.gemfile +0 -19
- data/gemfiles/without_oj.gemfile +0 -19
- data/logo/alba-card.png +0 -0
- data/logo/alba-sign.png +0 -0
- data/logo/alba-typography.png +0 -0
data/lib/alba.rb
CHANGED
@@ -46,13 +46,15 @@ module Alba
|
|
46
46
|
# @param root_key [Symbol, nil, true]
|
47
47
|
# @param block [Block] resource block
|
48
48
|
# @return [String] serialized JSON string
|
49
|
-
# @raise [ArgumentError] if
|
49
|
+
# @raise [ArgumentError] if both object and block are not given
|
50
50
|
def serialize(object = nil, with: :inference, root_key: nil, &block)
|
51
|
+
raise ArgumentError, 'Either object or block must be given' if object.nil? && block.nil?
|
52
|
+
|
51
53
|
if collection?(object)
|
52
|
-
h = hashify_collection(object, with, &block)
|
54
|
+
h = hashify_collection(object, with, root_key, &block)
|
53
55
|
Alba.encoder.call(h)
|
54
56
|
else
|
55
|
-
resource =
|
57
|
+
resource = resource_for(object, &block)
|
56
58
|
resource.serialize(root_key: root_key)
|
57
59
|
end
|
58
60
|
end
|
@@ -64,22 +66,24 @@ module Alba
|
|
64
66
|
# @param root_key [Symbol, nil, true]
|
65
67
|
# @param block [Block] resource block
|
66
68
|
# @return [String] serialized JSON string
|
67
|
-
# @raise [ArgumentError] if
|
69
|
+
# @raise [ArgumentError] if both object and block are not given
|
68
70
|
def hashify(object = nil, with: :inference, root_key: nil, &block)
|
71
|
+
raise ArgumentError, 'Either object or block must be given' if object.nil? && block.nil?
|
72
|
+
|
69
73
|
if collection?(object)
|
70
|
-
hashify_collection(object, with, &block)
|
74
|
+
hashify_collection(object, with, root_key, &block)
|
71
75
|
else
|
72
|
-
resource =
|
76
|
+
resource = resource_for(object, &block)
|
73
77
|
resource.as_json(root_key: root_key)
|
74
78
|
end
|
75
79
|
end
|
76
80
|
|
77
81
|
# Detect if object is a collection or not.
|
78
|
-
# When object is a Struct, it's Enumerable but not a collection
|
82
|
+
# When object is a Struct or a Range, it's Enumerable but not a collection
|
79
83
|
#
|
80
84
|
# @api private
|
81
85
|
def collection?(object)
|
82
|
-
object.is_a?(Enumerable) && !object.is_a?(Struct)
|
86
|
+
object.is_a?(Enumerable) && !object.is_a?(Struct) && !object.is_a?(Range) && !object.is_a?(Hash)
|
83
87
|
end
|
84
88
|
|
85
89
|
# Enable inference for key and resource name
|
@@ -162,8 +166,9 @@ module Alba
|
|
162
166
|
# @return [Symbol, String, nil]
|
163
167
|
def regularize_key(key)
|
164
168
|
return if key.nil?
|
169
|
+
return key.to_sym if @symbolize_keys
|
165
170
|
|
166
|
-
|
171
|
+
key.is_a?(Symbol) ? key.name : key.to_s
|
167
172
|
end
|
168
173
|
|
169
174
|
# Transform a key with given transform_type
|
@@ -218,19 +223,45 @@ module Alba
|
|
218
223
|
register_default_types
|
219
224
|
end
|
220
225
|
|
226
|
+
# @deprecated Use resource_for instead
|
227
|
+
def resource_with(object, with: :inference, &block)
|
228
|
+
Kernel.warn('Alba.resource_with is deprecated. Use `Alba.resource_for` instead.')
|
229
|
+
_resource_for(object, with: with, &block)
|
230
|
+
end
|
231
|
+
|
221
232
|
# Get a resource object from arguments
|
222
233
|
# If block is given, it creates a resource class with the block
|
223
|
-
# Otherwise, it
|
234
|
+
# Otherwise, it behaves depending on `with` argument
|
224
235
|
#
|
225
|
-
# @
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
236
|
+
# @param object [Object] the object whose class name is used for inferring resource class
|
237
|
+
# @param with [:inference, Proc, Class<Alba::Resource>] determines how to get resource class for `object`
|
238
|
+
# When it's `:inference`, it infers resource class from `object`'s class name
|
239
|
+
# When it's a Proc, it calls the Proc with `object` as an argument
|
240
|
+
# When it's a Class, it uses the Class as a resource class
|
241
|
+
# Otherwise, it raises an ArgumentError
|
242
|
+
# @return [Alba::Resource] resource class with `object` as its target object
|
243
|
+
# @raise [ArgumentError] if `with` argument is not one of `:inference`, Proc or Class
|
244
|
+
def resource_for(object, with: :inference, &block)
|
245
|
+
_resource_for(object, with: with, &block)
|
230
246
|
end
|
231
247
|
|
232
248
|
private
|
233
249
|
|
250
|
+
def _resource_for(object, with: :inference, &block) # rubocop:disable Metrics/MethodLength
|
251
|
+
klass = if block
|
252
|
+
resource_class(&block)
|
253
|
+
else
|
254
|
+
case with
|
255
|
+
when :inference then infer_resource_class(object.class.name)
|
256
|
+
when Class then with
|
257
|
+
when Proc then with.call(object)
|
258
|
+
else raise ArgumentError, '`with` argument must be either :inference, Proc or Class'
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
klass.new(object)
|
263
|
+
end
|
264
|
+
|
234
265
|
def inflector_from(name_or_module)
|
235
266
|
case name_or_module
|
236
267
|
when nil then nil
|
@@ -283,22 +314,14 @@ module Alba
|
|
283
314
|
end
|
284
315
|
end
|
285
316
|
|
286
|
-
def hashify_collection(collection, with, &block)
|
287
|
-
collection.map do |obj|
|
288
|
-
resource =
|
289
|
-
resource_class(&block)
|
290
|
-
else
|
291
|
-
case with
|
292
|
-
when Class then with
|
293
|
-
when :inference then infer_resource_class(obj.class.name)
|
294
|
-
when Proc then with.call(obj)
|
295
|
-
else raise ArgumentError, '`with` argument must be either :inference, Proc or Class'
|
296
|
-
end
|
297
|
-
end
|
317
|
+
def hashify_collection(collection, with, root_key, &block)
|
318
|
+
array = collection.map do |obj|
|
319
|
+
resource = resource_for(obj, with: with, &block)
|
298
320
|
raise Alba::Error if resource.nil?
|
299
321
|
|
300
|
-
resource.
|
322
|
+
resource.to_h
|
301
323
|
end
|
324
|
+
root_key ? {root_key => array} : array
|
302
325
|
end
|
303
326
|
|
304
327
|
def validate_inflector(inflector)
|
@@ -329,7 +352,3 @@ module Alba
|
|
329
352
|
|
330
353
|
reset!
|
331
354
|
end
|
332
|
-
|
333
|
-
# Monkey patch for TruffleRuby
|
334
|
-
# Delete this after 24.1.2 is released
|
335
|
-
File::SHARE_DELETE = 0 if defined?(Truffle)
|
metadata
CHANGED
@@ -1,28 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OKURA Masafumi
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
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'
|
10
|
+
date: 2025-05-08 00:00:00.000000000 Z
|
11
|
+
dependencies: []
|
26
12
|
description: Alba is the fastest JSON serializer for Ruby. It focuses on performance,
|
27
13
|
flexibility and usability.
|
28
14
|
email:
|
@@ -31,40 +17,9 @@ executables: []
|
|
31
17
|
extensions: []
|
32
18
|
extra_rdoc_files: []
|
33
19
|
files:
|
34
|
-
- ".codeclimate.yml"
|
35
|
-
- ".editorconfig"
|
36
|
-
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
37
|
-
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
38
|
-
- ".github/dependabot.yml"
|
39
|
-
- ".github/workflows/codeql-analysis.yml"
|
40
|
-
- ".github/workflows/lint.yml"
|
41
|
-
- ".github/workflows/main.yml"
|
42
|
-
- ".gitignore"
|
43
|
-
- ".rubocop.yml"
|
44
|
-
- ".yardopts"
|
45
20
|
- CHANGELOG.md
|
46
|
-
- CODE_OF_CONDUCT.md
|
47
|
-
- CONTRIBUTING.md
|
48
|
-
- Gemfile
|
49
|
-
- HACKING.md
|
50
21
|
- LICENSE.txt
|
51
22
|
- README.md
|
52
|
-
- Rakefile
|
53
|
-
- SECURITY.md
|
54
|
-
- alba.gemspec
|
55
|
-
- benchmark/Gemfile
|
56
|
-
- benchmark/README.md
|
57
|
-
- benchmark/collection.rb
|
58
|
-
- benchmark/prep.rb
|
59
|
-
- benchmark/single_resource.rb
|
60
|
-
- bin/console
|
61
|
-
- bin/setup
|
62
|
-
- codecov.yml
|
63
|
-
- docs/migrate_from_active_model_serializers.md
|
64
|
-
- docs/migrate_from_jbuilder.md
|
65
|
-
- docs/rails.md
|
66
|
-
- gemfiles/without_active_support.gemfile
|
67
|
-
- gemfiles/without_oj.gemfile
|
68
23
|
- lib/alba.rb
|
69
24
|
- lib/alba/association.rb
|
70
25
|
- lib/alba/conditional_attribute.rb
|
@@ -79,16 +34,13 @@ files:
|
|
79
34
|
- lib/alba/type.rb
|
80
35
|
- lib/alba/typed_attribute.rb
|
81
36
|
- lib/alba/version.rb
|
82
|
-
- logo/alba-card.png
|
83
|
-
- logo/alba-sign.png
|
84
|
-
- logo/alba-typography.png
|
85
37
|
homepage: https://github.com/okuramasafumi/alba
|
86
38
|
licenses:
|
87
39
|
- MIT
|
88
40
|
metadata:
|
89
41
|
bug_tracker_uri: https://github.com/okuramasafumi/alba/issues
|
90
42
|
changelog_uri: https://github.com/okuramasafumi/alba/blob/main/CHANGELOG.md
|
91
|
-
documentation_uri: https://
|
43
|
+
documentation_uri: https://okuramasafumi.github.io/alba/
|
92
44
|
source_code_uri: https://github.com/okuramasafumi/alba
|
93
45
|
rubygems_mfa_required: 'true'
|
94
46
|
rdoc_options: []
|
@@ -105,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
57
|
- !ruby/object:Gem::Version
|
106
58
|
version: '0'
|
107
59
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.7.0.dev
|
109
61
|
specification_version: 4
|
110
62
|
summary: Alba is the fastest JSON serializer for Ruby.
|
111
63
|
test_files: []
|
data/.codeclimate.yml
DELETED
data/.editorconfig
DELETED
@@ -1,26 +0,0 @@
|
|
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.
|
@@ -1,20 +0,0 @@
|
|
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.
|
data/.github/dependabot.yml
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
# For most projects, this workflow file will not need changing; you simply need
|
2
|
-
# to commit it to your repository.
|
3
|
-
#
|
4
|
-
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
-
# or to provide custom queries or build logic.
|
6
|
-
#
|
7
|
-
# ******** NOTE ********
|
8
|
-
# We have attempted to detect the languages in your repository. Please check
|
9
|
-
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
-
# supported CodeQL languages.
|
11
|
-
#
|
12
|
-
name: "CodeQL"
|
13
|
-
|
14
|
-
on:
|
15
|
-
push:
|
16
|
-
branches: [ main ]
|
17
|
-
pull_request:
|
18
|
-
# The branches below must be a subset of the branches above
|
19
|
-
branches: [ main ]
|
20
|
-
schedule:
|
21
|
-
- cron: '21 4 * * 5'
|
22
|
-
|
23
|
-
jobs:
|
24
|
-
analyze:
|
25
|
-
name: Analyze
|
26
|
-
runs-on: ubuntu-latest
|
27
|
-
permissions:
|
28
|
-
actions: read
|
29
|
-
contents: read
|
30
|
-
security-events: write
|
31
|
-
|
32
|
-
strategy:
|
33
|
-
fail-fast: false
|
34
|
-
matrix:
|
35
|
-
language: [ 'ruby' ]
|
36
|
-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
37
|
-
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
38
|
-
|
39
|
-
steps:
|
40
|
-
- name: Checkout repository
|
41
|
-
uses: actions/checkout@v4
|
42
|
-
|
43
|
-
# Initializes the CodeQL tools for scanning.
|
44
|
-
- name: Initialize CodeQL
|
45
|
-
uses: github/codeql-action/init@v3
|
46
|
-
with:
|
47
|
-
languages: ${{ matrix.language }}
|
48
|
-
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
|
-
# By default, queries listed here will override any specified in a config file.
|
50
|
-
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
52
|
-
|
53
|
-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
54
|
-
# If this step fails, then you should remove it and run the build manually (see below)
|
55
|
-
- name: Autobuild
|
56
|
-
uses: github/codeql-action/autobuild@v3
|
57
|
-
|
58
|
-
# ℹ️ Command-line programs to run using the OS shell.
|
59
|
-
# 📚 https://git.io/JvXDl
|
60
|
-
|
61
|
-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
62
|
-
# and modify them (or add more) to build your code if your project
|
63
|
-
# uses a compiled language
|
64
|
-
|
65
|
-
#- run: |
|
66
|
-
# make bootstrap
|
67
|
-
# make release
|
68
|
-
|
69
|
-
- name: Perform CodeQL Analysis
|
70
|
-
uses: github/codeql-action/analyze@v3
|
data/.github/workflows/lint.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
name: Lint
|
2
|
-
|
3
|
-
on: [push,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.0 # The lowest version Alba supports
|
14
|
-
bundler-cache: true
|
15
|
-
- name: Run RuboCop
|
16
|
-
run: |
|
17
|
-
bundle exec rubocop
|
data/.github/workflows/main.yml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
name: CI
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- main
|
7
|
-
pull_request:
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
build:
|
11
|
-
strategy:
|
12
|
-
fail-fast: false
|
13
|
-
matrix:
|
14
|
-
os: [ubuntu-latest, windows-latest, macos-latest]
|
15
|
-
ruby: ['3.0', 3.1, 3.2, 3.3, 3.4, head, jruby, truffleruby]
|
16
|
-
gemfile: [all, without_active_support, without_oj]
|
17
|
-
exclude:
|
18
|
-
- os: windows-latest
|
19
|
-
ruby: 3.4
|
20
|
-
- os: windows-latest
|
21
|
-
ruby: jruby
|
22
|
-
- os: windows-latest
|
23
|
-
ruby: truffleruby
|
24
|
-
runs-on: ${{ matrix.os }}
|
25
|
-
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
26
|
-
BUNDLE_GEMFILE: ${{ (matrix.gemfile == 'without_active_support' && 'gemfiles/without_active_support.gemfile') || (matrix.gemfile == 'without_oj' && 'gemfiles/without_oj.gemfile') || null }}
|
27
|
-
steps:
|
28
|
-
- uses: actions/checkout@v4
|
29
|
-
- name: Set up Ruby
|
30
|
-
uses: ruby/setup-ruby@v1
|
31
|
-
with:
|
32
|
-
ruby-version: ${{ matrix.ruby }}
|
33
|
-
bundler-cache: true
|
34
|
-
- name: Run the default task
|
35
|
-
run: |
|
36
|
-
bundle exec rake
|
37
|
-
- name: CodeCov
|
38
|
-
uses: codecov/codecov-action@v5
|
39
|
-
with:
|
40
|
-
files: ./coverage/coverage.xml
|
41
|
-
token: ${{ secrets.CODECOV_TOKEN }}
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1,156 +0,0 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
inherit_gem:
|
4
|
-
rubocop-gem_dev: 'config/rubocop.yml'
|
5
|
-
|
6
|
-
inherit_mode:
|
7
|
-
merge:
|
8
|
-
- Exclude
|
9
|
-
|
10
|
-
require:
|
11
|
-
- rubocop-md
|
12
|
-
- rubocop-minitest
|
13
|
-
- rubocop-performance
|
14
|
-
- rubocop-rake
|
15
|
-
|
16
|
-
AllCops:
|
17
|
-
Exclude:
|
18
|
-
- 'alba.gemspec'
|
19
|
-
- 'benchmark/**/*.rb'
|
20
|
-
- 'docs/**/*'
|
21
|
-
- 'script/**/*.rb'
|
22
|
-
NewCops: enable
|
23
|
-
EnabledByDefault: true
|
24
|
-
TargetRubyVersion: 3.0
|
25
|
-
|
26
|
-
Bundler/GemComment:
|
27
|
-
Exclude:
|
28
|
-
- 'benchmark/**/*'
|
29
|
-
|
30
|
-
# Items in Gemfile is dev dependencies and we don't have to specify versions.
|
31
|
-
Bundler/GemVersion:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
# Test class is a class, but not really
|
35
|
-
Layout/ClassStructure:
|
36
|
-
Exclude:
|
37
|
-
- 'test/**/*'
|
38
|
-
|
39
|
-
# LineLength 80 comes from restrictions in good old days.
|
40
|
-
Layout/LineLength:
|
41
|
-
Max: 160
|
42
|
-
|
43
|
-
# We'd like to write something like:
|
44
|
-
# assert_equal(
|
45
|
-
# expected,
|
46
|
-
# actual
|
47
|
-
# )
|
48
|
-
Layout/RedundantLineBreak:
|
49
|
-
Exclude:
|
50
|
-
- 'test/**/*'
|
51
|
-
|
52
|
-
Layout/SpaceInsideHashLiteralBraces:
|
53
|
-
EnforcedStyle: no_space
|
54
|
-
|
55
|
-
Layout/MultilineAssignmentLayout:
|
56
|
-
EnforcedStyle: same_line
|
57
|
-
|
58
|
-
Lint/ConstantResolution:
|
59
|
-
Enabled: false
|
60
|
-
|
61
|
-
# In test code we don't care about the metrics!
|
62
|
-
Metrics:
|
63
|
-
Exclude:
|
64
|
-
- 'test/**/*.rb'
|
65
|
-
|
66
|
-
# `Resource` module is a core module and its length tends to be long...
|
67
|
-
# `Alba` main module is also long because it has all parts of configuration
|
68
|
-
Metrics/ClassLength:
|
69
|
-
Exclude:
|
70
|
-
- 'lib/alba/resource.rb'
|
71
|
-
- 'lib/alba.rb'
|
72
|
-
- 'test/**/*.rb' # Neec to specify this
|
73
|
-
|
74
|
-
Metrics/ModuleLength:
|
75
|
-
Exclude:
|
76
|
-
- 'lib/alba/resource.rb'
|
77
|
-
- 'lib/alba.rb'
|
78
|
-
|
79
|
-
# Resource class includes DSLs, which tend to accept long list of parameters
|
80
|
-
Metrics/ParameterLists:
|
81
|
-
Max: 7
|
82
|
-
Exclude:
|
83
|
-
- 'test/**/*.rb'
|
84
|
-
|
85
|
-
# Putting extra empty line is not valuable in test
|
86
|
-
# We prefer shorter test code
|
87
|
-
Minitest/EmptyLineBeforeAssertionMethods:
|
88
|
-
Enabled: false
|
89
|
-
|
90
|
-
# By nature of that test
|
91
|
-
Minitest/NoTestCases:
|
92
|
-
Exclude:
|
93
|
-
- 'test/dependencies/test_dependencies.rb'
|
94
|
-
|
95
|
-
# We need to use `OpenStruct` to wrap object in ConfitionalAttribute
|
96
|
-
Performance/OpenStruct:
|
97
|
-
Exclude:
|
98
|
-
- 'lib/alba/conditional_attribute.rb'
|
99
|
-
|
100
|
-
# We need to eval resource code to test errors on resource classes
|
101
|
-
Security/Eval:
|
102
|
-
Exclude:
|
103
|
-
- 'test/**/*.rb'
|
104
|
-
|
105
|
-
Style/ConstantVisibility:
|
106
|
-
Exclude:
|
107
|
-
- 'lib/alba/version.rb'
|
108
|
-
- 'test/**/*.rb'
|
109
|
-
|
110
|
-
# Copyright is in README
|
111
|
-
Style/Copyright:
|
112
|
-
Enabled: false
|
113
|
-
|
114
|
-
# I know what I do :)
|
115
|
-
Style/DisableCopsWithinSourceCodeDirective:
|
116
|
-
Enabled: false
|
117
|
-
|
118
|
-
# Test files doesn't need to have documentation
|
119
|
-
Style/Documentation:
|
120
|
-
Exclude:
|
121
|
-
- 'test/**/*'
|
122
|
-
|
123
|
-
# In README it's so obvious
|
124
|
-
Style/DocumentationMethod:
|
125
|
-
Exclude:
|
126
|
-
- 'README.md'
|
127
|
-
|
128
|
-
# I don't want to think about error class in example code
|
129
|
-
Style/ImplicitRuntimeError:
|
130
|
-
Exclude:
|
131
|
-
- 'README.md'
|
132
|
-
|
133
|
-
# We use it, don't we?
|
134
|
-
Style/InlineComment:
|
135
|
-
Enabled: false
|
136
|
-
|
137
|
-
Style/MethodCallWithArgsParentheses:
|
138
|
-
AllowedMethods: ['require', 'require_relative', 'include', 'extend', 'puts', 'p', 'warn', 'raise', 'send', 'public_send', 'alias_method']
|
139
|
-
Exclude:
|
140
|
-
# There are so many calls like `attributes` and `register_type` without parenthese and that's absolutely fine
|
141
|
-
- 'test/**/*.rb'
|
142
|
-
- 'README.md'
|
143
|
-
|
144
|
-
# There are so many cases we just want `if` expression!
|
145
|
-
Style/MissingElse:
|
146
|
-
EnforcedStyle: case
|
147
|
-
|
148
|
-
# We need to use `OpenStruct` to wrap object in ConfitionalAttribute
|
149
|
-
Style/OpenStructUse:
|
150
|
-
Exclude:
|
151
|
-
- 'lib/alba/conditional_attribute.rb'
|
152
|
-
|
153
|
-
# It's example code, please forgive us
|
154
|
-
Style/OptionalBooleanParameter:
|
155
|
-
Exclude:
|
156
|
-
- 'README.md'
|
data/.yardopts
DELETED