seri 1.1.6 → 1.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67d59131777dda9175b3682b40c894a1b071406a6502ce3226fe633a476453cd
4
- data.tar.gz: d81180b1cdc96c89ea25e0d0cf20d30376637c2cbe9f78efbdae78990ff5f9a6
3
+ metadata.gz: 93d4a3c7d7f2166ee7b8f3a32a398b4047f46d19a73ce59cca497cc74843cfe4
4
+ data.tar.gz: 4e1e7a46dc70f2f1a0d9ffb93b11b625da277beee9593348736f91fd912a31f6
5
5
  SHA512:
6
- metadata.gz: d0dcf63ae0842ded29ea3f3a3b7f5cdcab6c5542364a42c019751b9733d2dc54e892cd98e9f98b0000652be779861ed57372a22e3fcb6c61512611e8ad3627df
7
- data.tar.gz: 26d7f29f43396a970eb14fd838b5e75cef4fdc04fe98acc0f1f946b6c81a04d2f79d29762f820326dd21f97626e8ce282677eabb0d6736e2828ca9088c9c6b73
6
+ metadata.gz: 0ce7148279857a7c35a535e250124dbb2b2a3957b246ab0c737d631ec9129451977f53e9abdb65d403acd72650587648d497dad330c80f710c31033b5cbff563
7
+ data.tar.gz: d433c26c41157799e77a6f8d786b3d7418cfe6147fe70187dd34dc9c44eea617b6ce9918df0c375e77e2fa1203607d968e1c7a3a098cd9b8c1cb365a53ae71ec
@@ -4,7 +4,7 @@ jobs:
4
4
  build:
5
5
  docker:
6
6
  # specify the version you desire here
7
- - image: circleci/ruby:2.5.3-node-browsers
7
+ - image: circleci/ruby:2.7.1
8
8
 
9
9
  working_directory: ~/repo
10
10
 
@@ -21,6 +21,7 @@ jobs:
21
21
  - run:
22
22
  name: install dependencies
23
23
  command: |
24
+ gem install bundler:1.17.3
24
25
  bundle install --jobs=4 --retry=3 --path vendor/bundle
25
26
 
26
27
  - save_cache:
@@ -3,6 +3,36 @@ Metrics/BlockLength:
3
3
  - 'spec/**/*.rb'
4
4
  Style/Documentation:
5
5
  Enabled: false
6
+ Style/FrozenStringLiteralComment:
7
+ Enabled: false
6
8
  # This is causing breaking changes:
7
9
  Style/ExpandPathArguments:
8
10
  Enabled: false
11
+ Layout/EmptyLinesAroundAttributeAccessor:
12
+ Enabled: false
13
+ Layout/SpaceAroundMethodCallOperator:
14
+ Enabled: false
15
+ Lint/DeprecatedOpenSSLConstant:
16
+ Enabled: false
17
+ Lint/MixedRegexpCaptureTypes:
18
+ Enabled: false
19
+ Lint/RaiseException:
20
+ Enabled: false
21
+ Lint/StructNewOverride:
22
+ Enabled: false
23
+ Style/ExponentialNotation:
24
+ Enabled: false
25
+ Style/HashEachMethods:
26
+ Enabled: false
27
+ Style/HashTransformKeys:
28
+ Enabled: false
29
+ Style/HashTransformValues:
30
+ Enabled: false
31
+ Style/RedundantFetchBlock:
32
+ Enabled: false
33
+ Style/RedundantRegexpCharacterClass:
34
+ Enabled: false
35
+ Style/RedundantRegexpEscape:
36
+ Enabled: false
37
+ Style/SlicingWithRange:
38
+ Enabled: false
@@ -1,54 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seri (1.1.5)
4
+ seri (1.1.11)
5
5
  oj (~> 3.7)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.0)
10
+ ast (2.4.1)
11
11
  diff-lcs (1.3)
12
- jaro_winkler (1.5.2)
13
- oj (3.7.12)
14
- parallel (1.17.0)
15
- parser (2.6.2.1)
16
- ast (~> 2.4.0)
17
- psych (3.1.0)
12
+ oj (3.10.6)
13
+ parallel (1.19.2)
14
+ parser (2.7.1.4)
15
+ ast (~> 2.4.1)
18
16
  rainbow (3.0.0)
19
- rake (10.5.0)
20
- rspec (3.8.0)
21
- rspec-core (~> 3.8.0)
22
- rspec-expectations (~> 3.8.0)
23
- rspec-mocks (~> 3.8.0)
24
- rspec-core (3.8.0)
25
- rspec-support (~> 3.8.0)
26
- rspec-expectations (3.8.2)
17
+ rake (13.0.1)
18
+ regexp_parser (1.7.1)
19
+ rexml (3.2.4)
20
+ rspec (3.9.0)
21
+ rspec-core (~> 3.9.0)
22
+ rspec-expectations (~> 3.9.0)
23
+ rspec-mocks (~> 3.9.0)
24
+ rspec-core (3.9.1)
25
+ rspec-support (~> 3.9.1)
26
+ rspec-expectations (3.9.1)
27
27
  diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.8.0)
