swagger-serializer 0.2.1 → 0.3.0

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: 5983d82c92611fe2b7cd99c467bea2042448f51833eadde7d89703f065dae8c1
4
- data.tar.gz: c7fba8038d1b4f452c572710960251342913dc770fc88712c0d8481abf5199de
3
+ metadata.gz: f4d846f481e8975a65912ee007fe889f92e86a791151ea43b1e195ab517c97d7
4
+ data.tar.gz: c7201cf60934814f35da516dd933885b54b30802b20cdb9230db28c30b28bf6b
5
5
  SHA512:
6
- metadata.gz: 4f25c9918ecbf3c1c977ed82e374507b38a083461da45c12521a679ac4d31b743d759d2411f72ff637d4f128159d85de49e25b9d76a944192c976881315c69f8
7
- data.tar.gz: e59f51f2cd2cccd92ef80d58146e2fe4451b7ece7abf63a65cba25b5b564858ea314ee14ac1cbf7ddadadb9b8b9d062ee7521946bdd9175b33b5842bebcfe888
6
+ metadata.gz: 4a94e1e3cf012f87d47e8b183057ab5a6047026ae03e98ccbad9d134a4cdca37ccbdb647354622880f0b1eff6bea87b16c411093e665c6a31c28a9cd2e25cc88
7
+ data.tar.gz: 9d02c59d26c0892e2f74dc481c1de55b78137b433504993a78ebbfb9368c28416df1295b62c68fd013b703f6d37a56116deabdc23daad46358a30163c22cff08
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Set up Ruby 2.x
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.x
16
+ - name: Build and test with Rake
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rake
data/CHANGELOG.md CHANGED
@@ -0,0 +1,9 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.2.0
4
+
5
+ - implove: injectors
6
+
7
+ ## 0.1.0
8
+
9
+ - released
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Swagger::Serializer
2
2
 
3
+ [![Actions Status](https://github.com/Narazaka/swagger-serializer/workflows/Ruby/badge.svg)](https://github.com/Narazaka/swagger-serializer/actions)
4
+ [![Gem Version](https://badge.fury.io/rb/swagger-serializer.svg)](https://badge.fury.io/rb/swagger-serializer)
5
+
3
6
  Swagger (OpenAPI 3) schema based serializer.
4
7
 
5
8
  ## Installation
@@ -128,7 +131,7 @@ Now you can get `{ "id" => 42, "name" => "me!!!!" }`.
128
131
 
129
132
  This serializer class detection uses the schema's `title` key.
130
133
  If you want to use `Foo::BarSerializer`, set `Foo::Bar` to `title` key.
131
- The key is configurable by `Swagger::Serializer::Store.current.inject_key = "my_inject_key"`.
134
+ The key is configurable by `Swagger::Serializer::Store.current[:inject_key] = "my_inject_key"`.
132
135
 
133
136
  Sometimes model needs direct serialize.
134
137
 
@@ -7,19 +7,36 @@ module Swagger
7
7
  end
8
8
  end
9
9
 
10
- attr_accessor :inject_key
10
+ def initialize(options = nil)
11
+ @options = options || {}
12
+ @options[:inject_key] ||= "title"
13
+ @options[:injectors] ||= Injectors.new(cache: @options[:cache])
14
+ end
15
+
16
+ def [](name)
17
+ @options[name]
18
+ end
11
19
 
12
- def initialize(inject_key = "title")
13
- @inject_key = inject_key
20
+ def []=(name, value)
21
+ @options[name] = value
14
22
  end
15
23
 
16
24
  def serializer_options
17
- { inject_key: inject_key, injectors: Injectors.new }
25
+ @options
18
26
  end
19
27
 
20
28
  class Injectors
29
+ def initialize(injectors: {}, cache: false)
30
+ @injectors = injectors
31
+ @cache = cache
32
+ end
33
+
21
34
  def [](name)
22
- "#{name}Serializer".safe_constantize
35
+ if @cache
36
+ @injectors[name] ||= "#{name}Serializer".safe_constantize
37
+ else
38
+ "#{name}Serializer".safe_constantize
39
+ end
23
40
  end
24
41
  end
25
42
  end
@@ -1,5 +1,5 @@
1
1
  module Swagger
2
2
  module Serializer
3
- VERSION = "0.2.1".freeze
3
+ VERSION = "0.3.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger-serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Narazaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-29 00:00:00.000000000 Z
11
+ date: 2019-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema-serializer
@@ -185,12 +185,12 @@ executables: []
185
185
  extensions: []
186
186
  extra_rdoc_files: []
187
187
  files:
188
+ - ".github/workflows/ruby.yml"
188
189
  - ".gitignore"
189
190
  - ".prettierrc"
190
191
  - ".rspec"
191
192
  - ".rubocop.yml"
192
193
  - ".rubocop_airbnb.yml"
193
- - ".travis.yml"
194
194
  - CHANGELOG.md
195
195
  - Gemfile
196
196
  - LICENSE
@@ -234,7 +234,7 @@ metadata:
234
234
  homepage_uri: https://github.com/Narazaka/swagger-serializer
235
235
  source_code_uri: https://github.com/Narazaka/swagger-serializer.git
236
236
  changelog_uri: https://github.com/Narazaka/swagger-serializer/blob/master/CHANGELOG.md
237
- documentation_uri: https://www.rubydoc.info/gems/swagger-serializer/0.2.1
237
+ documentation_uri: https://www.rubydoc.info/gems/swagger-serializer/0.3.0
238
238
  post_install_message:
239
239
  rdoc_options: []
240
240
  require_paths:
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.5
7
- before_install: gem install bundler -v 1.17.2