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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4236ffaf4f620afe1651f74fd41a45c8499956f
4
- data.tar.gz: 5da86df23412cf919f002ea8e7f7949efe7edee7
3
+ metadata.gz: f5bc6f2d8bd4235851b213da834c4e50f0440dab
4
+ data.tar.gz: dbd91908bec6fe96a8bda0530e24c56270bf9993
5
5
  SHA512:
6
- metadata.gz: 5276b2353644b3f626cc100f15461d164c6bb6261464f1e4fa23ba83a09175439f663eac8712cb295efa5d54131a238c97fd709f51dea6d9469ec5ae8fce139a
7
- data.tar.gz: 51f47bc40e5b8ad4bf99a1a2e1321b95e28b02e256f942265f41786c30b5938bed3115c57b4a84b378ca588821bfd773e8184789d5ee7b6dce652a7c4a37f450
6
+ metadata.gz: f976cd43680ca151dbdea5a5b500255a03099f832b36c9a179b3e6c6e8cd3cc2b654be3e43a1d8690a003c8814f6d386af2b2ca659fbb096c4d3b604f644b922
7
+ data.tar.gz: 97615ff3c0a3bdc9c51c1ba0e1f44782d62a87c50511412d0186a82c46f5a410919a22e99fdf99b6aba71c924eccd8b06cbac910d9a9e7f3fba702855040029f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  Tzispa Helpers
2
2
 
3
+ ## v0.1.21
4
+ - added requirer and sign_requirer dsl helpers
5
+ - added provider dsl helper
6
+
7
+ ## v0.1.20
8
+ - fix rack 2.0 incompatibility errors in response send_file
9
+
3
10
  ## v0.1.19
4
11
  - added DateTime helper module
5
12
 
@@ -11,6 +11,9 @@ module Tzispa
11
11
  require 'tzispa/helpers/response'
12
12
  require 'tzispa/helpers/security'
13
13
  require 'tzispa/helpers/text'
14
+ require 'tzispa/helpers/provider'
15
+ require 'tzispa/helpers/error_view'
16
+ require 'tzispa/helpers/recaptcha'
14
17
 
15
18
  end
16
19
  end
@@ -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
@@ -3,7 +3,7 @@
3
3
  module Tzispa
4
4
  module Helpers
5
5
 
6
- VERSION = '0.1.20'
6
+ VERSION = '0.1.21'
7
7
  NAME = 'Tzispa Helpers'
8
8
  GEM_NAME = 'tzispa_helpers'
9
9
 
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.20
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-03 00:00:00.000000000 Z
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