except_nested 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/.gitignore +31 -7
 - data/Gemfile.lock +57 -0
 - data/README.md +41 -4
 - data/except_nested.gemspec +2 -2
 - data/lib/except_nested/core_ext/hash/except_nested.rb +2 -2
 - data/lib/except_nested/version.rb +1 -1
 - metadata +6 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b17ef1eb5a2532ffb4a7da058b5493f6595fb497
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e8ae309967e1afa31518fb4ba3dd1a2f6d64ebf2
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d31a60ec88b8f5f983d348e02d02d31c0f2e13b3a17f1d62e9d04a5bf8fba27620871dca9162f266302de21c8d4e042e201479a91647cf375ba00d7234d7872f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8ff851e99d8231c20f1a9062b198a04e7946f3e6444c988ecd604b1ad49d34af1737a8bb807be756bfdccfc49255dd4efbf8432a69885ce06331616756e6c380
         
     | 
    
        data/.gitignore
    CHANGED
    
    | 
         @@ -1,12 +1,36 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # Created by https://www.gitignore.io/api/ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            ### Ruby ###
         
     | 
| 
      
 4 
     | 
    
         
            +
            *.gem
         
     | 
| 
      
 5 
     | 
    
         
            +
            *.rbc
         
     | 
| 
      
 6 
     | 
    
         
            +
            /.config
         
     | 
| 
       5 
7 
     | 
    
         
             
            /coverage/
         
     | 
| 
       6 
     | 
    
         
            -
            / 
     | 
| 
      
 8 
     | 
    
         
            +
            /InstalledFiles
         
     | 
| 
       7 
9 
     | 
    
         
             
            /pkg/
         
     | 
| 
       8 
10 
     | 
    
         
             
            /spec/reports/
         
     | 
| 
      
 11 
     | 
    
         
            +
            /spec/examples.txt
         
     | 
| 
      
 12 
     | 
    
         
            +
            /test/tmp/
         
     | 
| 
      
 13 
     | 
    
         
            +
            /test/version_tmp/
         
     | 
| 
       9 
14 
     | 
    
         
             
            /tmp/
         
     | 
| 
       10 
15 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
            #  
     | 
| 
       12 
     | 
    
         
            -
            . 
     | 
| 
      
 16 
     | 
    
         
            +
            # Used by dotenv library to load environment variables.
         
     | 
| 
      
 17 
     | 
    
         
            +
            # .env
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ## Documentation cache and generated files:
         
     | 
| 
      
 20 
     | 
    
         
            +
            /.yardoc/
         
     | 
| 
      
 21 
     | 
    
         
            +
            /_yardoc/
         
     | 
| 
      
 22 
     | 
    
         
            +
            /doc/
         
     | 
| 
      
 23 
     | 
    
         
            +
            /rdoc/
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            ## Environment normalization:
         
     | 
| 
      
 26 
     | 
    
         
            +
            /.bundle/
         
     | 
| 
      
 27 
     | 
    
         
            +
            /vendor/bundle
         
     | 
| 
      
 28 
     | 
    
         
            +
            /lib/bundler/man/
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
         
     | 
| 
      
 31 
     | 
    
         
            +
            .rvmrc
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            # End of https://www.gitignore.io/api/ruby
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            # Ignore publish script due to credentials
         
     | 
| 
      
 36 
     | 
    
         
            +
            .publish
         
     | 
    
        data/Gemfile.lock
    ADDED
    
    | 
         @@ -0,0 +1,57 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            PATH
         
     | 
| 
      
 2 
     | 
    
         
            +
              remote: .
         
     | 
| 
      
 3 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 4 
     | 
    
         
            +
                except_nested (0.1.1)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  activesupport (~> 4.2)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            GEM
         
     | 
| 
      
 8 
     | 
    
         
            +
              remote: https://rubygems.org/
         
     | 
| 
      
 9 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 10 
     | 
    
         
            +
                activesupport (4.2.9)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  i18n (~> 0.7)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  minitest (~> 5.1)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  thread_safe (~> 0.3, >= 0.3.4)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  tzinfo (~> 1.1)
         
     | 
| 
      
 15 
     | 
    
         
            +
                codeclimate-test-reporter (0.4.8)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  simplecov (>= 0.7.1, < 1.0.0)
         
     | 
| 
      
 17 
     | 
    
         
            +
                diff-lcs (1.3)
         
     | 
| 
      
 18 
     | 
    
         
            +
                docile (1.1.5)
         
     | 
| 
      
 19 
     | 
    
         
            +
                i18n (0.8.6)
         
     | 
| 
      
 20 
     | 
    
         
            +
                json (2.1.0)
         
     | 
| 
      
 21 
     | 
    
         
            +
                minitest (5.10.3)
         
     | 
| 
      
 22 
     | 
    
         
            +
                rake (10.5.0)
         
     | 
| 
      
 23 
     | 
    
         
            +
                rspec (3.6.0)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  rspec-core (~> 3.6.0)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  rspec-expectations (~> 3.6.0)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  rspec-mocks (~> 3.6.0)
         
     | 
