simple-navigation 3.7.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ *3.8.0
2
+
3
+ * Changed the way the context is fetched. Fixes incompatibility with Gretel. Thanks to Ivan Kasatenko.
4
+ * Added :join_with option to links renderer. Thanks to Stefan Melmuk.
5
+ * Added :prefix option to breadcrumb renderer. Credits to Rodrigo Manhães.
6
+ * Added :ordered option for allowing list renderer to render an <ol> rather than a <ul>.
7
+ * Sinatra adapter no longer renders attributes with nil values as attributes with empty strings in the output, instead electing not to render the attribute at all. Thanks to revdan for pointing this out.
8
+
1
9
  *3.7.0
2
10
 
3
11
  * Added new adapater for working with the Nanoc static site generation framework.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.7.0
1
+ 3.8.0
@@ -72,11 +72,9 @@ module SimpleNavigation
72
72
 
73
73
  # Extracts a controller from the context.
74
74
  def extract_controller_from(context)
75
- if context.respond_to? :controller
76
- context.controller
77
- else
75
+ context.respond_to?(:controller) ?
76
+ context.controller || context :
78
77
  context
79
- end
80
78
  end
81
79
 
82
80
  end
@@ -43,11 +43,11 @@ module SimpleNavigation
43
43
  end
44
44
 
45
45
  def link_to(name, url, options={})
46
- "<a href='#{url}' #{to_attributes(options)}>#{name}</a>"
46
+ "<a href='#{url}'#{to_attributes(options)}>#{name}</a>"
47
47
  end
48
48
 
49
49
  def content_tag(type, content, options={})
50
- "<#{type} #{to_attributes(options)}>#{content}</#{type}>"
50
+ "<#{type}#{to_attributes(options)}>#{content}</#{type}>"
51
51
  end
52
52
 
53
53
  protected
@@ -61,7 +61,7 @@ module SimpleNavigation
61
61
  end
62
62
 
63
63
  def to_attributes(options)
64
- options.map {|k, v| "#{k}='#{v}'"}.join(' ')
64
+ options.map {|k, v| v.nil? ? '' : " #{k}='#{v}'"}.join
65
65
  end
66
66
 
67
67
  end
@@ -11,7 +11,10 @@ module SimpleNavigation
11
11
  class Breadcrumbs < SimpleNavigation::Renderer::Base
12
12
 
13
13
  def render(item_container)
14
- content_tag(:div, a_tags(item_container).join(join_with), {:id => item_container.dom_id, :class => item_container.dom_class})
14
+ content = a_tags(item_container).join(join_with)
15
+ content_tag(:div,
16
+ prefix_for(content) + content,
17
+ {:id => item_container.dom_id, :class => item_container.dom_class})
15
18
  end
16
19
 
17
20
  protected
@@ -36,6 +39,10 @@ module SimpleNavigation
36
39
  super || (options[:static_leaf] && item.active_leaf_class)
37
40
  end
38
41
 
42
+ def prefix_for(content)
43
+ content.empty? ? '' : options[:prefix] || ''
44
+ end
45
+
39
46
  # Extracts the options relevant for the generated link
40
47
  #
41
48
  def link_options_for(item)
@@ -14,11 +14,16 @@ module SimpleNavigation
14
14
  def render(item_container)
15
15
  div_content = item_container.items.inject([]) do |list, item|
16
16
  list << tag_for(item)
17
- end.join
17
+ end.join(join_with)
18
18
  content_tag(:div, div_content, {:id => item_container.dom_id, :class => item_container.dom_class})
19
19
  end
20
20
 
21
21
  protected
22
+
23
+ def join_with
24
+ @join_with ||= options[:join_with] || ""
25
+ end
26
+
22
27
  def options_for(item)
23
28
  {:method => item.method}.merge(item.html_options)
24
29
  end
@@ -21,7 +21,7 @@ module SimpleNavigation
21
21
  if skip_if_empty? && item_container.empty?
22
22
  ''
23
23
  else
24
- content_tag(:ul, list_content, {:id => item_container.dom_id, :class => item_container.dom_class})
24
+ content_tag((options[:ordered] ? :ol : :ul), list_content, {:id => item_container.dom_id, :class => item_container.dom_class})
25
25
  end
26
26
  end
27
27
  end
@@ -23,7 +23,7 @@ describe SimpleNavigation::Renderer::Breadcrumbs do
23
23
  it "the rendered div-tag should have the specified class" do
24
24
  HTML::Selector.new('div.nav_dom_class').select(render).should have(1).entries
25
25
  end
26
-
26
+
27
27
  context 'without current_navigation set' do
28
28
  it "should not render any a-tag in the div-tag" do
29
29
  HTML::Selector.new('div a').select(render).should have(0).entries
@@ -59,6 +59,22 @@ describe SimpleNavigation::Renderer::Breadcrumbs do
59
59
  end
60
60
  end
61
61
 
62
+ context 'with prefix option' do
63
+ it 'should render prefix before breadcrumbs' do
64
+ selection = HTML::Selector.new('div').select(render(:subnav1, :level => :all, :prefix => 'You are here: '))
65
+ raise unless selection.count == 1
66
+ tag = selection.first
67
+ tag.to_s.should =~ /^\<div.+\>You are here\: /
68
+ end
69
+
70
+ it 'should not render prefix if there is no available breadcrumb' do
71
+ allow_message_expectations_on_nil
72
+ selection = HTML::Selector.new('div').select(render('', :prefix => 'You are here: '))
73
+ tag = selection.first
74
+ tag.to_s.should =~ /^\<div.+\>\<\/div\>/
75
+ end
76
+ end
77
+
62
78
  context 'with static_leaf option' do
63
79
  before(:each) do
64
80
  @selection = HTML::Selector.new('div *').select(render(:subnav1, :level => :all, :static_leaf => true))
@@ -51,6 +51,12 @@ describe SimpleNavigation::Renderer::Links do
51
51
  HTML::Selector.new('a.selected').select(render).should be_empty
52
52
  end
53
53
  end
54
+
55
+ context 'with a custom seperator specified' do
56
+ it "should separate the items with the separator" do
57
+ HTML::Selector.new('div').select_first(render(:subnav1, :join_with => " | ")).to_s.split(" | ").should have(4).entries
58
+ end
59
+ end
54
60
 
55
61
  end
56
62
 
metadata CHANGED
@@ -1,93 +1,91 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: simple-navigation
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 3
8
- - 7
9
- - 0
10
- version: 3.7.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.8.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Andi Schacke
14
9
  - Mark J. Titorenko
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-02-20 00:00:00 +00:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
23
- type: :runtime
24
- prerelease: false
13
+ date: 2012-08-19 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
25
16
  name: activesupport
26
- version_requirements: &id001 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
27
18
  none: false
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- hash: 7
32
- segments:
33
- - 2
34
- - 3
35
- - 2
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
36
22
  version: 2.3.2
37
- requirement: *id001
38
- - !ruby/object:Gem::Dependency
39
- type: :development
23
+ type: :runtime
40
24
  prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 2.3.2
31
+ - !ruby/object:Gem::Dependency
41
32
  name: rspec
42
- version_requirements: &id002 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
43
34
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- hash: 13
48
- segments:
49
- - 2
50
- - 0
51
- - 1
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
52
38
  version: 2.0.1
53
- requirement: *id002
54
- - !ruby/object:Gem::Dependency
55
39
  type: :development
56
40
  prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 2.0.1
47
+ - !ruby/object:Gem::Dependency
57
48
  name: rake
58
- version_requirements: &id003 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
59
50
  none: false
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- hash: 3
64
- segments:
65
- - 0
66
- version: "0"
67
- requirement: *id003
68
- - !ruby/object:Gem::Dependency
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
69
55
  type: :development
70
56
  prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
71
64
  name: rdoc
72
- version_requirements: &id004 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
73
74
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
81
- requirement: *id004
82
- description: With the simple-navigation gem installed you can easily create multilevel navigations for your Rails, Sinatra or Padrino applications. The navigation is defined in a single configuration file. It supports automatic as well as explicit highlighting of the currently active navigation through regular expressions.
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ description: With the simple-navigation gem installed you can easily create multilevel
80
+ navigations for your Rails, Sinatra or Padrino applications. The navigation is defined
81
+ in a single configuration file. It supports automatic as well as explicit highlighting
82
+ of the currently active navigation through regular expressions.
83
83
  email: andreas.schacke@gmail.com
84
84
  executables: []
85
-
86
85
  extensions: []
87
-
88
- extra_rdoc_files:
86
+ extra_rdoc_files:
89
87
  - README
90
- files:
88
+ files:
91
89
  - CHANGELOG
92
90
  - Gemfile
93
91
  - README
@@ -137,40 +135,31 @@ files:
137
135
  - spec/lib/simple_navigation/rendering/renderer/text_spec.rb
138
136
  - spec/lib/simple_navigation_spec.rb
139
137
  - spec/spec_helper.rb
140
- has_rdoc: true
141
138
  homepage: http://github.com/andi/simple-navigation
142
139
  licenses: []
143
-
144
140
  post_install_message:
145
- rdoc_options:
141
+ rdoc_options:
146
142
  - --inline-source
147
143
  - --charset=UTF-8
148
- require_paths:
144
+ require_paths:
149
145
  - lib
150
- required_ruby_version: !ruby/object:Gem::Requirement
146
+ required_ruby_version: !ruby/object:Gem::Requirement
151
147
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- hash: 3
156
- segments:
157
- - 0
158
- version: "0"
159
- required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
153
  none: false
161
- requirements:
162
- - - ">="
163
- - !ruby/object:Gem::Version
164
- hash: 3
165
- segments:
166
- - 0
167
- version: "0"
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
168
158
  requirements: []
169
-
170
159
  rubyforge_project: andi
171
- rubygems_version: 1.3.7
160
+ rubygems_version: 1.8.24
172
161
  signing_key:
173
162
  specification_version: 3
174
- summary: simple-navigation is a ruby library for creating navigations (with multiple levels) for your Rails2, Rails3, Sinatra or Padrino application.
163
+ summary: simple-navigation is a ruby library for creating navigations (with multiple
164
+ levels) for your Rails2, Rails3, Sinatra or Padrino application.
175
165
  test_files: []
176
-