loaf 0.6.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +67 -12
  3. data/LICENSE.txt +1 -1
  4. data/README.md +82 -39
  5. data/lib/loaf.rb +1 -0
  6. data/lib/loaf/configuration.rb +0 -12
  7. data/lib/loaf/controller_extensions.rb +9 -1
  8. data/lib/loaf/errors.rb +1 -1
  9. data/lib/loaf/translation.rb +12 -4
  10. data/lib/loaf/version.rb +3 -1
  11. data/lib/loaf/view_extensions.rb +16 -8
  12. metadata +19 -161
  13. data/.document +0 -5
  14. data/.gitignore +0 -23
  15. data/.rspec +0 -2
  16. data/.travis.yml +0 -48
  17. data/Appraisals +0 -36
  18. data/Gemfile +0 -19
  19. data/Gemfile.lock +0 -185
  20. data/Rakefile +0 -10
  21. data/assets/loaf_logo.png +0 -0
  22. data/bin/appraisal +0 -16
  23. data/bin/rake +0 -16
  24. data/bin/setup +0 -7
  25. data/gemfiles/rails3.2.gemfile +0 -24
  26. data/gemfiles/rails4.0.gemfile +0 -24
  27. data/gemfiles/rails4.1.gemfile +0 -23
  28. data/gemfiles/rails4.2.gemfile +0 -23
  29. data/gemfiles/rails5.0.gemfile +0 -22
  30. data/gemfiles/rails5.1.gemfile +0 -22
  31. data/lib/loaf/crumb_formatter.rb +0 -24
  32. data/loaf.gemspec +0 -28
  33. data/spec/integration/breadcrumb_trail_spec.rb +0 -60
  34. data/spec/integration/configuration_spec.rb +0 -12
  35. data/spec/rails_app/Rakefile +0 -8
  36. data/spec/rails_app/app/controllers/application_controller.rb +0 -5
  37. data/spec/rails_app/app/controllers/comments_controller.rb +0 -17
  38. data/spec/rails_app/app/controllers/home_controller.rb +0 -4
  39. data/spec/rails_app/app/controllers/posts_controller.rb +0 -20
  40. data/spec/rails_app/app/views/comments/index.html.erb +0 -1
  41. data/spec/rails_app/app/views/home/index.html.erb +0 -1
  42. data/spec/rails_app/app/views/layouts/_breadcrumbs.html.erb +0 -12
  43. data/spec/rails_app/app/views/layouts/application.html.erb +0 -14
  44. data/spec/rails_app/app/views/posts/index.html.erb +0 -1
  45. data/spec/rails_app/app/views/posts/new.html.erb +0 -4
  46. data/spec/rails_app/app/views/posts/show.html.erb +0 -1
  47. data/spec/rails_app/config.ru +0 -4
  48. data/spec/rails_app/config/application.rb +0 -48
  49. data/spec/rails_app/config/boot.rb +0 -10
  50. data/spec/rails_app/config/database.yml +0 -25
  51. data/spec/rails_app/config/environment.rb +0 -5
  52. data/spec/rails_app/config/environments/development.rb +0 -32
  53. data/spec/rails_app/config/environments/production.rb +0 -62
  54. data/spec/rails_app/config/environments/test.rb +0 -41
  55. data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
  56. data/spec/rails_app/config/initializers/inflections.rb +0 -10
  57. data/spec/rails_app/config/initializers/mime_types.rb +0 -5
  58. data/spec/rails_app/config/initializers/secret_token.rb +0 -7
  59. data/spec/rails_app/config/initializers/session_store.rb +0 -8
  60. data/spec/rails_app/config/initializers/wrap_parameters.rb +0 -14
  61. data/spec/rails_app/config/locales/en.yml +0 -5
  62. data/spec/rails_app/config/locales/loaf.en.yml +0 -6
  63. data/spec/rails_app/config/routes.rb +0 -7
  64. data/spec/rails_app/config/secrets.yml +0 -22
  65. data/spec/rails_app/public/404.html +0 -26
  66. data/spec/rails_app/public/422.html +0 -26
  67. data/spec/rails_app/public/500.html +0 -26
  68. data/spec/rails_app/public/favicon.ico +0 -0
  69. data/spec/rails_app/public/robots.txt +0 -5
  70. data/spec/spec_helper.rb +0 -52
  71. data/spec/support/capybara.rb +0 -8
  72. data/spec/support/dummy_controller.rb +0 -9
  73. data/spec/support/dummy_view.rb +0 -47
  74. data/spec/support/load_routes.rb +0 -4
  75. data/spec/unit/configuration_spec.rb +0 -39
  76. data/spec/unit/controller_extensions_spec.rb +0 -54
  77. data/spec/unit/crumb_formatter_spec.rb +0 -36
  78. data/spec/unit/crumb_spec.rb +0 -15
  79. data/spec/unit/generators/install_generator_spec.rb +0 -17
  80. data/spec/unit/options_validator_spec.rb +0 -15
  81. data/spec/unit/translation_spec.rb +0 -22
  82. data/spec/unit/view_extensions/breadcrumb_spec.rb +0 -22
  83. data/spec/unit/view_extensions/breadcrumb_trail_spec.rb +0 -232
  84. data/spec/unit/view_extensions/has_breadcrumbs_spec.rb +0 -10
  85. data/tasks/console.rake +0 -10
  86. data/tasks/coverage.rake +0 -11
  87. data/tasks/spec.rake +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ff7903e3c4af9741df52746a183ab5ce64be0390