| 
      
 27 
     | 
    
         
            +
                rspec-core (3.6.0)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  rspec-support (~> 3.6.0)
         
     | 
| 
      
 29 
     | 
    
         
            +
                rspec-expectations (3.6.0)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  rspec-support (~> 3.6.0)
         
     | 
| 
      
 32 
     | 
    
         
            +
                rspec-mocks (3.6.0)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  rspec-support (~> 3.6.0)
         
     | 
| 
      
 35 
     | 
    
         
            +
                rspec-support (3.6.0)
         
     | 
| 
      
 36 
     | 
    
         
            +
                simplecov (0.15.0)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  docile (~> 1.1.0)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  json (>= 1.8, < 3)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  simplecov-html (~> 0.10.0)
         
     | 
| 
      
 40 
     | 
    
         
            +
                simplecov-html (0.10.2)
         
     | 
| 
      
 41 
     | 
    
         
            +
                thread_safe (0.3.6)
         
     | 
| 
      
 42 
     | 
    
         
            +
                tzinfo (1.2.3)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  thread_safe (~> 0.1)
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            PLATFORMS
         
     | 
| 
      
 46 
     | 
    
         
            +
              ruby
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            DEPENDENCIES
         
     | 
| 
      
 49 
     | 
    
         
            +
              bundler (~> 1.15)
         
     | 
| 
      
 50 
     | 
    
         
            +
              codeclimate-test-reporter (~> 0.4.8)
         
     | 
| 
      
 51 
     | 
    
         
            +
              except_nested!
         
     | 
| 
      
 52 
     | 
    
         
            +
              rake (~> 10.0)
         
     | 
| 
      
 53 
     | 
    
         
            +
              rspec (~> 3.0)
         
     | 
| 
      
 54 
     | 
    
         
            +
              simplecov (~> 0.15.0)
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            BUNDLED WITH
         
     | 
