tainted_hash 0.0.1 → 0.0.2
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.
- data/lib/tainted_hash/rails.rb +4 -1
- data/lib/tainted_hash.rb +10 -4
- data/tainted_hash.gemspec +2 -2
- metadata +32 -50
data/lib/tainted_hash/rails.rb
CHANGED
@@ -4,7 +4,7 @@ TaintedHash.send :include, TaintedHash::RailsMethods
|
|
4
4
|
|
5
5
|
module TaintedHash::Controller
|
6
6
|
def wrap_params_with_tainted_hash
|
7
|
-
@_params = TaintedHash.new(@_params.to_hash)
|
7
|
+
@_params = TaintedHash.new(@_params.to_hash, HashWithIndifferentAccess)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -12,3 +12,6 @@ if defined?(ActionController::Base)
|
|
12
12
|
ActionController::Base.send :include, TaintedHash::Controller
|
13
13
|
end
|
14
14
|
|
15
|
+
if defined?(HashWithIndifferentAccess)
|
16
|
+
TaintedHash.default_hash_class = HashWithIndifferentAccess
|
17
|
+
end
|
data/lib/tainted_hash.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'set'
|
2
2
|
|
3
3
|
class TaintedHash < Hash
|
4
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.2"
|
5
5
|
|
6
6
|
class UnexposedError < StandardError
|
7
7
|
# Builds an exception when a TaintedHash has some unexposed keys. Useful
|
@@ -13,6 +13,12 @@ class TaintedHash < Hash
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
class << self
|
17
|
+
attr_accessor :default_hash_class
|
18
|
+
end
|
19
|
+
|
20
|
+
self.default_hash_class = Hash
|
21
|
+
|
16
22
|
def self.on_no_expose(&block)
|
17
23
|
@on_no_expose = block
|
18
24
|
end
|
@@ -34,13 +40,14 @@ class TaintedHash < Hash
|
|
34
40
|
# new_class - Optional class used to create basic Hashes. Default: Hash.
|
35
41
|
#
|
36
42
|
def initialize(hash = nil, new_class = nil)
|
37
|
-
|
43
|
+
@new_class = new_class || self.class.default_hash_class
|
44
|
+
|
45
|
+
(@original_hash = hash || @new_class.new).keys.each do |key|
|
38
46
|
key_s = key.to_s
|
39
47
|
next if key_s == key
|
40
48
|
@original_hash[key_s] = @original_hash.delete(key)
|
41
49
|
end
|
42
50
|
|
43
|
-
@new_class = new_class || Hash
|
44
51
|
@exposed_nothing = true
|
45
52
|
end
|
46
53
|
|
@@ -235,4 +242,3 @@ class TaintedHash < Hash
|
|
235
242
|
end
|
236
243
|
end
|
237
244
|
end
|
238
|
-
|
data/tainted_hash.gemspec
CHANGED
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
## If your rubyforge_project name is different, then edit it and comment out
|
13
13
|
## the sub! line in the Rakefile
|
14
14
|
s.name = 'tainted_hash'
|
15
|
-
s.version = '0.0.
|
16
|
-
s.date = '
|
15
|
+
s.version = '0.0.2'
|
16
|
+
s.date = '2013-05-21'
|
17
17
|
s.rubyforge_project = 'tainted_hash'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
metadata
CHANGED
@@ -1,45 +1,38 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: tainted_hash
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Rick Olson
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: test-unit
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :development
|
33
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
34
30
|
description: Hash wrapper.
|
35
31
|
email: technoweenie@gmail.com
|
36
32
|
executables: []
|
37
|
-
|
38
33
|
extensions: []
|
39
|
-
|
40
34
|
extra_rdoc_files: []
|
41
|
-
|
42
|
-
files:
|
35
|
+
files:
|
43
36
|
- LICENSE.md
|
44
37
|
- README.md
|
45
38
|
- Rakefile
|
@@ -49,38 +42,27 @@ files:
|
|
49
42
|
- test/tainted_hash_test.rb
|
50
43
|
homepage: https://github.com/technoweenie/tainted_hash
|
51
44
|
licenses: []
|
52
|
-
|
53
45
|
post_install_message:
|
54
46
|
rdoc_options: []
|
55
|
-
|
56
|
-
require_paths:
|
47
|
+
require_paths:
|
57
48
|
- lib
|
58
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
50
|
none: false
|
60
|
-
requirements:
|
61
|
-
- -
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
|
64
|
-
|
65
|
-
- 0
|
66
|
-
version: "0"
|
67
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
56
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
hash: 17
|
73
|
-
segments:
|
74
|
-
- 1
|
75
|
-
- 3
|
76
|
-
- 5
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
77
60
|
version: 1.3.5
|
78
61
|
requirements: []
|
79
|
-
|
80
62
|
rubyforge_project: tainted_hash
|
81
|
-
rubygems_version: 1.8.
|
63
|
+
rubygems_version: 1.8.23
|
82
64
|
signing_key:
|
83
65
|
specification_version: 2
|
84
66
|
summary: Hash wrapper.
|
85
|
-
test_files:
|
67
|
+
test_files:
|
86
68
|
- test/tainted_hash_test.rb
|