bootstrap-navbar 2.4.0 → 2.5.0

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: ca443255cbdf271153acd52fa96e6d787f4cc391
4
- data.tar.gz: 1450fb288c7eff37123cf59c4b6e4a1261f966d1
3
+ metadata.gz: edb6e5a1db3492adc9a4db8de92cc9d3e3b62350
4
+ data.tar.gz: 9ffa64927759a09172cad2abf3d54b71a071716a
5
5
  SHA512:
6
- metadata.gz: 0ad5a23c193df18e26bbaec8b687a9697b1b1d165d626e50e424b1049764c381fa891de3771af7cf92fe5bc41c9c114cfb092968b852dd20fb5a1f6146b359fd
7
- data.tar.gz: 47bd7e4873484fa597d5d2b378cda36c03f9a0815850987d7fbe4bed71a8ddc3d66188e9c141529c2351b750c8334ee3c255e9538b856b662896c836fba5e8bc
6
+ metadata.gz: 2e7765b69cb4cea0f7e3e67d00236da40fb1890c58fdf0739e3617d6f7c3402a859395cf4e8decb60d3e97fdf4d202dd4c50f2da7d4895ca97cecc8418a7bdc1
7
+ data.tar.gz: ff518322e2ff2da4e7990c42f987cd55745726ae2a1636bac0bbd18fff06b39aee64366d9123f40c238df3184499fb64c3f5be46c2fe667622f65df902d74f05
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.6
4
- - 2.3.3
5
- - 2.4.0
3
+ - 2.2.7
4
+ - 2.3.4
5
+ - 2.4.1
6
6
  before_install:
7
7
  - gem update --system
8
8
  - gem update bundler
@@ -1,3 +1,7 @@
1
+ ## 2.4.0
2
+
3
+ * Add support for `root_paths` configuration
4
+
1
5
  ## 2.3.0
2
6
 
3
7
  * Add support for Bootstrap 4
data/README.md CHANGED
@@ -65,7 +65,7 @@ When deciding whether a navbar link is marked as current, the following steps ar
65
65
  * If the link target is one of the root paths (only "/" by default), the link is only marked as current if the target is the current path.
66
66
  * Otherwise the link is marked as current if the target is the current path or a sub path of the current path.
67
67
 
68
- In certain cases a website might want to treat more paths as root paths, e.g. when it has different locales mapped at /en, /de etc. This can be achieved by setting the `root_paths` configuration.
68
+ In certain cases you might want to treat more paths as root paths, e.g. when different locales are mapped at "/en", "/de" etc. This can be achieved by setting the `root_paths` configuration.
69
69
 
70
70
  ```ruby
71
71
  BootstrapNavbar.configure do |config|
@@ -73,7 +73,7 @@ BootstrapNavbar.configure do |config|
73
73
  end
74
74
  ```
75
75
 
76
- With this configuration, if your brand link would be '/en' for example, it would not be marked as current if you are on '/en/some-page'.
76
+ With this configuration, if your brand link would be "/en" for example, it would not be marked as current if you are on "/en/some-page".
77
77
 
78
78
  ### Mix in the helpers into the rendering engine (required)
79
79
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  lib = File.expand_path('../lib', __FILE__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
 
@@ -25,7 +23,8 @@ Gem::Specification.new do |gem|
25
23
  gem.add_development_dependency 'rspec', '~> 3.0'
26
24
  gem.add_development_dependency 'rspec-html-matchers', '~> 0.6'
27
25
  gem.add_development_dependency 'guard-rspec', '~> 4.2'
28
- gem.add_development_dependency 'padrino-helpers', '~> 0.12'
26
+ gem.add_development_dependency 'padrino-helpers', '~> 0.13.3' # padrino-support 0.14.0 dropped the dependency on activesupport, which we need
29
27
  gem.add_development_dependency 'bootstrap-sass', '3.0.2.0'
28
+ gem.add_development_dependency 'bootstrap', '4.0.0.alpha6'
30
29
  gem.add_runtime_dependency 'gem_config', '~> 0.3'
31
30
  end
@@ -1,13 +1,12 @@
1
1
  module BootstrapNavbar::Helpers
2
2
  def self.included(base)
3
3
  if BootstrapNavbar.configuration.bootstrap_version.nil?
4
- if Gem.loaded_specs.keys.include?('bootstrap-sass')
5
- bootstrap_sass_version = Gem.loaded_specs['bootstrap-sass'].version
6
- bootstrap_version = bootstrap_sass_version.segments.take(3).join('.')
7
- BootstrapNavbar.configuration.bootstrap_version = bootstrap_version
8
- else
4
+ unless bootstrap_gem = %w(bootstrap bootstrap-sass).detect { |gem| Gem.loaded_specs.keys.include?(gem) }
9
5
  raise 'Bootstrap version is not configured.'
10
6
  end
7
+ bootstrap_gem_version = Gem.loaded_specs[bootstrap_gem].version
8
+ bootstrap_version = bootstrap_gem_version.segments.take(3).join('.')
9
+ BootstrapNavbar.configuration.bootstrap_version = bootstrap_version
11
10
  end
12
11
  helper_version = BootstrapNavbar.configuration.bootstrap_version[0]
13
12
  base.send :include, const_get("Bootstrap#{helper_version}")
@@ -9,11 +9,10 @@ module BootstrapNavbar::Helpers::Bootstrap2
9
9
 
10
10
  def navbar_group(options = {}, &block)
11
11
  options = options.dup
12
- css_classes = %w(nav).tap do |css_classes|
13
- css_classes << "pull-#{options.delete(:pull)}" if options.key?(:pull)
14
- css_classes << options.delete(:class) if options.key?(:class)
15
- end
16
- attributes = attributes_for_tag({ class: css_classes.join(' ') }.merge(options))
12
+ options[:class] = [options[:class], 'nav'].compact
13
+ options[:class] << "pull-#{options.delete(:pull)}" if options.key?(:pull)
14
+ options[:class] = options[:class].join(' ')
15
+ attributes = attributes_for_tag(options)
17
16
  prepare_html <<-HTML.chomp!
18
17
  <ul#{attributes}>
19
18
  #{capture(&block) if block_given?}
@@ -23,19 +22,14 @@ HTML
23
22
 
24
23
  def navbar_item(name = nil, path = nil, list_item_options = nil, link_options = nil, &block)
25
24
  name, path, list_item_options, link_options = capture(&block), name, path, list_item_options if block_given?
26
- path ||= '#'
27
- list_item_options = list_item_options.nil? ? {} : list_item_options.dup
28
- link_options = link_options.nil? ? {} : link_options.dup
29
- list_item_css_classes = [].tap do |css_classes|
30
- css_classes << 'active' if current_url_or_sub_url?(path)
31
- css_classes << list_item_options.delete(:class) if list_item_options.key?(:class)
32
- end
33
- list_item_attributes = attributes_for_tag(
34
- { class: list_item_css_classes.join(' ') }
35
- .delete_if { |k, v| v.empty? }
36
- .merge(list_item_options)
37
- )
38
- link_attributes = attributes_for_tag(link_options)
25
+ path ||= '#'
26
+ list_item_options = list_item_options ? list_item_options.dup : {}
27
+ link_options = link_options ? link_options.dup : {}
28
+ list_item_options[:class] = [list_item_options[:class]].compact
29
+ list_item_options[:class] << 'active' if current_url_or_sub_url?(path)
30
+ list_item_options[:class] = list_item_options[:class].join(' ')
31
+ list_item_attributes = attributes_for_tag(list_item_options)
32
+ link_attributes = attributes_for_tag(link_options)
39
33
  prepare_html <<-HTML.chomp!
40
34
  <li#{list_item_attributes}>
41
35
  <a href="#{path}"#{link_attributes}>
@@ -58,11 +52,9 @@ HTML
58
52
 
59
53
  def navbar_sub_dropdown(name, list_item_options = {}, link_options = {}, &block)
60
54
  list_item_options, link_options = list_item_options.dup, link_options.dup
61
- list_item_css_classes = %w(dropdown-submenu).tap do |css_classes|
62
- css_classes << list_item_options.delete(:class) if list_item_options.key?(:class)
63
- end
64
- list_item_attributes = attributes_for_tag({ class: list_item_css_classes.join(' ') }.merge(list_item_options))
65
- link_attributes = attributes_for_tag(link_options)
55
+ list_item_options[:class] = [list_item_options.delete(:class), 'dropdown-submenu'].compact.join(' ')
56
+ list_item_attributes = attributes_for_tag(list_item_options)
57
+ link_attributes = attributes_for_tag(link_options)
66
58
  prepare_html <<-HTML.chomp!
67
59
  <li#{list_item_attributes}>
68
60
  <a href="#"#{link_attributes}>
@@ -86,9 +78,8 @@ HTML
86
78
  end
87
79
 
88
80
  def navbar_text(text = nil, pull = nil, &block)
89
- css_classes = %w(navbar-text).tap do |css_classes|
90
- css_classes << "pull-#{pull}" if pull
91
- end
81
+ css_classes = %w(navbar-text)
82
+ css_classes << "pull-#{pull}" if pull
92
83
  prepare_html <<-HTML.chomp!
93
84
  <p class="#{css_classes.join(' ')}">
94
85
  #{block_given? ? capture(&block) : text}
@@ -105,18 +96,14 @@ HTML
105
96
  def wrapper(options, html_options, &block)
106
97
  options, html_options = options.dup, html_options.dup
107
98
  position = case
108
- when options.key?(:static)
109
- "static-#{options[:static]}"
110
- when options.key?(:fixed)
111
- "fixed-#{options[:fixed]}"
112
- end
113
- css_classes = %w(navbar).tap do |css_classes|
114
- css_classes << "navbar-#{position}" if position
115
- css_classes << 'navbar-inverse' if options[:inverse]
116
- css_classes << html_options.delete(:class)
117
- end
118
- attribute_hash = { class: css_classes.join(' ') }.merge(html_options)
119
- attributes = attributes_for_tag(attribute_hash)
99
+ when options.key?(:static) then "static-#{options[:static]}"
100
+ when options.key?(:fixed) then "fixed-#{options[:fixed]}"
101
+ end
102
+ html_options[:class] = [html_options[:class], 'navbar'].compact
103
+ html_options[:class] << "navbar-#{position}" if position
104
+ html_options[:class] << 'navbar-inverse' if options[:inverse]
105
+ html_options[:class] = html_options[:class].join(' ')
106
+ attributes = attributes_for_tag(html_options)
120
107
  prepare_html <<-HTML.chomp!
121
108
  <div#{attributes}>
122
109
  #{capture(&block) if block_given?}
@@ -134,14 +121,13 @@ HTML
134
121
 
135
122
  def container(brand, brand_link, responsive, fluid, &block)
136
123
  css_class = fluid ? 'container-fluid' : 'container'
137
- content = [].tap do |content|
138
- content << responsive_button if responsive
139
- content << navbar_brand_link(brand, brand_link) if brand || brand_link
140
- content << if responsive
141
- responsive_wrapper(&block)
142
- else
143
- capture(&block) if block_given?
144
- end
124
+ content = []
125
+ content << responsive_button if responsive
126
+ content << navbar_brand_link(brand, brand_link) if brand || brand_link
127
+ content << if responsive
128
+ responsive_wrapper(&block)
129
+ else
130
+ capture(&block) if block_given?
145
131
  end
146
132
  prepare_html <<-HTML.chomp!
147
133
  <div class="#{css_class}">
@@ -151,10 +137,9 @@ HTML
151
137
  end
152
138
 
153
139
  def responsive_wrapper(&block)
154
- css_classes = %w(nav-collapse).tap do |css_classes|
155
- css_classes << 'collapse' if BootstrapNavbar.configuration.bootstrap_version >= '2.2.0'
156
- end
157
- attributes = attributes_for_tag({ class: css_classes.join(' ') })
140
+ css_classes = %w(nav-collapse)
141
+ css_classes << 'collapse' if BootstrapNavbar.configuration.bootstrap_version >= '2.2.0'
142
+ attributes = attributes_for_tag(class: css_classes.join(' '))
158
143
  prepare_html <<-HTML.chomp!
159
144
  <div#{attributes}>
160
145
  #{capture(&block) if block_given?}
@@ -14,10 +14,8 @@ module BootstrapNavbar::Helpers::Bootstrap3
14
14
  def navbar_header(options = {}, &block)
15
15
  options = options.dup
16
16
  brand, brand_link = options.delete(:brand), options.delete(:brand_link)
17
- css_classes = %w(navbar-header).tap do |css_classes|
18
- css_classes << options.delete(:class) if options.key?(:class)
19
- end
20
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' ')))
17
+ options[:class] = [options[:class], 'navbar-header'].compact.join(' ')
18
+ attributes = attributes_for_tag(options)
21
19
  prepare_html <<-HTML.chomp!