| 
      
 57 
     | 
    
         
            +
               1.15.3
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -3,9 +3,9 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            [](https://travis-ci.org/abarrak/except_nested)
         
     | 
| 
       4 
4 
     | 
    
         
             
            [](https://gemnasium.com/github.com/abarrak/except_nested)
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            **except_nested** allows exclusion of given hash keys at  
     | 
| 
      
 6 
     | 
    
         
            +
            **except_nested** allows exclusion of given hash keys at various depth of the hash.
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
            It's an extended version of active_support `#except` hash utility
         
     | 
| 
      
 8 
     | 
    
         
            +
            It's an extended version of active_support `#except` hash utility.
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            ## Installation
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -28,10 +28,47 @@ $ gem install except_nested 
     | 
|
| 
       28 
28 
     | 
    
         
             
            ```
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
            ## Usage
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
            Given the following hash:
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 34 
     | 
    
         
            +
            h = { name: 'Zohoor', degree: 'Psychology', preferences: { color: 'mauve', drink: 'coffee', pet: 'cat' } }
         
     | 
| 
      
 35 
     | 
    
         
            +
            ```
         
     | 
| 
      
 36 
     | 
    
         
            +
            You can deep except keys:
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 39 
     | 
    
         
            +
            h.except_nested(:degree, preferences: [:color, :pet])
         
     | 
| 
      
 40 
     | 
    
         
            +
            => { name: "Zohoor", preferences: { drink: "coffee" } }
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            h.except_nested(preferences: :pet)
         
     | 
| 
      
 43 
     | 
    
         
            +
            => { name: "Zohoor", degree: "Psychology", preferences: { color: "mauve", drink: "coffee" } }
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            h.except_nested(preferences: [:pet], :name)
         
     | 
| 
      
 46 
     | 
    
         
            +
            => { degree: "Psychology", preferences: { color: "mauve", drink: "coffee" } }
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            h.except_nested(:degree, preferences: [:color, :pet, :drink])
         
     | 
| 
      
 49 
     | 
    
         
            +
            => { name: "Zohoor" }
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            # original hash is preserved ..
         
     | 
| 
      
 52 
     | 
    
         
            +
            h
         
     | 
| 
      
 53 
     | 
    
         
            +
            => { name: "Zohoor", degree: "Psychology", preferences: {color: "mauve", drink: "coffee", pet: "cat"}}
         
     | 
| 
      
 54 
     | 
    
         
            +
            ```
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            Or exclude keys at first level just like normal `#except` does:
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 59 
     | 
    
         
            +
            h.except_nested(:name)
         
     | 
| 
      
 60 
     | 
    
         
            +
            => { degree: "Psychology", preferences: { color: "mauve", drink: "coffee", pet: "cat" } }
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            h.except_nested(:name, :degree)
         
     | 
| 
      
 63 
     | 
    
         
            +
            => { preferences: { color: "mauve", drink: "coffee", pet: "cat" } }
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            h.except_nested(:name, :degree, :preferences)
         
     | 
| 
      
 66 
     | 
    
         
            +
            => {}
         
     | 
| 
      
 67 
     | 
    
         
            +
            ```
         
     | 
| 
       32 
68 
     | 
    
         | 
| 
       33 
69 
     | 
    
         
             
            ## Documentation
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            [RDoc version](http://www.rubydoc.info/gems/except_nested) at RubyDoc.
         
     | 
| 
       35 
72 
     | 
    
         | 
| 
       36 
73 
     | 
    
         
             
            ## Development
         
     | 
| 
       37 
74 
     | 
    
         | 
    
        data/except_nested.gemspec
    CHANGED
    
    | 
         @@ -13,7 +13,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       13 
13 
     | 
    
         
             
              spec.email         = ["abdullah@abarrak.com"]
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              spec.summary       = "An extended version of active_support #except hash utility."
         
     | 
| 
       16 
     | 
    
         
            -
              spec.description   = "except_nested allows exclusion of given hash keys at  
     | 
| 
      
 16 
     | 
    
         
            +
              spec.description   = "except_nested allows exclusion of given hash keys at various depth."
         
     | 
| 
       17 
17 
     | 
    
         
             
              spec.homepage      = "https://github.com/abarrak/except_nested"
         
     | 
| 
       18 
18 
     | 
    
         
             
              spec.license       = "MIT"
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
         @@ -28,6 +28,6 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       28 
28 
     | 
    
         
             
              spec.add_development_dependency "bundler", "~> 1.15"
         
     | 
| 
       29 
29 
     | 
    
         
             
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
       30 
30 
     | 
    
         
             
              spec.add_development_dependency "rspec", "~> 3.0"
         
     | 
| 
       31 
     | 
    
         
            -
              spec.add_development_dependency "simplecov", "~> 0. 
     | 
| 
      
 31 
     | 
    
         
            +
              spec.add_development_dependency "simplecov", "~> 0.15.0"
         
     | 
| 
       32 
32 
     | 
    
         
             
              spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4.8"
         
     | 
| 
       33 
33 
     | 
    
         
             
            end
         
     | 
| 
         @@ -17,8 +17,8 @@ class Hash 
     | 
|
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
              # Removes the given nested keys from hash and returns it.
         
     | 
| 
       19 
19 
     | 
    
         
             
              #   hash = { a: true, b: { x: true, y: false }, c: nil }
         
     | 
| 
       20 
     | 
    
         
            -
              #   hash.except_nested(b: [:y])       # => { a: true, b: { x: true }, c: nil }
         
     | 
| 
       21 
     | 
    
         
            -
              #   hash 
     | 
| 
      
 20 
     | 
    
         
            +
              #   hash.except_nested!(b: [:y])       # => { a: true, b: { x: true }, c: nil }
         
     | 
| 
      
 21 
     | 
    
         
            +
              #   hash                               # => { a: true, b: { x: true }, c: nil }
         
     | 
| 
       22 
22 
     | 
    
         
             
              def except_nested!(*nested_keys)
         
     | 
| 
       23 
23 
     | 
    
         
             
                nested_keys.each do |key|
         
     | 
| 
       24 
24 
     | 
    
         
             
                  if key.is_a?(Hash)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: except_nested
         
     | 
| 
       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 
     | 
    
         
             
            - Abdullah Barrak
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-08- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-08-19 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -72,14 +72,14 @@ dependencies: 
     | 
|
| 
       72 
72 
     | 
    
         
             
                requirements:
         
     | 
| 
       73 
73 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       74 
74 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       75 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 75 
     | 
    
         
            +
                    version: 0.15.0
         
     | 
| 
       76 
76 
     | 
    
         
             
              type: :development
         
     | 
| 
       77 
77 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       78 
78 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       79 
79 
     | 
    
         
             
                requirements:
         
     | 
| 
       80 
80 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       81 
81 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       82 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 82 
     | 
    
         
            +
                    version: 0.15.0
         
     | 
| 
       83 
83 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       84 
84 
     | 
    
         
             
              name: codeclimate-test-reporter
         
     | 
| 
       85 
85 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -94,7 +94,7 @@ dependencies: 
     | 
|
| 
       94 
94 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       95 
95 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
96 
     | 
    
         
             
                    version: 0.4.8
         
     | 
| 
       97 
     | 
    
         
            -
            description: except_nested allows exclusion of given hash keys at  
     | 
| 
      
 97 
     | 
    
         
            +
            description: except_nested allows exclusion of given hash keys at various depth.
         
     | 
| 
       98 
98 
     | 
    
         
             
            email:
         
     | 
| 
       99 
99 
     | 
    
         
             
            - abdullah@abarrak.com
         
     | 
| 
       100 
100 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -107,6 +107,7 @@ files: 
     | 
|
| 
       107 
107 
     | 
    
         
             
            - ".ruby-version"
         
     | 
| 
       108 
108 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       109 
109 
     | 
    
         
             
            - Gemfile
         
     | 
| 
      
 110 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
       110 
111 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       111 
112 
     | 
    
         
             
            - README.md
         
     | 
| 
       112 
113 
     | 
    
         
             
            - Rakefile
         
     |