Skip to content

Commit

Permalink
Prepare release 0.8.1 (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeFnord committed Jul 15, 2020
1 parent 5d6b712 commit 0a8cbb9
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 10 deletions.
82 changes: 81 additions & 1 deletion .rubocop.yml
Expand Up @@ -6,9 +6,14 @@ AllCops:
- example/**/*
TargetRubyVersion: 2.7

# Layout stuff
#
Layout/EmptyLinesAroundArguments:
Enabled: false

Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true

Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

Expand All @@ -17,6 +22,28 @@ Layout/LineLength:
Exclude:
- spec/**/*

Layout/SpaceAroundMethodCallOperator:
Enabled: true

# Lint stuff
#
Lint/DeprecatedOpenSSLConstant:
Enabled: true

Lint/DuplicateElsifCondition:
Enabled: true

Lint/MixedRegexpCaptureTypes:
Enabled: true

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

# Metrics stuff
#
Metrics/AbcSize:
Max: 25

Expand All @@ -25,7 +52,7 @@ Metrics/BlockLength:
- spec/**/*

Metrics/CyclomaticComplexity:
Max: 10
Max: 13

Metrics/ClassLength:
Max: 300
Expand All @@ -38,11 +65,64 @@ Metrics/MethodLength:
Metrics/PerceivedComplexity:
Max: 11

# Naming stuff
#

Naming:
Enabled: false

# Style stuff
#
Style/AccessorGrouping:
Enabled: true

Style/ArrayCoercion:
Enabled: true

Style/BisectedAttrAccessor:
Enabled: true

Style/CaseLikeIf:
Enabled: true

Style/Documentation:
Enabled: false

Style/ExponentialNotation:
Enabled: true

Style/HashAsLastArrayItem:
Enabled: true

Style/HashEachMethods:
Enabled: true

Style/HashLikeCase:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

Style/RedundantAssignment:
Enabled: true

Style/RedundantFetchBlock:
Enabled: true

Style/RedundantFileExtensionInRequire:
Enabled: true

Style/RedundantRegexpCharacterClass:
Enabled: true

Style/RedundantRegexpEscape:
Enabled: true

Style/RegexpLiteral:
Enabled: false

Style/SlicingWithRange:
Enabled: true
7 changes: 6 additions & 1 deletion CHANGELOG.md
Expand Up @@ -7,8 +7,13 @@
#### Fixes

* Your contribution here.
* [#333](https://github.com/ruby-grape/grape-entity/pull/333): Fix typo in CHANGELOG.md - [@eitoball](https://github.com/eitoball).

### 0.8.1 (2020-07-15)

#### Fixes

* [#336](https://github.com/ruby-grape/grape-entity/pull/336): Pass options to delegators when they accept it - [@dnesteryuk](https://github.com/dnesteryuk).
* [#333](https://github.com/ruby-grape/grape-entity/pull/333): Fix typo in CHANGELOG.md - [@eitoball](https://github.com/eitoball).

### 0.8.0 (2020-02-18)

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -5,7 +5,7 @@ source 'http://rubygems.org'
gemspec

group :development, :test do
gem 'rubocop', '~> 0.79.0', require: false
gem 'rubocop', '~> 0.88.0', require: false
end

group :test do
Expand Down
5 changes: 5 additions & 0 deletions bench/serializing.rb
Expand Up @@ -7,6 +7,7 @@
module Models
class School
attr_reader :classrooms

def initialize
@classrooms = []
end
Expand All @@ -15,6 +16,7 @@ def initialize
class ClassRoom
attr_reader :students
attr_accessor :teacher

def initialize(opts = {})
@teacher = opts[:teacher]
@students = []
Expand All @@ -23,13 +25,15 @@ def initialize(opts = {})

class Person
attr_accessor :name

def initialize(opts = {})
@name = opts[:name]
end
end

class Teacher < Models::Person
attr_accessor :tenure

def initialize(opts = {})
super(opts)
@tenure = opts[:tenure]
Expand All @@ -38,6 +42,7 @@ def initialize(opts = {})

class Student < Models::Person
attr_reader :grade

def initialize(opts = {})
super(opts)
@grade = opts[:grade]
Expand Down
4 changes: 1 addition & 3 deletions lib/grape_entity/entity.rb
Expand Up @@ -105,16 +105,14 @@ def root_exposure
@root_exposure ||= Exposure.new(nil, nesting: true)
end

attr_writer :root_exposure
attr_writer :root_exposure, :formatters

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

attr_writer :formatters

def hash_access
@hash_access ||= :to_sym
end
Expand Down
5 changes: 3 additions & 2 deletions lib/grape_entity/options.rb
Expand Up @@ -106,11 +106,12 @@ def build_for_nesting(key)
end

def build_symbolized_hash(attribute, hash)
if attribute.is_a?(Hash)
case attribute
when Hash
attribute.each do |attr, nested_attrs|
hash[attr.to_sym] = build_symbolized_hash(nested_attrs, {})
end
elsif attribute.is_a?(Array)
when Array
return attribute.each { |x| build_symbolized_hash(x, {}) }
else
hash[attribute.to_sym] = true
Expand Down
2 changes: 1 addition & 1 deletion lib/grape_entity/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module GrapeEntity
VERSION = '0.8.0'
VERSION = '0.8.1'
end
2 changes: 1 addition & 1 deletion spec/grape_entity/entity_spec.rb
Expand Up @@ -977,7 +977,7 @@ class Parent < Person
subject.expose(:user, using: user_entity)

representation = subject.represent(OpenStruct.new(user: {}),
only: [:id, :name, :phone, user: %i[id name email]],
only: [:id, :name, :phone, { user: %i[id name email] }],
except: [:phone, { user: [:id] }], serializable: true)
expect(representation).to eq(id: nil, name: nil, user: { name: nil, email: nil })
end
Expand Down

0 comments on commit 0a8cbb9

Please sign in to comment.