surrealist 1.3.2 → 1.3.3

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: 53786d7f717738e1ff5debaa04697803ff3f11fb373baf57b73efc84db6cd0fe
4
- data.tar.gz: b9941f1a8ddcf583eb054a3fa88540769436a03b53c3e584a9cb642978f38241
3
+ metadata.gz: 03b3b9607bd4d83e7848c7ff0a3e247147f8af67f15a4b017b19d3c0c9742147
4
+ data.tar.gz: dac6c3c5040e5df0c452808a96d9edb96f8ec47f366d70f5308ea85aeecb06f9
5
5
  SHA512:
6
- metadata.gz: 9de2e0941be4041ebd79d479d269c869d451a503e312aee16c6618b1059c63b8c5f7478ddffe931322cbb27651c90c883c0d032be8928d6308b2afd20c342024
7
- data.tar.gz: f6be30d1b9c050a722b6a7e435fd092494816caf108cc3f7cf5af8b43501f807e7c95a91815cb469c11a1ba254017a7e87af64120585f69068ce734d8f21cd8a
6
+ metadata.gz: fbae1762a9545c3aab9831cb9acfbef3a8ae754d0fdc73dc4c64c3bdeb4f92edf9f4fc861ec6156c330a54a0dd7fe6b2747fca9c97bf6f07a89a3c0f7bd1c795
7
+ data.tar.gz: 63ce4bceaa20ba5a4d770cacfd0f4fc574206ee58c22524ea63147ea11a4ced49bc19197895fc0ccfdee24706b410951c789243e3201e037de4fecbe212d46f7
data/.hound.yml CHANGED
@@ -1,3 +1,3 @@
1
- fail_on_violations: true
1
+ fail_on_violations: false
2
2
  ruby:
3
3
  config_file: .rubocop.yml
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.2
2
+ TargetRubyVersion: 2.3
3
3
  Exclude:
4
4
  - './gemfiles/*gemfile'
5
5
  - './tmp/*'
@@ -169,6 +169,3 @@ Style/MethodMissingSuper:
169
169
  Style/EvalWithLocation:
170
170
  Exclude:
171
171
  - spec/**/*.rb
172
-
173
- Style/AccessModifierDeclarations:
174
- Enabled: false
@@ -7,12 +7,12 @@ matrix:
7
7
  include:
8
8
  - rvm: ruby-head
9
9
  gemfile: Gemfile
10
+ - rvm: 2.6
11
+ gemfile: Gemfile
10
12
  - rvm: 2.5
11
13
  gemfile: Gemfile
12
14
  - rvm: 2.4
13
15
  gemfile: Gemfile
14
16
  - rvm: 2.3
15
- gemfile: Gemfile
16
- - rvm: 2.2
17
17
  gemfile: gemfiles/activerecord42.gemfile
18
18
 