29
- rspec-mocks (3.8.0)
28
+ rspec-support (~> 3.9.0)
29
+ rspec-mocks (3.9.1)
30
30
  diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.8.0)
32
- rspec-support (3.8.0)
33
- rubocop (0.67.2)
34
- jaro_winkler (~> 1.5.1)
31
+ rspec-support (~> 3.9.0)
32
+ rspec-support (3.9.2)
33
+ rubocop (0.86.0)
35
34
  parallel (~> 1.10)
36
- parser (>= 2.5, != 2.5.1.1)
37
- psych (>= 3.1.0)
35
+ parser (>= 2.7.0.1)
38
36
  rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.7)
38
+ rexml
39
+ rubocop-ast (>= 0.0.3, < 1.0)
39
40
  ruby-progressbar (~> 1.7)
40
- unicode-display_width (>= 1.4.0, < 1.6)
41
- ruby-progressbar (1.10.0)
42
- unicode-display_width (1.5.0)
41
+ unicode-display_width (>= 1.4.0, < 2.0)
42
+ rubocop-ast (0.0.3)
43
+ parser (>= 2.7.0.1)
44
+ ruby-progressbar (1.10.1)
45
+ unicode-display_width (1.7.0)
43
46
 
44
47
  PLATFORMS
45
48
  ruby
46
49
 
47
50
  DEPENDENCIES
48
51
  bundler (~> 1.16)
49
- rake (~> 10.0)
52
+ rake (~> 13.0)
50
53
  rspec (~> 3.0)
51
- rubocop (~> 0.67.2)
54
+ rubocop (~> 0.82)
52
55
  seri!
53
56
 
54
57
  BUNDLED WITH
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 grdw
3
+ Copyright (c) 2019 grdw
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,58 +1,60 @@
1
- class Value
2
- def initialize(attribute, scope = nil)
3
- @attribute = attribute
4
- @scope = scope
5
- end
1
+ class Serializer
2
+ class Value
3
+ def initialize(attribute, scope = nil)
4
+ @attribute = attribute
5
+ @scope = scope
6
+ end
6
7
 
7
- def extraction_key
8
- @attribute.from || @attribute.key
9
- end
8
+ def extraction_key
9
+ @attribute.from || @attribute.key
10
+ end
10
11
 
11
- def precondition?
12
- raise NotImplementedError, 'needs a method called precondition?'
13
- end
12
+ def precondition?
13
+ raise NotImplementedError, 'needs a method called precondition?'
14
+ end
14
15
 
15
- def value
16
- raise NotImplementedError, 'needs a method called value'
16
+ def value
17
+ raise NotImplementedError, 'needs a method called value'
18
+ end
17
19
  end
18
- end
19
20
 
20
- class StaticValue < Value
21
- def precondition?
22
- @attribute.options.key?(:static_value)
23
- end
21
+ class StaticValue < Value
22
+ def precondition?
23
+ @attribute.options.key?(:static_value)
24
+ end
24
25
 
25
- def value
26
- @attribute.options.fetch(:static_value)
26
+ def value
27
+ @attribute.options.fetch(:static_value)
28
+ end
27
29
  end
28
- end
29
30
 
30
- class SerializedValue < Value
31
- def precondition?
32
- @scope.respond_to?(extraction_key)
33
- end
31
+ class SerializedValue < Value
32
+ def precondition?
33
+ @scope.respond_to?(extraction_key)
34
+ end
34
35
 
35
- def value
36
- @scope.public_send(extraction_key)
36
+ def value
37
+ @scope.public_send(extraction_key)
38
+ end
37
39
  end
38
- end
39
40
 
40
- class HashValue < Value
41
- def precondition?
42
- @scope.is_a?(Hash) && @scope.key?(extraction_key)
43
- end
41
+ class HashValue < Value
42
+ def precondition?
43
+ @scope.is_a?(Hash)
44
+ end
44
45
 
45
- def value
46
- @scope.fetch(extraction_key)
46
+ def value
47
+ @scope[extraction_key]
48
+ end
47
49
  end
48
- end
49
50
 
50
- class ObjectValue < Value
51
- def precondition?
52
- @scope.respond_to?(extraction_key)
53
- end
51
+ class ObjectValue < Value
52
+ def precondition?
53
+ @scope.respond_to?(extraction_key)
54
+ end
54
55
 
55
- def value
56
- @scope.public_send(extraction_key)
56
+ def value
57
+ @scope.public_send(extraction_key)
58
+ end
57
59
  end
58
60
  end
@@ -1,59 +1,61 @@
1
- class ValueFetcher
2
- class SerializerError < StandardError; end
3
-
4
- ARRAYS = %w[
5
- Array
6
- ActiveRecord_AssociationRelation
7
- ActiveRecord_Associations_CollectionProxy
8
- ].freeze
9
-
10
- def self.fetch(attribute, object, serializer)
11
- new(attribute, object, serializer).fetch
12
- end
1
+ class Serializer
2
+ class ValueFetcher
3
+ class SerializerError < StandardError; end
4
+
5
+ ARRAYS = %w[
6
+ Array
7
+ ActiveRecord_AssociationRelation
8
+ ActiveRecord_Associations_CollectionProxy
9
+ ].freeze
10
+
11
+ def self.fetch(attribute, object, serializer)
12
+ new(attribute, object, serializer).fetch
13
+ end
13
14
 