4
- data.tar.gz: 2b2361cb571bc40e83dbaf37a58982a0fdcb8903
2
+ SHA256:
3
+ metadata.gz: 194d167e400d76180e87b1d93637c9c3cf59048dbe03ea32c416d48236778e15
4
+ data.tar.gz: 7f5c9f0d0c5f92e541b282a281327ccd327f057b844d9970e8a086ee05b735d6
5
5
  SHA512:
6
- metadata.gz: 6649ee9688af545490a3697cf277423b9f9db9b2fb35ebfde2655970fc8ea41fbfe027ee0925a8fa75b3e41b636e3f1f02a4e4f688478793657bb110f3033c0d
7
- data.tar.gz: 4cdc8efd1ff9f7eac3adfbbdaadd6e5ac1ef9496680d55de424ab3b73f06080b84b1b2329b5bebf8bb736d5f65578c74fd3f54ce23009982437526aa23875283
6
+ metadata.gz: 30f9a6c9eb2e4ca2513d1ec3c95dff3038a10d4fd55f12391a9dac5568ad34eef28c23f3ef22a2fe8f810e954674a759e1537255929e18fe117dba550a644b0c
7
+ data.tar.gz: 47ea3af5b670ae2d02ecddae7a71d70a96206487f93ef415853d18a222dc2b63729d485743bd0d2249965fd6918150facfe80b4626c0c662f45f1d302af0004c
@@ -1,5 +1,55 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.10.0] - 2020-11-21
4
+
5
+ ### Changed
6
+ * Reduce gem dependencies to `railties` by Christian Sutter (@csutter)
7
+ * Use `URI::DEFAULT_PARSER` instead of deprecated `URI.parser` by (@dsazup)
8
+ * Support Rails 6.1 in tests
9
+
10
+ ### Fixed
11
+ * Fix #breadcrumb_trail to allow overriding the match option
12
+ * Fix #breadcrumb_trail to return enumerator that includes passed in match option
13
+
14
+ ## [v0.9.0] - 2020-01-19
15
+
16
+ ### Changed
17
+ * Change gemspec to include metadata, license info and remove test artifacts
18
+ * Change to update testing to include Ruby 2.7
19
+ * Change to limit Ruby to 1.9.3 or greater
20
+
21
+ ### Fixed
22
+ * Fix Ruby 2.7 warnings
23
+
24
+ ## [v0.8.1] - 2019-02-04
25
+
26
+ ### Added
27
+ * Add console binary
28
+
29
+ ### Changed
30
+ * Remove rake & appraisal binaries
31
+ * Change setup binary to load correct env
32
+ * Change gemspec to load files directly in without using git
33
+
34
+ ## [v0.8.0] - 2018-08-07
35
+
36
+ ### Changed
37
+ * Change Translation to skip translating nil and empty string
38
+ * Change view extension to only lookup breadcrumb name translation
39
+ * Remove Configuration #crumb_length and #capitalize options
40
+ * Remove CrumbFormatter to skip truncating and formatting crumb names
41
+
42
+ ## Fix
43
+ * Fix issue with breadcrumb names being modified
44
+
45
+ ## [v0.7.0] - 2018-06-20
46
+
47
+ ### Added
48
+ * Add test setup for Rails 5.2 by Brendon Muir(@brendon)
49
+
50
+ ### Changed
51
+ * Change controller level #breadcrumb helper to accept Proc as name without controller parameter by Brendon Muir(@brendon)
52
+
3
53
  ## [v0.6.2] - 2018-03-30
