gretel 2.2.0.rc1 → 2.2.0.rc2

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: 8655da4c27996c4a3cfa81b8e64b7096a9a8a59a
4
- data.tar.gz: a108906eacb8b38d53fc748d55a57bab030d5dcd
3
+ metadata.gz: 63912baa8d7b8687330b6469ca18b82fef24a6d9
4
+ data.tar.gz: 93e5d1939577261f3ee204f6874749c4675d4c41
5
5
  SHA512:
6
- metadata.gz: 2807debcf21aa80f5643bdef961003f299520469ad07e60e03ce9a0484b656e3b626edf56a957eec39126ef68dc43e7576a89b23d7f6192a1e199d910fad0f14
7
- data.tar.gz: d69ab2b538e39e97de79ae712481f4bdd586062869ed552beb68af667f0ad4572c800baf01c550b9cc34af8c6416c8c96b9a3a892991ae1ba17a37c6fb0771c5
6
+ metadata.gz: 2d99b7fe134a685a49f6eb4b6d167ebe9e6c22134e2851fac27f3bee17159ab51bd5290a9647400a64b0a52470630e31305a62443469b29983e792036e0ed2ac
7
+ data.tar.gz: f17fdfdc5ab2a03578230b8d5c00b48b3094a611234621facbba87448c96b896b202e6ddc102d275583d6fa725b144f427a1c0f6c12eec9168f2f57d09a3bc26
data/.travis.yml CHANGED
@@ -2,7 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 1.9.3
5
- - 1.8.7
6
5
  before_script:
7
6
  - "cd test/dummy; rake db:migrate; rake db:test:prepare; cd ../.."
8
7
  notifications:
data/README.md CHANGED
@@ -205,10 +205,10 @@ If you supply a block to the `breadcrumbs` method, it will yield an array with t
205
205
  <% end %>