22
20
  <div#{attributes}>
23
21
  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapsable">
@@ -34,10 +32,9 @@ HTML
34
32
 
35
33
  def navbar_collapse(options = {}, &block)
36
34
  options = options.dup
37
- css_classes = %w(collapse navbar-collapse).tap do |css_classes|
38
- css_classes << options.delete(:class) if options.key?(:class)
39
- end
40
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' '), id: 'navbar-collapsable'))
35
+ options[:class] = [options[:class], 'collapse', 'navbar-collapse'].compact.join(' ')
36
+ options[:id] ||= 'navbar-collapsable'
37
+ attributes = attributes_for_tag(options)
41
38
  prepare_html <<-HTML.chomp!
42
39
  <div#{attributes}>
43
40
  #{capture(&block) if block_given?}
@@ -47,11 +44,10 @@ HTML
47
44
 
48
45
  def navbar_group(options = {}, &block)
49
46
  options = options.dup
50
- css_classes = %w(nav navbar-nav).tap do |css_classes|
51
- css_classes << "navbar-#{options.delete(:align)}" if options.key?(:align)
52
- css_classes << options.delete(:class) if options.key?(:class)
53
- end
54
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' ')))
47
+ options[:class] = [options[:class], 'nav', 'navbar-nav'].compact
48
+ options[:class] << "navbar-#{options.delete(:align)}" if options.key?(:align)
49
+ options[:class] = options[:class].join(' ')
50
+ attributes = attributes_for_tag(options)
55
51
  prepare_html <<-HTML.chomp!
