grape-entity 1.0.1 → 1.0.4
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 +28 -9
- data/README.md +5 -0
- data/lib/grape_entity/entity.rb +45 -9
- data/lib/grape_entity/version.rb +1 -1
- metadata +13 -38
- data/.coveralls.yml +0 -1
- data/.github/dependabot.yml +0 -20
- data/.github/workflows/ci.yml +0 -41
- data/.gitignore +0 -43
- data/.rspec +0 -3
- data/.rubocop.yml +0 -89
- data/.rubocop_todo.yml +0 -50
- data/.yardopts +0 -2
- data/CONTRIBUTING.md +0 -118
- data/Dangerfile +0 -3
- data/Gemfile +0 -28
- data/Guardfile +0 -16
- data/RELEASING.md +0 -84
- data/Rakefile +0 -20
- data/UPGRADING.md +0 -40
- data/bench/serializing.rb +0 -105
- data/grape-entity.gemspec +0 -26
- data/spec/grape_entity/entity_spec.rb +0 -2179
- data/spec/grape_entity/exposure/nesting_exposure/nested_exposures_spec.rb +0 -58
- data/spec/grape_entity/exposure/represent_exposure_spec.rb +0 -32
- data/spec/grape_entity/exposure_spec.rb +0 -102
- data/spec/grape_entity/hash_spec.rb +0 -91
- data/spec/grape_entity/options_spec.rb +0 -66
- data/spec/spec_helper.rb +0 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ea6cd1ab20b3f5c6e99438ee72c716cc28dde080ce2dc89490427bf3b7431212
|
|
4
|
+
data.tar.gz: 0e5ec30218c864e84984114a39fd3acc5bb980db637ba75c1c7572491ce5695b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7263a1369fc11a5e3290a6106175615c5d7e845b9d79456e0103c0ff28fd3da43d787d8386e67eedb96bbd00fc5ab023e42fabbeabb6bbc0214db454cbbdce67
|
|
7
|
+
data.tar.gz: 9fd6c031d4dcbc89404174e25712feabb75e0b3d6c2a529784e15cbeee5f30c0c3561f46ce3e98c6b1abcd8a8ccb0d2b1ea699f117759f2ab359f1a96f075fbc
|
data/CHANGELOG.md
CHANGED
|
@@ -1,27 +1,46 @@
|
|
|
1
|
-
###
|
|
1
|
+
### 1.0.4 (2026-04-17)
|
|
2
|
+
|
|
3
|
+
#### Fixes
|
|
4
|
+
|
|
5
|
+
* [#405](https://github.com/ruby-grape/grape-entity/pull/405): Fix `Time` serialization regression by reverting #385 and restoring `MultiJson.dump` - [@numbata](https://github.com/numbata).
|
|
6
|
+
* [#402](https://github.com/ruby-grape/grape-entity/pull/402): Remove `Json::ParseError` assignment - [@olivier-thatch](https://github.com/olivier-thatch).
|
|
7
|
+
|
|
8
|
+
### 1.0.3 (2026-04-15)
|
|
2
9
|
|
|
3
10
|
#### Features
|
|
4
11
|
|
|
5
|
-
*
|
|
12
|
+
* [#400](https://github.com/ruby-grape/grape-entity/pull/400): Switch to danger-pr-comment for PR checks - [@numbata](https://github.com/numbata).
|
|
13
|
+
* [#397](https://github.com/ruby-grape/grape-entity/pull/397): Reduce gem size by excluding test files - [@yuri-zubov](https://github.com/yuri-zubov).
|
|
14
|
+
* [#401](https://github.com/ruby-grape/grape-entity/pull/401): Modernize gemspec: add metadata, use Dir glob, require MFA - [@numbata](https://github.com/numbata).
|
|
15
|
+
|
|
16
|
+
#### Fixes
|
|
17
|
+
|
|
18
|
+
* [#399](https://github.com/ruby-grape/grape-entity/pull/399): Fix `ArgumentError` for single-argument lambdas in `expose` blocks and `if:` conditions - [@numbata](https://github.com/numbata).
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### 1.0.2 (2026-04-13)
|
|
6
22
|
|
|
7
23
|
#### Fixes
|
|
8
24
|
|
|
9
|
-
*
|
|
25
|
+
* [#394](https://github.com/ruby-grape/grape-entity/pull/394): Add `Entity.[]` for Grape >= 3.2 param type compatibility - [@numbata](https://github.com/numbata).
|
|
26
|
+
* [#388](https://github.com/ruby-grape/grape-entity/pull/388): Drop ruby-head from test matrix - [@numbata](https://github.com/numbata).
|
|
27
|
+
* [#389](https://github.com/ruby-grape/grape-entity/pull/389): Block arity detection (breaking change) - [@numbata](https://github.com/numbata).
|
|
28
|
+
* [#385](https://github.com/ruby-grape/grape-entity/pull/385): Drop multijson dependency - [@ericproulx](https://github.com/ericproulx).
|
|
29
|
+
* [#384](https://github.com/ruby-grape/grape-entity/pull/384): Fix `inspect` to correctly handle `nil` values - [@fcce](https://github.com/fcce).
|
|
10
30
|
|
|
11
31
|
|
|
12
|
-
###
|
|
32
|
+
### 1.0.1 (2024-04-10)
|
|
13
33
|
|
|
14
34
|
#### Fixes
|
|
15
35
|
|
|
16
36
|
* [#381](https://github.com/ruby-grape/grape-entity/pull/381): Fix `expose_nil: false` when using a block - [@magni-](https://github.com/magni-).
|
|
17
37
|
|
|
18
38
|
|
|
19
|
-
###
|
|
39
|
+
### 1.0.0 (2023-02-16)
|
|
20
40
|
|
|
21
41
|
#### Fixes
|
|
22
42
|
|
|
23
|
-
|
|
24
|
-
* [#352](https://github.com/ruby-grape/grape-entity/pull/369): Remove `FetchableObject` behavior. - [@danielvdao](https://github.com/danielvdao).
|
|
43
|
+
* [#369](https://github.com/ruby-grape/grape-entity/pull/369): Remove `FetchableObject` behavior (breaking change) - [@danielvdao](https://github.com/danielvdao).
|
|
25
44
|
* [#371](https://github.com/ruby-grape/grape-entity/pull/371): Allow default exposed value to be `false` or any empty data - [@norydev](https://github.com/norydev).
|
|
26
45
|
|
|
27
46
|
|
|
@@ -29,8 +48,8 @@
|
|
|
29
48
|
|
|
30
49
|
#### Fixes
|
|
31
50
|
|
|
32
|
-
* [#366](https://github.com/ruby-grape/grape-entity/pull/366): Don't suppress regular ArgumentError exceptions - [splattael](https://github.com/splattael).
|
|
33
|
-
* [#363](https://github.com/ruby-grape/grape-entity/pull/
|
|
51
|
+
* [#366](https://github.com/ruby-grape/grape-entity/pull/366): Don't suppress regular ArgumentError exceptions - [@splattael](https://github.com/splattael).
|
|
52
|
+
* [#363](https://github.com/ruby-grape/grape-entity/pull/363): Fix typo - [@OuYangJinTing](https://github.com/OuYangJinTing).
|
|
34
53
|
* [#361](https://github.com/ruby-grape/grape-entity/pull/361): Require 'active_support/core_ext' - [@pravi](https://github.com/pravi).
|
|
35
54
|
|
|
36
55
|
|
data/README.md
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
- [Using Entities](#using-entities)
|
|
34
34
|
- [Entity Organization](#entity-organization)
|
|
35
35
|
- [Caveats](#caveats)
|
|
36
|
+
- [Preloading Associations](#preloading-associations)
|
|
36
37
|
- [Installation](#installation)
|
|
37
38
|
- [Testing with Entities](#testing-with-entities)
|
|
38
39
|
- [Project Resources](#project-resources)
|
|
@@ -674,6 +675,10 @@ end
|
|
|
674
675
|
|
|
675
676
|
Also note that an `ArgumentError` is raised when unknown options are passed to either `expose` or `with_options`.
|
|
676
677
|
|
|
678
|
+
### Preloading Associations
|
|
679
|
+
|
|
680
|
+
Use [Grape::Entity::Preloader](https://github.com/OuYangJinTing/grape-entity-preloader) to preload associations and callbacks and avoid N+1 operations.
|
|
681
|
+
|
|
677
682
|
## Installation
|
|
678
683
|
|
|
679
684
|
Add this line to your application's Gemfile:
|
data/lib/grape_entity/entity.rb
CHANGED
|
@@ -129,6 +129,12 @@ module Grape
|
|
|
129
129
|
def delegation_opts
|
|
130
130
|
@delegation_opts ||= { hash_access: hash_access }
|
|
131
131
|
end
|
|
132
|
+
|
|
133
|
+
# Satisfies the respond_to?(:[]) check in Grape::DryTypes (>= 3.2)
|
|
134
|
+
# so Entity subclasses can be used as param types.
|
|
135
|
+
def [](val)
|
|
136
|
+
val
|
|
137
|
+
end
|
|
132
138
|
end
|
|
133
139
|
|
|
134
140
|
@formatters = {}
|
|
@@ -472,8 +478,13 @@ module Grape
|
|
|
472
478
|
|
|
473
479
|
# Prevent default serialization of :options or :delegator.
|
|
474
480
|
def inspect
|
|
475
|
-
|
|
476
|
-
|
|
481
|
+
object = serializable_hash
|
|
482
|
+
if object.nil?
|
|
483
|
+
"#<#{self.class.name}:#{object_id} nil>"
|
|
484
|
+
else
|
|
485
|
+
fields = object.map { |k, v| "#{k}=#{v}" }
|
|
486
|
+
"#<#{self.class.name}:#{object_id} #{fields.join(' ')}>"
|
|
487
|
+
end
|
|
477
488
|
end
|
|
478
489
|
|
|
479
490
|
def initialize(object, options = {})
|
|
@@ -514,19 +525,44 @@ module Grape
|
|
|
514
525
|
end
|
|
515
526
|
|
|
516
527
|
def exec_with_object(options, &block)
|
|
517
|
-
if block
|
|
528
|
+
if symbol_to_proc_wrapper?(block)
|
|
529
|
+
ensure_block_arity!(block)
|
|
530
|
+
instance_exec(object, &block)
|
|
531
|
+
elsif block.arity == 1
|
|
518
532
|
instance_exec(object, &block)
|
|
519
533
|
else
|
|
520
534
|
instance_exec(object, options, &block)
|
|
521
535
|
end
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
def ensure_block_arity!(block)
|
|
539
|
+
# MRI currently always includes "( &:foo )" for symbol-to-proc wrappers.
|
|
540
|
+
# If this format changes in a new Ruby version, this logic must be updated.
|
|
541
|
+
origin_method_name = block.to_s.scan(/(?<=\(&:)[^)]+(?=\))/).first&.to_sym
|
|
542
|
+
return unless origin_method_name
|
|
543
|
+
|
|
544
|
+
unless object.respond_to?(origin_method_name, true)
|
|
545
|
+
raise ArgumentError, <<~MSG
|
|
546
|
+
Cannot use `&:#{origin_method_name}` because that method is not defined in the object.
|
|
547
|
+
MSG
|
|
527
548
|
end
|
|
528
549
|
|
|
529
|
-
|
|
550
|
+
arity = object.method(origin_method_name).arity
|
|
551
|
+
return if arity.zero?
|
|
552
|
+
|
|
553
|
+
raise ArgumentError, <<~MSG
|
|
554
|
+
Cannot use `&:#{origin_method_name}` because that method expects #{arity} argument#{'s' if arity != 1}.
|
|
555
|
+
Symbol‐to‐proc shorthand only works for zero‐argument methods.
|
|
556
|
+
MSG
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
def symbol_to_proc_wrapper?(block)
|
|
560
|
+
params = block.parameters
|
|
561
|
+
|
|
562
|
+
return false unless block.lambda? && block.source_location.nil?
|
|
563
|
+
return false unless params.size >= 2
|
|
564
|
+
|
|
565
|
+
params[0].first == :req && params[1].first == :rest
|
|
530
566
|
end
|
|
531
567
|
|
|
532
568
|
def exec_with_attribute(attribute, &block)
|
data/lib/grape_entity/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: grape-entity
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LeFnord
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-04-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -31,14 +31,14 @@ dependencies:
|
|
|
31
31
|
requirements:
|
|
32
32
|
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: 1.
|
|
34
|
+
version: '1.0'
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
39
|
- - ">="
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: 1.
|
|
41
|
+
version: '1.0'
|
|
42
42
|
description: Extracted from Grape, A Ruby framework for rapid API development with
|
|
43
43
|
great conventions.
|
|
44
44
|
email:
|
|
@@ -48,26 +48,9 @@ executables: []
|
|
|
48
48
|
extensions: []
|
|
49
49
|
extra_rdoc_files: []
|
|
50
50
|
files:
|
|
51
|
-
- ".coveralls.yml"
|
|
52
|
-
- ".github/dependabot.yml"
|
|
53
|
-
- ".github/workflows/ci.yml"
|
|
54
|
-
- ".gitignore"
|
|
55
|
-
- ".rspec"
|
|
56
|
-
- ".rubocop.yml"
|
|
57
|
-
- ".rubocop_todo.yml"
|
|
58
|
-
- ".yardopts"
|
|
59
51
|
- CHANGELOG.md
|
|
60
|
-
- CONTRIBUTING.md
|
|
61
|
-
- Dangerfile
|
|
62
|
-
- Gemfile
|
|
63
|
-
- Guardfile
|
|
64
52
|
- LICENSE
|
|
65
53
|
- README.md
|
|
66
|
-
- RELEASING.md
|
|
67
|
-
- Rakefile
|
|
68
|
-
- UPGRADING.md
|
|
69
|
-
- bench/serializing.rb
|
|
70
|
-
- grape-entity.gemspec
|
|
71
54
|
- lib/grape-entity.rb
|
|
72
55
|
- lib/grape_entity.rb
|
|
73
56
|
- lib/grape_entity/condition.rb
|
|
@@ -94,17 +77,16 @@ files:
|
|
|
94
77
|
- lib/grape_entity/exposure/represent_exposure.rb
|
|
95
78
|
- lib/grape_entity/options.rb
|
|
96
79
|
- lib/grape_entity/version.rb
|
|
97
|
-
- spec/grape_entity/entity_spec.rb
|
|
98
|
-
- spec/grape_entity/exposure/nesting_exposure/nested_exposures_spec.rb
|
|
99
|
-
- spec/grape_entity/exposure/represent_exposure_spec.rb
|
|
100
|
-
- spec/grape_entity/exposure_spec.rb
|
|
101
|
-
- spec/grape_entity/hash_spec.rb
|
|
102
|
-
- spec/grape_entity/options_spec.rb
|
|
103
|
-
- spec/spec_helper.rb
|
|
104
80
|
homepage: https://github.com/ruby-grape/grape-entity
|
|
105
81
|
licenses:
|
|
106
82
|
- MIT
|
|
107
|
-
metadata:
|
|
83
|
+
metadata:
|
|
84
|
+
homepage_uri: https://github.com/ruby-grape/grape-entity
|
|
85
|
+
bug_tracker_uri: https://github.com/ruby-grape/grape-entity/issues
|
|
86
|
+
changelog_uri: https://github.com/ruby-grape/grape-entity/blob/v1.0.4/CHANGELOG.md
|
|
87
|
+
documentation_uri: https://www.rubydoc.info/gems/grape-entity/1.0.4
|
|
88
|
+
source_code_uri: https://github.com/ruby-grape/grape-entity/tree/v1.0.4
|
|
89
|
+
rubygems_mfa_required: 'true'
|
|
108
90
|
post_install_message:
|
|
109
91
|
rdoc_options: []
|
|
110
92
|
require_paths:
|
|
@@ -120,15 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
120
102
|
- !ruby/object:Gem::Version
|
|
121
103
|
version: '0'
|
|
122
104
|
requirements: []
|
|
123
|
-
rubygems_version: 3.5.
|
|
105
|
+
rubygems_version: 3.5.22
|
|
124
106
|
signing_key:
|
|
125
107
|
specification_version: 4
|
|
126
108
|
summary: A simple facade for managing the relationship between your model and API.
|
|
127
|
-
test_files:
|
|
128
|
-
- spec/grape_entity/entity_spec.rb
|
|
129
|
-
- spec/grape_entity/exposure/nesting_exposure/nested_exposures_spec.rb
|
|
130
|
-
- spec/grape_entity/exposure/represent_exposure_spec.rb
|
|
131
|
-
- spec/grape_entity/exposure_spec.rb
|
|
132
|
-
- spec/grape_entity/hash_spec.rb
|
|
133
|
-
- spec/grape_entity/options_spec.rb
|
|
134
|
-
- spec/spec_helper.rb
|
|
109
|
+
test_files: []
|
data/.coveralls.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
service_name: travis-ci
|
data/.github/dependabot.yml
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
-
# package ecosystems to update and where the package manifests are located.
|
|
3
|
-
# Please see the documentation for all configuration options:
|
|
4
|
-
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
-
|
|
6
|
-
version: 2
|
|
7
|
-
updates:
|
|
8
|
-
- package-ecosystem: "bundler" # See documentation for possible values
|
|
9
|
-
directory: "/" # Location of package manifests
|
|
10
|
-
schedule:
|
|
11
|
-
interval: "weekly"
|
|
12
|
-
day: "friday"
|
|
13
|
-
assignees:
|
|
14
|
-
- "LeFnord"
|
|
15
|
-
- package-ecosystem: "github-actions"
|
|
16
|
-
directory: "/"
|
|
17
|
-
schedule:
|
|
18
|
-
interval: weekly
|
|
19
|
-
assignees:
|
|
20
|
-
- "LeFnord"
|
data/.github/workflows/ci.yml
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
name: Ruby
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- '*'
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- '*'
|
|
10
|
-
|
|
11
|
-
permissions:
|
|
12
|
-
contents: read
|
|
13
|
-
|
|
14
|
-
jobs:
|
|
15
|
-
rubocop:
|
|
16
|
-
runs-on: ubuntu-latest
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v4
|
|
19
|
-
- uses: ruby/setup-ruby@v1
|
|
20
|
-
with:
|
|
21
|
-
ruby-version: '3.0'
|
|
22
|
-
bundler-cache: true
|
|
23
|
-
- name: Run rubocop
|
|
24
|
-
run: bundle exec rubocop --parallel --format progress
|
|
25
|
-
|
|
26
|
-
rspec:
|
|
27
|
-
runs-on: ubuntu-latest
|
|
28
|
-
needs: ['rubocop']
|
|
29
|
-
strategy:
|
|
30
|
-
matrix:
|
|
31
|
-
ruby-version: ['3.0', '3.1', '3.2', '3.3', 'head']
|
|
32
|
-
steps:
|
|
33
|
-
- name: Check out branch
|
|
34
|
-
uses: actions/checkout@v4
|
|
35
|
-
- name: Set up Ruby
|
|
36
|
-
uses: ruby/setup-ruby@v1
|
|
37
|
-
with:
|
|
38
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
39
|
-
bundler-cache: true
|
|
40
|
-
- name: Run rspec rest of the suite
|
|
41
|
-
run: bundle exec rspec
|
data/.gitignore
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
## MAC OS
|
|
2
|
-
.DS_Store
|
|
3
|
-
.com.apple.timemachine.supported
|
|
4
|
-
|
|
5
|
-
## TEXTMATE
|
|
6
|
-
*.tmproj
|
|
7
|
-
tmtags
|
|
8
|
-
|
|
9
|
-
## EMACS
|
|
10
|
-
*~
|
|
11
|
-
\#*
|
|
12
|
-
.\#*
|
|
13
|
-
|
|
14
|
-
## REDCAR
|
|
15
|
-
.redcar
|
|
16
|
-
|
|
17
|
-
## VIM
|
|
18
|
-
*.swp
|
|
19
|
-
*.swo
|
|
20
|
-
|
|
21
|
-
## RUBYMINE
|
|
22
|
-
.idea
|
|
23
|
-
|
|
24
|
-
## PROJECT::GENERAL
|
|
25
|
-
coverage
|
|
26
|
-
doc
|
|
27
|
-
pkg
|
|
28
|
-
.rvmrc
|
|
29
|
-
.bundle
|
|
30
|
-
.yardoc/*
|
|
31
|
-
dist
|
|
32
|
-
Gemfile.lock
|
|
33
|
-
tmp
|
|
34
|
-
coverage/
|
|
35
|
-
.byebug_history
|
|
36
|
-
.ruby-version
|
|
37
|
-
.ruby-gemset
|
|
38
|
-
|
|
39
|
-
## Rubinius
|
|
40
|
-
.rbx
|
|
41
|
-
|
|
42
|
-
## PROJECT::SPECIFIC
|
|
43
|
-
.project
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
|
2
|
-
|
|
3
|
-
AllCops:
|
|
4
|
-
Exclude:
|
|
5
|
-
- vendor/**/*
|
|
6
|
-
- example/**/*
|
|
7
|
-
NewCops: enable
|
|
8
|
-
TargetRubyVersion: 3.0
|
|
9
|
-
SuggestExtensions: false
|
|
10
|
-
|
|
11
|
-
# Layout stuff
|
|
12
|
-
#
|
|
13
|
-
Layout/EmptyLinesAroundArguments:
|
|
14
|
-
Enabled: false
|
|
15
|
-
|
|
16
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
|
17
|
-
Enabled: true
|
|
18
|
-
|
|
19
|
-
Layout/FirstHashElementIndentation:
|
|
20
|
-
EnforcedStyle: consistent
|
|
21
|
-
|
|
22
|
-
Layout/LineLength:
|
|
23
|
-
Max: 120
|
|
24
|
-
Exclude:
|
|
25
|
-
- spec/**/*
|
|
26
|
-
|
|
27
|
-
Layout/SpaceAroundMethodCallOperator:
|
|
28
|
-
Enabled: true
|
|
29
|
-
|
|
30
|
-
# Lint stuff
|
|
31
|
-
#
|
|
32
|
-
Lint/ConstantDefinitionInBlock:
|
|
33
|
-
Enabled: true
|
|
34
|
-
Exclude:
|
|
35
|
-
- spec/**/*
|
|
36
|
-
|
|
37
|
-
# Metrics stuff
|
|
38
|
-
#
|
|
39
|
-
Metrics/AbcSize:
|
|
40
|
-
Max: 25
|
|
41
|
-
AllowedMethods:
|
|
42
|
-
# from lib/grape_entity/exposure/nesting_exposure.rb
|
|
43
|
-
- 'normalized_exposures'
|
|
44
|
-
|
|
45
|
-
Metrics/BlockLength:
|
|
46
|
-
Exclude:
|
|
47
|
-
- spec/**/*
|
|
48
|
-
|
|
49
|
-
Metrics/CyclomaticComplexity:
|
|
50
|
-
Max: 13
|
|
51
|
-
|
|
52
|
-
Metrics/ClassLength:
|
|
53
|
-
Max: 300
|
|
54
|
-
|
|
55
|
-
Metrics/MethodLength:
|
|
56
|
-
Max: 26
|
|
57
|
-
Exclude:
|
|
58
|
-
- spec/**/*
|
|
59
|
-
|
|
60
|
-
Metrics/PerceivedComplexity:
|
|
61
|
-
Max: 11
|
|
62
|
-
AllowedMethods:
|
|
63
|
-
# from lib/grape_entity/entity.rb
|
|
64
|
-
- 'expose'
|
|
65
|
-
- 'merge_options'
|
|
66
|
-
# from lib/grape_entity/exposure/nesting_exposure.rb
|
|
67
|
-
- 'normalized_exposures'
|
|
68
|
-
|
|
69
|
-
# Naming stuff
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
Naming:
|
|
73
|
-
Enabled: false
|
|
74
|
-
|
|
75
|
-
# Style stuff
|
|
76
|
-
#
|
|
77
|
-
Style/Documentation:
|
|
78
|
-
Enabled: false
|
|
79
|
-
|
|
80
|
-
Style/HashSyntax:
|
|
81
|
-
Enabled: false
|
|
82
|
-
|
|
83
|
-
Style/OptionalBooleanParameter:
|
|
84
|
-
AllowedMethods:
|
|
85
|
-
# from lib/grape_entity/condition/base.rb
|
|
86
|
-
- 'initialize'
|
|
87
|
-
# form lib/grape_entity/entity.rb
|
|
88
|
-
- 'entity_class'
|
|
89
|
-
- 'present_collection'
|
data/.rubocop_todo.yml
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# This configuration was generated by
|
|
2
|
-
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2022-07-26 21:29:59 UTC using RuboCop version 1.32.0.
|
|
4
|
-
# The point is for the user to remove these configuration records
|
|
5
|
-
# one by one as the offenses are removed from the code base.
|
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
-
|
|
9
|
-
# Offense count: 1
|
|
10
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
11
|
-
# Configuration parameters: Include.
|
|
12
|
-
# Include: **/*.gemspec
|
|
13
|
-
Gemspec/DeprecatedAttributeAssignment:
|
|
14
|
-
Exclude:
|
|
15
|
-
- 'grape-entity.gemspec'
|
|
16
|
-
|
|
17
|
-
# Offense count: 1
|
|
18
|
-
# This cop supports safe autocorrection (--autocorrect).
|
|
19
|
-
# Configuration parameters: Include.
|
|
20
|
-
# Include: **/*.gemspec
|
|
21
|
-
Gemspec/RequireMFA:
|
|
22
|
-
Exclude:
|
|
23
|
-
- 'grape-entity.gemspec'
|
|
24
|
-
|
|
25
|
-
# Offense count: 1
|
|
26
|
-
# Configuration parameters: Include.
|
|
27
|
-
# Include: **/*.gemspec
|
|
28
|
-
Gemspec/RequiredRubyVersion:
|
|
29
|
-
Exclude:
|
|
30
|
-
- 'grape-entity.gemspec'
|
|
31
|
-
|
|
32
|
-
# Offense count: 6
|
|
33
|
-
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
34
|
-
Lint/BooleanSymbol:
|
|
35
|
-
Exclude:
|
|
36
|
-
- 'spec/grape_entity/exposure_spec.rb'
|
|
37
|
-
|
|
38
|
-
# Offense count: 15
|
|
39
|
-
Style/OpenStructUse:
|
|
40
|
-
Exclude:
|
|
41
|
-
- 'lib/grape_entity/delegator.rb'
|
|
42
|
-
- 'spec/grape_entity/entity_spec.rb'
|
|
43
|
-
|
|
44
|
-
# Offense count: 2
|
|
45
|
-
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
46
|
-
# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods, AllowComments.
|
|
47
|
-
# IgnoredMethods: respond_to, define_method
|
|
48
|
-
Style/SymbolProc:
|
|
49
|
-
Exclude:
|
|
50
|
-
- 'spec/grape_entity/entity_spec.rb'
|
data/.yardopts
DELETED
data/CONTRIBUTING.md
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
Contributing to Grape-Entity
|
|
2
|
-
============================
|
|
3
|
-
|
|
4
|
-
Grape-Entity is work of [many of contributors](https://github.com/ruby-grape/grape-entity/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/ruby-grape/grape-entity/pulls), [propose features and discuss issues](https://github.com/ruby-grape/grape-entity/issues). When in doubt, ask a question in the [Grape Google Group](http://groups.google.com/group/ruby-grape).
|
|
5
|
-
|
|
6
|
-
#### Fork the Project
|
|
7
|
-
|
|
8
|
-
Fork the [project on Github](https://github.com/ruby-grape/grape-entity) and check out your copy.
|
|
9
|
-
|
|
10
|
-
```
|
|
11
|
-
git clone https://github.com/contributor/grape-entity.git
|
|
12
|
-
cd grape-entity
|
|
13
|
-
git remote add upstream https://github.com/ruby-grape/grape-entity.git
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
#### Create a Topic Branch
|
|
17
|
-
|
|
18
|
-
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
git checkout master
|
|
22
|
-
git pull upstream master
|
|
23
|
-
git checkout -b my-feature-branch
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
#### Bundle Install and Test
|
|
27
|
-
|
|
28
|
-
Ensure that you can build the project and run tests.
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
bundle install
|
|
32
|
-
bundle exec rake
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
#### Write Tests
|
|
36
|
-
|
|
37
|
-
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/grape-entity](spec/grape-entity).
|
|
38
|
-
|
|
39
|
-
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
|
40
|
-
|
|
41
|
-
#### Write Code
|
|
42
|
-
|
|
43
|
-
Implement your feature or bug fix.
|
|
44
|
-
|
|
45
|
-
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
|
|
46
|
-
|
|
47
|
-
Make sure that `bundle exec rake` completes without errors.
|
|
48
|
-
|
|
49
|
-
#### Write Documentation
|
|
50
|
-
|
|
51
|
-
Document any external behavior in the [README](README.md).
|
|
52
|
-
|
|
53
|
-
#### Update Changelog
|
|
54
|
-
|
|
55
|
-
Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
|
|
56
|
-
|
|
57
|
-
#### Commit Changes
|
|
58
|
-
|
|
59
|
-
Make sure git knows your name and email address:
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
git config --global user.name "Your Name"
|
|
63
|
-
git config --global user.email "contributor@example.com"
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Writing good commit logs is important. A commit log should describe what changed and why.
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
git add ...
|
|
70
|
-
git commit
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
#### Push
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
git push origin my-feature-branch
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
#### Make a Pull Request
|
|
80
|
-
|
|
81
|
-
Go to https://github.com/ruby-grape/grape-entity and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
|
82
|
-
|
|
83
|
-
#### Rebase
|
|
84
|
-
|
|
85
|
-
If you've been working on a change for a while, rebase with upstream/master.
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
git fetch upstream
|
|
89
|
-
git rebase upstream/master
|
|
90
|
-
git push origin my-feature-branch -f
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
#### Update CHANGELOG Again
|
|
94
|
-
|
|
95
|
-
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
|
96
|
-
|
|
97
|
-
```
|
|
98
|
-
* [#123](https://github.com/ruby-grape/grape-entity/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Amend your previous commit and force push the changes.
|
|
102
|
-
|
|
103
|
-
```
|
|
104
|
-
git commit --amend
|
|
105
|
-
git push origin my-feature-branch -f
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
#### Check on Your Pull Request
|
|
109
|
-
|
|
110
|
-
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
|
111
|
-
|
|
112
|
-
#### Be Patient
|
|
113
|
-
|
|
114
|
-
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
|
115
|
-
|
|
116
|
-
#### Thank You
|
|
117
|
-
|
|
118
|
-
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/Dangerfile
DELETED