breadcrumble 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +2 -2
- data/LICENSE +2 -2
- data/README.md +35 -11
- data/breadcrumble.gemspec +3 -3
- data/lib/breadcrumble/action_controller.rb +33 -13
- data/lib/breadcrumble/action_view.rb +13 -4
- data/lib/breadcrumble/railtie.rb +1 -1
- data/lib/breadcrumble/version.rb +1 -1
- data/lib/generators/breadcrumble/views_generator.rb +5 -1
- data/spec/controllers/application_controller_spec.rb +32 -32
- data/spec/controllers/examples_controller_spec.rb +4 -4
- data/spec/dummy/app/views/breadcrumble/test/_breadcrumb.html.erb +14 -0
- data/spec/dummy/app/views/breadcrumble/test/_breadcrumb_trail.html.erb +11 -0
- data/spec/dummy/app/views/breadcrumble/test/_breadcrumb_trails.html.erb +16 -0
- data/spec/helpers/action_view_spec.rb +54 -5
- data/spec/spec_helper.rb +10 -1
- metadata +27 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 36689c78fce3a799926d7a385111ce842d3b548c
|
4
|
+
data.tar.gz: 4b1e2e2b5f50b026ab9e74f968fe2e61f804a9cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 20f6d52ae76ae12bb16bed3130baac2b5e75337dc49b20538f489943f17cfe0989e2d87fc11faaaa397919f793314e0e5748796b5cb1a58803c68a249433ddc0
|
7
|
+
data.tar.gz: b13fb67c602db5cb528bf79877ae487dfaf6deccfa3b5d83524e5375f5fbd7b127ece091dc8e534ad4a0a2a258a439b72ff51aea7c8c5e161898523e9133ebcc
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2012 ma2ge
|
1
|
+
Copyright (c) 2012-2013 ma2ge
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
[![Coverage Status](https://coveralls.io/repos/ma2gedev/breadcrumble/badge.png)](https://coveralls.io/r/ma2gedev/breadcrumble)
|
8
8
|
|
9
9
|
![Breadcrumble Logo](http://ma2gedev.github.io/breadcrumble/images/logo_s.png)
|
10
|
-
|
10
|
+
logo designed by [@524shoutz_nika](https://twitter.com/524shoutz_nika)
|
11
11
|
|
12
|
-
Breadcrumble is a simple breadcrumb navigation plugin for Ruby on Rails 3 and
|
12
|
+
Breadcrumble is a simple breadcrumb navigation plugin for Ruby on Rails 3, 4.0 and 4.1.
|
13
13
|
|
14
14
|
Support rich snippets mark up using microdata format as default.
|
15
15
|
|
@@ -32,18 +32,20 @@ Or install it yourself as:
|
|
32
32
|
$ gem install breadcrumble
|
33
33
|
|
34
34
|
## Usage
|
35
|
+
|
35
36
|
### Controller
|
37
|
+
|
36
38
|
In your controller, call `add_breadcrumb` to push a new crumb on the breadcrumb stack.
|
37
39
|
|
38
40
|
class SampleController
|
39
41
|
|
40
|
-
add_breadcrumb
|
41
|
-
add_breadcrumb
|
42
|
+
add_breadcrumb("home", home_url)
|
43
|
+
add_breadcrumb(-> context { context.title }, -> context { context.sample_path })
|
42
44
|
|
43
45
|
def index
|
44
|
-
add_breadcrumb
|
45
|
-
add_breadcrumb
|
46
|
-
add_breadcrumbs
|
46
|
+
add_breadcrumb("index", controller: 'sample', action: 'index')
|
47
|
+
add_breadcrumb("show", show_path(123))
|
48
|
+
add_breadcrumbs(["book", "/book"], ["page", "/book/page"])
|
47
49
|
end
|
48
50
|
|
49
51
|
end
|
@@ -56,15 +58,16 @@ If you would like to use multiple breadcrumb, call `add_breadcrumb_to` method wi
|
|
56
58
|
|
57
59
|
class SampleController
|
58
60
|
|
59
|
-
add_breadcrumb_to
|
60
|
-
add_breadcrumb_to
|
61
|
+
add_breadcrumb_to("level 1", "level 1 url", 0) # same as -> add_breadcrumb("level 1", "level 1 url")
|
62
|
+
add_breadcrumb_to("level 2", "level 2 url", 1)
|
61
63
|
|
62
64
|
def index
|
63
|
-
add_breadcrumb_to
|
64
|
-
add_breadcrumb_to
|
65
|
+
add_breadcrumb_to("level 1 second item", "level 1 second url", 0)
|
66
|
+
add_breadcrumb_to("level 2 second item", "level 2 second url", 1)
|
65
67
|
end
|
66
68
|
|
67
69
|
### View
|
70
|
+
|
68
71
|
In your view, you can render the breadcrumb navigation with the `render_breadcrumbs` helper.
|
69
72
|
|
70
73
|
<body>
|
@@ -78,6 +81,7 @@ You can render multiple breadcrumb by `render_breadcrumb_trails` helper.
|
|
78
81
|
</body>
|
79
82
|
|
80
83
|
### Customizing layout
|
84
|
+
|
81
85
|
Breadcrumble generates default partial template for your app.
|
82
86
|
|
83
87
|
Generate template. Run the follwoing.
|
@@ -86,12 +90,32 @@ Generate template. Run the follwoing.
|
|
86
90
|
|
87
91
|
then edit the partials in your app's `app/views/breadcrumble/` directory.
|
88
92
|
|
93
|
+
### Theme
|
94
|
+
|
95
|
+
You can choose template themes in a single application. Create a directory with theme name in your app's `app/views/breadcrumble/` and create custom template files.
|
96
|
+
|
97
|
+
```
|
98
|
+
$ rails g breadcrumble:views
|
99
|
+
$ cd app/views/breadcrumble
|
100
|
+
$ mkdir my_custom_theme
|
101
|
+
$ cp _*.erb my_custom_theme/
|
102
|
+
```
|
103
|
+
|
104
|
+
And then calling `render_breadcrumbs` or `render_breadcrumb_trails` method with theme option.
|
105
|
+
|
106
|
+
```
|
107
|
+
<%= render_breadcrumbs(theme: 'my_custom_theme') %>
|
108
|
+
<%= render_breadcrumb_trails(theme: 'my_custom_theme') %>
|
109
|
+
```
|
110
|
+
|
89
111
|
## Live Demo
|
112
|
+
|
90
113
|
<http://breadcrumble.herokuapp.com/>
|
91
114
|
|
92
115
|
## Contributing
|
93
116
|
|
94
117
|
### Easy way
|
118
|
+
|
95
119
|
It's easy to contribute. You only push the star button!
|
96
120
|
|
97
121
|
### The other way
|
data/breadcrumble.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/breadcrumble/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["ma2ge"]
|
6
6
|
gem.email = ["takayuki.1229@gmail.com"]
|
7
|
-
gem.description = "A breadcrumbs plugin for Ruby on Rails 3
|
8
|
-
gem.summary = "Breadcrumble is a simple breadcrumb navigation plugin for Ruby on Rails 3
|
7
|
+
gem.description = "A breadcrumbs plugin for Ruby on Rails 3, Rails 4.0 and 4.1."
|
8
|
+
gem.summary = "Breadcrumble is a simple breadcrumb navigation plugin for Ruby on Rails 3, Rails 4.0 and 4.1."
|
9
9
|
gem.homepage = "https://github.com/ma2gedev/breadcrumble"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
@@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_dependency "rails", ['>= 4.0.0']
|
19
19
|
gem.add_development_dependency "sqlite3"
|
20
|
-
gem.add_development_dependency "rspec-rails"
|
20
|
+
gem.add_development_dependency "rspec-rails", '~> 3.0'
|
21
21
|
gem.add_development_dependency "coveralls"
|
22
22
|
end
|
@@ -7,22 +7,32 @@ module Breadcrumble
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module ClassMethods
|
10
|
-
|
10
|
+
# Add a breadcrumb.
|
11
|
+
# @param filter_options filter_options passed before_filter method
|
12
|
+
# @example
|
13
|
+
# add_breadcrumb("home", home_url)
|
14
|
+
# add_breadcrumb(-> context { context.title }, -> context { context.sample_path })
|
15
|
+
def add_breadcrumb(name, url = nil, filter_options = {})
|
11
16
|
before_filter(filter_options) do |controller|
|
12
|
-
controller.send
|
17
|
+
controller.send(:add_breadcrumb, name, url)
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
16
|
-
|
21
|
+
# Add a breadcrumb to breadcrumb trail.
|
22
|
+
# @param trail_index index of breadcrumb trail
|
23
|
+
# @param filter_options filter_options passed before_filter method
|
24
|
+
# @example
|
25
|
+
# add_breadcrumb_to("level 1", "level 1 url", 0, only: :show)
|
26
|
+
def add_breadcrumb_to(name, url, trail_index, filter_options = {})
|
17
27
|
before_filter(filter_options) do |controller|
|
18
|
-
controller.send
|
28
|
+
controller.send(:add_breadcrumb_to, name, url, trail_index)
|
19
29
|
end
|
20
30
|
end
|
21
31
|
|
22
|
-
def add_breadcrumbs
|
32
|
+
def add_breadcrumbs(*args)
|
23
33
|
before_filter do |controller|
|
24
34
|
args.each do |arg|
|
25
|
-
controller.send
|
35
|
+
controller.send(:add_breadcrumb, arg[0], arg[1])
|
26
36
|
end
|
27
37
|
end
|
28
38
|
end
|
@@ -30,12 +40,20 @@ module Breadcrumble
|
|
30
40
|
|
31
41
|
protected
|
32
42
|
|
33
|
-
|
34
|
-
|
43
|
+
# Add a breadcrumb.
|
44
|
+
# @example
|
45
|
+
# add_breadcrumb("index", controller: 'sample', action: 'index')
|
46
|
+
# add_breadcrumb("show", show_path(123))
|
47
|
+
def add_breadcrumb(name, url = nil)
|
48
|
+
add_breadcrumb_to(name, url, 0)
|
35
49
|
end
|
36
50
|
|
37
|
-
|
38
|
-
|
51
|
+
# Add a breadcrumb to breadcrumb trail.
|
52
|
+
# @param trail_index index of breadcrumb trail
|
53
|
+
# @example
|
54
|
+
# add_breadcrumb_to("level 1", "level 1 url", 0)
|
55
|
+
def add_breadcrumb_to(name, url, trail_index)
|
56
|
+
breadcrumb_trails
|
39
57
|
@breadcrumb_trails[trail_index] ||= []
|
40
58
|
@breadcrumb_trails[trail_index] << {
|
41
59
|
name: case name
|
@@ -49,18 +67,20 @@ module Breadcrumble
|
|
49
67
|
}
|
50
68
|
end
|
51
69
|
|
52
|
-
def add_breadcrumbs
|
70
|
+
def add_breadcrumbs(*args)
|
53
71
|
args.each do |arg|
|
54
|
-
add_breadcrumb
|
72
|
+
add_breadcrumb(arg[0], arg[1])
|
55
73
|
end
|
56
74
|
end
|
57
75
|
|
76
|
+
# Array of the breadcrumb trails.
|
58
77
|
def breadcrumb_trails
|
59
78
|
@breadcrumb_trails ||= []
|
60
79
|
end
|
61
80
|
|
81
|
+
# Array of the breadcrumbs.
|
62
82
|
def breadcrumbs
|
63
|
-
|
83
|
+
breadcrumb_trails.first || []
|
64
84
|
end
|
65
85
|
end
|
66
86
|
end
|
@@ -1,11 +1,20 @@
|
|
1
1
|
module Breadcrumble
|
2
2
|
module ActionView
|
3
|
-
|
4
|
-
|
3
|
+
# Render breadcrumbs.
|
4
|
+
def render_breadcrumbs(options = {})
|
5
|
+
_render_breadcrumb('breadcrumb', options)
|
5
6
|
end
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
# Render breadcrumb trails.
|
9
|
+
def render_breadcrumb_trails(options = {})
|
10
|
+
_render_breadcrumb('breadcrumb_trails', options)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def _render_breadcrumb(path, options)
|
16
|
+
theme = options[:theme] ? "#{options[:theme]}/" : ''
|
17
|
+
render partial: "breadcrumble/#{theme}#{path}", locals: options
|
9
18
|
end
|
10
19
|
end
|
11
20
|
end
|
data/lib/breadcrumble/railtie.rb
CHANGED
data/lib/breadcrumble/version.rb
CHANGED
@@ -5,7 +5,11 @@ module Breadcrumble
|
|
5
5
|
desc 'This generator generates breadcrumbs partial template.'
|
6
6
|
|
7
7
|
def generate_views
|
8
|
-
names = [
|
8
|
+
names = [
|
9
|
+
'_breadcrumb.html.erb',
|
10
|
+
'_breadcrumb_trails.html.erb',
|
11
|
+
'_breadcrumb_trail.html.erb'
|
12
|
+
]
|
9
13
|
names.each do |name|
|
10
14
|
copy_file "#{name}", "app/views/breadcrumble/#{name}"
|
11
15
|
end
|
@@ -2,23 +2,23 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe ApplicationController do
|
4
4
|
controller do
|
5
|
-
add_breadcrumbs
|
6
|
-
add_breadcrumb
|
7
|
-
add_breadcrumb_to
|
8
|
-
add_breadcrumb_to
|
5
|
+
add_breadcrumbs(['root', '/'], ['nil', nil])
|
6
|
+
add_breadcrumb(-> c { c.examples_url }, -> c { c.examples_path })
|
7
|
+
add_breadcrumb_to(-> c { c.examples_url }, -> c { c.examples_path }, 1, only: :show)
|
8
|
+
add_breadcrumb_to('multi third 1', 'multi third url 1', 2, only: :show)
|
9
9
|
|
10
10
|
def index
|
11
|
-
add_breadcrumb
|
12
|
-
add_breadcrumb
|
13
|
-
add_breadcrumbs
|
11
|
+
add_breadcrumb('examples', controller: 'examples', action: 'index', only_path: true)
|
12
|
+
add_breadcrumb('example', example_path(123))
|
13
|
+
add_breadcrumbs(['crumb1'], ['crumb2', -> c { example_path(1234) }])
|
14
14
|
render text: 'test'
|
15
15
|
end
|
16
16
|
|
17
17
|
def show
|
18
|
-
add_breadcrumb_to
|
19
|
-
add_breadcrumb_to
|
20
|
-
add_breadcrumb_to
|
21
|
-
add_breadcrumb_to
|
18
|
+
add_breadcrumb_to('examples', {controller: 'examples', action: 'index', only_path: true}, 1)
|
19
|
+
add_breadcrumb_to('example', example_path(123), 1)
|
20
|
+
add_breadcrumb_to('multi third 2', 'multi third url 2', 2)
|
21
|
+
add_breadcrumb_to('multi third 3', 'multi third url 3', 2)
|
22
22
|
render text: 'test'
|
23
23
|
end
|
24
24
|
end
|
@@ -30,40 +30,40 @@ describe ApplicationController do
|
|
30
30
|
|
31
31
|
context '.add_breadcrumbs' do
|
32
32
|
it 'having breadcrumbs' do
|
33
|
-
|
34
|
-
assigns(:breadcrumb_trails)[0][0].
|
33
|
+
is_expected.to be_success
|
34
|
+
expect(assigns(:breadcrumb_trails)[0][0]).to eq({name: 'root', url: '/'})
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'url has nil value' do
|
38
|
-
|
39
|
-
assigns(:breadcrumb_trails)[0][1].
|
38
|
+
is_expected.to be_success
|
39
|
+
expect(assigns(:breadcrumb_trails)[0][1]).to eq({name: 'nil', url: nil})
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
context '.add_breadcrumb' do
|
44
44
|
it 'execute lambda in controller instance context' do
|
45
|
-
|
46
|
-
assigns(:breadcrumb_trails)[0][2].
|
45
|
+
is_expected.to be_success
|
46
|
+
expect(assigns(:breadcrumb_trails)[0][2]).to eq({name: 'http://test.host/examples', url: '/examples'})
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
context '#add_breadcrumb' do
|
51
51
|
it 'url options' do
|
52
|
-
|
53
|
-
assigns(:breadcrumb_trails)[0][3].
|
52
|
+
is_expected.to be_success
|
53
|
+
expect(assigns(:breadcrumb_trails)[0][3]).to eq({name: 'examples', url: '/examples'})
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'example_path' do
|
57
|
-
|
58
|
-
assigns(:breadcrumb_trails)[0][4].
|
57
|
+
is_expected.to be_success
|
58
|
+
expect(assigns(:breadcrumb_trails)[0][4]).to eq({name: 'example', url: '/examples/123'})
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
context '#add_breadcrumbs' do
|
63
63
|
it 'sequence is starting from first argument' do
|
64
|
-
|
65
|
-
assigns(:breadcrumb_trails)[0][5].
|
66
|
-
assigns(:breadcrumb_trails)[0][6].
|
64
|
+
is_expected.to be_success
|
65
|
+
expect(assigns(:breadcrumb_trails)[0][5]).to eq({name: 'crumb1', url: nil})
|
66
|
+
expect(assigns(:breadcrumb_trails)[0][6]).to eq({name: 'crumb2', url: '/examples/1234'})
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -75,17 +75,17 @@ describe ApplicationController do
|
|
75
75
|
|
76
76
|
context 'multiple breadcrumbs' do
|
77
77
|
it 'having breadcrumbs in second trail' do
|
78
|
-
|
79
|
-
assigns(:breadcrumb_trails)[1][0].
|
80
|
-
assigns(:breadcrumb_trails)[1][1].
|
81
|
-
assigns(:breadcrumb_trails)[1][2].
|
78
|
+
is_expected.to be_success
|
79
|
+
expect(assigns(:breadcrumb_trails)[1][0]).to eq({name: 'http://test.host/examples', url: '/examples'})
|
80
|
+
expect(assigns(:breadcrumb_trails)[1][1]).to eq({name: 'examples', url: '/examples'})
|
81
|
+
expect(assigns(:breadcrumb_trails)[1][2]).to eq({name: 'example', url: '/examples/123'})
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'having breadcrumbs in third trail' do
|
85
|
-
|
86
|
-
assigns(:breadcrumb_trails)[2][0].
|
87
|
-
assigns(:breadcrumb_trails)[2][1].
|
88
|
-
assigns(:breadcrumb_trails)[2][2].
|
85
|
+
is_expected.to be_success
|
86
|
+
expect(assigns(:breadcrumb_trails)[2][0]).to eq({name: 'multi third 1', url: 'multi third url 1'})
|
87
|
+
expect(assigns(:breadcrumb_trails)[2][1]).to eq({name: 'multi third 2', url: 'multi third url 2'})
|
88
|
+
expect(assigns(:breadcrumb_trails)[2][2]).to eq({name: 'multi third 3', url: 'multi third url 3'})
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -7,13 +7,13 @@ describe ExamplesController do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'breadcrumbs' do
|
10
|
-
|
11
|
-
controller.send(:breadcrumbs).
|
10
|
+
is_expected.to be_success
|
11
|
+
expect(controller.send(:breadcrumbs)).to eq([])
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'breadcrumb_trails' do
|
15
|
-
|
16
|
-
controller.send(:breadcrumb_trails).
|
15
|
+
is_expected.to be_success
|
16
|
+
expect(controller.send(:breadcrumb_trails)).to eq([])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
test breadcrumb theme
|
2
|
+
<div>
|
3
|
+
<% breadcrumbs.each_with_index do |crumb, i| %>
|
4
|
+
<%= '>' unless i == 0 %>
|
5
|
+
<span itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
6
|
+
<% span_title = content_tag(:span, crumb[:name], itemprop: "title") %>
|
7
|
+
<% if crumb[:url] == nil %>
|
8
|
+
<%= span_title %>
|
9
|
+
<% else %>
|
10
|
+
<%= link_to_unless_current span_title, crumb[:url], itemprop: "url" %>
|
11
|
+
<% end %>
|
12
|
+
</span>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<span itemscope="child" itemtype="http://data-vocabulary.org/Breadcrumb">
|
2
|
+
<% span_title = content_tag(:span, trail[0][:name], itemprop: "title") %>
|
3
|
+
<% if trail[0][:url] == nil %>
|
4
|
+
<%= span_title %>
|
5
|
+
<% else %>
|
6
|
+
<%= link_to_unless_current span_title, trail[0][:url], itemprop: "url" %>
|
7
|
+
<% end %>
|
8
|
+
<% if trail.size > 1 %>
|
9
|
+
><%= render partial: 'breadcrumble/breadcrumb_trail', locals: { trail: trail.drop(1) } %>
|
10
|
+
<% end %>
|
11
|
+
</span>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
test breadcrumb_trails theme
|
2
|
+
<div>
|
3
|
+
<% breadcrumb_trails.each do |trail| %>
|
4
|
+
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
|
5
|
+
<% span_title = content_tag(:span, trail[0][:name], itemprop: "title") %>
|
6
|
+
<% if trail[0][:url] == nil %>
|
7
|
+
<%= span_title %>
|
8
|
+
<% else %>
|
9
|
+
<%= link_to_unless_current span_title, trail[0][:url], itemprop: "url" %>
|
10
|
+
<% end %>
|
11
|
+
<% if trail.size > 1 %>
|
12
|
+
><%= render partial: 'breadcrumble/breadcrumb_trail', locals: { trail: trail.drop(1) } %>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
@@ -3,15 +3,64 @@ require 'spec_helper'
|
|
3
3
|
describe 'Breadcrumble::ActionView' do
|
4
4
|
context '#render_breadcrumbs' do
|
5
5
|
before do
|
6
|
-
helper.
|
6
|
+
allow(helper).to receive(:breadcrumbs).and_return([
|
7
7
|
{ name: 'root_name', url: '/root_url' },
|
8
8
|
{ name: 'test_name', url: '/test_url' }
|
9
9
|
])
|
10
10
|
end
|
11
11
|
subject { helper.render_breadcrumbs }
|
12
|
-
it {
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
12
|
+
it { is_expected.to match('root_name') }
|
13
|
+
it { is_expected.to match('root_url') }
|
14
|
+
it { is_expected.to match('test_name') }
|
15
|
+
it { is_expected.to match('test_url') }
|
16
|
+
end
|
17
|
+
context '#render_breadcrumb_trails' do
|
18
|
+
before do
|
19
|
+
allow(helper).to receive(:breadcrumb_trails).and_return([
|
20
|
+
[
|
21
|
+
{ name: 'trail1_level1', url: '/trail1_level1_url' },
|
22
|
+
{ name: 'trail1_level2', url: '/trail1_level2_url' }
|
23
|
+
],
|
24
|
+
[
|
25
|
+
{ name: 'trail2_level1', url: '/trail2_level1_url' },
|
26
|
+
{ name: 'trail2_level2', url: '/trail2_level2_url' }
|
27
|
+
]
|
28
|
+
])
|
29
|
+
end
|
30
|
+
subject { helper.render_breadcrumb_trails }
|
31
|
+
it { is_expected.to match('trail1_level1') }
|
32
|
+
it { is_expected.to match('trail1_level1_url') }
|
33
|
+
it { is_expected.to match('trail1_level2') }
|
34
|
+
it { is_expected.to match('trail1_level2_url') }
|
35
|
+
it { is_expected.to match('trail2_level1') }
|
36
|
+
it { is_expected.to match('trail2_level1_url') }
|
37
|
+
it { is_expected.to match('trail2_level2') }
|
38
|
+
it { is_expected.to match('trail2_level2_url') }
|
39
|
+
end
|
40
|
+
context '#render_breadcrumbs with theme' do
|
41
|
+
before do
|
42
|
+
allow(helper).to receive(:breadcrumbs).and_return([
|
43
|
+
{ name: 'root_name', url: '/root_url' },
|
44
|
+
{ name: 'test_name', url: '/test_url' }
|
45
|
+
])
|
46
|
+
end
|
47
|
+
subject { helper.render_breadcrumbs(theme: 'test') }
|
48
|
+
it { is_expected.to match('test breadcrumb theme') }
|
49
|
+
end
|
50
|
+
context '#render_breadcrumb_trails with theme' do
|
51
|
+
before do
|
52
|
+
allow(helper).to receive(:breadcrumb_trails).and_return([
|
53
|
+
[
|
54
|
+
{ name: 'trail1_level1', url: '/trail1_level1_url' },
|
55
|
+
{ name: 'trail1_level2', url: '/trail1_level2_url' }
|
56
|
+
],
|
57
|
+
[
|
58
|
+
{ name: 'trail2_level1', url: '/trail2_level1_url' },
|
59
|
+
{ name: 'trail2_level2', url: '/trail2_level2_url' }
|
60
|
+
]
|
61
|
+
])
|
62
|
+
end
|
63
|
+
subject { helper.render_breadcrumb_trails(theme: 'test') }
|
64
|
+
it { is_expected.to match('test breadcrumb_trails theme') }
|
16
65
|
end
|
17
66
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
ENV["RAILS_ENV"] ||= 'test'
|
2
2
|
require File.expand_path("../dummy/config/environment", __FILE__)
|
3
3
|
require 'rspec/rails'
|
4
|
-
require 'rspec/autorun'
|
5
4
|
|
6
5
|
require 'coveralls'
|
7
6
|
Coveralls.wear!
|
@@ -11,4 +10,14 @@ Coveralls.wear!
|
|
11
10
|
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
12
11
|
|
13
12
|
RSpec.configure do |config|
|
13
|
+
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
14
|
+
# from the file location. You can explicitly opt-in to the feature using this
|
15
|
+
# config option.
|
16
|
+
# To explicitly tag specs without using automatic inference, set the `:type`
|
17
|
+
# metadata manually:
|
18
|
+
#
|
19
|
+
# describe ThingsController, :type => :controller do
|
20
|
+
# # Equivalent to being in spec/controllers
|
21
|
+
# end
|
22
|
+
config.infer_spec_type_from_file_location!
|
14
23
|
end
|
metadata
CHANGED
@@ -1,81 +1,72 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breadcrumble
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
5
|
-
prerelease:
|
4
|
+
version: 4.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- ma2ge
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 4.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 4.0.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: sqlite3
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec-rails
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
47
|
+
version: '3.0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
54
|
+
version: '3.0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: coveralls
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
|
-
description: A breadcrumbs plugin for Ruby on Rails 3
|
69
|
+
description: A breadcrumbs plugin for Ruby on Rails 3, Rails 4.0 and 4.1.
|
79
70
|
email:
|
80
71
|
- takayuki.1229@gmail.com
|
81
72
|
executables: []
|
@@ -83,6 +74,7 @@ extensions: []
|
|
83
74
|
extra_rdoc_files: []
|
84
75
|
files:
|
85
76
|
- .gitignore
|
77
|
+
- .rubocop.yml
|
86
78
|
- .travis.yml
|
87
79
|
- Gemfile
|
88
80
|
- LICENSE
|
@@ -106,6 +98,9 @@ files:
|
|
106
98
|
- spec/dummy/app/controllers/concerns/.keep
|
107
99
|
- spec/dummy/app/controllers/examples_controller.rb
|
108
100
|
- spec/dummy/app/helpers/application_helper.rb
|
101
|
+
- spec/dummy/app/views/breadcrumble/test/_breadcrumb.html.erb
|
102
|
+
- spec/dummy/app/views/breadcrumble/test/_breadcrumb_trail.html.erb
|
103
|
+
- spec/dummy/app/views/breadcrumble/test/_breadcrumb_trails.html.erb
|
109
104
|
- spec/dummy/app/views/layouts/application.html.erb
|
110
105
|
- spec/dummy/bin/bundle
|
111
106
|
- spec/dummy/bin/rails
|
@@ -132,35 +127,28 @@ files:
|
|
132
127
|
- spec/spec_helper.rb
|
133
128
|
homepage: https://github.com/ma2gedev/breadcrumble
|
134
129
|
licenses: []
|
130
|
+
metadata: {}
|
135
131
|
post_install_message:
|
136
132
|
rdoc_options: []
|
137
133
|
require_paths:
|
138
134
|
- lib
|
139
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
-
none: false
|
141
136
|
requirements:
|
142
|
-
- -
|
137
|
+
- - '>='
|
143
138
|
- !ruby/object:Gem::Version
|
144
139
|
version: '0'
|
145
|
-
segments:
|
146
|
-
- 0
|
147
|
-
hash: -2621287384343674057
|
148
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
-
none: false
|
150
141
|
requirements:
|
151
|
-
- -
|
142
|
+
- - '>='
|
152
143
|
- !ruby/object:Gem::Version
|
153
144
|
version: '0'
|
154
|
-
segments:
|
155
|
-
- 0
|
156
|
-
hash: -2621287384343674057
|
157
145
|
requirements: []
|
158
146
|
rubyforge_project:
|
159
|
-
rubygems_version:
|
147
|
+
rubygems_version: 2.0.3
|
160
148
|
signing_key:
|
161
|
-
specification_version:
|
162
|
-
summary: Breadcrumble is a simple breadcrumb navigation plugin for Ruby on Rails 3
|
163
|
-
|
149
|
+
specification_version: 4
|
150
|
+
summary: Breadcrumble is a simple breadcrumb navigation plugin for Ruby on Rails 3,
|
151
|
+
Rails 4.0 and 4.1.
|
164
152
|
test_files:
|
165
153
|
- spec/controllers/application_controller_spec.rb
|
166
154
|
- spec/controllers/examples_controller_spec.rb
|
@@ -169,6 +157,9 @@ test_files:
|
|
169
157
|
- spec/dummy/app/controllers/concerns/.keep
|
170
158
|
- spec/dummy/app/controllers/examples_controller.rb
|
171
159
|
- spec/dummy/app/helpers/application_helper.rb
|
160
|
+
- spec/dummy/app/views/breadcrumble/test/_breadcrumb.html.erb
|
161
|
+
- spec/dummy/app/views/breadcrumble/test/_breadcrumb_trail.html.erb
|
162
|
+
- spec/dummy/app/views/breadcrumble/test/_breadcrumb_trails.html.erb
|
172
163
|
- spec/dummy/app/views/layouts/application.html.erb
|
173
164
|
- spec/dummy/bin/bundle
|
174
165
|
- spec/dummy/bin/rails
|