crumbs 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +1 -1
- data/lib/crumbs/action_controller/base.rb +3 -2
- data/lib/crumbs/history.rb +12 -9
- data/lib/crumbs/version.rb +1 -1
- data/test/dummy/app/controllers/pages_controller.rb +3 -3
- data/test/dummy/log/test.log +2026 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65c23c3a5031cc7aee4ea4f9345d356a920ae45a
|
4
|
+
data.tar.gz: 1eac4ee8c700f05faaa1686802121c7d4a6099c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11c1db3e6708873d5b70bdb8c852626e8db9ec0348b5e75d0e9c730fe5654fbd96f2037304451826bf63664f67eec1b1133c438d243f3c9530487e38908e9487
|
7
|
+
data.tar.gz: 15c226389376609305b7d1a26890df5788a67d4af6fbec7ad9e1a5e97b1e003072b5e3e6cd883594dfd2b0540d43c883b61e3918b42dd0a4b28e333b86a1dba0
|
data/README.rdoc
CHANGED
@@ -17,7 +17,7 @@ Then bundle:
|
|
17
17
|
In your controllers add crumbs to the actions you want to have a crumb:
|
18
18
|
crumb :home, 'Home'
|
19
19
|
|
20
|
-
You can use a proc
|
20
|
+
You can use a lambda, proc or block too, will receive the corresponding url parameters:
|
21
21
|
crumb :product, proc { |params| Product.find(params[:id]).name }
|
22
22
|
|
23
23
|
Then in your views would be available a crumbs variable:
|
@@ -63,7 +63,7 @@ module Crumbs
|
|
63
63
|
|
64
64
|
def join_parts(parts)
|
65
65
|
path = parts.join('/')
|
66
|
-
|
66
|
+
path[0] != '/' ? "/#{path}" : path
|
67
67
|
end
|
68
68
|
|
69
69
|
def is_last_referer?
|
@@ -109,8 +109,9 @@ module Crumbs
|
|
109
109
|
|
110
110
|
protected
|
111
111
|
|
112
|
-
def crumb(action, name)
|
112
|
+
def crumb(action, name = nil, &block)
|
113
113
|
controller = self.name.gsub('::', '/').gsub('Controller', '').underscore
|
114
|
+
name = block_given? ? block : name
|
114
115
|
History.add(controller, action, name)
|
115
116
|
end
|
116
117
|
|
data/lib/crumbs/history.rb
CHANGED
@@ -7,21 +7,24 @@ module Crumbs
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def add(controller, action, name)
|
10
|
-
|
11
|
-
|
10
|
+
controller = controller.to_sym
|
11
|
+
action = action.to_sym
|
12
|
+
unless all.has_key? controller
|
13
|
+
all[controller] = { action => name }
|
12
14
|
else
|
13
|
-
all[controller
|
15
|
+
all[controller][action] = name
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
def get_name(controller, action, params)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
when Proc
|
20
|
+
controller = controller.to_sym
|
21
|
+
action = action.to_sym
|
22
|
+
return false unless all.has_key? controller and all[controller].has_key? action
|
23
|
+
name = all[controller][action]
|
24
|
+
if name.respond_to? :call
|
24
25
|
value = name.call(params)
|
26
|
+
elsif
|
27
|
+
value = name
|
25
28
|
end
|
26
29
|
value ? value : ''
|
27
30
|
end
|
data/lib/crumbs/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class PagesController < ApplicationController
|
2
2
|
|
3
3
|
crumb :home, 'Home'
|
4
|
-
crumb
|
5
|
-
crumb :i18n
|
6
|
-
crumb :nested,
|
4
|
+
crumb(:static) { 'Static' }
|
5
|
+
crumb :i18n do I18n.t('hello') end
|
6
|
+
crumb :nested, ->(params) { 'Nested' }
|
7
7
|
crumb :param, proc { |params| params[:param] }
|
8
8
|
|
9
9
|
def home
|