seri 0.1.0 → 0.1.1
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/.circleci/config.yml +1 -9
- data/.gitignore +1 -0
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/serializer/version.rb +1 -1
- data/lib/serializer.rb +6 -4
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0cd689240bcf4de7c1e6e8e583a1a465c1d61102cb8d5aa26e99c50ddbe84399
         | 
| 4 | 
            +
              data.tar.gz: 69f82fa0bae7cd349713bf98f44454acb0fdd217491cf8cae9d07d0f1c4cceaf
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: '010940cfb05b32b29af2ed9df5539832003cc829de76b9878844474f822d8499a47a16cb4798a74ec4f34a4455d3126c61cc66ac7b958f882489d4432da64287'
         | 
| 7 | 
            +
              data.tar.gz: 7d1311e5bc7712923a4acc852d95e3525ce63a28cb9319c3e792e64c2132bb00870045705b2702f32dbff1747e05d2eccccbf600a605aaf7c9f54b8384e08a2b
         | 
    
        data/.circleci/config.yml
    CHANGED
    
    | @@ -1,18 +1,10 @@ | |
| 1 1 | 
             
            # Ruby CircleCI 2.0 configuration file
         | 
| 2 | 
            -
            #
         | 
| 3 | 
            -
            # Check https://circleci.com/docs/2.0/language-ruby/ for more details
         | 
| 4 | 
            -
            #
         | 
| 5 2 | 
             
            version: 2
         | 
| 6 3 | 
             
            jobs:
         | 
| 7 4 | 
             
              build:
         | 
| 8 5 | 
             
                docker:
         | 
| 9 6 | 
             
                  # specify the version you desire here
         | 
| 10 | 
            -
                   - image: circleci/ruby:2. | 
| 11 | 
            -
             | 
| 12 | 
            -
                  # Specify service dependencies here if necessary
         | 
| 13 | 
            -
                  # CircleCI maintains a library of pre-built images
         | 
| 14 | 
            -
                  # documented at https://circleci.com/docs/2.0/circleci-images/
         | 
| 15 | 
            -
                  # - image: circleci/postgres:9.4
         | 
| 7 | 
            +
                   - image: circleci/ruby:2.5.3-node-browsers
         | 
| 16 8 |  | 
| 17 9 | 
             
                working_directory: ~/repo
         | 
| 18 10 |  | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # Seri
         | 
| 2 2 |  | 
| 3 | 
            -
            [](https://circleci.com/gh/grdw/seri)
         | 
| 4 4 |  | 
| 5 5 | 
             
            A basic replacement for gems like `active_model_serializers`. Can turn any
         | 
| 6 6 | 
             
            basic Ruby object into a Hash or JSON string with features like:
         | 
    
        data/lib/serializer/version.rb
    CHANGED
    
    
    
        data/lib/serializer.rb
    CHANGED
    
    | @@ -36,13 +36,13 @@ class Serializer | |
| 36 36 | 
             
                  value = if attribute.options.has_key?(:static_value)
         | 
| 37 37 | 
             
                            attribute.options.fetch(:static_value)
         | 
| 38 38 | 
             
                          elsif respond_to?(extraction_key)
         | 
| 39 | 
            -
                            public_send(extraction_key)
         | 
| 40 | 
            -
                          elsif object.respond_to?(extraction_key) && attribute.serializer
         | 
| 41 | 
            -
                            value = object.public_send(extraction_key)
         | 
| 39 | 
            +
                            value = public_send(extraction_key)
         | 
| 42 40 |  | 
| 43 41 | 
             
                            serialize_value(value, attribute.serializer)
         | 
| 44 42 | 
             
                          elsif object.respond_to?(extraction_key)
         | 
| 45 | 
            -
                            object.public_send(extraction_key)
         | 
| 43 | 
            +
                            value = object.public_send(extraction_key)
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                            serialize_value(value, attribute.serializer)
         | 
| 46 46 | 
             
                          else
         | 
| 47 47 | 
             
                            raise SerializerError, "unknown attribute '#{extraction_key}'"
         | 
| 48 48 | 
             
                          end
         | 
| @@ -60,6 +60,8 @@ class Serializer | |
| 60 60 | 
             
              private
         | 
| 61 61 |  | 
| 62 62 | 
             
              def serialize_value(value, serializer)
         | 
| 63 | 
            +
                return value unless serializer
         | 
| 64 | 
            +
             | 
| 63 65 | 
             
                if value.is_a?(Array)
         | 
| 64 66 | 
             
                  value.map { |v| serializer.new(v).to_h }
         | 
| 65 67 | 
             
                else
         | 
    
        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: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - grdw
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018- | 
| 11 | 
            +
            date: 2018-12-03 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: oj
         |