swagger-serializer 0.2.1 → 0.3.0
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 +4 -4
- data/.github/workflows/ruby.yml +20 -0
- data/CHANGELOG.md +9 -0
- data/README.md +4 -1
- data/lib/swagger/serializer/store.rb +22 -5
- data/lib/swagger/serializer/version.rb +1 -1
- metadata +4 -4
- data/.travis.yml +0 -7
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f4d846f481e8975a65912ee007fe889f92e86a791151ea43b1e195ab517c97d7
         | 
| 4 | 
            +
              data.tar.gz: c7201cf60934814f35da516dd933885b54b30802b20cdb9230db28c30b28bf6b
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,5 +1,8 @@ | |
| 1 1 | 
             
            # Swagger::Serializer
         | 
| 2 2 |  | 
| 3 | 
            +
            [](https://github.com/Narazaka/swagger-serializer/actions)
         | 
| 4 | 
            +
            [](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 | 
| 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 | 
            -
                   | 
| 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  | 
| 13 | 
            -
                    @ | 
| 20 | 
            +
                  def []=(name, value)
         | 
| 21 | 
            +
                    @options[name] = value
         | 
| 14 22 | 
             
                  end
         | 
| 15 23 |  | 
| 16 24 | 
             
                  def serializer_options
         | 
| 17 | 
            -
                     | 
| 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 | 
            -
                       | 
| 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
         | 
    
        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. | 
| 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- | 
| 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. | 
| 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:
         |