gretel 3.0.9 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +5 -1
- data/.travis.yml +7 -9
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -19
- data/LICENSE.txt +1 -1
- data/README.md +16 -12
- data/Rakefile +1 -1
- data/coverage/coverage.txt +6 -0
- data/gretel.gemspec +8 -4
- data/lib/gretel.rb +1 -22
- data/lib/gretel/renderer.rb +15 -8
- data/lib/gretel/version.rb +1 -1
- data/test/dummy/app/assets/config/manifest.js +0 -0
- data/test/dummy/db/migrate/20130122163007_create_projects.rb +1 -1
- data/test/dummy/db/migrate/20130122163051_create_issues.rb +1 -1
- data/test/dummy/db/schema.rb +16 -17
- data/test/gretel_test.rb +1 -2
- data/test/helper_methods_test.rb +12 -0
- data/test/test_helper.rb +15 -7
- metadata +70 -22
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e6b2a5d8a3fd0fbb357c690e1d0189c54ab90ad1619c6ea5910b59f9cf718e89
|
4
|
+
data.tar.gz: d5c633b783445c773bb031dbd2377ca8af9265ced45f9aaafeabebc853c754d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5816c2df05e992e54868150d8f6689af7c2d2cb0af33b588c9ef552d54771efcf81b29a9b9f2bca223e784644288caf24987f8b38f546ea0b3a4be1944a73b1e
|
7
|
+
data.tar.gz: 80497833712a92ac207f663ab544761ebf65b7a93d8d5fd7712e3bb8b3c8785b72ee85020ead35cd2e118a03f09e81a3d844c7dbbd629a3cf6cfb1b3d78669ba
|
data/.gitignore
CHANGED
@@ -7,7 +7,6 @@ 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
|
@@ -22,3 +21,8 @@ test/dummy/log/*.log
|
|
22
21
|
test/dummy/tmp/
|
23
22
|
test/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,15 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
- gemfiles/Gemfile-rails.4.0.x
|
12
|
-
- gemfiles/Gemfile-rails.4.1.x
|
4
|
+
- 2.7
|
5
|
+
- 2.6
|
6
|
+
- 2.5
|
7
|
+
env:
|
8
|
+
- RAILS="~> '5.1.0'"
|
9
|
+
- RAILS="~> '5.2.0'"
|
10
|
+
- RAILS="~> '6.0.0'"
|
13
11
|
before_script:
|
14
12
|
- "cd test/dummy; rake db:migrate; rake db:test:prepare; cd ../.."
|
15
13
|
notifications:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Version 4.0.0
|
4
|
+
* Support Bootstrap 4. See the `:style` option in the readme for more info
|
5
|
+
* CSS class for fragment link or span is now customizable. See the `:fragment_class` option in the readme for more info
|
6
|
+
* Drop support Ruby < 2.5
|
7
|
+
* Drop support Rails < 5.1
|
8
|
+
* Deprecated codes have been removed:
|
9
|
+
* `breadcrumbs` is no longer accept block, use `tap` instead
|
10
|
+
* `breadcrumbs` is no longer accept `style: :default`, use `style: :inline` instead
|
11
|
+
* `breadcrumbs` is no longer accept `:show_root_alone` option, use `:display_single_fragment` option instead
|
12
|
+
|
3
13
|
## Version 3.0.9
|
4
14
|
* Adds breadcrumbs option `link_current_to_request_path` to link the current breadcrumb to the request path(#28 via #29)
|
5
15
|
* 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
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
<a href="http://travis-ci.org/
|
1
|
+
<a href="http://travis-ci.org/kzkn/gretel"><img src="https://secure.travis-ci.org/kzkn/gretel.png" alt="Build Status" /></a>
|
2
2
|
|
3
3
|
<img src="http://i.imgur.com/CAKEaBM.png" alt="Handle breadcrumb trails... like a boss :)" />
|
4
4
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
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
7
|
Gretel also supports [semantic breadcrumbs](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417) (those used in Google results).
|
8
8
|
|
9
|
-
Have fun!
|
9
|
+
Have fun!
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -91,6 +91,7 @@ Option | Description
|
|
91
91
|
:semantic | Whether it should generate [semantic breadcrumbs](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417). | False
|
92
92
|
:id | ID for the breadcrumbs container. | None
|
93
93
|
:class | CSS class for the breadcrumbs container. Can be set to `nil` for no class. | `"breadcrumbs"`
|
94
|
+
:fragment_class | CSS class for the fragment link or span. Can be set to `nil` for no class. | None
|
94
95
|
:current_class | CSS class for the current link or span. Can be set to `nil` for no class. | `"current"`
|
95
96
|
:pretext_class | CSS class for the pretext, if given. Can be set to `nil` for no class. | `"pretext"`
|
96
97
|
:posttext_class | CSS class for the posttext, if given. Can be set to `nil` for no class. | `"posttext"`
|
@@ -107,11 +108,12 @@ Style | Description
|
|
107
108
|
`:ol` | Renders the links in `<li>` elements contained in an outer `<ol>`.
|
108
109
|
`:ul` | Renders the links in `<li>` elements contained in an outer `<ul>`.
|
109
110
|
`:bootstrap` | Renders the links for use in [Twitter Bootstrap](http://getbootstrap.com/).
|
111
|
+
`:bootstrap4` | Renders the links for use in [Bootstrap v4](https://getbootstrap.com/).
|
110
112
|
`:foundation5` | Renders the links for use in [Foundation 5](http://foundation.zurb.com/).
|
111
113
|
|
112
114
|
Or you can build the breadcrumbs manually for full customization; see below.
|
113
115
|
|
114
|
-
If you add other widely used styles, please submit a [Pull Request](https://github.com/
|
116
|
+
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
117
|
|
116
118
|
## More examples
|
117
119
|
|
@@ -203,10 +205,10 @@ end
|
|
203
205
|
|
204
206
|
## Building the breadcrumbs manually
|
205
207
|
|
206
|
-
|
208
|
+
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
209
|
|
208
210
|
```erb
|
209
|
-
<% breadcrumbs do |links| %>
|
211
|
+
<% breadcrumbs.tap do |links| %>
|
210
212
|
<% if links.any? %>
|
211
213
|
You are here:
|
212
214
|
<% links.each do |link| %>
|
@@ -333,7 +335,7 @@ in `config/breadcrumbs.rb`.
|
|
333
335
|
## Documentation
|
334
336
|
|
335
337
|
* [Full documentation](http://rubydoc.info/gems/gretel)
|
336
|
-
* [Changelog](https://github.com/
|
338
|
+
* [Changelog](https://github.com/kzkn/gretel/blob/master/CHANGELOG.md)
|
337
339
|
* [Tutorial on using Gretel](http://www.sitepoint.com/breadcrumbs-rails-gretel/) (Sitepoint)
|
338
340
|
|
339
341
|
## Versioning
|
@@ -352,17 +354,19 @@ To contribute:
|
|
352
354
|
4. Add/Fix tests
|
353
355
|
5. Prepare database for testing: `cd test/dummy; rake db:migrate; rake db:test:prepare; cd ../..`
|
354
356
|
6. Run `rake` to make sure all tests pass
|
355
|
-
7.
|
356
|
-
8.
|
357
|
-
9.
|
357
|
+
7. Be sure to check in the changes to `coverage/coverage.txt`
|
358
|
+
8. Commit your changes (`git commit -am 'Add new feature'`)
|
359
|
+
9. Push to the branch (`git push origin my-new-feature`)
|
360
|
+
10. Create new pull request
|
358
361
|
|
359
362
|
Thanks.
|
360
363
|
|
361
364
|
## Contributors
|
362
365
|
|
363
|
-
Gretel was created by [@lassebunk](https://github.com/lassebunk) and
|
366
|
+
Gretel was created by [@lassebunk](https://github.com/lassebunk) and was maintained by [@WilHall](https://github.com/WilHall).
|
367
|
+
And it is maintained by [@kzkn](https://github.com/kzkn).
|
364
368
|
|
365
|
-
[See the list of contributors](https://github.com/
|
369
|
+
[See the list of contributors](https://github.com/kzkn/gretel/graphs/contributors)
|
366
370
|
|
367
371
|
## And then
|
368
372
|
|
@@ -370,4 +374,4 @@ Gretel was created by [@lassebunk](https://github.com/lassebunk) and is maintain
|
|
370
374
|
|
371
375
|
Have fun!
|
372
376
|
|
373
|
-
Copyright (c) 2010-
|
377
|
+
Copyright (c) 2010-2020 [Lasse Bunk](http://lassebunk.dk), released under the MIT license
|
data/Rakefile
CHANGED
@@ -0,0 +1,6 @@
|
|
1
|
+
--------------------------------------------------------------------------------
|
2
|
+
Incomplete test coverage
|
3
|
+
--------------------------------------------------------------------------------
|
4
|
+
|
5
|
+
/lib/gretel/renderer.rb: 99.12% (missed: 45)
|
6
|
+
/test/helper_methods_test.rb: 99.24% (missed: 17,196)
|
data/gretel.gemspec
CHANGED
@@ -6,17 +6,21 @@ require 'gretel/version'
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "gretel"
|
8
8
|
gem.version = Gretel::VERSION
|
9
|
-
gem.authors = ["Lasse Bunk"]
|
10
|
-
gem.email = ["
|
9
|
+
gem.authors = ["Lasse Bunk", "Kazuki Nishikawa"]
|
10
|
+
gem.email = ["kzkn@users.noreply.github.com"]
|
11
11
|
gem.description = %q{Gretel is a Ruby on Rails plugin that makes it easy yet flexible to create breadcrumbs.}
|
12
12
|
gem.summary = %q{Flexible Ruby on Rails breadcrumbs plugin.}
|
13
|
-
gem.homepage = "http://github.com/
|
13
|
+
gem.homepage = "http://github.com/kzkn/gretel"
|
14
14
|
gem.license = "MIT"
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
17
17
|
gem.test_files = gem.files.grep(%r{^test/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency "rails", ">=
|
20
|
+
gem.add_dependency "rails", ">= 5.1"
|
21
21
|
gem.add_development_dependency "sqlite3"
|
22
|
+
gem.add_development_dependency "jquery-rails"
|
23
|
+
gem.add_development_dependency "test-unit", "~> 3.0"
|
24
|
+
gem.add_development_dependency "simplecov", "~> 0.18.0"
|
25
|
+
gem.add_development_dependency "simplecov-erb", "~> 0.1"
|
22
26
|
end
|
data/lib/gretel.rb
CHANGED
@@ -5,7 +5,6 @@ require 'gretel/crumb'
|
|
5
5
|
require 'gretel/link'
|
6
6
|
require 'gretel/renderer'
|
7
7
|
require 'gretel/view_helpers'
|
8
|
-
require 'gretel/deprecated'
|
9
8
|
|
10
9
|
module Gretel
|
11
10
|
class << self
|
@@ -16,9 +15,7 @@ module Gretel
|
|
16
15
|
# breadcrumbs set in engines.
|
17
16
|
def breadcrumb_paths
|
18
17
|
@breadcrumb_paths ||= begin
|
19
|
-
engines = Rails::Engine
|
20
|
-
Rails::Engine::Railties.engines :
|
21
|
-
Rails::Engine.subclasses.map(&:instance)
|
18
|
+
engines = Rails::Engine.subclasses.map(&:instance)
|
22
19
|
|
23
20
|
engine_roots = engines.map { |e| e.config.root }
|
24
21
|
|
@@ -35,24 +32,6 @@ module Gretel
|
|
35
32
|
@breadcrumb_paths = paths
|
36
33
|
end
|
37
34
|
|
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
35
|
# Array of Rails environment names with automatic configuration reload. Default is +["development"]+.
|
57
36
|
def reload_environments
|
58
37
|
@reload_environments ||= ["development"]
|
data/lib/gretel/renderer.rb
CHANGED
@@ -22,6 +22,7 @@ module Gretel
|
|
22
22
|
ol: { container_tag: :ol, fragment_tag: :li },
|
23
23
|
ul: { container_tag: :ul, fragment_tag: :li },
|
24
24
|
bootstrap: { container_tag: :ol, fragment_tag: :li, class: "breadcrumb", current_class: "active" },
|
25
|
+
bootstrap4: { container_tag: :ol, fragment_tag: :li, class: "breadcrumb", fragment_class: "breadcrumb-item", current_class: "active" },
|
25
26
|
foundation5: { container_tag: :ul, fragment_tag: :li, class: "breadcrumbs", current_class: "current" }
|
26
27
|
}
|
27
28
|
|
@@ -171,12 +172,12 @@ module Gretel
|
|
171
172
|
|
172
173
|
# Loop through all but the last (current) link and build HTML of the fragments
|
173
174
|
fragments = links[0..-2].map do |link|
|
174
|
-
render_fragment(options[:fragment_tag], link.text, link.url, options[:semantic])
|
175
|
+
render_fragment(options[:fragment_tag], link.text, link.url, options[:semantic], fragment_class: options[:fragment_class])
|
175
176
|
end
|
176
177
|
|
177
178
|
# The current link is handled a little differently, and is only linked if specified in the options
|
178
179
|
current_link = links.last
|
179
|
-
fragments << render_fragment(options[:fragment_tag], current_link.text, (options[:link_current] ? current_link.url : nil), options[:semantic], class: options[:current_class], current_link: current_link.url)
|
180
|
+
fragments << render_fragment(options[:fragment_tag], current_link.text, (options[:link_current] ? current_link.url : nil), options[:semantic], fragment_class: options[:fragment_class], class: options[:current_class], current_link: current_link.url)
|
180
181
|
|
181
182
|
# Build the final HTML
|
182
183
|
html_fragments = []
|
@@ -208,6 +209,9 @@ module Gretel
|
|
208
209
|
|
209
210
|
# Renders semantic fragment HTML.
|
210
211
|
def render_semantic_fragment(fragment_tag, text, url, options = {})
|
212
|
+
fragment_class = [options[:fragment_class], options[:class]].join(' ').strip
|
213
|
+
fragment_class = nil if fragment_class.blank?
|
214
|
+
|
211
215
|
if fragment_tag
|
212
216
|
text = content_tag(:span, text, itemprop: "title")
|
213
217
|
|
@@ -218,23 +222,26 @@ module Gretel
|
|
218
222
|
text = text + tag(:meta, itemprop: "url", content: current_url)
|
219
223
|
end
|
220
224
|
|
221
|
-
content_tag(fragment_tag, text, class:
|
225
|
+
content_tag(fragment_tag, text, class: fragment_class, itemscope: "", itemtype: "http://data-vocabulary.org/Breadcrumb")
|
222
226
|
elsif url.present?
|
223
|
-
content_tag(:span, breadcrumb_link_to(content_tag(:span, text, itemprop: "title"), url, class:
|
227
|
+
content_tag(:span, breadcrumb_link_to(content_tag(:span, text, itemprop: "title"), url, class: fragment_class, itemprop: "url"), itemscope: "", itemtype: "http://data-vocabulary.org/Breadcrumb")
|
224
228
|
else
|
225
|
-
content_tag(:span, content_tag(:span, text, class:
|
229
|
+
content_tag(:span, content_tag(:span, text, class: fragment_class, itemprop: "title"), itemscope: "", itemtype: "http://data-vocabulary.org/Breadcrumb")
|
226
230
|
end
|
227
231
|
end
|
228
232
|
|
229
233
|
# Renders regular, non-semantic fragment HTML.
|
230
234
|
def render_nonsemantic_fragment(fragment_tag, text, url, options = {})
|
235
|
+
fragment_class = [options[:fragment_class], options[:class]].join(' ').strip
|
236
|
+
fragment_class = nil if fragment_class.blank?
|
237
|
+
|
231
238
|
if fragment_tag
|
232
239
|
text = breadcrumb_link_to(text, url) if url.present?
|
233
|
-
content_tag(fragment_tag, text, class:
|
240
|
+
content_tag(fragment_tag, text, class: fragment_class)
|
234
241
|
elsif url.present?
|
235
|
-
breadcrumb_link_to(text, url, class:
|
242
|
+
breadcrumb_link_to(text, url, class: fragment_class)
|
236
243
|
elsif options[:class].present?
|
237
|
-
content_tag(:span, text, class:
|
244
|
+
content_tag(:span, text, class: fragment_class)
|
238
245
|
else
|
239
246
|
text
|
240
247
|
end
|
data/lib/gretel/version.rb
CHANGED
File without changes
|
data/test/dummy/db/schema.rb
CHANGED
@@ -1,29 +1,28 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
5
4
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# from scratch.
|
10
|
-
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `rails
|
6
|
+
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
11
10
|
#
|
12
|
-
# It's strongly recommended
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
12
|
|
14
|
-
ActiveRecord::Schema.define(:
|
13
|
+
ActiveRecord::Schema.define(version: 2013_01_22_163051) do
|
15
14
|
|
16
|
-
create_table "issues", :
|
17
|
-
t.string
|
18
|
-
t.integer
|
19
|
-
t.datetime "created_at"
|
20
|
-
t.datetime "updated_at"
|
15
|
+
create_table "issues", force: :cascade do |t|
|
16
|
+
t.string "title"
|
17
|
+
t.integer "project_id"
|
18
|
+
t.datetime "created_at"
|
19
|
+
t.datetime "updated_at"
|
21
20
|
end
|
22
21
|
|
23
|
-
create_table "projects", :
|
24
|
-
t.string
|
25
|
-
t.datetime "created_at"
|
26
|
-
t.datetime "updated_at"
|
22
|
+
create_table "projects", force: :cascade do |t|
|
23
|
+
t.string "name"
|
24
|
+
t.datetime "created_at"
|
25
|
+
t.datetime "updated_at"
|
27
26
|
end
|
28
27
|
|
29
28
|
end
|
data/test/gretel_test.rb
CHANGED
@@ -11,7 +11,6 @@ class GretelTest < ActiveSupport::TestCase
|
|
11
11
|
Rails.root.join("app", "views", "breadcrumbs", "**", "*.rb")],
|
12
12
|
Gretel.breadcrumb_paths[-3..-1]
|
13
13
|
assert_equal ["development"], Gretel.reload_environments
|
14
|
-
assert !Gretel.suppress_deprecation_warnings?
|
15
14
|
end
|
16
15
|
|
17
16
|
test "configuration block" do
|
@@ -21,4 +20,4 @@ class GretelTest < ActiveSupport::TestCase
|
|
21
20
|
|
22
21
|
assert_equal ["development", "staging"], Gretel.reload_environments
|
23
22
|
end
|
24
|
-
end
|
23
|
+
end
|
data/test/helper_methods_test.rb
CHANGED
@@ -129,6 +129,12 @@ class HelperMethodsTest < ActionView::TestCase
|
|
129
129
|
breadcrumbs(class: "custom_class").to_s
|
130
130
|
end
|
131
131
|
|
132
|
+
test "custom fragment class" do
|
133
|
+
breadcrumb :basic
|
134
|
+
assert_dom_equal %{<div class="breadcrumbs"><a class="custom_fragment_class" href="/">Home</a> › <span class="custom_fragment_class current">About</span></div>},
|
135
|
+
breadcrumbs(fragment_class: "custom_fragment_class").to_s
|
136
|
+
end
|
137
|
+
|
132
138
|
test "custom current class" do
|
133
139
|
breadcrumb :basic
|
134
140
|
assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> › <span class="custom_current_class">About</span></div>},
|
@@ -358,6 +364,12 @@ class HelperMethodsTest < ActionView::TestCase
|
|
358
364
|
breadcrumbs(style: :bootstrap).to_s
|
359
365
|
end
|
360
366
|
|
367
|
+
test "bootstrap4 style" do
|
368
|
+
breadcrumb :basic
|
369
|
+
assert_dom_equal %{<ol class="breadcrumb"><li class="breadcrumb-item"><a href="/">Home</a></li><li class="breadcrumb-item active">About</li></ol>},
|
370
|
+
breadcrumbs(style: :bootstrap4).to_s
|
371
|
+
end
|
372
|
+
|
361
373
|
test "foundation5 style" do
|
362
374
|
breadcrumb :basic
|
363
375
|
assert_dom_equal %{<ul class="breadcrumbs"><li><a href="/">Home</a></li><li class="current">About</li></ul>},
|
data/test/test_helper.rb
CHANGED
@@ -1,15 +1,23 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
require "simplecov-erb"
|
3
|
+
|
4
|
+
SimpleCov.start do
|
5
|
+
enable_coverage :branch
|
6
|
+
formatter SimpleCov::Formatter::MultiFormatter.new([
|
7
|
+
SimpleCov::Formatter::ERBFormatter,
|
8
|
+
SimpleCov::Formatter::HTMLFormatter
|
9
|
+
])
|
10
|
+
end
|
11
|
+
|
12
|
+
SimpleCov.minimum_coverage 99 # TODO: Get to 100!
|
13
|
+
|
1
14
|
# Configure Rails Environment
|
2
15
|
ENV["RAILS_ENV"] = "test"
|
3
16
|
|
4
|
-
require File.expand_path("
|
17
|
+
require File.expand_path("dummy/config/environment.rb", __dir__)
|
5
18
|
require "rails/test_help"
|
6
19
|
|
7
20
|
Rails.backtrace_cleaner.remove_silencers!
|
8
21
|
|
9
22
|
# Load support files
|
10
|
-
Dir["#{
|
11
|
-
|
12
|
-
# Load fixtures from the engine
|
13
|
-
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
-
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
-
end
|
23
|
+
Dir["#{__dir__}/support/**/*.rb"].each { |f| require f }
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gretel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Bunk
|
8
|
-
|
8
|
+
- Kazuki Nishikawa
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2020-08-12 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rails
|
@@ -16,14 +17,14 @@ dependencies:
|
|
16
17
|
requirements:
|
17
18
|
- - ">="
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
+
version: '5.1'
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
+
version: '5.1'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: sqlite3
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,10 +39,66 @@ dependencies:
|
|
38
39
|
- - ">="
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: jquery-rails
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: test-unit
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: simplecov
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.18.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.18.0
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: simplecov-erb
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0.1'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0.1'
|
41
98
|
description: Gretel is a Ruby on Rails plugin that makes it easy yet flexible to create
|
42
99
|
breadcrumbs.
|
43
100
|
email:
|
44
|
-
-
|
101
|
+
- kzkn@users.noreply.github.com
|
45
102
|
executables: []
|
46
103
|
extensions: []
|
47
104
|
extra_rdoc_files: []
|
@@ -53,10 +110,7 @@ files:
|
|
53
110
|
- LICENSE.txt
|
54
111
|
- README.md
|
55
112
|
- Rakefile
|
56
|
-
-
|
57
|
-
- gemfiles/Gemfile-rails.3.2.x
|
58
|
-
- gemfiles/Gemfile-rails.4.0.x
|
59
|
-
- gemfiles/Gemfile-rails.4.1.x
|
113
|
+
- coverage/coverage.txt
|
60
114
|
- gretel.gemspec
|
61
115
|
- lib/generators/gretel/USAGE
|
62
116
|
- lib/generators/gretel/install_generator.rb
|
@@ -64,18 +118,13 @@ files:
|
|
64
118
|
- lib/gretel.rb
|
65
119
|
- lib/gretel/crumb.rb
|
66
120
|
- lib/gretel/crumbs.rb
|
67
|
-
- lib/gretel/deprecated.rb
|
68
|
-
- lib/gretel/deprecated/default_style_key.rb
|
69
|
-
- lib/gretel/deprecated/layout.rb
|
70
|
-
- lib/gretel/deprecated/show_root_alone.rb
|
71
|
-
- lib/gretel/deprecated/yield_links.rb
|
72
121
|
- lib/gretel/link.rb
|
73
122
|
- lib/gretel/renderer.rb
|
74
123
|
- lib/gretel/resettable.rb
|
75
124
|
- lib/gretel/version.rb
|
76
125
|
- lib/gretel/view_helpers.rb
|
77
|
-
- test/deprecated_test.rb
|
78
126
|
- test/dummy/Rakefile
|
127
|
+
- test/dummy/app/assets/config/manifest.js
|
79
128
|
- test/dummy/app/assets/javascripts/application.js
|
80
129
|
- test/dummy/app/assets/stylesheets/application.css
|
81
130
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -118,11 +167,11 @@ files:
|
|
118
167
|
- test/gretel_test.rb
|
119
168
|
- test/helper_methods_test.rb
|
120
169
|
- test/test_helper.rb
|
121
|
-
homepage: http://github.com/
|
170
|
+
homepage: http://github.com/kzkn/gretel
|
122
171
|
licenses:
|
123
172
|
- MIT
|
124
173
|
metadata: {}
|
125
|
-
post_install_message:
|
174
|
+
post_install_message:
|
126
175
|
rdoc_options: []
|
127
176
|
require_paths:
|
128
177
|
- lib
|
@@ -137,14 +186,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
186
|
- !ruby/object:Gem::Version
|
138
187
|
version: '0'
|
139
188
|
requirements: []
|
140
|
-
|
141
|
-
|
142
|
-
signing_key:
|
189
|
+
rubygems_version: 3.0.3
|
190
|
+
signing_key:
|
143
191
|
specification_version: 4
|
144
192
|
summary: Flexible Ruby on Rails breadcrumbs plugin.
|
145
193
|
test_files:
|
146
|
-
- test/deprecated_test.rb
|
147
194
|
- test/dummy/Rakefile
|
195
|
+
- test/dummy/app/assets/config/manifest.js
|
148
196
|
- test/dummy/app/assets/javascripts/application.js
|
149
197
|
- test/dummy/app/assets/stylesheets/application.css
|
150
198
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem "gretel", :path => ".."
|
4
|
-
|
5
|
-
gem "rails", "~> 3.1.0"
|
6
|
-
gem "sqlite3"
|
7
|
-
|
8
|
-
# jquery-rails is used by the dummy application
|
9
|
-
gem "jquery-rails"
|
10
|
-
|
11
|
-
# Declare any dependencies that are still in development here instead of in
|
12
|
-
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
-
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
-
# your gem to rubygems.org.
|
15
|
-
|
16
|
-
# To use debugger
|
17
|
-
# gem 'debugger'
|
18
|
-
|
19
|
-
gem 'test-unit', '~> 3.0' if RUBY_VERSION >= "2.2"
|
@@ -1,19 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem "gretel", :path => ".."
|
4
|
-
|
5
|
-
gem "rails", "~> 3.2.0"
|
6
|
-
gem "sqlite3"
|
7
|
-
|
8
|
-
# jquery-rails is used by the dummy application
|
9
|
-
gem "jquery-rails"
|
10
|
-
|
11
|
-
# Declare any dependencies that are still in development here instead of in
|
12
|
-
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
-
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
-
# your gem to rubygems.org.
|
15
|
-
|
16
|
-
# To use debugger
|
17
|
-
# gem 'debugger'
|
18
|
-
|
19
|
-
gem 'test-unit', '~> 3.0' if RUBY_VERSION >= "2.2"
|
@@ -1,19 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem "gretel", :path => ".."
|
4
|
-
|
5
|
-
gem "rails", "~> 4.0.0"
|
6
|
-
gem "sqlite3"
|
7
|
-
|
8
|
-
# jquery-rails is used by the dummy application
|
9
|
-
gem "jquery-rails"
|
10
|
-
|
11
|
-
# Declare any dependencies that are still in development here instead of in
|
12
|
-
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
-
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
-
# your gem to rubygems.org.
|
15
|
-
|
16
|
-
# To use debugger
|
17
|
-
# gem 'debugger'
|
18
|
-
|
19
|
-
gem 'test-unit', '~> 3.0' if RUBY_VERSION >= "2.2"
|
@@ -1,19 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem "gretel", :path => ".."
|
4
|
-
|
5
|
-
gem "rails", "~> 4.1.0"
|
6
|
-
gem "sqlite3"
|
7
|
-
|
8
|
-
# jquery-rails is used by the dummy application
|
9
|
-
gem "jquery-rails"
|
10
|
-
|
11
|
-
# Declare any dependencies that are still in development here instead of in
|
12
|
-
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
-
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
-
# your gem to rubygems.org.
|
15
|
-
|
16
|
-
# To use debugger
|
17
|
-
# gem 'debugger'
|
18
|
-
|
19
|
-
gem 'test-unit', '~> 3.0' if RUBY_VERSION >= "2.2"
|
data/lib/gretel/deprecated.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Dir[File.dirname(__FILE__) + "/deprecated/*.rb"].each { |file| require file }
|
@@ -1,25 +0,0 @@
|
|
1
|
-
if RUBY_VERSION < "2.0"
|
2
|
-
Gretel::Renderer.class_eval do
|
3
|
-
def options_for_style_with_default_style_key(style_key)
|
4
|
-
if style_key == :default
|
5
|
-
Gretel.show_deprecation_warning "The :default style key is now called :inline. Please use `breadcrumbs style: :inline` instead or omit it, as it is the default."
|
6
|
-
style_key = :inline
|
7
|
-
end
|
8
|
-
options_for_style_without_default_style_key(style_key)
|
9
|
-
end
|
10
|
-
|
11
|
-
alias_method_chain :options_for_style, :default_style_key
|
12
|
-
end
|
13
|
-
else
|
14
|
-
module DeprecatedDefaultStyleKey
|
15
|
-
def options_for_style(style_key)
|
16
|
-
if style_key == :default
|
17
|
-
Gretel.show_deprecation_warning "The :default style key is now called :inline. Please use `breadcrumbs style: :inline` instead or omit it, as it is the default."
|
18
|
-
style_key = :inline
|
19
|
-
end
|
20
|
-
super(style_key)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
Gretel::Renderer.send :prepend, DeprecatedDefaultStyleKey
|
25
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
Gretel::Crumbs.class_eval do
|
2
|
-
class << self
|
3
|
-
# Was used to lay out breadcrumbs in an initializer. Deprecated since v2.1.0
|
4
|
-
# and removed in v3.0.0. Will raise an exception if used. Put breadcrumbs in
|
5
|
-
# +config/breadcrumbs.rb+ instead (see
|
6
|
-
# https://github.com/lassebunk/gretel/blob/master/README.md for details).
|
7
|
-
def layout(&block)
|
8
|
-
raise (
|
9
|
-
"Gretel::Crumbs.layout was removed in Gretel version 3.0. " +
|
10
|
-
"Please put your breadcrumbs in `config/breadcrumbs.rb`. " +
|
11
|
-
"This will also automatically reload your breadcrumbs when you change them in the development environment. " +
|
12
|
-
"See https://github.com/lassebunk/gretel/blob/master/README.md for details.")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
if RUBY_VERSION < "2.0"
|
2
|
-
Gretel::Renderer.class_eval do
|
3
|
-
def options_for_render_with_show_root_alone(options = {})
|
4
|
-
options = options_for_render_without_show_root_alone(options)
|
5
|
-
if show_root_alone = options.delete(:show_root_alone)
|
6
|
-
Gretel.show_deprecation_warning "The :show_root_alone option is deprecated and will be removed in Gretel v4.0.0. Use `breadcrumbs(display_single_fragment: #{show_root_alone.inspect})` instead."
|
7
|
-
options[:display_single_fragment] = show_root_alone
|
8
|
-
end
|
9
|
-
options
|
10
|
-
end
|
11
|
-
|
12
|
-
alias_method_chain :options_for_render, :show_root_alone
|
13
|
-
end
|
14
|
-
else
|
15
|
-
module DeprecatedShowRootAlone
|
16
|
-
def options_for_render(options = {})
|
17
|
-
options = super(options)
|
18
|
-
if show_root_alone = options.delete(:show_root_alone)
|
19
|
-
Gretel.show_deprecation_warning "The :show_root_alone option is deprecated and will be removed in Gretel v4.0.0. Use `breadcrumbs(display_single_fragment: #{show_root_alone.inspect})` instead."
|
20
|
-
options[:display_single_fragment] = show_root_alone
|
21
|
-
end
|
22
|
-
options
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
Gretel::Renderer.send :prepend, DeprecatedShowRootAlone
|
27
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
if RUBY_VERSION < "2.0"
|
2
|
-
Gretel::ViewHelpers.class_eval do
|
3
|
-
|
4
|
-
def breadcrumbs_with_yield_links(options = {})
|
5
|
-
if block_given?
|
6
|
-
Gretel.show_deprecation_warning(
|
7
|
-
"Calling `breadcrumbs` with a block has been deprecated and will be removed in Gretel version 4.0. Please use `tap` instead. Example:\n" +
|
8
|
-
"\n" +
|
9
|
-
" breadcrumbs(autoroot: false).tap do |links|\n" +
|
10
|
-
" if links.any?\n" +
|
11
|
-
" # process links here\n" +
|
12
|
-
" end\n" +
|
13
|
-
" end\n"
|
14
|
-
)
|
15
|
-
yield gretel_renderer.render(options)
|
16
|
-
else
|
17
|
-
breadcrumbs_without_yield_links(options)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
alias_method_chain :breadcrumbs, :yield_links
|
22
|
-
end
|
23
|
-
else
|
24
|
-
module DeprecatedYieldLinks
|
25
|
-
def breadcrumbs(options = {})
|
26
|
-
if block_given?
|
27
|
-
Gretel.show_deprecation_warning(
|
28
|
-
"Calling `breadcrumbs` with a block has been deprecated and will be removed in Gretel version 4.0. Please use `tap` instead. Example:\n" +
|
29
|
-
"\n" +
|
30
|
-
" breadcrumbs(autoroot: false).tap do |links|\n" +
|
31
|
-
" if links.any?\n" +
|
32
|
-
" # process links here\n" +
|
33
|
-
" end\n" +
|
34
|
-
" end\n"
|
35
|
-
)
|
36
|
-
yield gretel_renderer.render(options)
|
37
|
-
else
|
38
|
-
super(options)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
Gretel::ViewHelpers.send :prepend, DeprecatedYieldLinks
|
44
|
-
end
|
data/test/deprecated_test.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class DeprecatedTest < ActionView::TestCase
|
4
|
-
include Gretel::ViewHelpers
|
5
|
-
fixtures :all
|
6
|
-
helper :application
|
7
|
-
|
8
|
-
setup do
|
9
|
-
Gretel.reset!
|
10
|
-
Gretel.suppress_deprecation_warnings = true
|
11
|
-
end
|
12
|
-
|
13
|
-
test "show root alone" do
|
14
|
-
breadcrumb :root
|
15
|
-
assert_equal %{<div class="breadcrumbs"><span class="current">Home</span></div>},
|
16
|
-
breadcrumbs(show_root_alone: true).to_s
|
17
|
-
end
|
18
|
-
|
19
|
-
test "deprecated configuration block" do
|
20
|
-
assert_raises RuntimeError do
|
21
|
-
Gretel::Crumbs.layout do
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
test ":default style key" do
|
27
|
-
breadcrumb :basic
|
28
|
-
|
29
|
-
assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> › <span class="current">About</span></div>},
|
30
|
-
breadcrumbs(style: :default).to_s
|
31
|
-
end
|
32
|
-
|
33
|
-
test "yield links" do
|
34
|
-
breadcrumb :multiple_links_with_parent
|
35
|
-
|
36
|
-
out = breadcrumbs do |links|
|
37
|
-
links.map { |link| [link.key, link.text, link.url] }
|
38
|
-
end
|
39
|
-
|
40
|
-
assert_equal [[:root, "Home", "/"],
|
41
|
-
[:basic, "About", "/about"],
|
42
|
-
[:multiple_links_with_parent, "Contact", "/about/contact"],
|
43
|
-
[:multiple_links_with_parent, "Contact form", "/about/contact/form"]], out
|
44
|
-
end
|
45
|
-
end
|