tzispa_helpers 0.1.20 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/tzispa/helpers.rb +3 -0
- data/lib/tzispa/helpers/provider.rb +37 -0
- data/lib/tzispa/helpers/requirer.rb +42 -0
- data/lib/tzispa/helpers/sign_requirer.rb +39 -0
- data/lib/tzispa/helpers/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5bc6f2d8bd4235851b213da834c4e50f0440dab
|
4
|
+
data.tar.gz: dbd91908bec6fe96a8bda0530e24c56270bf9993
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f976cd43680ca151dbdea5a5b500255a03099f832b36c9a179b3e6c6e8cd3cc2b654be3e43a1d8690a003c8814f6d386af2b2ca659fbb096c4d3b604f644b922
|
7
|
+
data.tar.gz: 97615ff3c0a3bdc9c51c1ba0e1f44782d62a87c50511412d0186a82c46f5a410919a22e99fdf99b6aba71c924eccd8b06cbac910d9a9e7f3fba702855040029f
|
data/CHANGELOG.md
CHANGED
data/lib/tzispa/helpers.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Tzispa
|
2
|
+
module Helpers
|
3
|
+
module Provider
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
def provides?(verb)
|
10
|
+
self.class.provides? verb
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
|
15
|
+
def provides(*args)
|
16
|
+
(@provides ||= Hash.new).tap { |prv|
|
17
|
+
args&.each { |s|
|
18
|
+
prv[s.to_sym] = s
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def provides?(verb)
|
24
|
+
value = verb.to_sym
|
25
|
+
provides.include?(value) && public_method_defined?(provides[value])
|
26
|
+
end
|
27
|
+
|
28
|
+
def provides_map(source, dest)
|
29
|
+
provides[source] = dest
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Tzispa
|
2
|
+
module Helpers
|
3
|
+
module Requirer
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
def required?(target, value)
|
10
|
+
self.class.required? target. value
|
11
|
+
end
|
12
|
+
|
13
|
+
def required_valid?(target, value)
|
14
|
+
self.class.required_valid? target, value, self
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
|
19
|
+
def required(target, value, &block)
|
20
|
+
@required ||= Hash.new
|
21
|
+
(@required[target] ||= Hash.new).tap { |reqt|
|
22
|
+
reqt[value] = block || true
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def required?(target, value)
|
27
|
+
@required&.fetch(target, nil)&.fetch(value, nil)
|
28
|
+
end
|
29
|
+
|
30
|
+
def required_valid?(target, value, obj)
|
31
|
+
if (rq = required?(target, value)) && rq.respond_to?(:call)
|
32
|
+
obj.instance_eval(&rq)
|
33
|
+
else
|
34
|
+
rq
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'requirer'
|
2
|
+
|
3
|
+
module Tzispa
|
4
|
+
module Helpers
|
5
|
+
module SignRequirer
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
base.include Tzispa::Helpers::Requirer
|
9
|
+
base.extend(ClassMethods)
|
10
|
+
end
|
11
|
+
|
12
|
+
def sign_required?
|
13
|
+
self.class.sign_required?
|
14
|
+
end
|
15
|
+
|
16
|
+
def sign_valid?
|
17
|
+
self.class.sign_valid? self
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
module ClassMethods
|
22
|
+
|
23
|
+
def sign_required!(&block)
|
24
|
+
required(:router_params, :sign, &block)
|
25
|
+
end
|
26
|
+
|
27
|
+
def sign_required?
|
28
|
+
required? :router_params, :sign
|
29
|
+
end
|
30
|
+
|
31
|
+
def sign_valid?(obj)
|
32
|
+
required_valid? :router_params, :sign, obj
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Antonio Piñero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -98,10 +98,13 @@ files:
|
|
98
98
|
- lib/tzispa/helpers/mail.rb
|
99
99
|
- lib/tzispa/helpers/mime.rb
|
100
100
|
- lib/tzispa/helpers/pattern.rb
|
101
|
+
- lib/tzispa/helpers/provider.rb
|
101
102
|
- lib/tzispa/helpers/recaptcha.rb
|
102
103
|
- lib/tzispa/helpers/request.rb
|
104
|
+
- lib/tzispa/helpers/requirer.rb
|
103
105
|
- lib/tzispa/helpers/response.rb
|
104
106
|
- lib/tzispa/helpers/security.rb
|
107
|
+
- lib/tzispa/helpers/sign_requirer.rb
|
105
108
|
- lib/tzispa/helpers/text.rb
|
106
109
|
- lib/tzispa/helpers/version.rb
|
107
110
|
- lib/tzispa_helpers.rb
|