Capcode 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ module Capcode
2
+ class << self
3
+ # Add a before filter :
4
+ #
5
+ # module Capcode
6
+ # before_filter :my_global_action
7
+ # before_filter :need_login, :except => [:Login]
8
+ # before_filter :check_mail, :only => [:MailBox]
9
+ # # ...
10
+ # end
11
+ #
12
+ # If the action return nil, the normal get or post will be executed, else no.
13
+ #
14
+ def before_filter( action, opts = {} )
15
+ Capcode::Filter.filters[action] = { }
16
+
17
+ opts.each do |k, v|
18
+ Capcode::Filter.filters[action][k] = v
19
+ end
20
+ end
21
+ end
22
+
23
+ class Filter #:nodoc:
24
+ class << self
25
+ def filters #:nodoc:
26
+ @filters ||= { }
27
+ end
28
+
29
+ def execute( klass ) #:nodoc:
30
+ klass_sym = "#{klass.class}".split( /::/)[-1].to_sym
31
+ actions = []
32
+ @filters.each do |action, data|
33
+ if (data[:only] and data[:only].include?(klass_sym)) or
34
+ (data[:except] and not data[:except].include?(klass_sym)) or
35
+ (data.keys.size == 0)
36
+ actions << action
37
+ end
38
+ end
39
+
40
+ klass.class.instance_eval{ include Capcode }
41
+ rCod = nil
42
+ actions.each do |a|
43
+ rCod = klass.send( a )
44
+ end
45
+
46
+ return rCod
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module Capcode
2
- CAPCOD_VERION="0.9.1"
2
+ CAPCOD_VERION="0.9.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Capcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Gr\xC3\xA9goire Lejeune"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-27 00:00:00 +01:00
12
+ date: 2010-02-05 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -64,6 +64,7 @@ files:
64
64
  - doc/rdoc/files/COPYING.html
65
65
  - doc/rdoc/files/lib/capcode/base/db_rb.html
66
66
  - doc/rdoc/files/lib/capcode/configuration_rb.html
67
+ - doc/rdoc/files/lib/capcode/filters_rb.html
67
68
  - doc/rdoc/files/lib/capcode/helpers/auth_rb.html
68
69
  - doc/rdoc/files/lib/capcode/render/text_rb.html
69
70
  - doc/rdoc/files/lib/capcode_rb.html
@@ -76,6 +77,7 @@ files:
76
77
  - lib/capcode/base/db.rb
77
78
  - lib/capcode/configuration.rb
78
79
  - lib/capcode/core_ext.rb
80
+ - lib/capcode/filters.rb
79
81
  - lib/capcode/helpers/auth.rb
80
82
  - lib/capcode/render/text.rb
81
83
  - lib/capcode/version.rb
@@ -86,6 +88,7 @@ files:
86
88
  - examples/erb/cf_layout.rhtml
87
89
  - examples/erb/layout.rhtml
88
90
  - examples/erb/m_hello.rhtml
91
+ - examples/filter.rb
89
92
  - examples/haml/cf.haml
90
93
  - examples/haml/cf_layout.haml
91
94
  - examples/haml/layout.haml
@@ -142,8 +145,6 @@ rdoc_options:
142
145
  - --quiet
143
146
  - --title
144
147
  - Capcode, the Documentation
145
- - --opname
146
- - index.html
147
148
  - --line-numbers
148
149
  - --main
149
150
  - README.rdoc