206
206
  ```
207
207
 
208
- Setting custom breadcrumb trails
208
+ Setting breadcrumb trails
209
209
  --------------------------------
210
210
 
211
- You can set a custom breadcrumb trail via `params[:trail]`. This makes it possible to link to a different breadcrumb trail than the one specified in your breadcrumb.
211
+ You can set a breadcrumb trail via `params[:trail]`. This makes it possible to link to a different breadcrumb trail than the one specified in your breadcrumb.
212
212
 
213
213
  An example is if you have a store with products that have a default parent to their category, but when linking from the review section, you want to link back to the reviews instead.
214
214
 
@@ -247,6 +247,14 @@ Gretel has a built-in view helper method named `breadcrumb_trail` that contains
247
247
 
248
248
  The product view will now have the breadcrumb trail from the first page (reviews) instead of its default parent.
249
249
 
250
+ ### Custom trail param
251
+
252
+ The default trail param is `params[:trail]`. You can change it in an initializer:
253
+
254
+ ```ruby
255
+ Gretel::Trail.trail_param = :other_param
256
+ ```
257
+
250
258
  ### Note
251
259
 
252
260
  Please use the trail functionality with care; the trails can get very long.
data/lib/gretel/trail.rb CHANGED
@@ -50,13 +50,13 @@ module Gretel
50
50
  # Encodes links array to Base64, internally using YAML for serialization.
51
51
  def encode_base64(links)
52
52
  arr = links.map { |link| [link.key, link.text, link.url] }
53
- Base64.urlsafe_encode64(arr.to_yaml)
53
+ Base64.urlsafe_encode64(arr.to_json)
54
54
  end
55
55
 
56
56
  # Decodes links array from Base64.
57
57
  def decode_base64(base64)
58
- yaml = Base64.urlsafe_decode64(base64)
59
- arr = YAML.load(yaml)
58
+ json = Base64.urlsafe_decode64(base64)
59
+ arr = JSON.parse(json)
60
60
  arr.map { |key, text, url| Link.new(key, text, url) }
61
61
  rescue
62
62
  Rails.logger.info "[Gretel] Trail decode failed: Invalid Base64 '#{base64}' in trail"
@@ -1,3 +1,3 @@
1
1
  module Gretel
2
- VERSION = "2.2.0.rc1"
2
+ VERSION = "2.2.0.rc2"
3
3
  end
@@ -181,11 +181,11 @@ class HelperMethodsTest < ActionView::TestCase
181
181
  test "trail helper" do
182
182
  breadcrumb :basic
183
183
 
184
- assert_equal "12hY7tdmRCBzQ_LS0tCi0gLSA6YmFzaWMKICAtIEFib3V0CiAgLSAvYWJvdXQK", breadcrumb_trail
184
+ assert_equal "12MoG3DY5eLzU_W1siYmFzaWMiLCJBYm91dCIsIi9hYm91dCJdXQ==", breadcrumb_trail
185
185
  end
186
186
 
187
187
  test "loading trail" do
188
- params[:trail] = "12hY7tdmRCBzQ_LS0tCi0gLSA6YmFzaWMKICAtIEFib3V0CiAgLSAvYWJvdXQK"
188
+ params[:trail] = "12MoG3DY5eLzU_W1siYmFzaWMiLCJBYm91dCIsIi9hYm91dCJdXQ=="
189
189
  breadcrumb :multiple_links
190
190
 
191
191
  assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &gt; <a href="/about">About</a> &gt; <a href="/about/contact">Contact</a> &gt; <span class="current">Contact form</span></div>},
@@ -194,7 +194,7 @@ class HelperMethodsTest < ActionView::TestCase
194
194
 
195
195
  test "different trail param" do
196
196
  Gretel::Trail.trail_param = :mytest
197
- params[:mytest] = "12hY7tdmRCBzQ_LS0tCi0gLSA6YmFzaWMKICAtIEFib3V0CiAgLSAvYWJvdXQK"
197
+ params[:mytest] = "12MoG3DY5eLzU_W1siYmFzaWMiLCJBYm91dCIsIi9hYm91dCJdXQ=="
198
198
  breadcrumb :multiple_links
199
199
 
200
200
  assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> &gt; <a href="/about">About</a> &gt; <a href="/about/contact">Contact</a> &gt; <span class="current">Contact form</span></div>},
data/test/trail_test.rb CHANGED
@@ -15,16 +15,16 @@ class TrailTest < ActiveSupport::TestCase
15
15
  end
16
16
 
17
17
  test "encoding" do
18
- assert_equal "12hY7tdmRCBzQ_LS0tCi0gLSByb290CiAgLSBIb21lCiAgLSAvCi0gLSBzdG9yZQogIC0gU3RvcmUKICAtIC9zdG9yZQotIC0gc2VhcmNoCiAgLSBTZWFyY2gKICAtIC9zdG9yZS9zZWFyY2g_cT10ZXN0Cg==",
18
+ assert_equal "122.5Th13fvkg_W1sicm9vdCIsIkhvbWUiLCIvIl0sWyJzdG9yZSIsIlN0b3JlIiwiL3N0b3JlIl0sWyJzZWFyY2giLCJTZWFyY2giLCIvc3RvcmUvc2VhcmNoP3E9dGVzdCJdXQ==",
19
19
  Gretel::Trail.encode(@links.map { |key, text, url| Gretel::Link.new(key, text, url) })
20
20
  end
21
21
 
22
22
  test "decoding" do
23
23
  assert_equal @links,
24
- Gretel::Trail.decode("12hY7tdmRCBzQ_LS0tCi0gLSByb290CiAgLSBIb21lCiAgLSAvCi0gLSBzdG9yZQogIC0gU3RvcmUKICAtIC9zdG9yZQotIC0gc2VhcmNoCiAgLSBTZWFyY2gKICAtIC9zdG9yZS9zZWFyY2g_cT10ZXN0Cg==").map { |link| [link.key, link.text, link.url] }
24
+ Gretel::Trail.decode("122.5Th13fvkg_W1sicm9vdCIsIkhvbWUiLCIvIl0sWyJzdG9yZSIsIlN0b3JlIiwiL3N0b3JlIl0sWyJzZWFyY2giLCJTZWFyY2giLCIvc3RvcmUvc2VhcmNoP3E9dGVzdCJdXQ==").map { |link| [link.key, link.text, link.url] }
25
25
  end
26
26
 
27
27
  test "invalid trail" do
28
- assert_equal [], Gretel::Trail.decode("12hY7tdmRCBzZ_LS0tCi0gLSByb290CiAgLSBIb21lCiAgLSAvCi0gLSBzdG9yZQogIC0gU3RvcmUKICAtIC9zdG9yZQotIC0gc2VhcmNoCiAgLSBTZWFyY2gKICAtIC9zdG9yZS9zZWFyY2g_cT10ZXN0Cc==")
28
+ assert_equal [], Gretel::Trail.decode("122.5Th13fvkg_X1sicm9vdCIsIkhvbWUiLCIvIl0sWyJzdG9yZSIsIlN0b3JlIiwiL3N0b3JlIl0sWyJzZWFyY2giLCJTZWFyY2giLCIvc3RvcmUvc2VhcmNoP3E9dGVzdCJdXQ==")
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gretel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.rc1
4
+ version: 2.2.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lasse Bunk