userializer 0.3.1 → 0.3.2

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: c60edc59f0b2c8635bec13e771422371ec92bf1eb696957321cea2cd56d14161
4
- data.tar.gz: 1d7b6365abd81700080e4d63c0995dcca6ff3a24047e22596ea954dd73c4db50
3
+ metadata.gz: 39db10c77bd519fffda4b6e6c7e613bc1105a951ab39e677dd8d1aaa0aa6f6b0
4
+ data.tar.gz: 5327aa7eb5e03f5abe504e4dde6d4e619df810af3802e896e28a72e9edc5c21f
5
5
  SHA512:
6
- metadata.gz: 7339df9d80d2fcad0b5fe7504b9df90c99d8eb2be1d36886a21c4efbd89b793bb37bd3b464b62aa97af05ae68815e6460e0b7e72fdc99e67d5a8387caf828fd9
7
- data.tar.gz: '01383c0f9f6e9b0290d25ac88042bd21465d4d10818c38d1c9c37d4f4ec49e64172506744551c0f4720d65a543467149450b4aad46a0ca7d8f9a6f736bf756d6'
6
+ metadata.gz: 1fcc67f9270e9c8359dc4488eaf11684fcb952f563a64d41f90cae3d83c1ff31a5c271c2247bc538fa3b5877241d3a7f769a32100c9e04ed9cb327caa15fa92f
7
+ data.tar.gz: 982d8a1495d2c3a6eb83b498b79a6e9d40910f05226b3e4d14a0d5ab1100d04c4145c1d7e14ccd083f5329cf380089300e131848b7d9d2e6692f498793057b91
@@ -0,0 +1,28 @@
1
+ ### What does this PR do?
2
+
3
+ <!-- A brief description of the context of this pull request and its purpose. -->
4
+
5
+ ### What are the observable changes?
6
+ <!-- This question could be adequate with multiple use cases, for example: -->
7
+
8
+ <!-- Frontend: explain the feature created / updated, give instructions telling how to see the change in staging -->
9
+ <!-- Performance: what metric should be impacted, link to the right graphana dashboard for exemple -->
10
+ <!-- Bug: a given issue trail on sentry should stop happening -->
11
+ <!-- Feature: Implements X thrift service / Z HTTP REST API added, provide instructions on how leverage your feature from staging or your workstation -->
12
+
13
+ ### Good PR checklist
14
+
15
+ - [ ] Title makes sense
16
+ - [ ] Is against the correct branch
17
+ - [ ] Only addresses one issue
18
+ - [ ] Properly assigned
19
+ - [ ] Added/updated tests
20
+ - [ ] Added/updated documentation
21
+ - [ ] Properly labeled
22
+
23
+ ### Additional Notes
24
+
25
+ <!--
26
+ You can add anything you want here, an explanation on the way you built your implementation,
27
+ precisions on the origin of the bug, gotchas you need to mention.
28
+ -->
@@ -0,0 +1,25 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ name: Run Tests
12
+ runs-on: ubuntu-20.04
13
+ strategy:
14
+ matrix:
15
+ ruby: [2.7, 3.0.3]
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v2
19
+ - name: Install Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+ - name: Run the Test Suite
25
+ run: bundle exec rspec --color --require spec_helper --format progress spec
@@ -45,6 +45,7 @@ module USerializer
45
45
  @opts = opts
46
46
  @meta = opts[:meta]
47
47
  @except = Set.new([opts[:except]].flatten.compact)
48
+ @only = Set.new([opts[:only]].flatten.compact)
48
49
 
49
50
  @root_key = (opts[:root] || ActiveSupport::Inflector.underscore(
50
51
  obj.class.name
@@ -99,15 +100,20 @@ module USerializer
99
100
  private
100
101
 
101
102
  def attributes
102
- @attributes ||= (self.class.attrs || {}).values.reject do |attr|
103
- @except.include?(attr.key)
103
+ @attributes ||= (self.class.attrs || {}).values.select do |attr|
104
+ allow?(attr.key)
104
105
  end
105
106
  end
106
107
 
107
108
  def relations
108
- @relations ||= (self.class.relations || {}).values.reject do |rel|
109
- @except.include?(rel.key)
109
+ @relations ||= (self.class.relations || {}).values.select do |rel|
110
+ allow?(rel.key)
110
111
  end
111
112
  end
113
+
114
+ def allow?(key)
115
+ return @only.include?(key) if @only.any?
116
+ !@except.include?(key)
117
+ end
112
118
  end
113
119
  end
@@ -1,3 +1,3 @@
1
1
  module USerializer
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: userializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Montagne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,7 +87,8 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".circleci/config.yml"
90
+ - ".github/pull_request_template.md"
91
+ - ".github/workflows/ci.yml"
91
92
  - ".gitignore"
92
93
  - ".rspec"
93
94
  - ".travis.yml"
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  - !ruby/object:Gem::Version
124
125
  version: '0'
125
126
  requirements: []
126
- rubygems_version: 3.1.4
127
+ rubygems_version: 3.1.2
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: Write a short summary, because RubyGems requires one.
data/.circleci/config.yml DELETED
@@ -1,18 +0,0 @@
1
- version: 2
2
- jobs:
3
- run_tests:
4
- docker:
5
- - image: circleci/ruby:2.7
6
-
7
- working_directory: ~/userializer
8
-
9
- steps:
10
- - checkout
11
- - run: bundle install --path=vendor/bundle
12
- - run: bundle exec rspec --color --require spec_helper --format progress spec
13
-
14
- workflows:
15
- version: 2
16
- test:
17
- jobs:
18
- - run_tests