56
52
  <ul#{attributes}>
57
53
  #{capture(&block) if block_given?}
@@ -61,18 +57,13 @@ HTML
61
57
 
62
58
  def navbar_item(text, url = nil, list_item_options = nil, link_options = nil, &block)
63
59
  text, url, list_item_options, link_options = capture(&block), text, url, list_item_options if block_given?
64
- url ||= '#'
65
- list_item_options = list_item_options.nil? ? {} : list_item_options.dup
66
- link_options = link_options.nil? ? {} : link_options.dup
67
- list_item_css_classes = [].tap do |css_classes|
68
- css_classes << 'active' if current_url_or_sub_url?(url)
69
- css_classes << list_item_options.delete(:class) if list_item_options.key?(:class)
70
- end
71
- list_item_attributes = attributes_for_tag(
72
- { class: list_item_css_classes.join(' ') }
73
- .delete_if { |k, v| v.empty? }
74
- .merge(list_item_options)
75
- )
60
+ url ||= '#'
61
+ list_item_options = list_item_options ? list_item_options.dup : {}
62
+ link_options = link_options ? link_options.dup : {}
63
+ list_item_options[:class] = [list_item_options[:class]].compact
64
+ list_item_options[:class] << 'active' if current_url_or_sub_url?(url)
65
+ list_item_options[:class] = list_item_options[:class].join(' ')
66
+ list_item_attributes = attributes_for_tag(list_item_options)
76
67
  link_attributes = attributes_for_tag(link_options)
77
68
  prepare_html <<-HTML.chomp!
78
69
  <li#{list_item_attributes}>
@@ -85,12 +76,11 @@ HTML
85
76
 
86
77
  def navbar_form(url, options = {}, &block)
87
78
  options = options.dup
88
- css_classes = %w(navbar-form).tap do |css_classes|
89
- css_classes << "navbar-#{options.delete(:align)}" if options.key?(:align)
90
- css_classes << options.delete(:class) if options.key?(:class)
91
- end
92
- role = options.delete(:role) || 'form'
93
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' '), role: role))
79
+ options[:class] = [options[:class], 'navbar-form'].compact
80
+ options[:class] << "navbar-#{options.delete(:align)}" if options.key?(:align)
81
+ options[:class] = options[:class].join(' ')
82
+ options[:role] ||= 'form'
83
+ attributes = attributes_for_tag(options)
94
84
  prepare_html <<-HTML.chomp!
95
85
  <form action="#{url}" #{attributes}>
