light_serializer 0.0.9 → 0.0.10

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: 1b6d67d6f9e6d029842817c86b63aedfc03b6e42f6f51d5fed49cced1b0f5de3
4
- data.tar.gz: 95681b5c15a5d8e82f9a896903e4752bcc081bfbc2289857095da0f638085f84
3
+ metadata.gz: d564779b261bd1b0751ceda79615339c652a854b4db3e0b18685ac2295d2c77b
4
+ data.tar.gz: 4f7b93e006562dd879956e48fa39dedd1dffcbc0d0185bd1d1a400756c8a6fa5
5
5
  SHA512:
6
- metadata.gz: 971d749ecb3b1d9ef7561d9ac84907090e7ed9218ee6d07d27a3af7f0fb0e3543c1485d0559268a6225217673b2649eb24eff872c011ff74f6df98b56c1a5808
7
- data.tar.gz: 8dd7ea83ec069c7a7b69e4fde2aadfa204ab431aa65829609e074f7dbc525642cc7cec1bea1b8af3032939d349bd6ec9a20e499b90d54ea570b56718c96dc384
6
+ metadata.gz: 9c4decd8233625ae224514096b42223dda6202c999e22d214a192a51baa4a3e9d1179f0bd60378880de3e322d3cd0b7f673bcf3ffa675526bb8504012d12292f
7
+ data.tar.gz: 4fb443a6fef01199eac70cbe4ffc4949f6bebf53c4ef353859a6f9bada72f9898c25087f72283b197d9adb1932ac46f9bbf862f5c389832a1edbc5e8c6a2b848
data/.gitignore CHANGED
@@ -10,6 +10,9 @@
10
10
  /test/version_tmp/
11
11
  /tmp/
12
12
 
13
+ .rspec_status
14
+ Gemfile.lock
15
+
13
16
  # Used by dotenv library to load environment variables.
14
17
  # .env
15
18
 
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.0
data/.travis.yml CHANGED
@@ -1,7 +1,22 @@
1
+ # single test suite, non-parallel build.
2
+
3
+ env:
4
+ global:
5
+ - CC_TEST_REPORTER_ID=d46701d452b4850669419007fd4cb743c728384765b817d3dff3267771c4aaa1
6
+ - WITH_COVERAGE=true
1
7
  language: ruby
2
8
  rvm:
3
- - 2.4
4
- - 2.5.1
5
- - ruby-head
9
+ - 2.3.8
10
+ - 2.4.9
11
+ - 2.5.7
12
+ - 2.6.5
13
+ - 2.7.0
14
+ before_script:
15
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
16
+ - chmod +x ./cc-test-reporter
17
+ - ./cc-test-reporter before-build
18
+ - ./bin/setup
6
19
  script:
