Skip to content

Commit 0a8cbb9

Browse files
authored
Prepare release 0.8.1 (#337)
1 parent 5d6b712 commit 0a8cbb9

File tree

8 files changed

+99
-10
lines changed

8 files changed

+99
-10
lines changed

.rubocop.yml

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ AllCops:
66
- example/**/*
77
TargetRubyVersion: 2.7
88

9+
# Layout stuff
10+
#
911
Layout/EmptyLinesAroundArguments:
1012
Enabled: false
1113

14+
Layout/EmptyLinesAroundAttributeAccessor:
15+
Enabled: true
16+
1217
Layout/FirstHashElementIndentation:
1318
EnforcedStyle: consistent
1419

@@ -17,6 +22,28 @@ Layout/LineLength:
1722
Exclude:
1823
- spec/**/*
1924

25+
Layout/SpaceAroundMethodCallOperator:
26+
Enabled: true
27+
28+
# Lint stuff
29+
#
30+
Lint/DeprecatedOpenSSLConstant:
31+
Enabled: true
32+
33+
Lint/DuplicateElsifCondition:
34+
Enabled: true
35+
36+
Lint/MixedRegexpCaptureTypes:
37+
Enabled: true
38+
39+
Lint/RaiseException:
40+
Enabled: true
41+
42+
Lint/StructNewOverride:
43+
Enabled: true
44+
45+
# Metrics stuff
46+
#
2047
Metrics/AbcSize:
2148
Max: 25
2249

@@ -25,7 +52,7 @@ Metrics/BlockLength:
2552
- spec/**/*
2653

2754
Metrics/CyclomaticComplexity:
28-
Max: 10
55+
Max: 13
2956

3057
Metrics/ClassLength:
3158
Max: 300
@@ -38,11 +65,64 @@ Metrics/MethodLength:
3865
Metrics/PerceivedComplexity:
3966
Max: 11
4067

68+
# Naming stuff
69+
#
70+
4171
Naming:
4272
Enabled: false
4373

74+
# Style stuff
75+
#
76+
Style/AccessorGrouping:
77+
Enabled: true
78+
79+
Style/ArrayCoercion:
80+
Enabled: true
81+
82+
Style/BisectedAttrAccessor:
83+
Enabled: true
84+
85+
Style/CaseLikeIf:
86+
Enabled: true
87+
4488
Style/Documentation:
4589
Enabled: false
4690

91+
Style/ExponentialNotation:
92+
Enabled: true
93+
94+
Style/HashAsLastArrayItem:
95+
Enabled: true
96+
97+
Style/HashEachMethods:
98+
Enabled: true
99+
100+
Style/HashLikeCase:
101+
Enabled: true
102+
103+
Style/HashTransformKeys:
104+
Enabled: true
105+
106+
Style/HashTransformValues:
107+
Enabled: true
108+
109+
Style/RedundantAssignment:
110+
Enabled: true
111+
112+
Style/RedundantFetchBlock:
113+
Enabled: true
114+
115+
Style/RedundantFileExtensionInRequire:
116+
Enabled: true
117+
118+
Style/RedundantRegexpCharacterClass:
119+
Enabled: true
120+
121+
Style/RedundantRegexpEscape:
122+
Enabled: true
123+
47124
Style/RegexpLiteral:
48125
Enabled: false
126+
127+
Style/SlicingWithRange:
128+
Enabled: true

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
#### Fixes
88

99
* Your contribution here.
10-
* [#333](https://github.com/ruby-grape/grape-entity/pull/333): Fix typo in CHANGELOG.md - [@eitoball](https://github.com/eitoball).
10+
11+
### 0.8.1 (2020-07-15)
12+
13+
#### Fixes
14+
1115
* [#336](https://github.com/ruby-grape/grape-entity/pull/336): Pass options to delegators when they accept it - [@dnesteryuk](https://github.com/dnesteryuk).
16+
* [#333](https://github.com/ruby-grape/grape-entity/pull/333): Fix typo in CHANGELOG.md - [@eitoball](https://github.com/eitoball).
1217

1318
### 0.8.0 (2020-02-18)
1419

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ source 'http://rubygems.org'
55
gemspec
66

77
group :development, :test do
8-
gem 'rubocop', '~> 0.79.0', require: false
8+
gem 'rubocop', '~> 0.88.0', require: false
99
end
1010

1111
group :test do

bench/serializing.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
module Models
88
class School
99
attr_reader :classrooms
10+
1011
def initialize
1112
@classrooms = []
1213
end
@@ -15,6 +16,7 @@ def initialize
1516
class ClassRoom
1617
attr_reader :students
1718
attr_accessor :teacher
19+
1820
def initialize(opts = {})
1921
@teacher = opts[:teacher]
2022
@students = []
@@ -23,13 +25,15 @@ def initialize(opts = {})
2325

2426
class Person
2527
attr_accessor :name
28+
2629
def initialize(opts = {})
2730
@name = opts[:name]
2831
end
2932
end
3033

3134
class Teacher < Models::Person
3235
attr_accessor :tenure
36+
3337
def initialize(opts = {})
3438
super(opts)
3539
@tenure = opts[:tenure]
@@ -38,6 +42,7 @@ def initialize(opts = {})
3842

3943
class Student < Models::Person
4044
attr_reader :grade
45+
4146
def initialize(opts = {})
4247
super(opts)
4348
@grade = opts[:grade]

lib/grape_entity/entity.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,14 @@ def root_exposure
105105
@root_exposure ||= Exposure.new(nil, nesting: true)
106106
end
107107

108-
attr_writer :root_exposure
108+
attr_writer :root_exposure, :formatters
109109

110110
# Returns all formatters that are registered for this and it's ancestors
111111
# @return [Hash] of formatters
112112
def formatters
113113
@formatters ||= {}
114114
end
115115

116-
attr_writer :formatters
117-
118116
def hash_access
119117
@hash_access ||= :to_sym
120118
end

lib/grape_entity/options.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,12 @@ def build_for_nesting(key)
106106
end
107107

108108
def build_symbolized_hash(attribute, hash)
109-
if attribute.is_a?(Hash)
109+
case attribute
110+
when Hash
110111
attribute.each do |attr, nested_attrs|
111112
hash[attr.to_sym] = build_symbolized_hash(nested_attrs, {})
112113
end
113-
elsif attribute.is_a?(Array)
114+
when Array
114115
return attribute.each { |x| build_symbolized_hash(x, {}) }
115116
else
116117
hash[attribute.to_sym] = true

lib/grape_entity/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module GrapeEntity
4-
VERSION = '0.8.0'
4+
VERSION = '0.8.1'
55
end

spec/grape_entity/entity_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ class Parent < Person
977977
subject.expose(:user, using: user_entity)
978978

979979
representation = subject.represent(OpenStruct.new(user: {}),
980-
only: [:id, :name, :phone, user: %i[id name email]],
980+
only: [:id, :name, :phone, { user: %i[id name email] }],
981981
except: [:phone, { user: [:id] }], serializable: true)
982982
expect(representation).to eq(id: nil, name: nil, user: { name: nil, email: nil })
983983
end

0 commit comments

Comments
 (0)