4
54
 
5
55
  ### Added
@@ -59,7 +109,7 @@
59
109
  ### Fixed
60
110
  * Fix bug with url parameter to allow for regular rails path variables
61
111
 
62
- ## [0.3.0] - 2012-02-25
112
+ ## [v0.3.0] - 2012-02-25
63
113
 
64
114
  ### Added
65
115
  * Add loaf gem errors
@@ -70,13 +120,13 @@
70
120
  * Renamed main gem helpers for adding breadcrumbs from `add_breadcrumb` to
71
121
  `breadcrumb`, both inside controllers and views.
72
122
 
73
- ## [0.2.1] - 2012-02-22
123
+ ## [v0.2.1] - 2012-02-22
74
124
 
75
125
  ### Added
76
126
  * Add more integration tests and fixed bug with adding breadcrumbs inside view
77
127
  * Add specs for controller extensions
78
128
 
79
- ## [0.2.0] - 2012-02-18
129
+ ## [v0.2.0] - 2012-02-18
80
130
 
81
131
  ### Added
82
132
  * Add integration tests for breadcrumbs view rendering
@@ -92,12 +142,17 @@
92
142
 
93
143
  * Initial implementation and release
94
144
 
95
- [v0.6.2]: https://github.com/piotrmurach/tty-spinner/compare/v0.6.1...v0.6.2
96
- [v0.6.1]: https://github.com/piotrmurach/tty-spinner/compare/v0.6.0...v0.6.1
97
- [v0.6.0]: https://github.com/piotrmurach/tty-spinner/compare/v0.5.0...v0.6.0
98
- [v0.5.0]: https://github.com/piotrmurach/tty-spinner/compare/v0.4.0...v0.5.0
99
- [v0.4.0]: https://github.com/piotrmurach/tty-spinner/compare/v0.3.0...v0.4.0
100
- [v0.3.0]: https://github.com/piotrmurach/tty-spinner/compare/v0.2.1...v0.3.0
101
- [v0.2.1]: https://github.com/piotrmurach/tty-spinner/compare/v0.2.0...v0.2.1
102
- [v0.2.0]: https://github.com/piotrmurach/tty-spinner/compare/v0.1.0...v0.2.0
103
- [v0.1.0]: https://github.com/piotrmurach/tty-spinner/compare/v0.1.0...HEAD
145
+ [v0.10.0]: https://github.com/piotrmurach/loaf/compare/v0.9.0...v0.10.0
146
+ [v0.9.0]: https://github.com/piotrmurach/loaf/compare/v0.8.1...v0.9.0
147
+ [v0.8.1]: https://github.com/piotrmurach/loaf/compare/v0.8.0...v0.8.1
148
+ [v0.8.0]: https://github.com/piotrmurach/loaf/compare/v0.7.0...v0.8.0
149
+ [v0.7.0]: https://github.com/piotrmurach/loaf/compare/v0.6.2...v0.7.0
150
+ [v0.6.2]: https://github.com/piotrmurach/loaf/compare/v0.6.1...v0.6.2
151
+ [v0.6.1]: https://github.com/piotrmurach/loaf/compare/v0.6.0...v0.6.1
152
+ [v0.6.0]: https://github.com/piotrmurach/loaf/compare/v0.5.0...v0.6.0
153
+ [v0.5.0]: https://github.com/piotrmurach/loaf/compare/v0.4.0...v0.5.0
154
+ [v0.4.0]: https://github.com/piotrmurach/loaf/compare/v0.3.0...v0.4.0
155
+ [v0.3.0]: https://github.com/piotrmurach/loaf/compare/v0.2.1...v0.3.0
156
+ [v0.2.1]: https://github.com/piotrmurach/loaf/compare/v0.2.0...v0.2.1
157
+ [v0.2.0]: https://github.com/piotrmurach/loaf/compare/v0.1.0...v0.2.0
158
+ [v0.1.0]: https://github.com/piotrmurach/loaf/compare/v0.1.0...HEAD
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Piotr Murach
1
+ Copyright (c) 2011 Piotr Murach (https://piotrmurach.com)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,20 +1,18 @@
1
1
  <div align="center">
2
- <img width="237" src="https://cdn.rawgit.com/piotrmurach/loaf/master/assets/loaf_logo.png" alt="loaf logo" />
2
+ <img width="237" src="https://github.com/piotrmurach/loaf/blob/master/assets/loaf_logo.png" alt="Loaf gem logo" />
3
3
  </div>
4
4
 
5
5
  # Loaf
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/loaf.svg)][gem]
8
- [![Build Status](https://secure.travis-ci.org/piotrmurach/loaf.svg?branch=master)][travis]
8
+ [![Actions CI](https://github.com/piotrmurach/loaf/workflows/CI/badge.svg?branch=master)][gh_actions_ci]
9
9
  [![Maintainability](https://api.codeclimate.com/v1/badges/966193dafa3895766977/maintainability)][codeclimate]
10
- [![Dependency Status](https://gemnasium.com/piotrmurach/loaf.svg?travis)][gemnasium]
11
10
  [![Coverage Status](https://coveralls.io/repos/github/piotrmurach/loaf/badge.svg?branch=master)][coveralls]
12
11
  [![Inline docs](http://inch-ci.org/github/piotrmurach/loaf.svg?branch=master)][inchpages]
13
12
 
14
13
  [gem]: http://badge.fury.io/rb/loaf
15
- [travis]: http://travis-ci.org/piotrmurach/loaf
14
+ [gh_actions_ci]: https://github.com/piotrmurach/loaf/actions?query=workflow%3ACI
16
15
  [codeclimate]: https://codeclimate.com/github/piotrmurach/loaf/maintainability
17
- [gemnasium]: https://gemnasium.com/piotrmurach/loaf
18
16
  [coveralls]: https://coveralls.io/github/piotrmurach/loaf
19
17
  [inchpages]: http://inch-ci.org/github/piotrmurach/loaf
20
18
 
@@ -33,7 +31,7 @@
33
31
  Add this line to your application's Gemfile:
34
32
 
35
33
  ```ruby
36
- gem 'loaf'
34
+ gem "loaf"
37
35
  ```
38
36
 
39
37
  And then execute:
@@ -75,7 +73,7 @@ In order to add breadcrumbs in controller use `breadcrumb` method ([see 2.1](#21
75
73
  ```ruby
76
74
  class Blog::CategoriesController < ApplicationController
77
75
 
78
- breadcrumb 'Article Categories', :blog_categories_path, only: [:show]
76
+ breadcrumb "Article Categories", :blog_categories_path, only: [:show]
79
77
 
80
78
  def show
81
79
  breadcrumb @category.title, blog_category_path(@category)
@@ -96,7 +94,7 @@ The `breadcrumb` method takes at minimum two arguments: the first is a name for
96
94
  When using path variable `blog_categories_path`:
97
95
 
98
96
  ```ruby
99
- breadcrumb 'Categories', blog_categories_path
97
+ breadcrumb "Categories", blog_categories_path
100
98
  ```
101
99
 
102
100
  When using an instance `@category`:
@@ -114,7 +112,7 @@ breadcrumb @category.title, [:blog, @category]
114
112
  You can specify segments of the url:
115
113
 
116
114
  ```ruby
117
- breadcrumb @category.title, {controller: 'categories', action: 'show', id: @category.id}
115
+ breadcrumb @category.title, {controller: "categories", action: "show", id: @category.id}
118
116
  ```
119
117
 
120
118
  #### 2.1.1 controller
@@ -123,7 +121,7 @@ Breadcrumbs are inherited, so if you set a breadcrumb in `ApplicationController`
123
121
 
124
122
  ```ruby
125
123
  class ApplicationController < ActionController::Base
126
- breadcrumb 'Home', :root_path
124
+ breadcrumb "Home", :root_path
127
125
  end
128
126
  ```
129
127
 
@@ -131,7 +129,7 @@ Outside of controller actions the `breadcrumb` helper behaviour is similar to fi
131
129
 
132
130
  ```ruby
133
131
  class ArticlesController < ApplicationController
134
- breadcrumb 'All Articles', :articles_path, only: [:new, :create]
132
+ breadcrumb "All Articles", :articles_path, only: [:new, :create]
135
133
  end
136
134
  ```
137
135
 
@@ -139,12 +137,12 @@ Each time you call the `breadcrumb` helper, a new element is added to a breadcru
139
137
 
140
138
  ```ruby
141
139
  class ArticlesController < ApplicationController
142
- breadcrumb 'Home', :root_path
143
- breadcrumb 'All Articles', :articles_path
140
+ breadcrumb "Home", :root_path
141
+ breadcrumb "All Articles", :articles_path
144
142
 
145
143
  def show
146
- breadcrumb 'Article One', article_path(:one)
147
- breadcrumb 'Article Two', article_path(:two)
144
+ breadcrumb "Article One", article_path(:one)
145
+ breadcrumb "Article Two", article_path(:two)
148
146
  end
149
147
  end
150
148
  ```
@@ -153,18 +151,30 @@ end
153
151
 
154
152
  ```ruby
155
153
  class CommentsController < ApplicationController
156
- breadcrumb ->(c) { c.find_article(c.params[:post_id]).title }, :articles_path
154
+ breadcrumb -> { find_article(params[:post_id]).title }, :articles_path
157
155
  end
158
156
  ```
159
157
 
160
- Also, to dynamically evalute parameters inside the url argument do:
158
+ Also, to dynamically evaluate parameters inside the url argument do:
161
159
 
162
160
  ```ruby
163
161
  class CommentsController < ApplicationController
164
- breadcrumb 'All Comments', ->(c) { c.post_comments_path(c.params[:post_id]) }
162
+ breadcrumb "All Comments", -> { post_comments_path(params[:post_id]) }
165
163
  end
166
164
  ```
167
165
 
166
+ You may wish to define breadcrumbs over a collection. This is easy within views, and controller actions (just loop your collection), but if you want to do this in the controller class you can use the `before_action` approach:
167
+
168
+ ```ruby
169
+ before_action do
170
+ ancestors.each do |ancestor|
171
+ breadcrumb ancestor.name, [:admin, ancestor]
172
+ end
173
+ end
174
+ ```
175
+
176
+ Assume `ancestors` method is defined inside the controller.
177
+
168
178
  #### 2.1.2 view
169
179
 
170
180
  **Loaf** adds `breadcrumb` helper also to the views. Together with controller breadcrumbs, the view breadcrumbs are appended as the last in breadcrumb trail. For instance, to specify view breadcrumb do:
@@ -181,25 +191,27 @@ The `:match` key accepts the following values:
181
191
 
182
192
  * `:inclusive` - the default value, which matches nested paths
183
193
  * `:exact` - matches only the exact same path
184
- * `:exclusive` - matches only direct path and its query params if present
194
+ * `:exclusive` - matches only direct path and its query parameters if present
185
195
  * `/regex/` - matches based on regular expression
186
- * `{foo: bar}` - match based on query params
196
+ * `{foo: bar}` - match based on query parameters
187
197
 
188
198
  For example, to force a breadcrumb to be the current regardless do:
189
199
 
190
200
  ```ruby
191
- breadcrumb 'New Post', new_post_path, match: :exact
201
+ breadcrumb "New Post", new_post_path, match: :exact
192
202
  ```
193
203
 
194
- To make a breadcrumb current based on the query params do:
204
+ To make a breadcrumb current based on the query parameters do:
195
205
 
196
206
  ```ruby
197
- breadcrumb 'Posts', posts_path(order: :desc), match: {order: :desc}
207
+ breadcrumb "Posts", posts_path(order: :desc), match: {order: :desc}
198
208
  ```
199
209
 
200
210
  ### 2.2 breadcrumb_trail
201
211
 
202
- In order to display breadcrumbs use the `breadcrumb_trail` view helper which as an argument accepts options and yields all breadcrumbs to a block:
212
+ In order to display breadcrumbs use the `breadcrumb_trail` view helper. It accepts optional argument of configuration options and can be used in two ways.
213
+
214
+ One way, given a block it will yield all the breadcrumbs in order of definition:
203
215
 
204
216
  ```ruby
205
217
  breadcrumb_trail do |crumb|
@@ -207,7 +219,7 @@ breadcrumb_trail do |crumb|
207
219
  end
208
220
  ```
209
221
 
210
- The yielded pararmeter is a `Loaf::Crumb` object that provides the following methods:
222
+ The yielded parameter is an instance of `Loaf::Crumb` object with the following methods:
211
223
 
212
224
  ```ruby
213
225
  crumb.name # => the name as string
@@ -220,10 +232,10 @@ For example, you can add the following semantic markup to show breadcrumbs using
220
232
 
221
233
  ```erb
222
234
  <nav aria-label="breadcrumb">
223
- <ol class='breadcrumbs'>
235
+ <ol class="breadcrumbs">
224
236
  <% breadcrumb_trail do |crumb| %>
225
- <li class="<%= crumb.current? ? 'current' : '' %>">
226
- <%= link_to crumb.name, crumb.url, (crumb.current? ? {'aria-current' => 'page'} : {}) %>
237
+ <li class="<%= crumb.current? ? "current" : "" %>">
238
+ <%= link_to crumb.name, crumb.url, (crumb.current? ? {"aria-current" => "page"} : {}) %>
227
239
  <% unless crumb.current? %><span>::</span><% end %>
228
240
  </li>
229
241
  <% end %>
@@ -231,36 +243,59 @@ For example, you can add the following semantic markup to show breadcrumbs using
231
243
  </nav>
232
244
  ```
233
245
 
234
- For bootstrap,
246
+ For Bootstrap 4:
247
+
235
248
  ```erb
249
+ <% #erb %>
236
250
  <nav aria-label="breadcrumb">
237
- <ol class='breadcrumbs'>
251
+ <ol class="breadcrumb">
238
252
  <% breadcrumb_trail do |crumb| %>
239
- <li class="breadcrumb-item <%= crumb.current? ? 'active' : '' %>">
240
- <%= link_to_unless crumb.current?, crumb.name, crumb.url, (crumb.current? ? {'aria-current' => 'page'} : {}) %>
253
+ <li class="breadcrumb-item <%= crumb.current? ? "active" : "" %>">
254
+ <%= link_to_unless crumb.current?, crumb.name, crumb.url, (crumb.current? ? {"aria-current" => "page"} : {}) %>
241
255
  </li>
242
256
  <% end %>
243
257
  </ol>
244
258
  </nav>
245
259
  ```
246
260
 
261
+ And, if you are using `HAML` do:
262
+
263
+ ```haml
264
+ - # haml
265
+ %ol.breadcrumb
266
+ - breadcrumb_trail do |crumb|
267
+ %li.breadcrumb-item{class: crumb.current? ? "active" : "" }
268
+ = link_to_unless crumb.current?, crumb.name, crumb.url, (crumb.current? ? {"aria-current" => "page"} : {})
269
+ ```
270
+
271
+ Usually best practice is to put such snippet inside its own `_breadcrumbs.html.erb` partial.
247
272
 
248
- Usually best practice is to put such snippet inside its own partial.
273
+ The second way is to use the `breadcrumb_trail` without passing a block. In this case, the helper will return an enumerator that you can use to, for example, access an array of names pushed into the breadcrumb trail in order of addition. This can be handy for generating page titles from breadcrumb data.
274
+
275
+ For example, you can define a `breadcrumbs_to_title` method in `ApplicationHelper` like so:
276
+
277
+ ```ruby
278
+ module ApplicationHelper
279
+ def breadcrumbs_to_title
280
+ breadcrumb_trail.map(&:name).join(">")
281
+ end
282
+ end
283
+ ```
284
+
285
+ Use whichever of the two ways is more convenient given your application structure and needs.
249
286
 
250
287
  ## 3. Configuration
251
288
 
252
289
  There is a small set of custom opinionated defaults. The following options are valid parameters:
253
290
 
254
291
  ```ruby
255
- :capitalize # set breadcrumbs to have initial letter uppercase, default false
256
- :crumb_length # breadcrumb length in integer, default length is 30 characters
257
- :match # set match type, default :inclusive
292
+ :match # set match type, default :inclusive (see [:match](#213-match) for more details)
258
293
  ```
259
294
 
260
295
  You can override them in your views by passing them to the view `breadcrumb` helper
261
296
 
262
297
  ```erb
263
- <% breadcrumb_trail crumb_length: 20 do |name, url, styles| %>
298
+ <% breadcrumb_trail(match: :exclusive) do |name, url, styles| %>
264
299
  ..
265
300
  <% end %>
266
301
  ```
@@ -269,7 +304,7 @@ or by configuring an option in `config/initializers/loaf.rb`:
269
304
 
270
305
  ```ruby
271
306
  Loaf.configure do |config|
272
- config.crumb_length = 20
307
+ config.match = :exclusive
273
308
  end
274
309
  ```
275
310
 
@@ -306,6 +341,14 @@ en:
306
341
 
307
342
  Questions or problems? Please post them on the [issue tracker](https://github.com/piotrmurach/loaf/issues). You can contribute changes by forking the project and submitting a pull request. You can ensure the tests are passing by running `bundle` and `rake`.
308
343
 
344
+ ## License
345
+
346
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
347
+
348
+ ## Code of Conduct
349
+
350
+ Everyone interacting in the Loaf project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/piotrmurach/loaf/blob/master/CODE_OF_CONDUCT.md).
351
+
309
352
  ## Copyright
310
353
 
311
- Copyright (c) 2011-2018 Piotr Murach. See LICENSE.txt for further details.
354
+ Copyright (c) 2011 Piotr Murach. See LICENSE.txt for further details.
@@ -1,5 +1,6 @@
1
1
  require_relative 'loaf/configuration'
2
2
  require_relative 'loaf/railtie'
3
+ require_relative 'loaf/version'
3
4
 
4
5
  module Loaf
5
6
  # Set global configuration
@@ -4,8 +4,6 @@ module Loaf
4
4
  class Configuration
5
5
  VALID_ATTRIBUTES = [
6
6
  :locales_path,
7
- :crumb_length,
8
- :capitalize,
9
7
  :match
10
8
  ].freeze
11
9
 
@@ -13,18 +11,8 @@ module Loaf
13
11
 
14
12
  DEFAULT_LOCALES_PATH = '/'
15
13
 
16
- DEFAULT_STYLE_CLASSES = 'selected'
17
-
18
- DEFAULT_CRUMB_LENGTH = 30
19
-
20
- DEFAULT_LAST_CRUMB_LINKED = false
21
-
22
- DEFAULT_CAPITALIZE = false
23
-
24
14
  DEFAULT_MATCH = :inclusive
25
15
 
26
- DEFAULT_ROOT = true
27
-
28
16
  # Setup this configuration
29
17
  #
30
18
  # @api public
@@ -38,12 +38,20 @@ module Loaf
38
38
  respond_to?(:before_action) ? :before_action : :before_filter
39
39
  end
40
40
 
41
+ # Convert breadcrumb name to string
42
+ #
43
+ # @return [String]
44
+ #
41
45
  # @api private
42
46
  def _normalize_name(name, instance)
43
47
  case name
44
48
  when NilClass
45
49
  when Proc
46
- name.call(instance)
50
+ if name.arity == 1
51
+ instance.instance_exec(instance, &name)
52
+ else
53
+ instance.instance_exec(&name)
54
+ end
47
55
  else
48
56
  name
49
57
  end