nav_links 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17e44c0c934f2ca8ef5c953f752521f6b86312df
4
- data.tar.gz: af182e5ef54744896589ab463b2887c922fe56bf
3
+ metadata.gz: c83c3166e65ec953386d185e6946029484cdae99
4
+ data.tar.gz: 209a7c45549b7b6cfcce91dccd54480aab097c36
5
5
  SHA512:
6
- metadata.gz: 7698f9298ae48e69264e2ab8d3209f73524438f2bb753418831c445a8ffa70d33db41719909536c65cc378f1fe48578cca7b5912294ec1b10b8d17f756457619
7
- data.tar.gz: 0714d40a2ee19402c56285e8e64408b4b8df64d0cc5468d14fc32793cd36b201543a6434ff33be6e5c5e83d847c385728fe8ad7c07332514c0853c439366aa3c
6
+ metadata.gz: dffc9c4c7888647e50454138f284552844551027c51dc6e22046b4eb4dd32efacae16b68e090ee7c3d95299292629cbcec4bacb27d6bd695df0663c44c44ba05
7
+ data.tar.gz: d40a26e3d4112a3e054795257032b706d92178ed73f51acebd332dbbfefb847f8c5ffe4fc5f07d5bdf77cf5f53d33befab92fd93f820825af80da310d309d9ae
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Behold, the NavLinks:
2
2
 
3
3
  [![Build Status](https://travis-ci.org/bxt/wptemplates.png?branch=master)](https://travis-ci.org/bxt/wptemplates)
4
+ [![Gem Version](https://badge.fury.io/rb/nav_links.png)](http://badge.fury.io/rb/nav_links)
4
5
 
5
- Gem. Rails. Nav links. The nav_link_to helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link. Just replace `link_to` with `nav_link_to` in your templates.
6
+ Gem. Rails. Nav links. The nav_link_to helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link. Just replace `link_to` with `nav_link_to` in your templates.
6
7
 
7
8
  ## Installation
8
9
 
@@ -36,13 +37,13 @@ Same usage as `link_to`:
36
37
 
37
38
  ### Group links with same options
38
39
 
39
- You can reduce duplication and wrap `nav_link_to` calls with the same options with a call to `nav_links` like this:
40
+ You can reduce duplication and wrap `nav_link_to` calls with the same options with a call to `nav_links` like this:
40
41
 
41
42
  <ul class="nav">
42
- <% nav_links url_segment: 1, wrapper: 'li', selected_class:'active' do |n| %>
43
- <%= n.nav_link_to "Projects", projects_path %>
44
- <%= n.nav_link_to "People", people_path %>
45
- <%= n.nav_link_to "About", about_path %>
43
+ <% nav_links url_segment: 1, wrapper: 'li', selected_class:'active' do |nav| %>
44
+ <%= nav.link_to "Projects", projects_path %>
45
+ <%= nav.link_to "People", people_path %>
46
+ <%= nav.link_to "About", about_path %>
46
47
  <% end %>
47
48
  </ul>
48
49
 
@@ -1,3 +1,3 @@
1
1
  module NavLinks
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -21,15 +21,17 @@ module NavLinks
21
21
  @options = options
22
22
  end
23
23
 
24
- def nav_link_to(*args, &block)
24
+ def link_to(*args, &block)
25
25
  index = block_given? ? 2 : 3
26
26
  args[index] = @options.merge(args[index] || {})
27
27
 
28
28
  @base.nav_link_to(*args, &block)
29
29
  end
30
30
 
31
+ alias_method :nav_link_to, :link_to # deprecated, remove in 2.x
32
+
31
33
  end
32
34
  end
33
35
  end
34
36
 
35
- ActionView::Base.send :include, NavLinks::ViewHelpers
37
+ ActionView::Base.send :include, NavLinks::ViewHelpers
@@ -14,8 +14,17 @@ describe NavLinks::ViewHelpers do
14
14
  NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {})
15
15
  .and_return(link_generator)
16
16
 
17
- helper.nav_links do |n|
18
- n.nav_link_to("My Title", "/path")
17
+ helper.nav_links do |nav|
18
+ nav.link_to("My Title", "/path")
19
+ end
20
+ end
21
+
22
+ it 'supports the deprecated method name with nav_ prefix' do
23
+ NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {})
24
+ .and_return(link_generator)
25
+
26
+ helper.nav_links do |nav|
27
+ nav.nav_link_to("My Title", "/path")
19
28
  end
20
29
  end
21
30
 
@@ -23,8 +32,8 @@ describe NavLinks::ViewHelpers do
23
32
  NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {foo: :bar})
24
33
  .and_return(link_generator)
25
34
 
26
- helper.nav_links foo: :bar do |n|
27
- n.nav_link_to("My Title", "/path")
35
+ helper.nav_links foo: :bar do |nav|
36
+ nav.link_to("My Title", "/path")
28
37
  end
29
38
  end
30
39
 
@@ -32,11 +41,11 @@ describe NavLinks::ViewHelpers do
32
41
  NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {foo: :baz})
33
42
  .and_return(link_generator)
34
43
 
35
- helper.nav_links foo: :bar do |n|
36
- n.nav_link_to("My Title", "/path", {}, {foo: :baz})
44
+ helper.nav_links foo: :bar do |nav|
45
+ nav.link_to("My Title", "/path", {}, {foo: :baz})
37
46
  end
38
47
  end
39
48
 
40
49
  end
41
50
 
42
- end
51
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nav_links
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernhard Häussner
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-09-19 00:00:00.000000000 Z
14
+ date: 2013-10-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails