gretel 3.0.7 → 3.0.8

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: c41db63d201de11de1dbc6d9b9c2a172418ffa20
4
- data.tar.gz: 48db9abfdc31f7900b0f32afdc9536fd2839efdf
3
+ metadata.gz: f6ea439e9c5de59ad623d0f2f90affb3ec5a4815
4
+ data.tar.gz: d95784f691b047b1dd58f324eecdc8157beb78b0
5
5
  SHA512:
6
- metadata.gz: aa877e11f8c2037c68f9f01c9722101161163747e017e7be78606b56e7504d2a6bcbc253bb97144ab77c0d5ccd70a81a4323fe82ee2f0d4bc2b5d32ba79e21bb
7
- data.tar.gz: 4e6d5c1f40b484fe1ac448fda62654756b17efbc1bb7a262a69229571de91a86512104e9aeec70a0f655259e2ba61e2971fcd0fb8f17f0672c10a04bfae08182
6
+ metadata.gz: 0f2e1c8b30834d532aaa245ab4aba2b01738712108ae7f00ce990db684c9a4821d7da21ce90ca8abdbc7e1eccecbcd6836ae19e0b9a014b6d2a49fb3ebb00cb8
7
+ data.tar.gz: 7c6975eb29de22545495a7e990970527b5794876ec360c8b776a1b26b2a2c57b82bf66deb55984b06cbf0f46213279edb59a774be3e552d2d2c2abb2ff407473
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.1.0
3
4
  - 2.0.0
4
5
  - 1.9.3
5
6
  gemfile:
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 3.0.8
4
+ * Parent breadcrumbs can now also be inferred from models responding to `model_name`.
5
+
3
6
  ## Version 3.0.7
4
7
  * Pretext and posttext classes are now customizable with `<%= breadcrumbs pretext_class: "some-class" %>` and `<%= breadcrumbs posttext_class: "some-other-class" %>`.
5
8
 
data/README.md CHANGED
@@ -8,23 +8,6 @@ Gretel also supports [semantic breadcrumbs](http://support.google.com/webmasters
8
8
 
9
9
  Have fun! And please do write, if you (dis)like it – [lassebunk@gmail.com](mailto:lassebunk@gmail.com).
10
10
 
11
- ## New in version 3.0
12
-
13
- * Breadcrumbs can now be rendered in different styles like ul- and ol lists, and for use with the [Twitter Bootstrap](http://getbootstrap.com/) framework. See the `:style` option below for more info.
14
- * Defining breadcrumbs using `Gretel::Crumbs.layout do ... end` in an initializer has been removed. See below for details on how to upgrade.
15
- * The `:show_root_alone` option is now called `:display_single_fragment` and can be used to hide the breadcrumbs when there is only one link, also if it is not the root breadcrumb.
16
- The old `:show_root_alone` option is still supported until Gretel version 4.0 and will show a deprecation warning when it's used.
17
- * Links yielded from `<%= breadcrumbs do |links| %>` now have a `current?` helper that returns true if the link is the last in the trail.
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.
19
- You can supply options like `:autoroot` etc.
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 instance of an object that responds to `model_name` (like an ActiveRecord model instance). E.g. `breadcrumb @product` is short for `breadcrumb :product, @product`.
22
-
23
-
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).
25
-
26
- See below for more info or the [changelog](https://github.com/lassebunk/gretel/blob/master/CHANGELOG.md) for less significant changes.
27
-
28
11
  ## Installation
29
12
 
30
13
  In your *Gemfile*:
@@ -84,7 +67,7 @@ This will generate the following HTML (indented for readability):
84
67
 
85
68
  ```html
86
69
  <div class="breadcrumbs">
87
- You are here:
70
+ <span class="pretext">You are here:</span>
88
71
  <a href="/">Home</a> &rsaquo;
89
72
  <a href="/issues">All issues</a> &rsaquo;
90
73
  <span class="current">My Issue</span>
@@ -147,7 +130,7 @@ end
147
130
  # Parent crumbs
148
131
  crumb :project_issues do |project|
149
132
  link "Issues", project_issues_path(project)
150
- parent :project, project
133
+ parent project # inferred to :project
151
134
  end
152
135
 
153
136
  # Child
@@ -160,7 +143,7 @@ end
160
143
  crumb :category do |category|
161
144
  link category.name, category
162
145
  if category.parent
163
- parent :category, category.parent
146
+ parent category.parent # inferred to :category
164
147
  else
165
148
  parent :categories
166
149
  end
@@ -169,7 +152,7 @@ end
169
152
  # Product crumb with recursive parent categories (as defined above)
170
153
  crumb :product do |product|
171
154
  link product.name, product
172
- parent :category, product.category
155
+ parent product.category # inferred to :category
173
156
  end
174
157
 
175
158
  # Crumb with multiple links
@@ -190,7 +173,7 @@ crumb :product do |product|
190
173
  if keyword = params[:q].presence
191
174
  parent :search, keyword
192
175
  else # default
193
- parent :category, product.category
176
+ parent product.category # inferred to :category
194
177
  end
195
178
  end
196
179
 
@@ -3,6 +3,12 @@ module Gretel
3
3
  # Initializes a new crumb from the given +key+.
4
4
  # It finds the breadcrumb created in +Gretel::Crumbs.layout+ and renders the block using the arguments supplied in +args+.
5
5
  def initialize(context, key, *args)
6
+ if key.class.respond_to?(:model_name)
7
+ # Enables calling `breadcrumb @product` instead of `breadcrumb :product, @product`
8
+ args.unshift key
9
+ key = key.class.model_name.to_s.underscore.to_sym
10
+ end
11
+
6
12
  block = Gretel::Crumbs.crumbs[key]
7
13
  raise ArgumentError, "Breadcrumb :#{key} not found." unless block
8
14
  @key = key
@@ -38,6 +44,9 @@ module Gretel
38
44
  #
39
45
  # Example:
40
46
  # parent :category, category
47
+ #
48
+ # Or short, which will infer the key from the model's `model_name`:
49
+ # parent category
41
50
  def parent(*args)
42
51
  return @parent if args.empty?
43
52
  key = args.shift
@@ -1,3 +1,3 @@
1
1
  module Gretel
2
- VERSION = "3.0.7"
2
+ VERSION = "3.0.8"
3
3
  end
@@ -10,10 +10,6 @@ module Gretel
10
10
  def breadcrumb(key = nil, *args)
11
11
  if key.nil? || key.is_a?(Hash)
12
12
  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?"
13
- elsif key.class.respond_to?(:model_name)
14
- # Enables calling `breadcrumb @product` instead of `breadcrumb :product, @product`
15
- args.unshift key
16
- key = key.class.model_name.to_s.underscore.to_sym
17
13
  end
18
14
  @_gretel_renderer = Gretel::Renderer.new(self, key, *args)
19
15
  end
@@ -77,4 +77,9 @@ end
77
77
  crumb :with_link_options do
78
78
  link "Test", about_path, title: "My Title", other: "Other Option"
79
79
  link "Other Link", some_option: "Test"
80
+ end
81
+
82
+ crumb :with_inferred_parent do
83
+ link "Test", about_path
84
+ parent Project.first
80
85
  end
@@ -318,6 +318,13 @@ class HelperMethodsTest < ActionView::TestCase
318
318
  breadcrumbs.to_s
319
319
  end
320
320
 
321
+ test "inferred parent" do
322
+ breadcrumb :with_inferred_parent
323
+
324
+ assert_dom_equal %{<div class="breadcrumbs"><a href="/">Home</a> &rsaquo; <a href="/projects/1">Test Project</a> &rsaquo; <span class="current">Test</span></div>},
325
+ breadcrumbs.to_s
326
+ end
327
+
321
328
  # Styles
322
329
 
323
330
  test "default style" do
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gretel
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lasse Bunk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-14 00:00:00.000000000 Z
11
+ date: 2014-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Gretel is a Ruby on Rails plugin that makes it easy yet flexible to create
@@ -46,8 +46,8 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .gitignore
50
- - .travis.yml
49
+ - ".gitignore"
50
+ - ".travis.yml"
51
51
  - CHANGELOG.md
52
52
  - Gemfile
53
53
  - LICENSE.txt
@@ -127,17 +127,17 @@ require_paths:
127
127
  - lib
128
128
  required_ruby_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - '>='
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - '>='
135
+ - - ">="
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.1.10
140
+ rubygems_version: 2.2.2
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Flexible Ruby on Rails breadcrumbs plugin.