grape-roar 0.4.1 → 0.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 +5 -5
- data/.github/FUNDING.yml +2 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/danger.yml +22 -0
- data/.github/workflows/lint.yml +15 -0
- data/.github/workflows/test-activerecord.yml +34 -0
- data/.github/workflows/test-mongodb.yml +33 -0
- data/.github/workflows/test.yml +19 -0
- data/.rubocop.yml +7 -6
- data/.rubocop_todo.yml +163 -21
- data/CHANGELOG.md +13 -11
- data/Dangerfile +4 -0
- data/Gemfile +16 -8
- data/Gemfile.danger +6 -0
- data/README.md +41 -22
- data/grape-roar.gemspec +2 -3
- data/lib/grape/roar/extensions/relations/adapters/base.rb +1 -1
- data/lib/grape/roar/extensions/relations/adapters/mongoid.rb +1 -1
- data/lib/grape/roar/extensions/relations/adapters.rb +2 -2
- data/lib/grape/roar/extensions/relations/mapper.rb +7 -2
- data/lib/grape/roar/extensions/relations/validations/active_record.rb +11 -38
- data/lib/grape/roar/extensions/relations/validations/mongoid/6.rb +48 -0
- data/lib/grape/roar/extensions/relations/validations/mongoid/7.rb +75 -0
- data/lib/grape/roar/extensions/relations/validations/mongoid.rb +5 -84
- data/lib/grape/roar/representer.rb +4 -1
- data/lib/grape/roar/version.rb +1 -1
- data/spec/decorator_spec.rb +0 -2
- data/spec/extensions/relations/adapters/active_record_spec.rb +21 -17
- data/spec/extensions/relations/adapters/adapters_module_spec.rb +3 -2
- data/spec/extensions/relations/adapters/mongoid_spec.rb +21 -17
- data/spec/extensions/relations/dsl_methods_spec.rb +14 -14
- data/spec/extensions/relations/mapper_spec.rb +10 -10
- data/spec/extensions/relations/validations/active_record_spec.rb +35 -32
- data/spec/extensions/relations/validations/mongoid_spec.rb +64 -61
- data/spec/nested_representer_spec.rb +0 -2
- data/spec/present_with_spec.rb +0 -2
- data/spec/relations_spec.rb +6 -5
- data/spec/representer_spec.rb +34 -8
- data/spec/spec_helper.rb +6 -2
- data/spec/support/all/article_representer.rb +1 -0
- data/spec/support/all/grape_app_context.rb +0 -2
- metadata +19 -12
- data/.travis.yml +0 -36
- data/Appraisals +0 -9
- data/gemfiles/with_activerecord.gemfile +0 -22
- data/gemfiles/with_mongoid.gemfile +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 887bd8d1a53f42649682a8df91a13dc3143225a87ded8dc347c57971e5af4e0d
|
4
|
+
data.tar.gz: 1e4993cb040f531d43c0f4c7667c36e4f60c78913fd924d1acc85d56c4b33121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a34c2b45f19f32fe162888b1aead79d38c873b8e401359f508fa64871be69544c536dab862c339b6352a67bb48c1f65653b175040ddcdf9845366a281cb1625f
|
7
|
+
data.tar.gz: 507e0234bd5c0835926d4d13a68f7ea0fc506ca371de03a5231a5ad560fa9a33be72e15e67bcf82b92ff80f8fcb4a13b8a5b20f151b2123ba79c0cb65b5be543
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
name: danger
|
2
|
+
on: pull_request
|
3
|
+
jobs:
|
4
|
+
danger:
|
5
|
+
name: Dangerfile
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
env:
|
8
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile.danger
|
9
|
+
steps:
|
10
|
+
- name: Checkout
|
11
|
+
uses: actions/checkout@v5
|
12
|
+
with:
|
13
|
+
fetch-depth: 0
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: '3.4'
|
18
|
+
bundler-cache: true
|
19
|
+
- run: |
|
20
|
+
# the token is public, has public_repo scope and belongs to the grape-bot user owned by @dblock, this is ok
|
21
|
+
TOKEN=$(echo -n Z2hwX2lYb0dPNXNyejYzOFJyaTV3QUxUdkNiS1dtblFwZTFuRXpmMwo= | base64 --decode)
|
22
|
+
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
|
@@ -0,0 +1,15 @@
|
|
1
|
+
name: lint
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
rubocop:
|
5
|
+
name: RuboCop
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- name: Checkout
|
9
|
+
uses: actions/checkout@v5
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: '3.4'
|
14
|
+
bundler-cache: true
|
15
|
+
- run: bundle exec rubocop
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
name: test-activerecord
|
3
|
+
on: [push, pull_request]
|
4
|
+
jobs:
|
5
|
+
test:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
strategy:
|
8
|
+
matrix:
|
9
|
+
entry:
|
10
|
+
- { ruby: '3.4', postgresql: '15', activerecord: '~> 6.1.0', grape: '~> 1.8.0' }
|
11
|
+
- { ruby: '3.4', postgresql: '16', activerecord: '~> 7.2.0', grape: '~> 2.4.0' }
|
12
|
+
- { ruby: '3.4', postgresql: '17', activerecord: '~> 8.0.3', grape: '~> 2.4.0' }
|
13
|
+
name: test (ruby=${{ matrix.entry.ruby }}, postgresql=${{ matrix.entry.postgresql }}, activerecord=${{ matrix.entry.activerecord }}, grape=${{ matrix.entry.grape }})
|
14
|
+
env:
|
15
|
+
ACTIVERECORD_VERSION: ${{ matrix.entry.activerecord }}
|
16
|
+
GRAPE_VERSION: ${{ matrix.entry.grape }}
|
17
|
+
steps:
|
18
|
+
- uses: harmon758/postgresql-action@v1
|
19
|
+
with:
|
20
|
+
postgresql version: ${{ matrix.entry.postgresql }}
|
21
|
+
postgresql db: slack_ruby_bot_server_test
|
22
|
+
postgresql user: test
|
23
|
+
postgresql password: password
|
24
|
+
- uses: actions/checkout@v5
|
25
|
+
- uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.entry.ruby }}
|
28
|
+
bundler-cache: true
|
29
|
+
- name: Run ActiveRecord Tests
|
30
|
+
env:
|
31
|
+
SPEC_OPTS: --tag activerecord
|
32
|
+
run: bundle exec rake
|
33
|
+
- name: Run Tests
|
34
|
+
run: bundle exec rake
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
name: test-mongodb
|
3
|
+
on: [push, pull_request]
|
4
|
+
jobs:
|
5
|
+
test:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
strategy:
|
8
|
+
matrix:
|
9
|
+
entry:
|
10
|
+
- { ruby: '3.4', mongoid: '~> 6.4.8', mongodb: '6.0', grape: '~> 1.7.0' }
|
11
|
+
- { ruby: '3.4', mongoid: '~> 6.4.8', mongodb: '6.0', grape: '~> 2.0.0' }
|
12
|
+
- { ruby: '3.4', mongoid: '~> 7.5.4', mongodb: '7.0', grape: '~> 2.4.0' }
|
13
|
+
- { ruby: '3.4', mongoid: '~> 8.1.11', mongodb: '8.0', grape: '~> 2.4.0' }
|
14
|
+
- { ruby: '3.4', mongoid: '~> 9.0.8', mongodb: '8.0', grape: '~> 2.4.0' }
|
15
|
+
name: test (ruby=${{ matrix.entry.ruby }}, mongoid=${{ matrix.entry.mongoid }}, mongodb=${{ matrix.entry.mongodb }}, grape=${{ matrix.entry.grape }})
|
16
|
+
env:
|
17
|
+
MONGOID_VERSION: ${{ matrix.entry.mongoid }}
|
18
|
+
GRAPE_VERSION: ${{ matrix.entry.grape }}
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v5
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.entry.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
- uses: supercharge/mongodb-github-action@1.12.0
|
26
|
+
with:
|
27
|
+
mongodb-version: ${{ matrix.entry.mongodb }}
|
28
|
+
- name: Run Tests
|
29
|
+
run: bundle exec rake
|
30
|
+
- name: Run Mongoid Tagged Tests
|
31
|
+
env:
|
32
|
+
SPEC_OPTS: --tag mongoid
|
33
|
+
run: bundle exec rake
|
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
name: test
|
3
|
+
on: [push, pull_request]
|
4
|
+
jobs:
|
5
|
+
test:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
strategy:
|
8
|
+
matrix:
|
9
|
+
entry:
|
10
|
+
- { ruby: 3.4 }
|
11
|
+
name: test (ruby=${{ matrix.entry.ruby }})
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v5
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: ${{ matrix.entry.ruby }}
|
17
|
+
bundler-cache: true
|
18
|
+
- name: Run Tests
|
19
|
+
run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion:
|
3
|
-
|
2
|
+
TargetRubyVersion: 3.0
|
3
|
+
NewCops: enable
|
4
4
|
Exclude:
|
5
|
-
- bin/**/*
|
6
|
-
- gemfiles/**/*
|
7
|
-
- spec/**/*
|
8
5
|
- vendor/**/*
|
9
6
|
|
10
|
-
inherit_from: .rubocop_todo.yml
|
7
|
+
inherit_from: .rubocop_todo.yml
|
8
|
+
|
9
|
+
plugins:
|
10
|
+
- rubocop-rake
|
11
|
+
- rubocop-rspec
|
data/.rubocop_todo.yml
CHANGED
@@ -1,18 +1,157 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2025-09-25 02:19:21 UTC using RuboCop version 1.80.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
# Configuration parameters:
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Severity.
|
11
|
+
Gemspec/RequiredRubyVersion:
|
12
|
+
Exclude:
|
13
|
+
- 'grape-roar.gemspec'
|
14
|
+
|
15
|
+
# Offense count: 1
|
16
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
17
|
+
Metrics/MethodLength:
|
18
|
+
Max: 11
|
19
|
+
|
20
|
+
# Offense count: 1
|
21
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
22
|
+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
23
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
24
|
+
Naming/FileName:
|
25
|
+
Exclude:
|
26
|
+
- 'Rakefile.rb'
|
27
|
+
- 'lib/grape-roar.rb'
|
28
|
+
|
29
|
+
# Offense count: 9
|
30
|
+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
|
31
|
+
# NamePrefix: is_, has_, have_, does_
|
32
|
+
# ForbiddenPrefixes: is_, has_, have_, does_
|
33
|
+
# AllowedMethods: is_a?
|
34
|
+
# MethodDefinitionMacros: define_method, define_singleton_method
|
35
|
+
Naming/PredicatePrefix:
|
36
|
+
Exclude:
|
37
|
+
- 'spec/**/*'
|
38
|
+
- 'lib/grape/roar/extensions/relations/validations/active_record.rb'
|
39
|
+
- 'lib/grape/roar/extensions/relations/validations/mongoid/6.rb'
|
40
|
+
- 'lib/grape/roar/extensions/relations/validations/mongoid/7.rb'
|
41
|
+
|
42
|
+
# Offense count: 8
|
43
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
44
|
+
RSpec/BeEql:
|
45
|
+
Exclude:
|
46
|
+
- 'spec/extensions/relations/adapters/active_record_spec.rb'
|
47
|
+
- 'spec/extensions/relations/adapters/mongoid_spec.rb'
|
48
|
+
- 'spec/extensions/relations/validations/active_record_spec.rb'
|
49
|
+
- 'spec/extensions/relations/validations/mongoid_spec.rb'
|
50
|
+
- 'spec/relations_spec.rb'
|
51
|
+
|
52
|
+
# Offense count: 11
|
53
|
+
# Configuration parameters: Prefixes, AllowedPatterns.
|
54
|
+
# Prefixes: when, with, without
|
55
|
+
RSpec/ContextWording:
|
56
|
+
Exclude:
|
57
|
+
- 'spec/decorator_spec.rb'
|
58
|
+
- 'spec/extensions/relations/validations/mongoid_spec.rb'
|
59
|
+
- 'spec/nested_representer_spec.rb'
|
60
|
+
- 'spec/present_with_spec.rb'
|
61
|
+
- 'spec/relations_spec.rb'
|
62
|
+
- 'spec/representer_spec.rb'
|
63
|
+
- 'spec/support/all/grape_app_context.rb'
|
64
|
+
|
65
|
+
# Offense count: 4
|
66
|
+
# Configuration parameters: CountAsOne.
|
67
|
+
RSpec/ExampleLength:
|
68
|
+
Max: 14
|
69
|
+
|
70
|
+
# Offense count: 3
|
71
|
+
RSpec/ExpectInHook:
|
72
|
+
Exclude:
|
73
|
+
- 'spec/extensions/relations/dsl_methods_spec.rb'
|
74
|
+
- 'spec/extensions/relations/validations/active_record_spec.rb'
|
75
|
+
- 'spec/extensions/relations/validations/mongoid_spec.rb'
|
76
|
+
|
77
|
+
# Offense count: 1
|
78
|
+
RSpec/MessageChain:
|
79
|
+
Exclude:
|
80
|
+
- 'spec/extensions/relations/dsl_methods_spec.rb'
|
81
|
+
|
82
|
+
# Offense count: 18
|
83
|
+
# Configuration parameters: .
|
84
|
+
# SupportedStyles: have_received, receive
|
85
|
+
RSpec/MessageSpies:
|
86
|
+
EnforcedStyle: receive
|
14
87
|
|
15
|
-
# Offense count:
|
88
|
+
# Offense count: 10
|
89
|
+
RSpec/MultipleExpectations:
|
90
|
+
Max: 5
|
91
|
+
|
92
|
+
# Offense count: 58
|
93
|
+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
94
|
+
# SupportedStyles: always, named_only
|
95
|
+
RSpec/NamedSubject:
|
96
|
+
Exclude:
|
97
|
+
- 'spec/decorator_spec.rb'
|
98
|
+
- 'spec/extensions/relations/adapters/active_record_spec.rb'
|
99
|
+
- 'spec/extensions/relations/adapters/mongoid_spec.rb'
|
100
|
+
- 'spec/extensions/relations/dsl_methods_spec.rb'
|
101
|
+
- 'spec/extensions/relations/mapper_spec.rb'
|
102
|
+
- 'spec/extensions/relations/validations/active_record_spec.rb'
|
103
|
+
- 'spec/extensions/relations/validations/mongoid_spec.rb'
|
104
|
+
- 'spec/nested_representer_spec.rb'
|
105
|
+
- 'spec/present_with_spec.rb'
|
106
|
+
- 'spec/relations_spec.rb'
|
107
|
+
- 'spec/representer_spec.rb'
|
108
|
+
- 'spec/support/all/grape_app_context.rb'
|
109
|
+
|
110
|
+
# Offense count: 2
|
111
|
+
# Configuration parameters: AllowedGroups.
|
112
|
+
RSpec/NestedGroups:
|
113
|
+
Max: 4
|
114
|
+
|
115
|
+
# Offense count: 2
|
116
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
117
|
+
RSpec/ReceiveMessages:
|
118
|
+
Exclude:
|
119
|
+
- 'spec/extensions/relations/mapper_spec.rb'
|
120
|
+
|
121
|
+
# Offense count: 8
|
122
|
+
# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata.
|
123
|
+
RSpec/SpecFilePathFormat:
|
124
|
+
Exclude:
|
125
|
+
- '**/spec/routing/**/*'
|
126
|
+
- 'spec/decorator_spec.rb'
|
127
|
+
- 'spec/extensions/relations/adapters/adapters_module_spec.rb'
|
128
|
+
- 'spec/extensions/relations/dsl_methods_spec.rb'
|
129
|
+
- 'spec/extensions/relations/mapper_spec.rb'
|
130
|
+
- 'spec/nested_representer_spec.rb'
|
131
|
+
- 'spec/present_with_spec.rb'
|
132
|
+
- 'spec/relations_spec.rb'
|
133
|
+
- 'spec/representer_spec.rb'
|
134
|
+
|
135
|
+
# Offense count: 3
|
136
|
+
RSpec/StubbedMock:
|
137
|
+
Exclude:
|
138
|
+
- 'spec/extensions/relations/dsl_methods_spec.rb'
|
139
|
+
- 'spec/extensions/relations/mapper_spec.rb'
|
140
|
+
|
141
|
+
# Offense count: 11
|
142
|
+
RSpec/SubjectStub:
|
143
|
+
Exclude:
|
144
|
+
- 'spec/extensions/relations/dsl_methods_spec.rb'
|
145
|
+
- 'spec/extensions/relations/mapper_spec.rb'
|
146
|
+
|
147
|
+
# Offense count: 1
|
148
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
149
|
+
RSpec/VerifiedDoubleReference:
|
150
|
+
Exclude:
|
151
|
+
- 'spec/extensions/relations/mapper_spec.rb'
|
152
|
+
|
153
|
+
# Offense count: 15
|
154
|
+
# Configuration parameters: AllowedConstants.
|
16
155
|
Style/Documentation:
|
17
156
|
Exclude:
|
18
157
|
- 'spec/**/*'
|
@@ -27,23 +166,26 @@ Style/Documentation:
|
|
27
166
|
- 'lib/grape/roar/extensions/relations/mapper.rb'
|
28
167
|
- 'lib/grape/roar/extensions/relations/validations/active_record.rb'
|
29
168
|
- 'lib/grape/roar/extensions/relations/validations/misc.rb'
|
30
|
-
- 'lib/grape/roar/extensions/relations/validations/mongoid.rb'
|
169
|
+
- 'lib/grape/roar/extensions/relations/validations/mongoid/6.rb'
|
170
|
+
- 'lib/grape/roar/extensions/relations/validations/mongoid/7.rb'
|
31
171
|
- 'lib/grape/roar/formatter.rb'
|
32
172
|
- 'lib/grape/roar/representer.rb'
|
33
173
|
|
34
|
-
# Offense count:
|
35
|
-
|
36
|
-
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
37
|
-
Style/FileName:
|
174
|
+
# Offense count: 2
|
175
|
+
Style/OpenStructUse:
|
38
176
|
Exclude:
|
39
|
-
- '
|
177
|
+
- 'spec/extensions/relations/dsl_methods_spec.rb'
|
40
178
|
|
41
|
-
# Offense count:
|
42
|
-
# Configuration parameters:
|
43
|
-
#
|
44
|
-
|
45
|
-
# NameWhitelist: is_a?
|
46
|
-
Style/PredicateName:
|
179
|
+
# Offense count: 1
|
180
|
+
# Configuration parameters: AllowedMethods.
|
181
|
+
# AllowedMethods: respond_to_missing?
|
182
|
+
Style/OptionalBooleanParameter:
|
47
183
|
Exclude:
|
48
|
-
- '
|
49
|
-
|
184
|
+
- 'lib/grape/roar/extensions/relations/dsl_methods.rb'
|
185
|
+
|
186
|
+
# Offense count: 2
|
187
|
+
# This cop supports safe autocorrection (--autocorrect).
|
188
|
+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
189
|
+
# URISchemes: http, https
|
190
|
+
Layout/LineLength:
|
191
|
+
Max: 304
|
data/CHANGELOG.md
CHANGED
@@ -1,28 +1,30 @@
|
|
1
|
-
0.
|
2
|
-
----
|
1
|
+
### 0.5.0 (2025/09/25)
|
3
2
|
|
4
|
-
* [#
|
3
|
+
* [#31](https://github.com/ruby-grape/grape-roar/pull/31): Add support for Mongoid 7, 8 and 9 - [@dblock](https://github.com/dblock).
|
4
|
+
* [#23](https://github.com/ruby-grape/grape-roar/pull/23): Resolves pollution issue with invoking representers on singletons - [@mach-kernel](https://github.com/mach-kernel).
|
5
|
+
* [#28](https://github.com/ruby-grape/grape-roar/pull/28): Replaced Travis-CI with GHA - [@dblock](https://github.com/dblock).
|
5
6
|
|
6
7
|
|
7
|
-
0.4.
|
8
|
-
|
8
|
+
### 0.4.1 (2017/07/14)
|
9
|
+
|
10
|
+
* [#22](https://github.com/ruby-grape/grape-roar/pull/22): Adds Grape::Roar::Extensions::Relations - [@mach-kernel](https://github.com/mach-kernel).
|
11
|
+
|
12
|
+
|
13
|
+
### 0.4.0 (2017/02/18)
|
9
14
|
|
10
15
|
* [#21](https://github.com/ruby-grape/grape-roar/pull/21): Fixes serialization issue due to [representable](https://github.com/trailblazer/representable) API change, drop support for Ruby < `2.1.0` - [@mach-kernel](https://github.com/mach-kernel).
|
11
16
|
|
12
17
|
|
13
|
-
0.3.0 (12/31
|
14
|
-
------------------
|
18
|
+
### 0.3.0 (2014/12/31)
|
15
19
|
|
16
20
|
* Added support for Roar 1.0 - [@dblock](https://github.com/dblock).
|
17
21
|
|
18
22
|
|
19
|
-
0.2.0 (12/18
|
20
|
-
------------------
|
23
|
+
### 0.2.0 (2014/12/18)
|
21
24
|
|
22
25
|
* [#10](https://github.com/ruby-grape/grape-roar/pull/10): Support for Roar decorator - [@sdbondi](https://github.com/sdbondi).
|
23
26
|
|
24
27
|
|
25
|
-
0.1.0 (7/17
|
26
|
-
-----------------
|
28
|
+
### 0.1.0 (2014/7/17)
|
27
29
|
|
28
30
|
* Initial public release, with support for Grape `present` - [@dblock](https://github.com/dblock).
|
data/Dangerfile
ADDED
data/Gemfile
CHANGED
@@ -2,19 +2,27 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
|
5
|
+
gem 'activerecord', ENV['ACTIVERECORD_VERSION'], require: 'active_record' if ENV.key?('ACTIVERECORD_VERSION')
|
6
|
+
gem 'grape', ENV['GRAPE_VERSION'] if ENV.key?('GRAPE_VERSION')
|
7
|
+
gem 'mongoid', ENV['MONGOID_VERSION'], require: 'mongoid' if ENV.key?('MONGOID_VERSION')
|
6
8
|
|
7
|
-
|
8
|
-
gem 'appraisal', '2.2.0'
|
9
|
-
end
|
9
|
+
gemspec
|
10
10
|
|
11
11
|
group :test do
|
12
12
|
gem 'rack-test'
|
13
|
-
gem 'rspec'
|
13
|
+
gem 'rspec'
|
14
14
|
end
|
15
15
|
|
16
16
|
group :development, :test do
|
17
|
-
gem '
|
18
|
-
gem '
|
19
|
-
gem '
|
17
|
+
gem 'base64'
|
18
|
+
gem 'bigdecimal'
|
19
|
+
gem 'mutex_m'
|
20
|
+
gem 'nokogiri'
|
21
|
+
gem 'ostruct'
|
22
|
+
gem 'rack', '~> 2.2.17'
|
23
|
+
gem 'rake'
|
24
|
+
gem 'rubocop', '1.80.2'
|
25
|
+
gem 'rubocop-rake'
|
26
|
+
gem 'rubocop-rspec'
|
27
|
+
gem 'sorted_set'
|
20
28
|
end
|
data/Gemfile.danger
ADDED
data/README.md
CHANGED
@@ -1,20 +1,43 @@
|
|
1
1
|
Grape::Roar
|
2
|
-
|
2
|
+
-----------
|
3
3
|
|
4
4
|
[](http://badge.fury.io/rb/grape-roar)
|
5
|
-
[](https://github.com/ruby-grape/grape-roar/actions/workflows/test.yml)
|
6
|
+
[](https://github.com/ruby-grape/grape-roar/actions/workflows/test-activerecord.yml)
|
7
|
+
[](https://github.com/ruby-grape/grape-roar/actions/workflows/test-mongodb.yml)
|
8
8
|
|
9
9
|
Use [Roar](https://github.com/apotonick/roar) with [Grape](https://github.com/intridea/grape).
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
## Table of Contents
|
12
|
+
|
13
|
+
- [Demo](#demo)
|
14
|
+
- [Installation](#installation)
|
15
|
+
- [Usage](#usage)
|
16
|
+
- [Tell your API to use Grape::Formatter::Roar](#tell-your-api-to-use-grapeformatterroar)
|
17
|
+
- [Use Grape’s Present](#use-grapes-present)
|
18
|
+
- [Accessing the Request Inside a Representer](#accessing-the-request-inside-a-representer)
|
19
|
+
- [Decorators](#decorators)
|
20
|
+
- [Relation Extensions](#relation-extensions)
|
21
|
+
- [Designing Representers](#designing-representers)
|
22
|
+
- [Example Models](#example-models)
|
23
|
+
- [Example Representers](#example-representers)
|
24
|
+
- [Example Item](#example-item)
|
25
|
+
- [Example Cart](#example-cart)
|
26
|
+
- [Errors](#errors)
|
27
|
+
- [Change how URLs are presented](#change-how-urls-are-presented)
|
28
|
+
- [Override base URI mappings](#override-base-uri-mappings)
|
29
|
+
- [Override resource URI mappings](#override-resource-uri-mappings)
|
30
|
+
- [Designing Adapters](#designing-adapters)
|
31
|
+
- [Example: ActiveRecord Adapter](#example-activerecord-adapter)
|
32
|
+
- [Validations](#validations)
|
33
|
+
- [Contributing](#contributing)
|
34
|
+
- [Copyright and License](#copyright-and-license)
|
35
|
+
|
36
|
+
## Demo
|
37
|
+
|
38
|
+
See [grape-with-roar](https://github.com/ruby-grape/grape-with-roar).
|
39
|
+
|
40
|
+
## Installation
|
18
41
|
|
19
42
|
Add the `grape`, `roar` and `grape-roar` gems to Gemfile.
|
20
43
|
|
@@ -26,8 +49,7 @@ gem 'grape-roar'
|
|
26
49
|
|
27
50
|
If you're upgrading from an older version of this gem, please see [UPGRADING](UPGRADING.md).
|
28
51
|
|
29
|
-
Usage
|
30
|
-
-----
|
52
|
+
## Usage
|
31
53
|
|
32
54
|
### Tell your API to use Grape::Formatter::Roar
|
33
55
|
|
@@ -224,11 +246,11 @@ Although this example uses `Grape::Roar::Decorator`, you can also use a module a
|
|
224
246
|
|
225
247
|
#### Errors
|
226
248
|
|
227
|
-
Should you incorrectly describe a relationship (e.g. you specify has_one but your model specifies has_many), an exception will be raised to notify you of the mismatch:
|
249
|
+
Should you incorrectly describe a relationship (e.g. you specify `has_one` but your model specifies `has_many`), an exception will be raised to notify you of the mismatch:
|
228
250
|
|
229
251
|
```ruby
|
230
252
|
Grape::Roar::Extensions::Relations::Exceptions::InvalidRelationError:
|
231
|
-
Expected Mongoid::
|
253
|
+
Expected Mongoid::Association::Referenced::HasOne, got Mongoid::Association::Referenced::HasMany!
|
232
254
|
```
|
233
255
|
|
234
256
|
#### Change how URLs are presented
|
@@ -286,7 +308,7 @@ module Extensions
|
|
286
308
|
include Validations::ActiveRecord
|
287
309
|
|
288
310
|
# We map your domain object to the correct adapter
|
289
|
-
#
|
311
|
+
# at runtime.
|
290
312
|
valid_for { |klass| klass < ::ActiveRecord::Base }
|
291
313
|
|
292
314
|
def collection_methods
|
@@ -338,15 +360,12 @@ end
|
|
338
360
|
|
339
361
|
After writing your validation methods, just mix them into your adapter. You can choose to not write validation methods; they are only invoked if your adapter responds to them.
|
340
362
|
|
341
|
-
|
342
|
-
Contributing
|
343
|
-
------------
|
363
|
+
## Contributing
|
344
364
|
|
345
365
|
See [CONTRIBUTING](CONTRIBUTING.md).
|
346
366
|
|
347
|
-
Copyright and License
|
348
|
-
---------------------
|
367
|
+
## Copyright and License
|
349
368
|
|
350
369
|
MIT License, see [LICENSE](LICENSE) for details.
|
351
370
|
|
352
|
-
(c) 2012-
|
371
|
+
(c) 2012-2025 [Daniel Doubrovkine](https://github.com/dblock) & Contributors, [Artsy](https://artsy.net)
|
data/grape-roar.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('lib/grape/roar/version', __dir__)
|
5
4
|
|
6
5
|
Gem::Specification.new do |gem|
|
7
6
|
gem.authors = ['Daniel Doubrovkine']
|
@@ -13,7 +12,6 @@ Gem::Specification.new do |gem|
|
|
13
12
|
|
14
13
|
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
15
14
|
gem.files = `git ls-files`.split("\n")
|
16
|
-
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
17
15
|
gem.name = 'grape-roar'
|
18
16
|
gem.require_paths = ['lib']
|
19
17
|
gem.version = Grape::Roar::VERSION
|
@@ -22,4 +20,5 @@ Gem::Specification.new do |gem|
|
|
22
20
|
gem.add_dependency 'multi_json'
|
23
21
|
gem.add_dependency 'roar', '~> 1.1.0'
|
24
22
|
gem.required_ruby_version = '>= 2.1.0'
|
23
|
+
gem.metadata['rubygems_mfa_required'] = 'true'
|
25
24
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'grape/roar/extensions/relations/adapters/base'
|
4
|
-
require 'grape/roar/extensions/relations/adapters/active_record'
|
5
|
-
require 'grape/roar/extensions/relations/adapters/mongoid'
|
4
|
+
require 'grape/roar/extensions/relations/adapters/active_record' if defined?(ActiveRecord)
|
5
|
+
require 'grape/roar/extensions/relations/adapters/mongoid' if defined?(Mongoid)
|
6
6
|
|
7
7
|
module Grape
|
8
8
|
module Roar
|