7
- - ./bin/test
20
+ - bundle exec rspec
21
+ after_script:
22
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Light and Fast serializer
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/light_serializer.svg)](https://badge.fury.io/rb/light_serializer)
5
6
  [![Build Status](https://travis-ci.org/krim/light_serializer.svg?branch=master)](https://travis-ci.org/krim/light_serializer)
6
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/b9167078ec6b75117d0d/maintainability)](https://codeclimate.com/github/krim/light_serializer/maintainability)
7
8
  [![Test Coverage](https://api.codeclimate.com/v1/badges/b9167078ec6b75117d0d/test_coverage)](https://codeclimate.com/github/krim/light_serializer/test_coverage)
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'light_serializer'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ require 'pry'
12
+ Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
@@ -4,6 +4,8 @@ module LightSerializer
4
4
  class HashedObject
5
5
  include Helpers::WithCustomRoot
6
6
 
7
+ UnknownAttribute = Class.new(RuntimeError)
8
+
7
9
  attr_reader :raw_object, :serializer
8
10
 
9
11
  def self.get(*args)
@@ -37,7 +39,7 @@ module LightSerializer
37
39
 
38
40
  def values_from_nested_resource(attributes, object, result)
39
41
  attributes.each do |attribute_name, nested_serializer|
40
- value = obtain_value(object, attribute_name)
42
+ value = obtain_value(object, attribute_name, nested_serializer)
41
43
  result[attribute_name] = hashed_nested_resource(value, nested_serializer)
42
44
  end
43
45
  end
@@ -71,13 +73,15 @@ module LightSerializer
71
73
  end
72
74
 
73
75
  # :reek:ManualDispatch
74
- def obtain_value(object, attribute)
76
+ def obtain_value(object, attribute, nested_serializer = nil)
75
77
  if serializer.respond_to?(attribute)
76
78
  serializer.public_send(attribute)
77
79
  elsif object.respond_to?(attribute)
78
80
  object.public_send(attribute)
79
- else
81
+ elsif raw_object != object
80
82
  object
83
+ elsif !nested_serializer
84
+ raise UnknownAttribute, "Unknown attribute: #{attribute}"
81
85
  end
82
86
  end
83
87
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LightSerializer
4
- VERSION = '0.0.9'
4
+ VERSION = '0.0.10'
5
5
  end
@@ -21,11 +21,12 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.required_ruby_version = '>= 2.3'
23
23
  spec.add_dependency 'oj', '~> 3'
24
- spec.add_development_dependency 'bundler', '~> 1.0'
24
+ spec.add_development_dependency 'bundler', '>= 1.0'
25
25
  spec.add_development_dependency 'pry-byebug', '~> 3.0'
26
- spec.add_development_dependency 'rake', '~> 10.0'
27
- spec.add_development_dependency 'reek', '~> 5.1'
26
+ spec.add_development_dependency 'rake', '~> 13.0'
27
+ spec.add_development_dependency 'reek', '~> 5.3'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
- spec.add_development_dependency 'rubocop', '~> 0.59.2'
29
+ spec.add_development_dependency 'rubocop', '~> 0.79.0'
30
30
  spec.add_development_dependency 'rubocop-rspec', '~> 1.30'
31
+ spec.add_development_dependency 'simplecov'
31
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: light_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Rodionov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-01 00:00:00.000000000 Z
12
+ date: 2020-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oj
@@ -29,14 +29,14 @@ dependencies:
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '1.0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.0'
42
42
  - !ruby/object:Gem::Dependency
@@ -59,28 +59,28 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '10.0'
62
+ version: '13.0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '10.0'
69
+ version: '13.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: reek
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '5.1'
76
+ version: '5.3'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '5.1'
83
+ version: '5.3'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rspec
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 0.59.2
104
+ version: 0.79.0
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 0.59.2
111
+ version: 0.79.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: rubocop-rspec
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +123,20 @@ dependencies:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: '1.30'
126
+ - !ruby/object:Gem::Dependency
127
+ name: simplecov
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
126
140
  description:
127
141
  email:
128
142
  - pasha.rod@mail.ru
@@ -134,12 +148,14 @@ files:
134
148
  - ".reek.yml"
135
149
  - ".rspec"
136
150
  - ".rubocop.yml"
151
+ - ".ruby-version"
137
152
  - ".travis.yml"
138
153
  - Gemfile
139
- - Gemfile.lock
140
154
  - LICENSE
141
155
  - README.md
142
156
  - bench.rb
157
+ - bin/console
158
+ - bin/setup
143
159
  - bin/test
144
160
  - lib/light_serializer.rb
145
161
  - lib/light_serializer/hashed_object.rb
@@ -168,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
184
  - !ruby/object:Gem::Version
169
185
  version: '0'
170
186
  requirements: []
171
- rubygems_version: 3.0.1
187
+ rubygems_version: 3.1.2
172
188
  signing_key:
173
189
  specification_version: 4
174
190
  summary: Light and Fast Serializer
data/Gemfile.lock DELETED
@@ -1,93 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- light_serializer (0.0.9)
5
- oj (~> 3)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.0)
11
- axiom-types (0.1.1)
12
- descendants_tracker (~> 0.0.4)
13
- ice_nine (~> 0.11.0)
14
- thread_safe (~> 0.3, >= 0.3.1)
15
- byebug (10.0.2)
16
- codeclimate-engine-rb (0.4.1)
17
- virtus (~> 1.0)
18
- coderay (1.1.2)
19
- coercible (1.0.0)
20
- descendants_tracker (~> 0.0.1)
21
- descendants_tracker (0.0.4)
22
- thread_safe (~> 0.3, >= 0.3.1)
23
- diff-lcs (1.3)
24
- equalizer (0.0.11)
25
- ice_nine (0.11.2)
26
- jaro_winkler (1.5.1)
27
- kwalify (0.7.2)
28
- method_source (0.9.0)
29
- oj (3.7.6)
30
- parallel (1.12.1)
31
- parser (2.5.3.0)
32
- ast (~> 2.4.0)
33
- powerpack (0.1.2)
34
- pry (0.11.3)
35
- coderay (~> 1.1.0)
36
- method_source (~> 0.9.0)
37
- pry-byebug (3.6.0)
38
- byebug (~> 10.0)
39
- pry (~> 0.10)
40
- rainbow (3.0.0)
41
- rake (10.5.0)
42
- reek (5.2.0)
43
- codeclimate-engine-rb (~> 0.4.0)
44
- kwalify (~> 0.7.0)
45
- parser (>= 2.5.0.0, < 2.6, != 2.5.1.1)
46
- rainbow (>= 2.0, < 4.0)
47
- rspec (3.8.0)
48
- rspec-core (~> 3.8.0)
49
- rspec-expectations (~> 3.8.0)
50
- rspec-mocks (~> 3.8.0)
51
- rspec-core (3.8.0)
52
- rspec-support (~> 3.8.0)
53
- rspec-expectations (3.8.1)
54
- diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.8.0)
56
- rspec-mocks (3.8.0)
57
- diff-lcs (>= 1.2.0, < 2.0)
58
- rspec-support (~> 3.8.0)
59
- rspec-support (3.8.0)
60
- rubocop (0.59.2)
61
- jaro_winkler (~> 1.5.1)
62
- parallel (~> 1.10)
63
- parser (>= 2.5, != 2.5.1.1)
64
- powerpack (~> 0.1)
65
- rainbow (>= 2.2.2, < 4.0)
66
- ruby-progressbar (~> 1.7)
67
- unicode-display_width (~> 1.0, >= 1.0.1)
68
- rubocop-rspec (1.30.0)
69
- rubocop (>= 0.58.0)
70
- ruby-progressbar (1.10.0)
71
- thread_safe (0.3.6)
72
- unicode-display_width (1.4.0)
73
- virtus (1.0.5)
74
- axiom-types (~> 0.1)
75
- coercible (~> 1.0)
76
- descendants_tracker (~> 0.0, >= 0.0.3)
77
- equalizer (~> 0.0, >= 0.0.9)
78
-
79
- PLATFORMS
80
- ruby
81
-
82
- DEPENDENCIES
83
- bundler (~> 1.0)
84
- light_serializer!
85
- pry-byebug (~> 3.0)
86
- rake (~> 10.0)
87
- reek (~> 5.1)
88
- rspec (~> 3.0)
89
- rubocop (~> 0.59.2)
90
- rubocop-rspec (~> 1.30)
91
-
92
- BUNDLED WITH
93
- 1.17.3