96
86
  #{capture(&block) if block_given?}
@@ -99,13 +89,11 @@ HTML
99
89
  end
100
90
 
101
91
  def navbar_text(text = nil, options = {}, &block)
102
- raise StandardError, 'Please provide either the "text" parameter or a block.' if (text.nil? && !block_given?) || (!text.nil? && block_given?)
92
+ raise StandardError, 'Please provide either the "text" parameter or a block.' if !!text == block_given?
103
93
  options = options.dup
104
94
  text ||= capture(&block)
105
- css_classes = %w(navbar-text).tap do |css_classes|
106
- css_classes << options.delete(:class) if options.key?(:class)
107
- end
108
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' ')))
95
+ options[:class] = [options[:class], 'navbar-text'].compact.join(' ')
96
+ attributes = attributes_for_tag(options)
109
97
  prepare_html <<-HTML.chomp!
110
98
  <p#{attributes}>#{text}</p>
111
99
  HTML
@@ -113,11 +101,9 @@ HTML
113
101
 
114
102
  def navbar_button(text, options = {})
115
103
  options = options.dup
116
- css_classes = %w(btn navbar-btn).tap do |css_classes|
117
- css_classes << options.delete(:class) if options.key?(:class)
118
- end
119
- type = options.delete(:type) || 'button'
120
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' '), type: type))
104
+ options[:class] = [options[:class], 'btn', 'navbar-btn'].compact.join(' ')
105
+ options[:type] ||= 'button'
106
+ attributes = attributes_for_tag(options)
121
107
  prepare_html <<-HTML.chomp!
122
108
  <button#{attributes}>#{text}</button>
123
109
  HTML
@@ -177,14 +163,13 @@ HTML
177
163
 
178
164
  def wrapper(options, &block)
179
165
  options = options.dup
180
- css_classes = %w(navbar).tap do |css_classes|
181
- css_classes << "navbar-#{options.delete(:inverse) ? 'inverse' : 'default'}"
182
- css_classes << "navbar-fixed-#{options.delete(:fixed)}" if options.key?(:fixed)
183
- css_classes << 'navbar-static-top' if options.delete(:static)
184
- css_classes << options.delete(:class) if options.key?(:class)
185
- end
186
- role = options.delete(:role) || 'navigation'
187
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' '), role: role))
166
+ options[:class] = [options[:class], 'navbar'].compact
167
+ options[:class] << "navbar-#{options.delete(:inverse) ? 'inverse' : 'default'}"
168
+ options[:class] << "navbar-fixed-#{options.delete(:fixed)}" if options.key?(:fixed)
169
+ options[:class] << 'navbar-static-top' if options.delete(:static)
170
+ options[:class] = options[:class].join(' ')
171
+ options[:role] ||= 'navigation'
172
+ attributes = attributes_for_tag(options)
188
173
  prepare_html <<-HTML.chomp!
189
174
  <nav#{attributes}>
190
175
  #{capture(&block) if block_given?}
@@ -17,31 +17,29 @@ module BootstrapNavbar::Helpers::Bootstrap4
17
17
  toggleable = options.delete(:toggleable)
18
18
  toggleable = 'xs' if toggleable == true
19
19
  end
20
- css_classes = %w(collapse).tap do |css_classes|
21
- css_classes << options.delete(:class) if options.key?(:class)
22
- css_classes << "navbar-toggleable-#{toggleable}" if toggleable
23
- end
20
+ options[:class] = [options[:class], 'collapse'].compact
21
+ options[:class] << "navbar-toggleable-#{toggleable}" if toggleable
22
+ options[:class] = options[:class].join(' ')
24
23
  toggler_css_classes = %w(navbar-toggler).tap do |css_classes|
25
24
  if toggleable
26
25
  following_grid_size = case toggleable
