forbidium 1.2.0 → 2.0.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
  SHA1:
3
- metadata.gz: 5b41e5cb910d5e3f0c7bc288c1bef273770f904d
4
- data.tar.gz: b629928ec78b528e5d85b48073eebf32cf95fbf1
3
+ metadata.gz: 81868b5c81c95377d8fe37c1f64dc9ba68cf1153
4
+ data.tar.gz: 84efec5075cca2d2b3f11016c178d181093d5cdd
5
5
  SHA512:
6
- metadata.gz: 70373e7f8f34e3a1e31c27c02bfe1fcaaf08434718661f90e620f66987a7b53cf9d6aef56339fbc175fccbb2e3413333aa36b43a4b1ca223be4969520a6b4a6d
7
- data.tar.gz: 24599ce3d6152468d7239364844281ef3f1689607bc4b68538c8382320f06d95ce6908f84fd31c21a61d5788a04bfe2c62a51868b861b544ff788e3f7582ce1a
6
+ metadata.gz: 76f8da6a468c88063cc2181ec50e9b760b8a77264a129b9a291437ac34c2986afa6ac7f39913b60485e656f2fd8ed0b9fa4ee8fa72dfcf6a3b9e4229bf37f94a
7
+ data.tar.gz: 7615c7b7b5455fa33b93271e362de02687aa967e3b3aa12113eec7298463300ab89a74741e45acdf207344286a13912f057bada2f0a80dadd308f6a319599280
data/README.md CHANGED
@@ -1,97 +1,11 @@
1
- # Forbidium
2
- [![Gem Version](https://badge.fury.io/rb/forbidium.svg)](https://badge.fury.io/rb/forbidium)
3
- [![Code Climate](https://codeclimate.com/github/msimonborg/forbidium/badges/gpa.svg)](https://codeclimate.com/github/msimonborg/forbidium)
4
- [![Build Status](https://travis-ci.org/msimonborg/forbidium.svg?branch=master)](https://travis-ci.org/msimonborg/forbidium)
5
- [![Coverage Status](https://coveralls.io/repos/github/msimonborg/forbidium/badge.svg?branch=master)](https://coveralls.io/github/msimonborg/forbidium?branch=master)
1
+ # I was Forbidium
2
+ # Now I'm [Allowable](https://github.com/msimonborg/allowable)
6
3
 
7
- Filter hashes by setting allowed or forbidden values for specific keys.
8
-
9
- ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'forbidium'
15
- ```
16
-
17
- And then execute:
18
-
19
- $ bundle
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install forbidium
24
-
25
- ## Usage
26
- The gem will add four methods to `Hash`: `#allow`, `#allow!`, `#forbid`, and `#forbid!`
27
-
28
- ```ruby
29
- hash = { one: 'one', two: 'two' }
30
-
31
- hash.forbid(one: 'one') # => { two: 'two' }
32
-
33
- hash.allow(one: 'two') # => { two: 'two' }
34
-
35
- hash.allow(one: ['one', 'two']) # => { one: 'one', two: 'two' }
36
-
37
- hash.forbid(one: ['one', 'two']) # => { two: 'two' }
38
-
39
- hash.allow!(one: 'two') # => { two: 'two' }
40
-
41
- hash.forbid!(two: 'two') # => {}
42
-
43
- hash # => {}
44
- ```
45
-
46
- ### Type sensitive for `Hash`
47
-
48
- ```ruby
49
- hash = { 'one' => 'one', 'two' => 'two' }
50
-
51
- hash.forbid(one: 'one') # => { "one" => "one", "two" => "two" }
52
-
53
- hash.forbid('one' => 'one') # => { "two" => "two" }
54
- ```
55
-
56
- When added to the `Gemfile` in a Rails project, `ActionController::Parameters` will also receive these methods so you can use them with your `strong_parameters`:
57
-
58
- ```ruby
59
- def user_params
60
- params.require(:user).permit(:email, :password, :role).forbid(role: ['sys_admin', 'owner'])
61
- end
62
- ```
63
-
64
- ### Type insensitive for `HashWithIndifferentAccess`
65
- ```ruby
66
- params = ActionController::Parameters.new('one' => 'one', 'two' => 'two').permit(:one, :two)
67
-
68
- params.forbid(one: 'one').to_h # => { "two" => "two" }
69
-
70
- params.forbid('one' => 'one').to_h # => { "two" => "two" }
71
- ```
72
-
73
- If your custom `Hash`-like class implements the `#[]` finder and `#delete`, you can `include Forbidium` to mix in the methods.
74
-
75
- ## Platform support
76
-
77
- Tested against:
78
- * MRI 2.2.2
79
- * MRI 2.3.0
80
- * MRI 2.3.4
81
- * MRI 2.4.1
82
- * JRuby 9.1.6.0
83
- * JRuby HEAD
84
- * MRI HEAD
85
-
86
- ## Development
87
-
88
- 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.
89
-
90
- 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).
4
+ I'll still work. All I do is install the latest version of `allowable` and `include Allowable`. You might as well do that directly.
91
5
 
92
6
  ## Contributing
93
7
 
94
- Bug reports and pull requests are welcome on GitHub at https://github.com/msimonborg/forbidium.
8
+ Bug reports and pull requests are welcome on GitHub at https://github.com/msimonborg/allowable.
95
9
 
96
10
 
97
11
  ## License
@@ -1,6 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'allowable'
3
4
  require 'forbidium/version'
4
- require 'forbidium/forbidium'
5
- require 'forbidium/core_ext/hash'
6
- require 'forbidium/railtie' if defined? Rails
5
+
6
+ # frozen_string_literal: true
7
+
8
+ # Filter hashes by setting allowed or forbidden values for specific keys.
9
+ #
10
+ # hash = { one: 'one', two: 'two' }
11
+ #
12
+ # hash.forbid(one: 'one') # => { two: 'two' }
13
+ #
14
+ # hash.allow(one: 'two') # => { two: 'two' }
15
+ #
16
+ # hash.allow(one: ['one', 'two']) # => { one: 'one', two: 'two' }
17
+ #
18
+ # hash.forbid(one: ['one', 'two']) # => { two: 'two' }
19
+ #
20
+ # hash.allow!(one: 'two') # => { two: 'two' }
21
+ #
22
+ # hash.forbid!(two: 'two') # => {}
23
+ #
24
+ # hash # => {}
25
+ module Forbidium
26
+ include Allowable
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Forbidium
4
- VERSION = '1.2.0'
4
+ VERSION = '2.0.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forbidium
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. Simon Borg
@@ -10,6 +10,20 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2017-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: allowable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,7 +52,7 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '10.0'
41
- description: Filter hash keys based on allowed and forbidden values.
55
+ description: Filter hash keys based on allowed and forbidden values. Renamed "Allowable".
42
56
  email:
43
57
  - msimonborg@gmail.com
44
58
  executables: []
@@ -49,17 +63,15 @@ files:
49
63
  - LICENSE.txt
50
64
  - README.md
51
65
  - lib/forbidium.rb
52
- - lib/forbidium/allow.rb
53
- - lib/forbidium/core_ext/hash.rb
54
- - lib/forbidium/forbid.rb
55
- - lib/forbidium/forbidium.rb
56
- - lib/forbidium/railtie.rb
57
66
  - lib/forbidium/version.rb
58
67
  homepage: https://github.com/msimonborg/forbidium
59
68
  licenses:
60
69
  - MIT
61
70
  metadata: {}
62
- post_install_message:
71
+ post_install_message: "`Forbidium` has been renamed to `Allowable`. Please remove
72
+ `forbidium` from your Gemfile and replace it with `allowable`. `forbidium` just
73
+ installs the latest version of `allowable` anyway, so it will still work. But you
74
+ won't be able to lock the version. Do the right thing and switch to `allowable`"
63
75
  rdoc_options: []
64
76
  require_paths:
65
77
  - lib
@@ -78,5 +90,5 @@ rubyforge_project:
78
90
  rubygems_version: 2.6.11
79
91
  signing_key:
80
92
  specification_version: 4
81
- summary: Filter hash keys based on allowed and forbidden values.
93
+ summary: Filter hash keys based on allowed and forbidden values. Renamed "Allowable".
82
94
  test_files: []
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Forbidium
4
- # Adds the #allow and #allow! methods
5
- module Allow
6
- def allow(filters = {})
7
- dup.allow!(filters)
8
- end
9
-
10
- def allow!(filters = {})
11
- filters.each do |key, val|
12
- delete(key) unless Array(val).include?(self[key])
13
- end
14
- self
15
- end
16
- end
17
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Add #allow, #allow!, #forbid, and #forbid! to Hash
4
- class Hash
5
- include Forbidium
6
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Forbidium
4
- # Adds the #forbid and #forbid! methods
5
- module Forbid
6
- def forbid(filters = {})
7
- dup.forbid!(filters)
8
- end
9
-
10
- def forbid!(filters = {})
11
- filters.each do |key, val|
12
- delete(key) if Array(val).include?(self[key])
13
- end
14
- self
15
- end
16
- end
17
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'forbidium/allow'
4
- require 'forbidium/forbid'
5
-
6
- # Filter hashes by setting allowed or forbidden values for specific keys.
7
- #
8
- # hash = { one: 'one', two: 'two' }
9
- #
10
- # hash.forbid(one: 'one') # => { two: 'two' }
11
- #
12
- # hash.allow(one: 'two') # => { two: 'two' }
13
- #
14
- # hash.allow(one: ['one', 'two']) # => { one: 'one', two: 'two' }
15
- #
16
- # hash.forbid(one: ['one', 'two']) # => { two: 'two' }
17
- #
18
- # hash.allow!(one: 'two') # => { two: 'two' }
19
- #
20
- # hash.forbid!(two: 'two') # => {}
21
- #
22
- # hash # => {}
23
- module Forbidium
24
- include Forbid
25
- include Allow
26
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/railtie'
4
-
5
- module Forbidium
6
- # Railtie initializer that adds Forbidium methods to controller params
7
- class Railtie < ::Rails::Railtie
8
- initializer :forbidium do
9
- ActiveSupport.on_load :action_controller do
10
- ActionController::Parameters.send :include, Forbidium
11
- end
12
- end
13
- end
14
- end