gretel 4.0.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +52 -0
  3. data/.gitignore +7 -6
  4. data/CHANGELOG.md +20 -0
  5. data/Gemfile +3 -1
  6. data/README.md +46 -44
  7. data/Rakefile +3 -7
  8. data/coverage/coverage.txt +1 -2
  9. data/gretel.gemspec +9 -11
  10. data/lib/gretel.rb +1 -7
  11. data/lib/gretel/crumb.rb +5 -2
  12. data/lib/gretel/crumbs.rb +26 -7
  13. data/lib/gretel/railtie.rb +11 -0
  14. data/lib/gretel/renderer.rb +65 -33
  15. data/lib/gretel/version.rb +1 -1
  16. data/lib/gretel/view_helpers.rb +2 -0
  17. metadata +37 -112
  18. data/.travis.yml +0 -14
  19. data/test/dummy/Rakefile +0 -7
  20. data/test/dummy/app/assets/config/manifest.js +0 -0
  21. data/test/dummy/app/assets/javascripts/application.js +0 -15
  22. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  23. data/test/dummy/app/controllers/application_controller.rb +0 -3
  24. data/test/dummy/app/helpers/application_helper.rb +0 -5
  25. data/test/dummy/app/mailers/.gitkeep +0 -0
  26. data/test/dummy/app/models/.gitkeep +0 -0
  27. data/test/dummy/app/models/issue.rb +0 -3
  28. data/test/dummy/app/models/project.rb +0 -3
  29. data/test/dummy/app/views/breadcrumbs/site.rb +0 -3
  30. data/test/dummy/config.ru +0 -4
  31. data/test/dummy/config/application.rb +0 -14
  32. data/test/dummy/config/boot.rb +0 -10
  33. data/test/dummy/config/breadcrumbs.rb +0 -3
  34. data/test/dummy/config/breadcrumbs/test_crumbs.rb +0 -85
  35. data/test/dummy/config/database.yml +0 -25
  36. data/test/dummy/config/environment.rb +0 -5
  37. data/test/dummy/config/environments/development.rb +0 -2
  38. data/test/dummy/config/environments/production.rb +0 -2
  39. data/test/dummy/config/environments/test.rb +0 -2
  40. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  41. data/test/dummy/config/initializers/inflections.rb +0 -15
  42. data/test/dummy/config/initializers/mime_types.rb +0 -5
  43. data/test/dummy/config/initializers/secret_token.rb +0 -7
  44. data/test/dummy/config/initializers/session_store.rb +0 -8
  45. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  46. data/test/dummy/config/locales/en.yml +0 -5
  47. data/test/dummy/config/routes.rb +0 -11
  48. data/test/dummy/db/migrate/20130122163007_create_projects.rb +0 -9
  49. data/test/dummy/db/migrate/20130122163051_create_issues.rb +0 -10
  50. data/test/dummy/db/schema.rb +0 -28
  51. data/test/dummy/lib/assets/.gitkeep +0 -0
  52. data/test/dummy/log/.gitkeep +0 -0
  53. data/test/dummy/public/404.html +0 -26
  54. data/test/dummy/public/422.html +0 -26
  55. data/test/dummy/public/500.html +0 -25
  56. data/test/dummy/public/favicon.ico +0 -0
  57. data/test/dummy/script/rails +0 -6
  58. data/test/fixtures/issues.yml +0 -4
  59. data/test/fixtures/projects.yml +0 -3
  60. data/test/gretel_test.rb +0 -23
  61. data/test/helper_methods_test.rb +0 -558
  62. data/test/test_helper.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6b2a5d8a3fd0fbb357c690e1d0189c54ab90ad1619c6ea5910b59f9cf718e89
4
- data.tar.gz: d5c633b783445c773bb031dbd2377ca8af9265ced45f9aaafeabebc853c754d6
3
+ metadata.gz: c1fe62ed99bb8f03e6a00a782f55adc5f6b6fcf84a444d77aa1c771b41d148a9
4
+ data.tar.gz: 1660db0b73ddbf77dac315c8d1466fb66958b9ebab59629c96f999536f17b824
5
5
  SHA512:
6
- metadata.gz: 5816c2df05e992e54868150d8f6689af7c2d2cb0af33b588c9ef552d54771efcf81b29a9b9f2bca223e784644288caf24987f8b38f546ea0b3a4be1944a73b1e
7
- data.tar.gz: 80497833712a92ac207f663ab544761ebf65b7a93d8d5fd7712e3bb8b3c8785b72ee85020ead35cd2e118a03f09e81a3d844c7dbbd629a3cf6cfb1b3d78669ba
6
+ metadata.gz: 4bddd221544196836669a1309c97d536ad2d2b11ef10c74a265e034d0a1463ba5b4955651235ad395b9c37249a9d5eff2ef9ec9b659ab896a8fbca959b199924
7
+ data.tar.gz: ebd6e183dc3597f83c9ac8b22399d0ad52e345da6586b9de59c2386c8b5116d40199fcf494c44cd8d094a25ed543d5ee21397506d1979ebf851a973e23da3ced
@@ -0,0 +1,52 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ schedule:
7
+ - cron: '0 0 * * 0'
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ rails_version: [5.1.0, 5.2.0, 6.0.0, 6.1.0, master]
15
+ ruby_version: [3.0, 2.7, 2.6, 2.5]
16
+ exclude:
17
+ - ruby_version: 2.5
18
+ rails_version: master
19
+ - ruby_version: 2.6
20
+ rails_version: master
21
+ - ruby_version: 3.0
22
+ rails_version: 5.1.0
23
+ - ruby_version: 3.0
24
+ rails_version: 5.2.0
25
+
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+
29
+ - name: Setup Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby_version }}
33
+
34
+ - name: Run test
35
+ env:
36
+ RAILS_VERSION: ${{ matrix.rails_version }}
37
+ run: |
38
+ bundle update
39
+ cd spec/dummy; rake db:migrate db:test:prepare; cd ../..
40
+ bundle exec rake
41
+
42
+ - name: Upload coverage
43
+ uses: actions/upload-artifact@v2
44
+ if: always()
45
+ with:
46
+ name: coverage-ruby-${{ matrix.ruby_version }}-rails-${{ matrix.rails_version }}
47
+ path: coverage
48
+
49
+ - name: Show coverage
50
+ if: always()
51
+ run: |
52
+ cat coverage/coverage.txt
data/.gitignore CHANGED
@@ -12,17 +12,18 @@ lib/bundler/man
12
12
  pkg
13
13
  rdoc
14
14
  spec/reports
15
- test/tmp
16
- test/version_tmp
15
+ spec/tmp
16
+ spec/version_tmp
17
17
  tmp
18
18
  log/*.log
19
- test/dummy/db/*.sqlite3
20
- test/dummy/log/*.log
21
- test/dummy/tmp/
22
- test/dummy/.sass-cache
19
+ spec/dummy/db/*.sqlite3
20
+ spec/dummy/log/*.log
21
+ spec/dummy/tmp/
22
+ spec/dummy/.sass-cache
23
23
  .DS_Store
24
24
 
25
25
  /coverage/index.html
26
26
  /coverage/assets
27
27
  /coverage/*.json
28
28
  /coverage/*.json.lock
29
+ /.ruby-version
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 4.3.0
4
+ * Support generating `aria-current` attribute. It's disabled by default. See the readme for more info
5
+
6
+ ## Version 4.2.0
7
+ * Support generating JSON-LD structured data. See the readme for more info (via #26, thanks @dkniffin)
8
+
9
+ ## Version 4.1.0
10
+ * Depends only `railties` and `actionview`, not `rails` (via #7)
11
+ * Include `Gretel::ViewHelpers` module in `ActiveSupport.on_load(:action_view)` block
12
+ * Fix ruby 2.7 keywords warning (via #24, thanks @aki77)
13
+ * Fix multithreaded environment issue (via #13)
14
+ * `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`
15
+
16
+ ## Version 4.0.2
17
+ * The return value of `breadcrumbs` is `html_safe` now (via #22)
18
+ * For the slim template engine users: You don't need to use `==` instead of `=` for `breadcrumbs`
19
+
20
+ ## Version 4.0.1
21
+ * Replaces data-vocabulary markup as google doesn't support it and now uses schema.org markup (via #17)
22
+
3
23
  ## Version 4.0.0
4
24
  * Support Bootstrap 4. See the `:style` option in the readme for more info
5
25
  * CSS class for fragment link or span is now customizable. See the `:fragment_class` option in the readme for more info
data/Gemfile CHANGED
@@ -3,4 +3,6 @@ source "http://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  rails_version = ENV['RAILS_VERSION'] || '>= 0'
6
- gem 'rails', rails_version
6
+ rails_version = "~> #{rails_version}" if rails_version =~ /^\d/
7
+
8
+ gem 'rails', rails_version == 'master' ? { github: 'rails/rails' } : rails_version
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
- <a href="http://travis-ci.org/kzkn/gretel"><img src="https://secure.travis-ci.org/kzkn/gretel.png" alt="Build Status" /></a>
1
+ [![Gem Version](https://badge.fury.io/rb/gretel.svg)](http://badge.fury.io/rb/gretel)
2
+ ![](https://github.com/kzkn/gretel/workflows/CI/badge.svg)
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](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417) (those used in Google results).
8
+ Gretel also supports [semantic breadcrumbs](https://developers.google.com/search/docs/data-types/breadcrumb) (those used in Google results).
8
9
 
9
10
  Have fun!
10
11
 
@@ -88,7 +89,7 @@ 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](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417). | False
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"`
94
95
  :fragment_class | CSS class for the fragment link or span. Can be set to `nil` for no class. | None
@@ -97,6 +98,7 @@ Option | Description
97
98
  :posttext_class | CSS class for the posttext, if given. Can be set to `nil` for no class. | `"posttext"`
98
99
  :container_tag | Tag type that contains the breadcrumbs. | `:div`
99
100
  :fragment_tag | Tag type to contain each breadcrumb fragment/link. | None
101
+ :aria_current | Value of `aria-current` attribute. | None
100
102
 
101
103
  ### Styles
102
104
 
@@ -104,12 +106,12 @@ These are the styles you can use with `breadcrumbs style: :xx`.
104
106
 
105
107
  Style | Description
106
108
  -------------- | -----------
107
- `:inline` | Renders each link by itself with `&rsaquo;` as the seperator.
109
+ `:inline` | Default. Renders each link by itself with `&rsaquo;` as the seperator.
108
110
  `:ol` | Renders the links in `<li>` elements contained in an outer `<ol>`.
109
111
  `:ul` | Renders the links in `<li>` elements contained in an outer `<ul>`.
110
- `:bootstrap` | Renders the links for use in [Twitter Bootstrap](http://getbootstrap.com/).
112
+ `:bootstrap` | Renders the links for use in [Bootstrap v3](https://getbootstrap.com/docs/3.4/).
111
113
  `:bootstrap4` | Renders the links for use in [Bootstrap v4](https://getbootstrap.com/).
112
- `:foundation5` | Renders the links for use in [Foundation 5](http://foundation.zurb.com/).
114
+ `:foundation5` | Renders the links for use in [Foundation 5](https://get.foundation/).
113
115
 
114
116
  Or you can build the breadcrumbs manually for full customization; see below.
115
117
 
@@ -201,6 +203,11 @@ end
201
203
  crumb :user do |user|
202
204
  link user_name_for(user), user
203
205
  end
206
+
207
+ # I18n
208
+ crumb :home do
209
+ link t("breadcrumbs.home"), root_path
210
+ end
204
211
  ```
205
212
 
206
213
  ## Building the breadcrumbs manually
@@ -218,6 +225,23 @@ You can use the `breadcrumbs` method directly as an array. It will return an arr
218
225
  <% end %>
219
226
  ```
220
227
 
228
+ If you use this approach, you lose the built-in semantic breadcrumb functionality. One way to
229
+ add them back is to use JSON-LD structured data:
230
+
231
+ ```erb
232
+ <script type="application/ld+json">
233
+ <%= breadcrumbs.structured_data(url_base: "https://example.com") %>
234
+ </script>
235
+ ```
236
+
237
+ Or, you can infer `url_base` from `request`:
238
+
239
+ ```erb
240
+ <script type="application/ld+json">
241
+ <%= breadcrumbs.structured_data(url_base: "#{request.protocol}#{request.host_with_port}") %>
242
+ </script>
243
+ ```
244
+
221
245
  ## Getting the parent breadcrumb
222
246
 
223
247
  If you want to add a link to the parent breadcrumb, you can use the `parent_breadcrumb` view helper.
@@ -291,56 +315,34 @@ breadcrumbs do |links|
291
315
  end
292
316
  ```
293
317
 
294
- ### Automatic reloading of breadcrumb configuration files
295
-
296
- 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.
297
-
298
- ### Setting breadcrumb trails
299
-
300
- 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
301
- 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.
302
-
303
- 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.
304
-
305
- Check out the gem [here](https://github.com/lassebunk/gretel-trails).
306
-
307
-
308
- ## Upgrading from version 2.0 or below
309
-
310
- 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).
311
- In the Rails development environment, these files are automatically reloaded when changed.
318
+ ### ARIA support
312
319
 
313
- 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.
320
+ You can improve the accessibility of your page with the markup that specified in [ARIA](https://www.w3.org/TR/wai-aria-practices/examples/breadcrumb/index.html). Gretel supports generating `aria-current` attribute:
314
321
 
315
- To update to the latest version of Gretel, use `bundle update gretel`. Then remove the `Gretel::Crumbs.layout do ... end` block, so instead of:
316
-
317
- ```ruby
318
- Gretel::Crumbs.layout do
319
- crumb :root do
320
- link "Home", root_path
321
- end
322
- end
322
+ ```erb
323
+ <% breadcrumb :issue, @issue %>
324
+ <%= breadcrumbs aria_current: "page" %>
323
325
  ```
324
326
 
325
- in the initializer, you write:
327
+ This will generate the following HTML (indented for readability):
326
328
 
327
- ```ruby
328
- crumb :root do
329
- link "Home", root_path
330
- end
329
+ ```html
330
+ <div class="breadcrumbs">
331
+ <a href="/">Home</a> &rsaquo;
332
+ <a href="/issues">All issues</a> &rsaquo;
333
+ <span class="current" aria-current="page">My Issue</span>
334
+ </div>
331
335
  ```
332
336
 
333
- in `config/breadcrumbs.rb`.
334
-
335
337
  ## Documentation
336
338
 
337
- * [Full documentation](http://rubydoc.info/gems/gretel)
339
+ * [Full documentation](https://rubydoc.info/gems/gretel)
338
340
  * [Changelog](https://github.com/kzkn/gretel/blob/master/CHANGELOG.md)
339
- * [Tutorial on using Gretel](http://www.sitepoint.com/breadcrumbs-rails-gretel/) (Sitepoint)
341
+ * [Tutorial on using Gretel](https://www.sitepoint.com/breadcrumbs-rails-gretel/) (Sitepoint)
340
342
 
341
343
  ## Versioning
342
344
 
343
- Follows [semantic versioning](http://semver.org/).
345
+ Follows [semantic versioning](https://semver.org/).
344
346
 
345
347
  ## Contributing
346
348
 
@@ -352,7 +354,7 @@ To contribute:
352
354
  2. Create your feature branch (`git checkout -b my-new-feature`)
353
355
  3. Make your changes
354
356
  4. Add/Fix tests
355
- 5. Prepare database for testing: `cd test/dummy; rake db:migrate; rake db:test:prepare; cd ../..`
357
+ 5. Prepare database for testing: `cd spec/dummy; rake db:migrate; rake db:test:prepare; cd ../..`
356
358
  6. Run `rake` to make sure all tests pass
357
359
  7. Be sure to check in the changes to `coverage/coverage.txt`
358
360
  8. Commit your changes (`git commit -am 'Add new feature'`)
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
- Rake::TestTask.new do |t|
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: :test
6
+ task default: :spec
@@ -2,5 +2,4 @@
2
2
  Incomplete test coverage
3
3
  --------------------------------------------------------------------------------
4
4
 
5
- /lib/gretel/renderer.rb: 99.12% (missed: 45)
6
- /test/helper_methods_test.rb: 99.24% (missed: 17,196)
5
+ 100% test coverage. You're all set, friend!
data/gretel.gemspec CHANGED
@@ -1,7 +1,4 @@
1
- # -*- encoding: utf-8 -*-
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"
@@ -13,14 +10,15 @@ Gem::Specification.new do |gem|
13
10
  gem.homepage = "http://github.com/kzkn/gretel"
14
11
  gem.license = "MIT"
15
12
 
16
- gem.files = `git ls-files`.split($/)
17
- gem.test_files = gem.files.grep(%r{^test/})
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 "rails", ">= 5.1"
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"
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"
21
+ gem.add_development_dependency "rspec-rails"
22
+ gem.add_development_dependency "simplecov"
23
+ gem.add_development_dependency "simplecov-erb"
26
24
  end
data/lib/gretel.rb CHANGED
@@ -1,10 +1,6 @@
1
1
  require 'gretel/version'
2
2
  require 'gretel/resettable'
3
- require 'gretel/crumbs'
4
- require 'gretel/crumb'
5
- require 'gretel/link'
6
- require 'gretel/renderer'
7
- require 'gretel/view_helpers'
3
+ require 'gretel/railtie'
8
4
 
9
5
  module Gretel
10
6
  class << self
@@ -57,5 +53,3 @@ module Gretel
57
53
  end
58
54
  end
59
55
  end
60
-
61
- 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 *args, &block
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
data/lib/gretel/crumbs.rb CHANGED
@@ -3,11 +3,6 @@ module Gretel
3
3
  class << self
4
4
  include Resettable
5
5
 
6
- # Stores the supplied block for later use.
7
- def crumb(key, &block)
8
- crumbs[key] = block
9
- end
10
-
11
6
  # Returns a hash of all stored crumb blocks.
12
7
  def crumbs
13
8
  @crumbs ||= {}
@@ -20,14 +15,15 @@ module Gretel
20
15
 
21
16
  # Loads the breadcrumb configuration files.
22
17
  def load_breadcrumbs
23
- @crumbs = {}
18
+ builder = Builder.new
24
19
 
25
20
  loaded_file_mtimes.clear
26
21
  breadcrumb_files.each do |file|
27
- instance_eval open(file).read, file
22
+ builder.instance_eval open(file).read, file
28
23
  loaded_file_mtimes << File.mtime(file)
29
24
  end
30
25
 
26
+ @crumbs = builder.crumbs
31
27
  @loaded = true
32
28
  end
33
29
 
@@ -59,6 +55,29 @@ module Gretel
59
55
  def loaded_file_mtimes
60
56
  @loaded_file_mtimes ||= []
61
57
  end
58
+
59
+ class Builder
60
+ attr_reader :crumbs
61
+
62
+ def initialize
63
+ @crumbs = {}
64
+ end
65
+
66
+ # Stores the supplied block for later use.
67
+ def crumb(key, &block)
68
+ crumbs[key] = block
69
+ end
70
+
71
+ # Returns a hash of all stored crumb blocks.
72
+ def crumbs
73
+ @crumbs ||= {}
74
+ end
75
+
76
+ # Returns true if a crumb with the given key has been set.
77
+ def crumb_defined?(key)
78
+ crumbs.has_key?(key)
79
+ end
80
+ end
62
81
  end
63
82
  end
64
83
  end