@@ -1,3 +1,8 @@
1
+ # 1.3.3
2
+
3
+ ## Fixed
4
+ * Struct serialization ([@wildkain][]) [#135](https://github.com/nesaulov/surrealist/pull/135)
5
+
1
6
  # 1.3.2
2
7
 
3
8
  ## Fixed
@@ -127,3 +132,4 @@
127
132
  [@stefkin]: https://github.com/stefkin
128
133
  [@gjhenrique]: https://github.com/gjhenrique
129
134
  [@kolasss]: https://github.com/kolasss
135
+ [@wildkain]: https://github.com/wildkain
data/Gemfile CHANGED
@@ -15,6 +15,6 @@ group :development, :test do
15
15
  gem 'rom-repository'
16
16
  gem 'rom-sql'
17
17
  gem 'sequel'
18
- gem 'sqlite3'
18
+ gem 'sqlite3', '~> 1.3.6'
19
19
  gem 'yard', require: false unless ENV['TRAVIS']
20
20
  end
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Inline docs](http://inch-ci.org/github/nesaulov/surrealist.svg?branch=master)](http://inch-ci.org/github/nesaulov/surrealist)
5
5
  [![Gem Version](https://badge.fury.io/rb/surrealist.svg)](https://rubygems.org/gems/surrealist)
6
6
  [![Open Source Helpers](https://www.codetriage.com/nesaulov/surrealist/badges/users.svg)](https://www.codetriage.com/nesaulov/surrealist)
7
+ [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
7
8
 
8
9
  ![Surrealist](surrealist-icon.png)
9
10
 
@@ -780,7 +781,7 @@ Car.new.surrealize
780
781
  ### Other notes
781
782
  * nil values are allowed by default, so if you have, say, `age: String`, but the actual value is nil,
782
783
  type check will be passed. If you want to be strict about `nil`s consider using `Dry::Types`.
783
- * Surrealist [officially supports](https://travis-ci.org/nesaulov/surrealist) MRI Ruby 2.2+ but should be working on other platforms as well.
784
+ * Surrealist [officially supports](https://travis-ci.org/nesaulov/surrealist) MRI Ruby 2.3+ but should be working on other platforms as well.
784
785
 
785
786
  ## Roadmap
786
787
  Here is a list of features that are not implemented yet (contributions are welcome):
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
2
4
  require_relative '../lib/surrealist'
3
5
  require 'benchmark/ips'
@@ -7,7 +9,7 @@ require 'active_model_serializers'
7
9
  require 'blueprinter'
8
10
 
9
11
  ActiveRecord::Base.establish_connection(
10
- adapter: 'sqlite3',
12
+ adapter: 'sqlite3',
11
13
  database: ':memory:',
12
14
  )
13
15
 
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require_relative '../lib/surrealist'
4
5
  require 'bundler/setup'
@@ -11,7 +11,7 @@ group :development, :test do
11
11
  gem 'rom-repository'
12
12
  gem 'rom-sql'
13
13
  gem 'sequel'
14
- gem 'sqlite3'
14
+ gem 'sqlite3', '~> 1.3.6'
15
15
  gem 'yard', require: false unless ENV['TRAVIS']
16
16
  end
17
17
 
@@ -30,9 +30,9 @@ module Surrealist
30
30
 
31
31
  # A class that raises all Surrealist exceptions
32
32
  module ExceptionRaiser
33
- CLASS_NAME_NOT_PASSED = "Can't wrap schema in root key - class name was not passed".freeze
34
- MUST_BEHAVE_LIKE_ENUMERABLE = "Can't serialize collection - must behave like enumerable".freeze
35
- CLASS_DOESNT_INCLUDE_SURREALIST = 'Class does not include Surrealist'.freeze
33
+ CLASS_NAME_NOT_PASSED = "Can't wrap schema in root key - class name was not passed"
34
+ MUST_BEHAVE_LIKE_ENUMERABLE = "Can't serialize collection - must behave like enumerable"
35
+ CLASS_DOESNT_INCLUDE_SURREALIST = 'Class does not include Surrealist'
36
36
 
37
37
  class << self
38
38
  # Raises Surrealist::InvalidSchemaDelegation if destination of delegation does not
@@ -16,7 +16,9 @@ module Surrealist
16
16
  # 4.2 AR relation object did not include Enumerable (it defined
17
17
  # all necessary method through ActiveRecord::Delegation module),
18
18
  # so we need to explicitly check for this
19
- (object.is_a?(Enumerable) && !object.instance_of?(Hash)) || ar_relation?(object)
19
+ return false if object.is_a?(Struct)
20
+
21
+ object.is_a?(Enumerable) && !object.instance_of?(Hash) || ar_relation?(object)
20
22
  end
21
23
 
22
24
  def self.ar_relation?(object)
@@ -3,7 +3,7 @@
3
3
  module Surrealist
4
4
  # A class that defines a method on the object that stores the schema.
5
5
  module SchemaDefiner
6
- SCHEMA_TYPE_ERROR = 'Schema should be defined as a hash'.freeze
6
+ SCHEMA_TYPE_ERROR = 'Schema should be defined as a hash'
7
7
 
8
8
  class << self
9
9
  # Defines an instance variable on the object that stores the schema.
@@ -3,14 +3,14 @@
3
3
  module Surrealist
4
4
  # A helper class for strings transformations.
5
5
  module StringUtils
6
- DASH = '-'.freeze
7
- UNDERSCORE = '_'.freeze
8
- EMPTY_STRING = ''.freeze
9
- DASH_REGEXP1 = /([A-Z]+)([A-Z][a-z])/o
10
- DASH_REGEXP2 = /([a-z\d])([A-Z])/o
11
- UNDERSCORE_REGEXP = /(?:^|_)([^_\s]+)/o
12
- NAMESPACES_SEPARATOR = '::'.freeze
13
- UNDERSCORE_SUBSTITUTE = '\1_\2'.freeze
6
+ DASH = '-'
7
+ UNDERSCORE = '_'
8
+ EMPTY_STRING = ''
9
+ DASH_REGEXP1 = /([A-Z]+)([A-Z][a-z])/o.freeze
10
+ DASH_REGEXP2 = /([a-z\d])([A-Z])/o.freeze
11
+ UNDERSCORE_REGEXP = /(?:^|_)([^_\s]+)/o.freeze
12
+ NAMESPACES_SEPARATOR = '::'
13
+ UNDERSCORE_SUBSTITUTE = '\1_\2'
14
14
 
15
15
  class << self
16
16
  # Converts a string to snake_case.
@@ -69,7 +69,7 @@ module Surrealist
69
69
  #
70
70
  # @return [Hash] a nested hash.
71
71
  def break_namespaces(klass, camelize, nesting_level)
72
- Surrealist::ExceptionRaiser.raise_invalid_nesting!(nesting_level) unless nesting_level > 0
72
+ Surrealist::ExceptionRaiser.raise_invalid_nesting!(nesting_level) unless nesting_level.positive?
73
73
 
74
74
  klass.split(NAMESPACES_SEPARATOR).last(nesting_level).reverse.inject({}) do |a, n|
75
75
  camelize ? Hash[camelize(uncapitalize(n), false).to_sym => a] : Hash[underscore(n).to_sym => a]
@@ -4,7 +4,7 @@ module Surrealist
4
4
  # Service class for type checking
5
5
  module TypeHelper
6
6
  # Dry-types class matcher
7
- DRY_TYPE_CLASS = /Dry::Types/
7
+ DRY_TYPE_CLASS = /Dry::Types/.freeze
8
8
 
9
9
  class << self
10
10
  # Checks if value returned from a method is an instance of type class specified
@@ -1,16 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Surrealist
2
4
  # Module for finding and setting hash into vars
3
5
  module VarsHelper
4
6
  # Instance variable name that is set by SchemaDefiner
5
- INSTANCE_VARIABLE = '@__surrealist_schema'.freeze
7
+ INSTANCE_VARIABLE = '@__surrealist_schema'
6
8
  # Instance's parent instance variable name that is set by SchemaDefiner
7
- PARENT_VARIABLE = '@__surrealist_schema_parent'.freeze
9
+ PARENT_VARIABLE = '@__surrealist_schema_parent'
8
10
  # Class variable name that is set by SchemaDefiner
9
- CLASS_VARIABLE = '@@__surrealist_schema'.freeze
11
+ CLASS_VARIABLE = '@@__surrealist_schema'
10
12
  # Regexp to resolve ROM structure
11
- ROM_REGEXP = /ROM::Struct/o
13
+ ROM_REGEXP = /ROM::Struct/o.freeze
12
14
  # Instance variable that keeps serializer classes
13
- SERIALIZER_CLASSES = '@__surrealist_serializers'.freeze
15
+ SERIALIZER_CLASSES = '@__surrealist_serializers'
14
16
  # Tag for default behaviour in multiple serializers
15
17
  DEFAULT_TAG = :default
16
18
 
@@ -49,7 +51,7 @@ module Surrealist
49
51
  def find_serializer(klass, tag: nil)
50
52
  tag ||= DEFAULT_TAG
51
53
  hash = klass.instance_variable_get(SERIALIZER_CLASSES)
52
- serializer = hash && hash.fetch(tag.to_sym, nil)
54
+ serializer = hash&.fetch(tag.to_sym, nil)
53
55
  Surrealist::ExceptionRaiser.raise_unknown_tag!(tag) if serializer.nil? && tag != DEFAULT_TAG
54
56
  serializer
55
57
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Surrealist
4
4
  # Defines the version of Surrealist
5
- VERSION = '1.3.2'.freeze
5
+ VERSION = '1.3.3'
6
6
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Surrealist
2
- # A helper class for wrapphing hashes.
4
+ # A helper class for wrapping hashes.
3
5
  module Wrapper
4
6
  class << self
5
7
  # Wraps the schema hash into root/namespaces if there is a need to.
@@ -22,13 +22,13 @@ Gem::Specification.new do |spec|
22
22
  spec.bindir = 'exe'
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ['lib']
25
- spec.required_ruby_version = '>= 2.2.0'
25
+ spec.required_ruby_version = '>= 2.3.0'
26
26
 
27
27
  spec.add_runtime_dependency 'oj', '~> 3.0'
28
28
 
29
- spec.add_development_dependency 'bundler', '~> 1.16'
30
- spec.add_development_dependency 'pry', '~> 0.11'
29
+ spec.add_development_dependency 'bundler'
30
+ spec.add_development_dependency 'pry', '~> 0.12'
31
31
  spec.add_development_dependency 'rake', '~> 12.3'
32
- spec.add_development_dependency 'rspec', '~> 3.7'
33
- spec.add_development_dependency 'rubocop', '~> 0.57'
32
+ spec.add_development_dependency 'rspec', '~> 3.8'
33
+ spec.add_development_dependency 'rubocop', '~> 0.66'
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: surrealist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Esaulov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-01 00:00:00.000000000 Z
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -28,30 +28,30 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.16'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.16'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.11'
47
+ version: '0.12'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.11'
54
+ version: '0.12'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.7'
75
+ version: '3.8'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.7'
82
+ version: '3.8'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.57'
89
+ version: '0.66'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.57'
96
+ version: '0.66'
97
97
  description: A gem that provides DSL for serialization of plain old Ruby objects to
98
98
  JSON in a declarative style by defining a `schema`. It also provides a trivial type
99
99
  checking in the runtime before serialization.
@@ -151,15 +151,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
- version: 2.2.0
154
+ version: 2.3.0
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  requirements: []
161
- rubyforge_project:
162
- rubygems_version: 2.7.6
161
+ rubygems_version: 3.0.3
163
162
  signing_key:
164
163
  specification_version: 4
165
164
  summary: A gem that provides DSL for serialization of plain old Ruby objects to JSON