14
- private_class_method :new
15
+ private_class_method :new
15
16
 
16
- def initialize(attribute, object, serializer)
17
- @attribute = attribute
18
- @values = [
19
- StaticValue.new(attribute),
20
- SerializedValue.new(attribute, serializer),
21
- HashValue.new(attribute, object),
22
- ObjectValue.new(attribute, object)
23
- ]
24
- end
17
+ def initialize(attribute, object, serializer)
18
+ @attribute = attribute
19
+ @values = [
20
+ StaticValue.new(attribute),
21
+ SerializedValue.new(attribute, serializer),
22
+ HashValue.new(attribute, object),
23
+ ObjectValue.new(attribute, object)
24
+ ]
25
+ end
25
26
 
26
- def fetch
27
- serializer = @attribute.serializer
27
+ def fetch
28
+ serializer = @attribute.serializer
28
29
 
29
- return value unless serializer
30
+ return value unless serializer
30
31
 
31
- if array?
32
- value.map { |item| serializer.new(item).to_h }
33
- else
34
- serializer.new(value).to_h
32
+ if array?
33
+ value.map { |item| serializer.new(item).to_h }
34
+ else
35
+ serializer.new(value).to_h
36
+ end
35
37
  end
36
- end
37
38
 
38
- # Fetches a value from an attribute by checking if there's a ..
39
- # .. static value set, or a ..
40
- # .. method defined in the serializer, or a ..
41
- # .. method/attribute defined in the object or ..
42
- # .. it raises an error
43
- def value
44
- @value ||= begin
45
- extracted_value = @values.detect(&:precondition?)
46
-
47
- if extracted_value.nil?
48
- raise SerializerError,
49
- "unknown attribute '#{@values[0].extraction_key}'"
39
+ # Fetches a value from an attribute by checking if there's a ..
40
+ # .. static value set, or a ..
41
+ # .. method defined in the serializer, or a ..
42
+ # .. method/attribute defined in the object or ..
43
+ # .. it raises an error
44
+ def value
45
+ @value ||= begin
46
+ extracted_value = @values.detect(&:precondition?)
47
+
48
+ if extracted_value.nil?
49
+ raise SerializerError,
50
+ "unknown attribute '#{@values[0].extraction_key}'"
51
+ end
52
+
53
+ extracted_value.value
50
54
  end
51
-
52
- extracted_value.value
53
55
  end
54
- end
55
56
 
56
- def array?
57
- ARRAYS.any? { |match| value.class.to_s.end_with?(match) }
57
+ def array?
58
+ ARRAYS.any? { |match| value.class.to_s.end_with?(match) }
59
+ end
58
60
  end
59
61
  end
@@ -1,3 +1,3 @@
1
1
  class Serializer
2
- VERSION = '1.1.6'.freeze
2
+ VERSION = '1.1.11'.freeze
3
3
  end
@@ -21,14 +21,13 @@ Gem::Specification.new do |spec|
21
21
  f.match(%r{^(test|spec|features)/})
22
22
  end
23
23
  end
24
- spec.bindir = 'exe'
25
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+
26
25
  spec.require_paths = ['lib']
27
26
 
28
27
  spec.add_dependency 'oj', '~> 3.7'
29
28
 
30
29
  spec.add_development_dependency 'bundler', '~> 1.16'
31
- spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rake', '~> 13.0'
32
31
  spec.add_development_dependency 'rspec', '~> 3.0'
33
- spec.add_development_dependency 'rubocop', '~> 0.67.2'
32
+ spec.add_development_dependency 'rubocop', '~> 0.82'
34
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - grdw
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-12 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
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: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.67.2
75
+ version: '0.82'
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: 0.67.2
82
+ version: '0.82'
83
83
  description: A basic serializer
84
84
  email:
85
85
  - gerard@wetransfer.com
@@ -98,8 +98,6 @@ files:
98
98
  - LICENSE.txt
99
99
  - README.md
100
100
  - Rakefile
101
- - bin/console
102
- - bin/setup
103
101
  - lib/serializer.rb
104
102
  - lib/serializer/group_serializer.rb
105
103
  - lib/serializer/value.rb
@@ -110,7 +108,7 @@ homepage: https://github.com/grdw/seri
110
108
  licenses:
111
109
  - MIT
112
110
  metadata: {}
113
- post_install_message:
111
+ post_install_message:
114
112
  rdoc_options: []
115
113
  require_paths:
116
114
  - lib
@@ -125,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
123
  - !ruby/object:Gem::Version
126
124
  version: '0'
127
125
  requirements: []
128
- rubygems_version: 3.0.4
129
- signing_key:
126
+ rubygems_version: 3.1.2
127
+ signing_key:
130
128
  specification_version: 4
131
129
  summary: A basic serializer
132
130
  test_files: []
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'serializer'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require 'pry'
11
- # Pry.start
12
-
13
- require 'irb'
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here