grape-entity 1.0.1 → 1.1.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 +40 -9
- data/README.md +5 -0
- data/lib/grape_entity/entity.rb +74 -13
- data/lib/grape_entity/version.rb +1 -1
- metadata +11 -50
- 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: 629fcce5dd878171471587ff40412484bdf2dad7207260e640178cad5de5906d
|
|
4
|
+
data.tar.gz: 6ffde278282ef2538348ebbb64e2f81ec212c5afb049b05245ab124e9a61d5b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac996bcc2636195158354945aafbba70a619aa104537e2dfb7ec1a55b00bc572be9569926c0b7973fa56be4d6a38618ff93699f987525120c283cb546cb5d12a
|
|
7
|
+
data.tar.gz: 933701a08a1c20e521615a0dea7e4cab08787ce20efe4f33dbb383e704cbf3c37ac2bd652f64d0435521a70ec716b00d0a9f5b28bf46fdd0891c6e796553a00c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,27 +1,58 @@
|
|
|
1
|
-
###
|
|
1
|
+
### 1.1.0 (2026-06-05)
|
|
2
2
|
|
|
3
3
|
#### Features
|
|
4
4
|
|
|
5
|
-
*
|
|
5
|
+
* [#404](https://github.com/ruby-grape/grape-entity/pull/404): Drop `MultiJson` dependency, use `Hash#to_json` for ActiveSupport-aware serialization - [@numbata](https://github.com/numbata).
|
|
6
6
|
|
|
7
7
|
#### Fixes
|
|
8
8
|
|
|
9
|
-
*
|
|
9
|
+
* [#406](https://github.com/ruby-grape/grape-entity/pull/406): Handle symbol-to-proc wrappers (`&:method_name`) where the method uses `delegate` or `method_missing`, and let unknown methods raise a native `NoMethodError` - [@marcrohloff](https://github.com/marcrohloff).
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
###
|
|
12
|
+
### 1.0.4 (2026-04-17)
|
|
13
|
+
|
|
14
|
+
#### Fixes
|
|
15
|
+
|
|
16
|
+
* [#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).
|
|
17
|
+
* [#402](https://github.com/ruby-grape/grape-entity/pull/402): Remove `Json::ParseError` assignment - [@olivier-thatch](https://github.com/olivier-thatch).
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### 1.0.3 (2026-04-15)
|
|
21
|
+
|
|
22
|
+
#### Features
|
|
23
|
+
|
|
24
|
+
* [#400](https://github.com/ruby-grape/grape-entity/pull/400): Switch to danger-pr-comment for PR checks - [@numbata](https://github.com/numbata).
|
|
25
|
+
* [#397](https://github.com/ruby-grape/grape-entity/pull/397): Reduce gem size by excluding test files - [@yuri-zubov](https://github.com/yuri-zubov).
|
|
26
|
+
* [#401](https://github.com/ruby-grape/grape-entity/pull/401): Modernize gemspec: add metadata, use Dir glob, require MFA - [@numbata](https://github.com/numbata).
|
|
27
|
+
|
|
28
|
+
#### Fixes
|
|
29
|
+
|
|
30
|
+
* [#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).
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### 1.0.2 (2026-04-13)
|
|
34
|
+
|
|
35
|
+
#### Fixes
|
|
36
|
+
|
|
37
|
+
* [#394](https://github.com/ruby-grape/grape-entity/pull/394): Add `Entity.[]` for Grape >= 3.2 param type compatibility - [@numbata](https://github.com/numbata).
|
|
38
|
+
* [#388](https://github.com/ruby-grape/grape-entity/pull/388): Drop ruby-head from test matrix - [@numbata](https://github.com/numbata).
|
|
39
|
+
* [#389](https://github.com/ruby-grape/grape-entity/pull/389): Block arity detection (breaking change) - [@numbata](https://github.com/numbata).
|
|
40
|
+
* [#385](https://github.com/ruby-grape/grape-entity/pull/385): Drop multijson dependency - [@ericproulx](https://github.com/ericproulx).
|
|
41
|
+
* [#384](https://github.com/ruby-grape/grape-entity/pull/384): Fix `inspect` to correctly handle `nil` values - [@fcce](https://github.com/fcce).
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### 1.0.1 (2024-04-10)
|
|
13
45
|
|
|
14
46
|
#### Fixes
|
|
15
47
|
|
|
16
48
|
* [#381](https://github.com/ruby-grape/grape-entity/pull/381): Fix `expose_nil: false` when using a block - [@magni-](https://github.com/magni-).
|
|
17
49
|
|
|
18
50
|
|
|
19
|
-
###
|
|
51
|
+
### 1.0.0 (2023-02-16)
|
|
20
52
|
|
|
21
53
|
#### Fixes
|
|
22
54
|
|
|
23
|
-
|
|
24
|
-
* [#352](https://github.com/ruby-grape/grape-entity/pull/369): Remove `FetchableObject` behavior. - [@danielvdao](https://github.com/danielvdao).
|
|
55
|
+
* [#369](https://github.com/ruby-grape/grape-entity/pull/369): Remove `FetchableObject` behavior (breaking change) - [@danielvdao](https://github.com/danielvdao).
|
|
25
56
|
* [#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
57
|
|
|
27
58
|
|
|
@@ -29,8 +60,8 @@
|
|
|
29
60
|
|
|
30
61
|
#### Fixes
|
|
31
62
|
|
|
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/
|
|
63
|
+
* [#366](https://github.com/ruby-grape/grape-entity/pull/366): Don't suppress regular ArgumentError exceptions - [@splattael](https://github.com/splattael).
|
|
64
|
+
* [#363](https://github.com/ruby-grape/grape-entity/pull/363): Fix typo - [@OuYangJinTing](https://github.com/OuYangJinTing).
|
|
34
65
|
* [#361](https://github.com/ruby-grape/grape-entity/pull/361): Require 'active_support/core_ext' - [@pravi](https://github.com/pravi).
|
|
35
66
|
|
|
36
67
|
|
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
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'multi_json'
|
|
4
|
-
|
|
5
3
|
module Grape
|
|
6
4
|
# An Entity is a lightweight structure that allows you to easily
|
|
7
5
|
# represent data from your application in a consistent and abstracted
|
|
@@ -129,6 +127,12 @@ module Grape
|
|
|
129
127
|
def delegation_opts
|
|
130
128
|
@delegation_opts ||= { hash_access: hash_access }
|
|
131
129
|
end
|
|
130
|
+
|
|
131
|
+
# Satisfies the respond_to?(:[]) check in Grape::DryTypes (>= 3.2)
|
|
132
|
+
# so Entity subclasses can be used as param types.
|
|
133
|
+
def [](val)
|
|
134
|
+
val
|
|
135
|
+
end
|
|
132
136
|
end
|
|
133
137
|
|
|
134
138
|
@formatters = {}
|
|
@@ -287,7 +291,7 @@ module Grape
|
|
|
287
291
|
end
|
|
288
292
|
|
|
289
293
|
# This allows you to declare a Proc in which exposures can be formatted with.
|
|
290
|
-
# It
|
|
294
|
+
# It takes a block with a single argument which is passed as the value of the exposed attribute.
|
|
291
295
|
#
|
|
292
296
|
# @param name [Symbol] the name of the formatter
|
|
293
297
|
# @param block [Proc] the block that will interpret the exposed attribute
|
|
@@ -472,8 +476,13 @@ module Grape
|
|
|
472
476
|
|
|
473
477
|
# Prevent default serialization of :options or :delegator.
|
|
474
478
|
def inspect
|
|
475
|
-
|
|
476
|
-
|
|
479
|
+
object = serializable_hash
|
|
480
|
+
if object.nil?
|
|
481
|
+
"#<#{self.class.name}:#{object_id} nil>"
|
|
482
|
+
else
|
|
483
|
+
fields = object.map { |k, v| "#{k}=#{v}" }
|
|
484
|
+
"#<#{self.class.name}:#{object_id} #{fields.join(' ')}>"
|
|
485
|
+
end
|
|
477
486
|
end
|
|
478
487
|
|
|
479
488
|
def initialize(object, options = {})
|
|
@@ -514,19 +523,71 @@ module Grape
|
|
|
514
523
|
end
|
|
515
524
|
|
|
516
525
|
def exec_with_object(options, &block)
|
|
517
|
-
if block
|
|
526
|
+
if symbol_to_proc_wrapper?(block)
|
|
527
|
+
ensure_block_arity!(block)
|
|
528
|
+
instance_exec(object, &block)
|
|
529
|
+
elsif block.arity == 1
|
|
518
530
|
instance_exec(object, &block)
|
|
519
531
|
else
|
|
520
532
|
instance_exec(object, options, &block)
|
|
521
533
|
end
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
def ensure_block_arity!(block)
|
|
537
|
+
# Strict anchor to match MRI Proc#to_s format for symbol-to-proc: #<Proc:0x0...(&:method_name) (lambda)>
|
|
538
|
+
match = block.to_s.match(/\A#<Proc:(?:0x)?\h+\(&:(?<name>.+)\) \(lambda\)>\z/)
|
|
539
|
+
return unless match # Unrecognized format -> bail safe rather than misidentify
|
|
540
|
+
|
|
541
|
+
origin_method_name = match[:name].to_sym
|
|
542
|
+
required_positional_arg_count, required_keyword_arg_count, variadic_positional =
|
|
543
|
+
arity_requirement_for(origin_method_name)
|
|
544
|
+
return unless required_positional_arg_count
|
|
545
|
+
|
|
546
|
+
required_arguments =
|
|
547
|
+
required_arguments_summary(required_positional_arg_count, required_keyword_arg_count, variadic_positional)
|
|
548
|
+
|
|
549
|
+
raise ArgumentError, <<~MSG
|
|
550
|
+
Cannot use `&:#{origin_method_name}` because that method expects #{required_arguments}.
|
|
551
|
+
Symbol-to-proc shorthand only works for methods that can be called with no arguments.
|
|
552
|
+
MSG
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
def arity_requirement_for(method_name)
|
|
556
|
+
origin_method = object.method(method_name)
|
|
557
|
+
parameters = origin_method.parameters
|
|
558
|
+
|
|
559
|
+
required_positional_arg_count = parameters.count { |type, _| type == :req }
|
|
560
|
+
required_keyword_arg_count = parameters.count { |type, _| type == :keyreq }
|
|
561
|
+
return nil if required_positional_arg_count.zero? && required_keyword_arg_count.zero?
|
|
562
|
+
|
|
563
|
+
[required_positional_arg_count, required_keyword_arg_count, parameters.any? { |type, _| type == :rest }]
|
|
564
|
+
rescue NameError
|
|
565
|
+
# Delegation wrappers and method_missing proxies may not expose a Method; let Ruby raise natively at call time.
|
|
566
|
+
nil
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
def required_arguments_summary(required_positional_arg_count, required_keyword_arg_count, variadic_positional)
|
|
570
|
+
parts = []
|
|
571
|
+
unless required_positional_arg_count.zero?
|
|
572
|
+
suffix = required_positional_arg_count == 1 ? 'argument' : 'arguments'
|
|
573
|
+
suffix += ' or more' if variadic_positional
|
|
574
|
+
parts << "#{required_positional_arg_count} #{suffix}"
|
|
575
|
+
end
|
|
576
|
+
unless required_keyword_arg_count.zero?
|
|
577
|
+
suffix = required_keyword_arg_count == 1 ? 'keyword argument' : 'keyword arguments'
|
|
578
|
+
parts << "#{required_keyword_arg_count} #{suffix}"
|
|
527
579
|
end
|
|
528
580
|
|
|
529
|
-
|
|
581
|
+
parts.join(' and ')
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
def symbol_to_proc_wrapper?(block)
|
|
585
|
+
params = block.parameters
|
|
586
|
+
|
|
587
|
+
return false unless block.lambda? && block.source_location.nil?
|
|
588
|
+
return false unless params.size >= 2
|
|
589
|
+
|
|
590
|
+
params[0].first == :req && params[1].first == :rest
|
|
530
591
|
end
|
|
531
592
|
|
|
532
593
|
def exec_with_attribute(attribute, &block)
|
|
@@ -558,7 +619,7 @@ module Grape
|
|
|
558
619
|
|
|
559
620
|
def to_json(options = {})
|
|
560
621
|
options = options.to_h if options&.respond_to?(:to_h)
|
|
561
|
-
|
|
622
|
+
serializable_hash(options).to_json
|
|
562
623
|
end
|
|
563
624
|
|
|
564
625
|
def to_xml(options = {})
|
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.1.0
|
|
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-06-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -25,20 +25,6 @@ dependencies:
|
|
|
25
25
|
- - ">="
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: 3.0.0
|
|
28
|
-
- !ruby/object:Gem::Dependency
|
|
29
|
-
name: multi_json
|
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
|
31
|
-
requirements:
|
|
32
|
-
- - ">="
|
|
33
|
-
- !ruby/object:Gem::Version
|
|
34
|
-
version: 1.3.2
|
|
35
|
-
type: :runtime
|
|
36
|
-
prerelease: false
|
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
-
requirements:
|
|
39
|
-
- - ">="
|
|
40
|
-
- !ruby/object:Gem::Version
|
|
41
|
-
version: 1.3.2
|
|
42
28
|
description: Extracted from Grape, A Ruby framework for rapid API development with
|
|
43
29
|
great conventions.
|
|
44
30
|
email:
|
|
@@ -48,26 +34,9 @@ executables: []
|
|
|
48
34
|
extensions: []
|
|
49
35
|
extra_rdoc_files: []
|
|
50
36
|
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
37
|
- CHANGELOG.md
|
|
60
|
-
- CONTRIBUTING.md
|
|
61
|
-
- Dangerfile
|
|
62
|
-
- Gemfile
|
|
63
|
-
- Guardfile
|
|
64
38
|
- LICENSE
|
|
65
39
|
- README.md
|
|
66
|
-
- RELEASING.md
|
|
67
|
-
- Rakefile
|
|
68
|
-
- UPGRADING.md
|
|
69
|
-
- bench/serializing.rb
|
|
70
|
-
- grape-entity.gemspec
|
|
71
40
|
- lib/grape-entity.rb
|
|
72
41
|
- lib/grape_entity.rb
|
|
73
42
|
- lib/grape_entity/condition.rb
|
|
@@ -94,17 +63,16 @@ files:
|
|
|
94
63
|
- lib/grape_entity/exposure/represent_exposure.rb
|
|
95
64
|
- lib/grape_entity/options.rb
|
|
96
65
|
- 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
66
|
homepage: https://github.com/ruby-grape/grape-entity
|
|
105
67
|
licenses:
|
|
106
68
|
- MIT
|
|
107
|
-
metadata:
|
|
69
|
+
metadata:
|
|
70
|
+
homepage_uri: https://github.com/ruby-grape/grape-entity
|
|
71
|
+
bug_tracker_uri: https://github.com/ruby-grape/grape-entity/issues
|
|
72
|
+
changelog_uri: https://github.com/ruby-grape/grape-entity/blob/v1.1.0/CHANGELOG.md
|
|
73
|
+
documentation_uri: https://www.rubydoc.info/gems/grape-entity/1.1.0
|
|
74
|
+
source_code_uri: https://github.com/ruby-grape/grape-entity/tree/v1.1.0
|
|
75
|
+
rubygems_mfa_required: 'true'
|
|
108
76
|
post_install_message:
|
|
109
77
|
rdoc_options: []
|
|
110
78
|
require_paths:
|
|
@@ -120,15 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
120
88
|
- !ruby/object:Gem::Version
|
|
121
89
|
version: '0'
|
|
122
90
|
requirements: []
|
|
123
|
-
rubygems_version: 3.5.
|
|
91
|
+
rubygems_version: 3.5.22
|
|
124
92
|
signing_key:
|
|
125
93
|
specification_version: 4
|
|
126
94
|
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
|
|
95
|
+
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