breadcrumble 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -28,6 +28,7 @@ In your controller, call `add_breadcrumb` to push a new crumb on the breadcrumb
|
|
28
28
|
def index
|
29
29
|
add_breadcrumb "index", controller: 'sample', action: 'index'
|
30
30
|
add_breadcrumb "show", show_path(123)
|
31
|
+
add_breadcrumbs ["book", "/book"], ["page", "/book/page"]
|
31
32
|
end
|
32
33
|
|
33
34
|
end
|
@@ -12,6 +12,14 @@ module Breadcrumble
|
|
12
12
|
controller.send :add_breadcrumb, name, url
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
def add_breadcrumbs *args
|
17
|
+
before_filter do |controller|
|
18
|
+
args.each do |arg|
|
19
|
+
controller.send :add_breadcrumb, arg[0], arg[1]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
15
23
|
end
|
16
24
|
|
17
25
|
protected
|
@@ -30,6 +38,12 @@ module Breadcrumble
|
|
30
38
|
}
|
31
39
|
end
|
32
40
|
|
41
|
+
def add_breadcrumbs *args
|
42
|
+
args.each do |arg|
|
43
|
+
add_breadcrumb arg[0], arg[1]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
33
47
|
def breadcrumbs
|
34
48
|
@breadcrumbs
|
35
49
|
end
|
data/lib/breadcrumble/version.rb
CHANGED
@@ -2,13 +2,13 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe ApplicationController do
|
4
4
|
controller do
|
5
|
-
|
6
|
-
add_breadcrumb 'nil', nil
|
5
|
+
add_breadcrumbs ['root', '/'], ['nil', nil]
|
7
6
|
add_breadcrumb -> c { c.examples_url }, -> c { c.examples_path }
|
8
7
|
|
9
8
|
def index
|
10
9
|
add_breadcrumb 'examples', controller: 'examples', action: 'index', only_path: true
|
11
10
|
add_breadcrumb 'example', example_path(123)
|
11
|
+
add_breadcrumbs ['crumb1'], ['crumb2', -> c { example_path(1234) }]
|
12
12
|
render text: 'test'
|
13
13
|
end
|
14
14
|
end
|
@@ -18,7 +18,7 @@ describe ApplicationController do
|
|
18
18
|
get :index
|
19
19
|
end
|
20
20
|
|
21
|
-
context '.
|
21
|
+
context '.add_breadcrumbs' do
|
22
22
|
it 'having breadcrumbs' do
|
23
23
|
should be_success
|
24
24
|
assigns(:breadcrumbs)[0][:name].should eq('root')
|
@@ -30,7 +30,9 @@ describe ApplicationController do
|
|
30
30
|
assigns(:breadcrumbs)[1][:name].should eq('nil')
|
31
31
|
assigns(:breadcrumbs)[1][:url].should be_nil
|
32
32
|
end
|
33
|
+
end
|
33
34
|
|
35
|
+
context '.add_breadcrumb' do
|
34
36
|
it 'execute lambda in controller instance context' do
|
35
37
|
should be_success
|
36
38
|
assigns(:breadcrumbs)[2][:name].should eq('http://test.host/examples')
|
@@ -51,5 +53,15 @@ describe ApplicationController do
|
|
51
53
|
assigns(:breadcrumbs)[4][:url].should eq('/examples/123')
|
52
54
|
end
|
53
55
|
end
|
56
|
+
|
57
|
+
context '#add_breadcrumbs' do
|
58
|
+
it 'sequence is starting from first argument' do
|
59
|
+
should be_success
|
60
|
+
assigns(:breadcrumbs)[5][:name].should eq('crumb1')
|
61
|
+
assigns(:breadcrumbs)[5][:url].should be_nil
|
62
|
+
assigns(:breadcrumbs)[6][:name].should eq('crumb2')
|
63
|
+
assigns(:breadcrumbs)[6][:url].should eq('/examples/1234')
|
64
|
+
end
|
65
|
+
end
|
54
66
|
end
|
55
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breadcrumble
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -125,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
segments:
|
127
127
|
- 0
|
128
|
-
hash: -
|
128
|
+
hash: -2832618272314011603
|
129
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
130
|
none: false
|
131
131
|
requirements:
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
segments:
|
136
136
|
- 0
|
137
|
-
hash: -
|
137
|
+
hash: -2832618272314011603
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
140
|
rubygems_version: 1.8.23
|