gretel 3.0.9 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +11 -7
- data/.travis.yml +11 -10
- data/CHANGELOG.md +27 -0
- data/Gemfile +2 -19
- data/LICENSE.txt +1 -1
- data/README.md +43 -62
- data/Rakefile +3 -7
- data/coverage/coverage.txt +5 -0
- data/gretel.gemspec +12 -10
- data/lib/gretel.rb +2 -29
- data/lib/gretel/crumb.rb +5 -2
- data/lib/gretel/crumbs.rb +26 -7
- data/lib/gretel/railtie.rb +11 -0
- data/lib/gretel/renderer.rb +62 -30
- data/lib/gretel/version.rb +1 -1
- data/lib/gretel/view_helpers.rb +2 -0
- metadata +83 -110
- data/gemfiles/Gemfile-rails.3.1.x +0 -19
- data/gemfiles/Gemfile-rails.3.2.x +0 -19
- data/gemfiles/Gemfile-rails.4.0.x +0 -19
- data/gemfiles/Gemfile-rails.4.1.x +0 -19
- data/lib/gretel/deprecated.rb +0 -1
- data/lib/gretel/deprecated/default_style_key.rb +0 -25
- data/lib/gretel/deprecated/layout.rb +0 -15
- data/lib/gretel/deprecated/show_root_alone.rb +0 -27
- data/lib/gretel/deprecated/yield_links.rb +0 -44
- data/test/deprecated_test.rb +0 -45
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -15
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -5
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/issue.rb +0 -3
- data/test/dummy/app/models/project.rb +0 -3
- data/test/dummy/app/views/breadcrumbs/site.rb +0 -3
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -14
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/breadcrumbs.rb +0 -3
- data/test/dummy/config/breadcrumbs/test_crumbs.rb +0 -85
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -2
- data/test/dummy/config/environments/production.rb +0 -2
- data/test/dummy/config/environments/test.rb +0 -2
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -15
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -11
- data/test/dummy/db/migrate/20130122163007_create_projects.rb +0 -9
- data/test/dummy/db/migrate/20130122163051_create_issues.rb +0 -10
- data/test/dummy/db/schema.rb +0 -29
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/fixtures/issues.yml +0 -4
- data/test/fixtures/projects.yml +0 -3
- data/test/gretel_test.rb +0 -24
- data/test/helper_methods_test.rb +0 -546
- data/test/test_helper.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b80e71f865388974401274f84159318e012a5e9e40800888549453e301881bec
|
4
|
+
data.tar.gz: 06d1a078802e9b8d175f17376c7534ba8004c15327e2fc75b0e01e9386653cb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b8c092e5e04c48099f0fcad18230b89a6f4c11e760d59f89f629792cb4225eb5db1cf4648c8a6145c6be99bcf104b0d08ee0b74b82d39d1e7b9e366fda6ea37
|
7
|
+
data.tar.gz: 582e6471d0fa5fb59d490bee9a41b1cdd7b0f419b107c9acb56914832ad5b3a5dfc5c4590918dcb38ea46495a0df2578ceeb5e6384e57c0ed7e37ab8e39ea3e7
|
data/.gitignore
CHANGED
@@ -7,18 +7,22 @@ Gemfile.lock
|
|
7
7
|
gemfiles/*.lock
|
8
8
|
InstalledFiles
|
9
9
|
_yardoc
|
10
|
-
coverage
|
11
10
|
doc/
|
12
11
|
lib/bundler/man
|
13
12
|
pkg
|
14
13
|
rdoc
|
15
14
|
spec/reports
|
16
|
-
|
17
|
-
|
15
|
+
spec/tmp
|
16
|
+
spec/version_tmp
|
18
17
|
tmp
|
19
18
|
log/*.log
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
spec/dummy/db/*.sqlite3
|
20
|
+
spec/dummy/log/*.log
|
21
|
+
spec/dummy/tmp/
|
22
|
+
spec/dummy/.sass-cache
|
24
23
|
.DS_Store
|
24
|
+
|
25
|
+
/coverage/index.html
|
26
|
+
/coverage/assets
|
27
|
+
/coverage/*.json
|
28
|
+
/coverage/*.json.lock
|
data/.travis.yml
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
-
|
12
|
-
- gemfiles/Gemfile-rails.4.1.x
|
4
|
+
- 2.7
|
5
|
+
- 2.6
|
6
|
+
- 2.5
|
7
|
+
env:
|
8
|
+
- RAILS_VERSION="~> 5.1.0"
|
9
|
+
- RAILS_VERSION="~> 5.2.0"
|
10
|
+
- RAILS_VERSION="~> 6.0.0"
|
11
|
+
- RAILS_VERSION="master"
|
13
12
|
before_script:
|
14
|
-
- "cd
|
13
|
+
- "cd spec/dummy; rake db:migrate; rake db:test:prepare; cd ../.."
|
14
|
+
after_script:
|
15
|
+
- "cat coverage/coverage.txt"
|
15
16
|
notifications:
|
16
17
|
email: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Version 4.2.0
|
4
|
+
* Support generating JSON-LD structured data. See the readme for more info (via #26, thanks @dkniffin)
|
5
|
+
|
6
|
+
## Version 4.1.0
|
7
|
+
* Depends only `railties` and `actionview`, not `rails` (via #7)
|
8
|
+
* Include `Gretel::ViewHelpers` module in `ActiveSupport.on_load(:action_view)` block
|
9
|
+
* Fix ruby 2.7 keywords warning (via #24, thanks @aki77)
|
10
|
+
* Fix multithreaded environment issue (via #13)
|
11
|
+
* `breadcrumbs.rb` is now evaluated in a instance of `Gretel::Crumbs::Builder`. If you want to call methods from `breadcrumbs.rb` other than `crumb`, `crumbs` and `crumb_defined?`, you need to call it via full reference like `Gretel::Crumbs.xxxx`
|
12
|
+
|
13
|
+
## Version 4.0.2
|
14
|
+
* The return value of `breadcrumbs` is `html_safe` now (via #22)
|
15
|
+
* For the slim template engine users: You don't need to use `==` instead of `=` for `breadcrumbs`
|
16
|
+
|
17
|
+
## Version 4.0.1
|
18
|
+
* Replaces data-vocabulary markup as google doesn't support it and now uses schema.org markup (via #17)
|
19
|
+
|
20
|
+
## Version 4.0.0
|
21
|
+
* Support Bootstrap 4. See the `:style` option in the readme for more info
|
22
|
+
* CSS class for fragment link or span is now customizable. See the `:fragment_class` option in the readme for more info
|
23
|
+
* Drop support Ruby < 2.5
|
24
|
+
* Drop support Rails < 5.1
|
25
|
+
* Deprecated codes have been removed:
|
26
|
+
* `breadcrumbs` is no longer accept block, use `tap` instead
|
27
|
+
* `breadcrumbs` is no longer accept `style: :default`, use `style: :inline` instead
|
28
|
+
* `breadcrumbs` is no longer accept `:show_root_alone` option, use `:display_single_fragment` option instead
|
29
|
+
|
3
30
|
## Version 3.0.9
|
4
31
|
* Adds breadcrumbs option `link_current_to_request_path` to link the current breadcrumb to the request path(#28 via #29)
|
5
32
|
* Fixes semantic breadcrumbs when the last item has no link (via #55)
|
data/Gemfile
CHANGED
@@ -1,23 +1,6 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
# Declare your gem's dependencies in gretel.gemspec.
|
4
|
-
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
-
# development dependencies will be added by default to the :development group.
|
6
3
|
gemspec
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
-
# your gem to rubygems.org.
|
12
|
-
|
13
|
-
# To use debugger
|
14
|
-
# gem 'debugger'
|
15
|
-
|
16
|
-
group :development do
|
17
|
-
# jquery-rails is used by the dummy application
|
18
|
-
gem "jquery-rails"
|
19
|
-
end
|
20
|
-
|
21
|
-
group :test do
|
22
|
-
gem 'test-unit', '~> 3.0' if RUBY_VERSION >= "2.2"
|
23
|
-
end
|
5
|
+
rails_version = ENV['RAILS_VERSION'] || '>= 0'
|
6
|
+
gem 'rails', rails_version == 'master' ? { github: 'rails/rails' } : rails_version
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/gretel.svg)](http://badge.fury.io/rb/gretel)
|
2
|
+
[![Build Status](https://travis-ci.org/kzkn/gretel.svg?branch=master)](https://travis-ci.org/kzkn/gretel)
|
2
3
|
|
3
4
|
<img src="http://i.imgur.com/CAKEaBM.png" alt="Handle breadcrumb trails... like a boss :)" />
|
4
5
|
|
5
6
|
([TL;DR](http://i.imgur.com/nH25yiH.png)) Gretel is a [Ruby on Rails](http://rubyonrails.org) plugin that makes it easy yet flexible to create breadcrumbs.
|
6
7
|
It is based around the idea that breadcrumbs are a concern of the view, so you define a set of breadcrumbs in *config/breadcrumbs.rb* (or multiple files; see below) and specify in the view which breadcrumb to use.
|
7
|
-
Gretel also supports [semantic breadcrumbs](
|
8
|
+
Gretel also supports [semantic breadcrumbs](https://developers.google.com/search/docs/data-types/breadcrumb) (those used in Google results).
|
8
9
|
|
9
|
-
Have fun!
|
10
|
+
Have fun!
|
10
11
|
|
11
12
|
## Installation
|
12
13
|
|
@@ -88,9 +89,10 @@ Option | Description
|
|
88
89
|
:display_single_fragment | Whether it should display the breadcrumb if it includes only one link. | False
|
89
90
|
:link_current | Whether the current crumb should be linked to. | False
|
90
91
|
:link_current_to_request_path | Whether the current crumb should always link to the current request path. *Note:* This option will have no effect unless `:link_current` is set to `true`. | True
|
91
|
-
:semantic | Whether it should generate [semantic breadcrumbs](
|
92
|
+
:semantic | Whether it should generate [semantic breadcrumbs](https://developers.google.com/search/docs/data-types/breadcrumb). | False
|
92
93
|
:id | ID for the breadcrumbs container. | None
|
93
94
|
:class | CSS class for the breadcrumbs container. Can be set to `nil` for no class. | `"breadcrumbs"`
|
95
|
+
:fragment_class | CSS class for the fragment link or span. Can be set to `nil` for no class. | None
|
94
96
|
:current_class | CSS class for the current link or span. Can be set to `nil` for no class. | `"current"`
|
95
97
|
:pretext_class | CSS class for the pretext, if given. Can be set to `nil` for no class. | `"pretext"`
|
96
98
|
:posttext_class | CSS class for the posttext, if given. Can be set to `nil` for no class. | `"posttext"`
|
@@ -103,15 +105,16 @@ These are the styles you can use with `breadcrumbs style: :xx`.
|
|
103
105
|
|
104
106
|
Style | Description
|
105
107
|
-------------- | -----------
|
106
|
-
`:inline` | Renders each link by itself with `›` as the seperator.
|
108
|
+
`:inline` | Default. Renders each link by itself with `›` as the seperator.
|
107
109
|
`:ol` | Renders the links in `<li>` elements contained in an outer `<ol>`.
|
108
110
|
`:ul` | Renders the links in `<li>` elements contained in an outer `<ul>`.
|
109
|
-
`:bootstrap` | Renders the links for use in [
|
110
|
-
`:
|
111
|
+
`:bootstrap` | Renders the links for use in [Bootstrap v3](https://getbootstrap.com/docs/3.4/).
|
112
|
+
`:bootstrap4` | Renders the links for use in [Bootstrap v4](https://getbootstrap.com/).
|
113
|
+
`:foundation5` | Renders the links for use in [Foundation 5](https://get.foundation/).
|
111
114
|
|
112
115
|
Or you can build the breadcrumbs manually for full customization; see below.
|
113
116
|
|
114
|
-
If you add other widely used styles, please submit a [Pull Request](https://github.com/
|
117
|
+
If you add other widely used styles, please submit a [Pull Request](https://github.com/kzkn/gretel/pulls) so others can use them too.
|
115
118
|
|
116
119
|
## More examples
|
117
120
|
|
@@ -203,10 +206,10 @@ end
|
|
203
206
|
|
204
207
|
## Building the breadcrumbs manually
|
205
208
|
|
206
|
-
|
209
|
+
You can use the `breadcrumbs` method directly as an array. It will return an array with the breadcrumb links so you can build the breadcrumbs HTML manually:
|
207
210
|
|
208
211
|
```erb
|
209
|
-
<% breadcrumbs do |links| %>
|
212
|
+
<% breadcrumbs.tap do |links| %>
|
210
213
|
<% if links.any? %>
|
211
214
|
You are here:
|
212
215
|
<% links.each do |link| %>
|
@@ -216,6 +219,23 @@ If you supply a block to the `breadcrumbs` method, it will yield an array with t
|
|
216
219
|
<% end %>
|
217
220
|
```
|
218
221
|
|
222
|
+
If you use this approach, you lose the built-in semantic breadcrumb functionality. One way to
|
223
|
+
add them back is to use JSON-LD structured data:
|
224
|
+
|
225
|
+
```erb
|
226
|
+
<script type="application/ld+json">
|
227
|
+
<%= breadcrumbs.structured_data(url_base: "https://example.com")) %>
|
228
|
+
</script>
|
229
|
+
```
|
230
|
+
|
231
|
+
Or, you can infer `url_base` from `request`:
|
232
|
+
|
233
|
+
```erb
|
234
|
+
<script type="application/ld+json">
|
235
|
+
<%= breadcrumbs.structured_data(url_base: "#{request.protocol}#{request.host_with_port}")) %>
|
236
|
+
</script>
|
237
|
+
```
|
238
|
+
|
219
239
|
## Getting the parent breadcrumb
|
220
240
|
|
221
241
|
If you want to add a link to the parent breadcrumb, you can use the `parent_breadcrumb` view helper.
|
@@ -289,56 +309,15 @@ breadcrumbs do |links|
|
|
289
309
|
end
|
290
310
|
```
|
291
311
|
|
292
|
-
### Automatic reloading of breadcrumb configuration files
|
293
|
-
|
294
|
-
Since Gretel version 2.1.0, the breadcrumb configuration files are now reloaded in the Rails development environment if they change. In other environments, like production, the files are loaded once, when first needed.
|
295
|
-
|
296
|
-
### Setting breadcrumb trails
|
297
|
-
|
298
|
-
The [gretel-trails](https://github.com/lassebunk/gretel-trails) gem can handle adding and hiding trails from the URL automatically. This makes it possible to link back to a different breadcrumb trail than the one specified in your breadcrumb, for example if you have a
|
299
|
-
store with products that have a default parent to the category breadcrumb, but when visiting from the reviews section, you want to link back to the reviews instead.
|
300
|
-
|
301
|
-
You can apply trails to select links by adding a simple JS selector (`js-append-trail` or another you choose), and after each page load it hides the trail from the URL, so the server sees it but the users don't.
|
302
|
-
|
303
|
-
Check out the gem [here](https://github.com/lassebunk/gretel-trails).
|
304
|
-
|
305
|
-
|
306
|
-
## Upgrading from version 2.0 or below
|
307
|
-
|
308
|
-
Instead of using the initializer that in Gretel version 2.0 and below required restarting the application after breadcrumb configuration changes, the configuration of the breadcrumbs is now loaded from `config/breadcrumbs.rb` (and `config/breadcrumbs/*.rb` if you want to split your breadcrumbs configuration across multiple files).
|
309
|
-
In the Rails development environment, these files are automatically reloaded when changed.
|
310
|
-
|
311
|
-
Using the initializer (e.g. `config/initializers/breadcrumbs.rb`) was deprecated in Gretel version 2.1.0 and removed in version 3.0. It raises an error if you try to use it.
|
312
|
-
|
313
|
-
To update to the latest version of Gretel, use `bundle update gretel`. Then remove the `Gretel::Crumbs.layout do ... end` block, so instead of:
|
314
|
-
|
315
|
-
```ruby
|
316
|
-
Gretel::Crumbs.layout do
|
317
|
-
crumb :root do
|
318
|
-
link "Home", root_path
|
319
|
-
end
|
320
|
-
end
|
321
|
-
```
|
322
|
-
|
323
|
-
in the initializer, you write:
|
324
|
-
|
325
|
-
```ruby
|
326
|
-
crumb :root do
|
327
|
-
link "Home", root_path
|
328
|
-
end
|
329
|
-
```
|
330
|
-
|
331
|
-
in `config/breadcrumbs.rb`.
|
332
|
-
|
333
312
|
## Documentation
|
334
313
|
|
335
|
-
* [Full documentation](
|
336
|
-
* [Changelog](https://github.com/
|
337
|
-
* [Tutorial on using Gretel](
|
314
|
+
* [Full documentation](https://rubydoc.info/gems/gretel)
|
315
|
+
* [Changelog](https://github.com/kzkn/gretel/blob/master/CHANGELOG.md)
|
316
|
+
* [Tutorial on using Gretel](https://www.sitepoint.com/breadcrumbs-rails-gretel/) (Sitepoint)
|
338
317
|
|
339
318
|
## Versioning
|
340
319
|
|
341
|
-
Follows [semantic versioning](
|
320
|
+
Follows [semantic versioning](https://semver.org/).
|
342
321
|
|
343
322
|
## Contributing
|
344
323
|
|
@@ -350,19 +329,21 @@ To contribute:
|
|
350
329
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
351
330
|
3. Make your changes
|
352
331
|
4. Add/Fix tests
|
353
|
-
5. Prepare database for testing: `cd
|
332
|
+
5. Prepare database for testing: `cd spec/dummy; rake db:migrate; rake db:test:prepare; cd ../..`
|
354
333
|
6. Run `rake` to make sure all tests pass
|
355
|
-
7.
|
356
|
-
8.
|
357
|
-
9.
|
334
|
+
7. Be sure to check in the changes to `coverage/coverage.txt`
|
335
|
+
8. Commit your changes (`git commit -am 'Add new feature'`)
|
336
|
+
9. Push to the branch (`git push origin my-new-feature`)
|
337
|
+
10. Create new pull request
|
358
338
|
|
359
339
|
Thanks.
|
360
340
|
|
361
341
|
## Contributors
|
362
342
|
|
363
|
-
Gretel was created by [@lassebunk](https://github.com/lassebunk) and
|
343
|
+
Gretel was created by [@lassebunk](https://github.com/lassebunk) and was maintained by [@WilHall](https://github.com/WilHall).
|
344
|
+
And it is maintained by [@kzkn](https://github.com/kzkn).
|
364
345
|
|
365
|
-
[See the list of contributors](https://github.com/
|
346
|
+
[See the list of contributors](https://github.com/kzkn/gretel/graphs/contributors)
|
366
347
|
|
367
348
|
## And then
|
368
349
|
|
@@ -370,4 +351,4 @@ Gretel was created by [@lassebunk](https://github.com/lassebunk) and is maintain
|
|
370
351
|
|
371
352
|
Have fun!
|
372
353
|
|
373
|
-
Copyright (c) 2010-
|
354
|
+
Copyright (c) 2010-2020 [Lasse Bunk](http://lassebunk.dk), released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
require 'rake/testtask'
|
2
1
|
require 'bundler/gem_tasks'
|
2
|
+
require "rspec/core/rake_task"
|
3
3
|
|
4
|
-
|
5
|
-
t.libs << "test"
|
6
|
-
t.test_files = FileList['test/**/*_test.rb']
|
7
|
-
t.verbose = true
|
8
|
-
end
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
5
|
|
10
|
-
task default: :
|
6
|
+
task default: :spec
|
data/gretel.gemspec
CHANGED
@@ -1,22 +1,24 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'gretel/version'
|
1
|
+
require_relative 'lib/gretel/version'
|
5
2
|
|
6
3
|
Gem::Specification.new do |gem|
|
7
4
|
gem.name = "gretel"
|
8
5
|
gem.version = Gretel::VERSION
|
9
|
-
gem.authors = ["Lasse Bunk"]
|
10
|
-
gem.email = ["
|
6
|
+
gem.authors = ["Lasse Bunk", "Kazuki Nishikawa"]
|
7
|
+
gem.email = ["kzkn@users.noreply.github.com"]
|
11
8
|
gem.description = %q{Gretel is a Ruby on Rails plugin that makes it easy yet flexible to create breadcrumbs.}
|
12
9
|
gem.summary = %q{Flexible Ruby on Rails breadcrumbs plugin.}
|
13
|
-
gem.homepage = "http://github.com/
|
10
|
+
gem.homepage = "http://github.com/kzkn/gretel"
|
14
11
|
gem.license = "MIT"
|
15
12
|
|
16
|
-
gem.files =
|
17
|
-
|
13
|
+
gem.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
14
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
+
end
|
18
16
|
gem.require_paths = ["lib"]
|
19
17
|
|
20
|
-
gem.add_dependency "
|
18
|
+
gem.add_dependency "railties", [">= 5.1", "< 7.0"]
|
19
|
+
gem.add_dependency "actionview", [">= 5.1", "< 7.0"]
|
21
20
|
gem.add_development_dependency "sqlite3"
|
21
|
+
gem.add_development_dependency "rspec-rails"
|
22
|
+
gem.add_development_dependency "simplecov"
|
23
|
+
gem.add_development_dependency "simplecov-erb"
|
22
24
|
end
|
data/lib/gretel.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
require 'gretel/version'
|
2
2
|
require 'gretel/resettable'
|
3
|
-
require 'gretel/
|
4
|
-
require 'gretel/crumb'
|
5
|
-
require 'gretel/link'
|
6
|
-
require 'gretel/renderer'
|
7
|
-
require 'gretel/view_helpers'
|
8
|
-
require 'gretel/deprecated'
|
3
|
+
require 'gretel/railtie'
|
9
4
|
|
10
5
|
module Gretel
|
11
6
|
class << self
|
@@ -16,9 +11,7 @@ module Gretel
|
|
16
11
|
# breadcrumbs set in engines.
|
17
12
|
def breadcrumb_paths
|
18
13
|
@breadcrumb_paths ||= begin
|
19
|
-
engines = Rails::Engine
|
20
|
-
Rails::Engine::Railties.engines :
|
21
|
-
Rails::Engine.subclasses.map(&:instance)
|
14
|
+
engines = Rails::Engine.subclasses.map(&:instance)
|
22
15
|
|
23
16
|
engine_roots = engines.map { |e| e.config.root }
|
24
17
|
|
@@ -35,24 +28,6 @@ module Gretel
|
|
35
28
|
@breadcrumb_paths = paths
|
36
29
|
end
|
37
30
|
|
38
|
-
# Whether to suppress deprecation warnings.
|
39
|
-
def suppress_deprecation_warnings?
|
40
|
-
!!@suppress_deprecation_warnings
|
41
|
-
end
|
42
|
-
|
43
|
-
# Sets whether to suppress deprecation warnings.
|
44
|
-
def suppress_deprecation_warnings=(value)
|
45
|
-
@suppress_deprecation_warnings = value
|
46
|
-
end
|
47
|
-
|
48
|
-
# Shows a deprecation warning.
|
49
|
-
def show_deprecation_warning(message)
|
50
|
-
return if suppress_deprecation_warnings?
|
51
|
-
message = "[Gretel] #{message}"
|
52
|
-
puts message
|
53
|
-
Rails.logger.warn message
|
54
|
-
end
|
55
|
-
|
56
31
|
# Array of Rails environment names with automatic configuration reload. Default is +["development"]+.
|
57
32
|
def reload_environments
|
58
33
|
@reload_environments ||= ["development"]
|
@@ -78,5 +53,3 @@ module Gretel
|
|
78
53
|
end
|
79
54
|
end
|
80
55
|
end
|
81
|
-
|
82
|
-
ActionView::Base.send :include, Gretel::ViewHelpers
|
data/lib/gretel/crumb.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'gretel/link'
|
2
|
+
|
1
3
|
module Gretel
|
2
4
|
class Crumb
|
3
5
|
# Initializes a new crumb from the given +key+.
|
@@ -13,7 +15,7 @@ module Gretel
|
|
13
15
|
raise ArgumentError, "Breadcrumb :#{key} not found." unless block
|
14
16
|
@key = key
|
15
17
|
@context = context
|
16
|
-
instance_exec
|
18
|
+
instance_exec(*args, &block)
|
17
19
|
end
|
18
20
|
|
19
21
|
# Sets link of the breadcrumb.
|
@@ -29,7 +31,7 @@ module Gretel
|
|
29
31
|
|
30
32
|
# Transform objects to real paths.
|
31
33
|
url = url_for(url) if url
|
32
|
-
|
34
|
+
|
33
35
|
links << Gretel::Link.new(key, text, url, options)
|
34
36
|
end
|
35
37
|
|
@@ -64,5 +66,6 @@ module Gretel
|
|
64
66
|
def method_missing(method, *args, &block)
|
65
67
|
context.send(method, *args, &block)
|
66
68
|
end
|
69
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
67
70
|
end
|
68
71
|
end
|