27
- when 'xs' then 'sm'
28
- when 'sm' then 'md'
29
- when 'md' then 'lg'
30
- when 'lg' then 'xl'
31
- else
32
- fail %(Unexpected "toggleable" parameter: #{toggleable}. Must be "xs", "sm", "md", "lg" or `true` (equals "xs").)
33
- end
26
+ when 'xs' then 'sm'
27
+ when 'sm' then 'md'
28
+ when 'md' then 'lg'
29
+ when 'lg' then 'xl'
30
+ else fail %(Unexpected "toggleable" parameter: #{toggleable}. Must be "xs", "sm", "md", "lg" or `true` (equals "xs").)
31
+ end
34
32
  css_classes << "hidden-#{following_grid_size}-up"
35
33
  end
36
34
  end
37
- id = options.delete(:id) || 'navbar-collapsable'
38
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' '), id: id))
35
+ options[:id] ||= 'navbar-collapsable'
36
+ attributes = attributes_for_tag(options)
39
37
  toggler_attributes = attributes_for_tag(
40
38
  class: toggler_css_classes.join(' '),
41
39
  type: 'button',
42
40
  'data-toggle' => 'collapse',
43
- 'data-target' => "##{id}",
44
- 'aria-controls' => id,
41
+ 'data-target' => "##{options[:id]}",
42
+ 'aria-controls' => options[:id],
45
43
  'aria-expanded' => false,
46
44
  'aria-label' => 'Toggle navigation'
47
45
  )
@@ -57,10 +55,8 @@ HTML
57
55
 
58
56
  def navbar_group(options = {}, &block)
59
57
  options = options.dup
60
- css_classes = %w(nav navbar-nav).tap do |css_classes|
61
- css_classes << options.delete(:class) if options.key?(:class)
62
- end
63
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' ')))
58
+ options[:class] = [options[:class], 'nav', 'navbar-nav'].compact.join(' ')
59
+ attributes = attributes_for_tag(options)
64
60
  prepare_html <<-HTML.chomp!
65
61
  <ul#{attributes}>
66
62
  #{capture(&block) if block_given?}
@@ -70,26 +66,15 @@ HTML
70
66
 
71
67
  def navbar_item(text, url = nil, list_item_options = nil, link_options = nil, &block)
72
68
  text, url, list_item_options, link_options = capture(&block), text, url, list_item_options if block_given?
73
- url ||= '#'
74
- list_item_options = list_item_options.nil? ? {} : list_item_options.dup
75
- link_options = link_options.nil? ? {} : link_options.dup
76
- list_item_css_classes = %w(nav-item).tap do |css_classes|
77
- css_classes << 'active' if current_url_or_sub_url?(url)
78
- css_classes << list_item_options.delete(:class) if list_item_options.key?(:class)
79
- end
80
- link_css_classes = %w(nav-link).tap do |css_classes|
81
- css_classes << link_options.delete(:class) if link_options.key?(:class)
82
- end
83
- list_item_attributes = attributes_for_tag(
84
- { class: list_item_css_classes.join(' ') }
85
- .delete_if { |k, v| v.empty? }
86
- .merge(list_item_options)
87
- )
88
- link_attributes = attributes_for_tag(
89
- { class: link_css_classes.join(' ') }
90
- .delete_if { |k, v| v.empty? }
91
- .merge(link_options)
92
- )
69
+ url ||= '#'
70
+ list_item_options = list_item_options ? list_item_options.dup : {}
71
+ link_options = link_options ? link_options.dup : {}
72
+ list_item_options[:class] = [list_item_options[:class], 'nav-item'].compact
73
+ list_item_options[:class] << 'active' if current_url_or_sub_url?(url)
74
+ list_item_options[:class] = list_item_options[:class].join(' ')
75
+ link_options[:class] = [link_options[:class], 'nav-link'].compact.join(' ')
76
+ list_item_attributes = attributes_for_tag(list_item_options)
77
+ link_attributes = attributes_for_tag(link_options)
93
78
  prepare_html <<-HTML.chomp!
94
79
  <li#{list_item_attributes}>
95
80
  <a href="#{url}"#{link_attributes}>
@@ -119,14 +104,13 @@ HTML
119
104
 
120
105
  def wrapper(options, &block)
121
106
  options = options.dup
122
- css_classes = %w(navbar).tap do |css_classes|
123
- css_classes << "navbar-#{options.key?(:color_scheme) ? options.delete(:color_scheme) : 'dark'}"
124
- css_classes << "bg-#{options.delete(:bg) || 'primary'}" unless options[:bg] == false
125
- css_classes << "navbar-#{options.delete(:placement)}" if options.key?(:placement)
126
- css_classes << options.delete(:class) if options.key?(:class)
127
- end
107
+ options[:class] = [options[:class], 'navbar'].compact
108
+ options[:class] << "navbar-#{options.key?(:color_scheme) ? options.delete(:color_scheme) : 'dark'}"
109
+ options[:class] << "bg-#{options.delete(:bg) || 'primary'}" unless options[:bg] == false
110
+ options[:class] << "navbar-#{options.delete(:placement)}" if options.key?(:placement)
111
+ options[:class] = options[:class].join(' ')
128
112
  brand = brand_link(options[:brand], options[:brand_url]) if options[:brand]
