forbidium 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d49ef2c415c56614ba5b0a9e1b95ed4e46166830
4
+ data.tar.gz: 4f3737cd6bd4ba2b20e023d9d644e21a47eb45a1
5
+ SHA512:
6
+ metadata.gz: b564c7eac506a5532e0106cf75ffae36a2cdd834ccdda2ec42f8dd46253000b01de5f875ea8b1532c7d83fe88c922990f7226ecc78cab88348c524d7d3ddd085
7
+ data.tar.gz: 59291af8d1d00907195ddf011a02fad75040152a95e226986fa0c039f9af3a077c90fc5b0d475dac96548a625273d727f094df260ca5e38702ce58d1e3117751
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 M. Simon Borg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Forbidium
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/forbidium`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'forbidium'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install forbidium
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/forbidium.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,16 @@
1
+ module Forbidium
2
+ module Allow
3
+ def allow(filters = {})
4
+ dup.allow!(filters)
5
+ end
6
+
7
+ def allow!(filters = {})
8
+ filters.each do |key, val|
9
+ delete_if do |k, v|
10
+ key.to_s == k.to_s && !Array(val).include?(v)
11
+ end
12
+ end
13
+ self
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ class Hash
2
+ include Forbidium
3
+ end
@@ -0,0 +1,16 @@
1
+ module Forbidium
2
+ module Forbid
3
+ def forbid(filters = {})
4
+ dup.forbid!(filters)
5
+ end
6
+
7
+ def forbid!(filters = {})
8
+ filters.each do |key, val|
9
+ delete_if do |k, v|
10
+ key.to_s == k.to_s && Array(val).include?(v)
11
+ end
12
+ end
13
+ self
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forbidium/allow'
4
+ require 'forbidium/forbid'
5
+
6
+ module Forbidium
7
+ def self.included(base)
8
+ [Forbidium::Allow, Forbidium::Forbid].each { |mod| base.include mod }
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Forbidium
2
+ VERSION = '0.1.0'.freeze
3
+ end
data/lib/forbidium.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'forbidium/version'
2
+
3
+ require 'forbidium/forbidium'
4
+ require 'forbidium/core_ext/hash'
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: forbidium
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - M. Simon Borg
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Filter hash keys based on allowed and forbidden values.
56
+ email:
57
+ - msimonborg@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE.txt
63
+ - README.md
64
+ - lib/forbidium.rb
65
+ - lib/forbidium/allow.rb
66
+ - lib/forbidium/core_ext/hash.rb
67
+ - lib/forbidium/forbid.rb
68
+ - lib/forbidium/forbidium.rb
69
+ - lib/forbidium/version.rb
70
+ homepage: https://github.com/msimonborg/forbidium
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.6.11
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Filter hash keys based on allowed and forbidden values.
94
+ test_files: []