grape-entity 0.10.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a89222a95fe66dc86d907762352275aa328a0423a461e2f5a7c8fc806a92f09
4
- data.tar.gz: a06ad75430e568a7e4cd2e9b6b329011e8382003c5882f690199403be58928c7
3
+ metadata.gz: f98548d9171133e0bf95ba1e4ce84b148a124e7e3b6927054bdd748986e833fb
4
+ data.tar.gz: 641d9453158181536d24f5f9c907e8e5eee45bbf76ad746db94bd77815329749
5
5
  SHA512:
6
- metadata.gz: 1bc3419fea51eb0c7c7c78f8f4e510c9d73bfe210cee2aa1f2aaaee92725d02334ab235818a37300c733c0970c9ee40cf56a022b421937ec6662d3e67da3e85f
7
- data.tar.gz: 4f31cb8e01fbba21883bbf432fa557d0ca7f85d3c1d42a0aac0e4143c4add3af37e7f24b4fc315ff55502a640bffa0d185e8c3081d8a8b5492d45dc1b0102233
6
+ metadata.gz: 7df4614a5dddfc479d691b5d6e4c1c7644bb7cfe11ec8ac5256d962d63551530ccaed1eb8c56c70218eba0ec370a37f15e83aae148753cc29036148bdea43514
7
+ data.tar.gz: 985b7ad4f9a2d9f70d5fe5c207fc5ab1cf78529c0cf62bed66b22274038d36e4fb6ffe5c0af7367b5c3c6e13093799130c875e29c9d33ea462f3e9cb721d4ff4
@@ -18,7 +18,7 @@ jobs:
18
18
  - uses: actions/checkout@v3
19
19
  - uses: ruby/setup-ruby@v1
20
20
  with:
21
- ruby-version: '3.1'
21
+ ruby-version: '3.2'
22
22
  bundler-cache: true
23
23
  - name: Run rubocop
24
24
  run: bundle exec rubocop --parallel --format progress
@@ -28,7 +28,7 @@ jobs:
28
28
  needs: ['rubocop']
29
29
  strategy:
30
30
  matrix:
31
- ruby-version: ['2.7', '3.0', '3.1', 'head', jruby, truffleruby]
31
+ ruby-version: ['3.0', '3.1', '3.2', 'head']
32
32
  steps:
33
33
  - name: Check out branch
34
34
  uses: actions/checkout@v3
data/.rubocop.yml CHANGED
@@ -5,7 +5,7 @@ AllCops:
5
5
  - vendor/**/*
6
6
  - example/**/*
7
7
  NewCops: enable
8
- TargetRubyVersion: 3.1
8
+ TargetRubyVersion: 3.2
9
9
  SuggestExtensions: false
10
10
 
11
11
  # Layout stuff
@@ -38,7 +38,7 @@ Lint/ConstantDefinitionInBlock:
38
38
  #
39
39
  Metrics/AbcSize:
40
40
  Max: 25
41
- IgnoredMethods:
41
+ AllowedMethods:
42
42
  # from lib/grape_entity/exposure/nesting_exposure.rb
43
43
  - 'normalized_exposures'
44
44
 
@@ -59,7 +59,7 @@ Metrics/MethodLength:
59
59
 
60
60
  Metrics/PerceivedComplexity:
61
61
  Max: 11
62
- IgnoredMethods:
62
+ AllowedMethods:
63
63
  # from lib/grape_entity/entity.rb
64
64
  - 'expose'
65
65
  - 'merge_options'
data/CHANGELOG.md CHANGED
@@ -9,6 +9,15 @@
9
9
  * Your contribution here.
10
10
 
11
11
 
12
+ ### ### 1.0.0 (2023-02-16)
13
+
14
+ #### Fixes
15
+
16
+ **Breaking change:**
17
+ * [#352](https://github.com/ruby-grape/grape-entity/pull/369): Remove `FetchableObject` behavior. - [@danielvdao](https://github.com/danielvdao).
18
+ * [#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).
19
+
20
+
12
21
  ### 0.10.2 (2022-07-29)
13
22
 
14
23
  #### Fixes
data/Gemfile CHANGED
@@ -5,7 +5,15 @@ source 'http://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :development, :test do
8
- gem 'rubocop', '~> 1.0', require: false
8
+ gem 'bundler'
9
+ gem 'maruku'
10
+ gem 'pry' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
11
+ gem 'pry-byebug' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
12
+ gem 'rack-test'
13
+ gem 'rake'
14
+ gem 'rspec', '~> 3.9'
15
+ gem 'rubocop', '~> 1.0'
16
+ gem 'yard'
9
17
  end
10
18
 
11
19
  group :test do
data/UPGRADING.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Upgrading Grape Entity
2
2
 
3
3
 
4
+ ### Upgrading to >= 0.10.2
5
+ Official support for `FetchableObject` was removed.
6
+
7
+ See [#352](https://github.com/ruby-grape/grape-entity/pull/369) for more information.
8
+
4
9
  ### Upgrading to >= 0.8.2
5
10
 
6
11
  Official support for ruby < 2.5 removed, ruby 2.5 only in testing mode, but no support.
data/grape-entity.gemspec CHANGED
@@ -7,28 +7,19 @@ Gem::Specification.new do |s|
7
7
  s.name = 'grape-entity'
8
8
  s.version = GrapeEntity::VERSION
9
9
  s.platform = Gem::Platform::RUBY
10
- s.authors = ['Michael Bleigh']
11
- s.email = ['michael@intridea.com']
10
+ s.authors = ['LeFnord', 'Michael Bleigh']
11
+ s.email = ['pscholz.le@gmail.com', 'michael@intridea.com']
12
12
  s.homepage = 'https://github.com/ruby-grape/grape-entity'
13
13
  s.summary = 'A simple facade for managing the relationship between your model and API.'
14
14
  s.description = 'Extracted from Grape, A Ruby framework for rapid API development with great conventions.'
15
15
  s.license = 'MIT'
16
16
 
17
- s.required_ruby_version = '>= 2.5'
17
+ s.required_ruby_version = '>= 2.7'
18
18
 
19
19
  s.add_runtime_dependency 'activesupport', '>= 3.0.0'
20
20
  # FIXME: remove dependecy
21
21
  s.add_runtime_dependency 'multi_json', '>= 1.3.2'
22
22
 
23
- s.add_development_dependency 'bundler'
24
- s.add_development_dependency 'maruku'
25
- s.add_development_dependency 'pry' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
26
- s.add_development_dependency 'pry-byebug' unless RUBY_PLATFORM.eql?('java') || RUBY_ENGINE.eql?('rbx')
27
- s.add_development_dependency 'rack-test'
28
- s.add_development_dependency 'rake'
29
- s.add_development_dependency 'rspec', '~> 3.9'
30
- s.add_development_dependency 'yard'
31
-
32
23
  s.files = `git ls-files`.split("\n")
33
24
  s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
34
25
  s.require_paths = ['lib']
@@ -3,7 +3,6 @@
3
3
  require 'grape_entity/delegator/base'
4
4
  require 'grape_entity/delegator/hash_object'
5
5
  require 'grape_entity/delegator/openstruct_object'
6
- require 'grape_entity/delegator/fetchable_object'
7
6
  require 'grape_entity/delegator/plain_object'
8
7
 
9
8
  module Grape
@@ -15,8 +14,6 @@ module Grape
15
14
  HashObject
16
15
  elsif defined?(OpenStruct) && object.is_a?(OpenStruct)
17
16
  OpenStructObject
18
- elsif object.respond_to?(:fetch, true)
19
- FetchableObject
20
17
  else
21
18
  PlainObject
22
19
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'multi_json'
4
- require 'set'
5
4
 
6
5
  module Grape
7
6
  # An Entity is a lightweight structure that allows you to easily
@@ -89,7 +89,7 @@ module Grape
89
89
  return unless valid?(entity)
90
90
 
91
91
  output = value(entity, options)
92
- output.blank? && @default_value.present? ? @default_value : output
92
+ output.blank? && !@default_value.nil? ? @default_value : output
93
93
  end
94
94
 
95
95
  def should_return_key?(options)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GrapeEntity
4
- VERSION = '0.10.2'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -30,7 +30,9 @@ describe Grape::Entity do
30
30
 
31
31
  it 'makes sure that :format_with as a proc cannot be used with a block' do
32
32
  # rubocop:disable Style/BlockDelimiters
33
+ # rubocop:disable Lint/Debugger
33
34
  expect { subject.expose :name, format_with: proc {} do p 'hi' end }.to raise_error ArgumentError
35
+ # rubocop:enable Lint/Debugger
34
36
  # rubocop:enable Style/BlockDelimiters
35
37
  end
36
38
 
@@ -245,9 +247,9 @@ describe Grape::Entity do
245
247
  context 'when default option is set' do
246
248
  it 'exposes default values for attributes' do
247
249
  subject.expose(:a, default: 'a')
248
- subject.expose(:b, default: 'b')
250
+ subject.expose(:b, default: false)
249
251
  subject.expose(:c, default: 'c')
250
- expect(subject.represent(model).serializable_hash).to eq(a: 'a', b: 'b', c: 'value')
252
+ expect(subject.represent(model).serializable_hash).to eq(a: 'a', b: false, c: 'value')
251
253
  end
252
254
  end
253
255
 
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-entity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
+ - LeFnord
7
8
  - Michael Bleigh
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2022-07-29 00:00:00.000000000 Z
12
+ date: 2023-02-16 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
@@ -38,121 +39,10 @@ dependencies:
38
39
  - - ">="
39
40
  - !ruby/object:Gem::Version
40
41
  version: 1.3.2
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: maruku
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: pry-byebug
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rack-test
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rake
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rspec
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '3.9'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '3.9'
139
- - !ruby/object:Gem::Dependency
140
- name: yard
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
42
  description: Extracted from Grape, A Ruby framework for rapid API development with
154
43
  great conventions.
155
44
  email:
45
+ - pscholz.le@gmail.com
156
46
  - michael@intridea.com
157
47
  executables: []
158
48
  extensions: []
@@ -187,7 +77,6 @@ files:
187
77
  - lib/grape_entity/condition/symbol_condition.rb
188
78
  - lib/grape_entity/delegator.rb
189
79
  - lib/grape_entity/delegator/base.rb
190
- - lib/grape_entity/delegator/fetchable_object.rb
191
80
  - lib/grape_entity/delegator/hash_object.rb
192
81
  - lib/grape_entity/delegator/openstruct_object.rb
193
82
  - lib/grape_entity/delegator/plain_object.rb
@@ -224,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
113
  requirements:
225
114
  - - ">="
226
115
  - !ruby/object:Gem::Version
227
- version: '2.5'
116
+ version: '2.7'
228
117
  required_rubygems_version: !ruby/object:Gem::Requirement
229
118
  requirements:
230
119
  - - ">="
231
120
  - !ruby/object:Gem::Version
232
121
  version: '0'
233
122
  requirements: []
234
- rubygems_version: 3.3.7
123
+ rubygems_version: 3.4.6
235
124
  signing_key:
236
125
  specification_version: 4
237
126
  summary: A simple facade for managing the relationship between your model and API.
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- class Entity
5
- module Delegator
6
- class FetchableObject < Base
7
- def delegate(attribute)
8
- object.fetch attribute
9
- end
10
- end
11
- end
12
- end
13
- end