129
- attributes = attributes_for_tag(options.reverse_merge(class: css_classes.join(' ')))
113
+ attributes = attributes_for_tag(options)
130
114
  prepare_html <<-HTML.chomp!
131
115
  <nav#{attributes}>
132
116
  #{brand}
@@ -1,3 +1,3 @@
1
1
  module BootstrapNavbar
2
- VERSION = '2.4.0'
2
+ VERSION = '2.5.0'
3
3
  end
@@ -21,16 +21,20 @@ describe BootstrapNavbar::Helpers do
21
21
  BootstrapNavbar.configuration.unset :bootstrap_version
22
22
  end
23
23
 
24
- context 'when bootstrap-sass gem is not loaded' do
24
+ def remove_gems_from_loaded_specs(*gems)
25
+ loaded_specs = Gem.loaded_specs.dup
26
+ gems.each do |gem|
27
+ loaded_specs.delete(gem)
28
+ end
29
+ allow(Gem).to receive(:loaded_specs).and_return(loaded_specs)
30
+ end
31
+
32
+ context 'when neither the bootstrap-sass gem nor the bootstrap gem is not loaded' do
25
33
  before do
26
- # Remove bootstrap-sass from loaded specs
27
- loaded_specs = Gem.loaded_specs.dup
28
- loaded_specs.delete('bootstrap-sass')
29
- allow(Gem).to receive(:loaded_specs).and_return(loaded_specs)
34
+ remove_gems_from_loaded_specs('bootstrap-sass', 'bootstrap')
30
35
  end
31
36
 
32
37
  it 'raises an exception' do
33
- expect(Gem.loaded_specs.keys).to_not include('bootstrap-sass')
34
38
  expect do
35
39
  Class.new do
36
40
  include BootstrapNavbar::Helpers
@@ -39,9 +43,12 @@ describe BootstrapNavbar::Helpers do
39
43
  end
40
44
  end
41
45
 
42
- context 'when bootstrap-sass gem is loaded' do
46
+ context 'when only the bootstrap-sass gem is loaded' do
47
+ before do
48
+ remove_gems_from_loaded_specs('bootstrap')
49
+ end
50
+
43
51
  it 'sniffs the Bootstrap version from bootstrap-sass' do
44
- expect(Gem.loaded_specs.keys).to include('bootstrap-sass')
45
52
  expect do
46
53
  Class.new do
47
54
  include BootstrapNavbar::Helpers
@@ -50,6 +57,21 @@ describe BootstrapNavbar::Helpers do
50
57
  expect(BootstrapNavbar.configuration.bootstrap_version).to eq('3.0.2')
51
58
  end
52
59
  end
60
+
61
+ context 'when only the bootstrap gem is loaded' do
62
+ before do
63
+ remove_gems_from_loaded_specs('bootstrap-sass')
64
+ end
65
+
66
+ it 'sniffs the Bootstrap version from bootstrap-sass' do
67
+ expect do
68
+ Class.new do
69
+ include BootstrapNavbar::Helpers
70
+ end
71
+ end.to_not raise_exception
72
+ expect(BootstrapNavbar.configuration.bootstrap_version).to eq('4.0.0')
73
+ end
74
+ end
53
75
  end
54
76
  end
55
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-navbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Meurer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.12'
75
+ version: 0.13.3
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.12'
82
+ version: 0.13.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bootstrap-sass
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 3.0.2.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: bootstrap
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 4.0.0.alpha6
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 4.0.0.alpha6
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: gem_config
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -155,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
169
  version: '0'
156
170
  requirements: []
157
171
  rubyforge_project:
158
- rubygems_version: 2.6.8
172
+ rubygems_version: 2.6.11
159
173
  signing_key:
160
174
  specification_version: 4
161
175
  summary: Helpers to generate a Bootstrap style navbar