gretel 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3591671a58fa51ef230c08c05fc535f6e8aad39b
4
- data.tar.gz: cbd4f1d910a5b92b74c8952cc30cf313c502e2ca
3
+ metadata.gz: b35944b5de1eba707a9be4b26bc73f5bdc0716fe
4
+ data.tar.gz: c36db3b340cc0e3a992c0ed4c7f001cea361e594
5
5
  SHA512:
6
- metadata.gz: 93a1b0736c9fc45bd743f2bbfad9fcb1c629eddbbaae9f77bd5badcda3d2a2488f3de6554f053558a610c10366d077b1c6eb8ce508ebb93ec2b59d184a471826
7
- data.tar.gz: 740422f9236bfecb8b0115df2d33007bf09b0fa49f3f1b5b90d01336c2e29bbc6f1980033c275bb5d7683d024f3a2badfb7c7fb3e7ddd43baf96ad9e70822e41
6
+ metadata.gz: 0de7bbe764ebedc259521e875dbbfbcaf99de5cef1f71d8240a207366ae5ee1204cd9a61e57cf3739aa97189a6d59a6d0a7acd76d415ea685457c3e667fd5fff
7
+ data.tar.gz: a1e5792570f980b9a67aba3e25498844c6b1df043ebe9d72ac13333f0937070090b4f6bebe8937778ebc10f710e3995ee1af69f1cc18322e8d9d46a6c35b93da
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ Version 3.0.1
5
+ -------------
6
+ * Breadcrumbs can now be inferred if you pass in an ActiveRecord model instance. E.g. `breadcrumb @product` is short for `breadcrumb :product, @product`.
7
+
4
8
  Version 3.0
5
9
  -----------
6
10
  * Support for defining breadcrumbs using `Gretel::Crumbs.layout do ... end` in an initializer has been removed. See the readme for details on how to upgrade.
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
- [![Build Status](https://secure.travis-ci.org/lassebunk/gretel.png)](http://travis-ci.org/lassebunk/gretel)
1
+ <a href="http://travis-ci.org/lassebunk/gretel"><img src="https://secure.travis-ci.org/lassebunk/gretel.png" alt="Build Status" /></a>
2
2
 
3
- Gretel is a [Ruby on Rails](http://rubyonrails.org) plugin that makes it easy yet flexible to create breadcrumbs.
4
- It is based around the idea that breadcrumbs are a separate concern, and therefore should be defined in their own place.
5
- You define a set of breadcrumbs in the config folder and specify in the view which breadcrumb to use.
3
+ <img src="http://i.imgur.com/CAKEaBM.png" alt="Handle breadcrumb trails... like a boss :)" />
4
+
5
+ ([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
+ 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.
6
7
  Gretel also supports [semantic breadcrumbs](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=185417) (those used in Google results).
7
8
 
8
9
  Have fun! And please do write, if you (dis)like it – [lassebunk@gmail.com](mailto:lassebunk@gmail.com).
@@ -17,6 +18,8 @@ Have fun! And please do write, if you (dis)like it – [lassebunk@gmail.com](mai
17
18
  * New view helper: `parent_breadcrumb` returns the parent breadcrumb link (with `#key`, `#text`, and `#url`). This can for example be used to create a dynamic back link.
18
19
  You can supply options like `:autoroot` etc.
19
20
  If you supply a block, it will yield the parent breadcrumb if it is present.
21
+ * Breadcrumbs can now be inferred if you pass in an ActiveRecord model instance. E.g. `breadcrumb @product` is short for `breadcrumb :product, @product`.
22
+
20
23
 
21
24
  I hope you find these changes as useful as I did – if you have more suggestions, please create an [Issue](https://github.com/lassebunk/gretel/issues) or [Pull Request](https://github.com/lassebunk/gretel/pulls).
22
25
 
@@ -110,7 +113,7 @@ Option | Description
110
113
 
111
114
  ### Styles
112
115
 
113
- These are the styles you can use with `breadcrumb style: :xx`.
116
+ These are the styles you can use with `breadcrumbs style: :xx`.
114
117
 
115
118
  Style | Description
116
119
  ------------ | -----------
@@ -251,6 +254,13 @@ When configuring breadcrumbs inside a `crumb :xx do ... end` block, you have acc
251
254
  If you have a large site and you want to split your breadcrumbs configuration over multiple files, you can create a folder named `config/breadcrumbs` and put your configuration files (e.g. `products.rb` or `frontend.rb`) in there.
252
255
  The format is the same as `config/breadcrumbs.rb` which is also loaded.
253
256
 
257
+ ### Inferring breadcrumbs
258
+
259
+ Breadcrumbs can be automatically inferred if you pass in an ActiveRecord model instance.
260
+
261
+ For example `breadcrumb @product` is short for `breadcrumb :product, @product`.
262
+
263
+
254
264
  ### Automatic reloading of breadcrumb configuration files
255
265
 
256
266
  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.
@@ -301,8 +311,28 @@ in `config/breadcrumbs.rb`.
301
311
 
302
312
  Follows [semantic versioning](http://semver.org/).
303
313
 
314
+ ## Contributing
315
+
316
+ You are very welcome to help improve Gretel if you have suggestions for features that other people can use.
317
+
318
+ To contribute:
319
+
320
+ 1. Fork the project
321
+ 2. Create your feature branch (git checkout -b my-new-feature)
322
+ 3. Commit your changes (git commit -am 'Add new feature')
323
+ 4. Push to the branch (git push origin my-new-feature)
324
+ 5. Create new pull request
325
+
326
+ Thanks.
327
+
304
328
  ## Contributors
305
329
 
306
330
  * [See the list of contributors](https://github.com/lassebunk/gretel/graphs/contributors)
307
331
 
332
+ ## And then
333
+
334
+ <img src="http://i.imgur.com/u4Wbt4n.png" alt="After using Gretel, you'll be like this" />
335
+
336
+ Have fun!
337
+
308
338
  Copyright (c) 2010-2013 [Lasse Bunk](http://lassebunk.dk), released under the MIT license
data/lib/gretel/crumbs.rb CHANGED
@@ -8,7 +8,7 @@ module Gretel
8
8
  crumbs[key] = block
9
9
  end
10
10
 
11
- # Returns an array of all stored crumb blocks.
11
+ # Returns a hash of all stored crumb blocks.
12
12
  def crumbs
13
13
  @crumbs ||= {}
14
14
  end
@@ -1,3 +1,3 @@
1
1
  module Gretel
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -7,6 +7,10 @@ module Gretel
7
7
  def breadcrumb(key = nil, *args)
8
8
  if key.nil? || key.is_a?(Hash)
9
9
  raise ArgumentError, "The `breadcrumb` method was called with #{key.inspect} as the key. This method is used to set the breadcrumb. Maybe you meant to call the `breadcrumbs` method (with an 's' in the end) which is used to render the breadcrumbs?"
10
+ elsif key.is_a?(ActiveRecord::Base)
11
+ # Enables calling `breadcrumb @product` instead of `breadcrumb :product, @product`
12
+ args.unshift key
13
+ key = key.class.model_name.to_s.underscore.to_sym
10
14
  end
11
15
  @_gretel_renderer = Gretel::Renderer.new(self, key, *args)
12
16
  end
@@ -68,4 +68,8 @@ end
68
68
 
69
69
  crumb :using_view_helper do
70
70
  link times_two("Test"), about_path
71
+ end
72
+
73
+ crumb :project do |project|
74
+ link project.name, project
71
75
  end
@@ -265,6 +265,12 @@ class HelperMethodsTest < ActionView::TestCase
265
265
  end
266
266
  end
267
267
 
268
+ test "inferred breadcrumb" do
269
+ breadcrumb Project.first
270
+ assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <span class="current">Test Project</span></div>},
271
+ breadcrumbs
272
+ end
273
+
268
274
  # Styles
269
275
 
270
276
  test "default style" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gretel
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lasse Bunk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-02 00:00:00.000000000 Z
11
+ date: 2013-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails