navigator 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +43 -43
- data/lib/navigator/identity.rb +1 -1
- data/lib/navigator/menu.rb +23 -4
- data/lib/navigator/tag_activator.rb +3 -1
- metadata +31 -17
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20887cf2bca68709c18f7d4925e30141e0b19815
|
4
|
+
data.tar.gz: dac5ba93f0eb26efc3f2e81647ce5bacc609b647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1d02e611878a314844739bbf646313a73b64992ad250867f3406c100e2631163c0c3c05a099b3a2d384350b4b9cba328e5df302b8a66265625c26e72406ee3d
|
7
|
+
data.tar.gz: 1c477bd924d09242e6b920335fd850791d3d04b4a330bd3b404b671160699ff3e66299a389107c1e47869d16188a939856e3a2805610bc8aa0a671c9e0eb22b1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -4,38 +4,38 @@
|
|
4
4
|
[![Code Climate GPA](https://codeclimate.com/github/bkuhlmann/navigator.svg)](https://codeclimate.com/github/bkuhlmann/navigator)
|
5
5
|
[![Code Climate Coverage](https://codeclimate.com/github/bkuhlmann/navigator/coverage.svg)](https://codeclimate.com/github/bkuhlmann/navigator)
|
6
6
|
[![Gemnasium Status](https://gemnasium.com/bkuhlmann/navigator.svg)](https://gemnasium.com/bkuhlmann/navigator)
|
7
|
-
[![
|
7
|
+
[![Circle CI Status](https://circleci.com/gh/bkuhlmann/navigator.svg?style=svg)](https://circleci.com/gh/bkuhlmann/navigator)
|
8
8
|
[![Patreon](https://img.shields.io/badge/patreon-donate-brightgreen.svg)](https://www.patreon.com/bkuhlmann)
|
9
9
|
|
10
10
|
Enhances Rails with a DSL for menu navigation.
|
11
11
|
|
12
12
|
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
- [Features](#features)
|
17
|
-
- [Requirements](#requirements)
|
18
|
-
- [Setup](#setup)
|
19
|
-
- [Usage](#usage)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- [Customization](#customization)
|
28
|
-
- [Tests](#tests)
|
29
|
-
- [Versioning](#versioning)
|
30
|
-
- [Code of Conduct](#code-of-conduct)
|
31
|
-
- [Contributions](#contributions)
|
32
|
-
- [License](#license)
|
33
|
-
- [History](#history)
|
34
|
-
- [Credits](#credits)
|
14
|
+
## Table of Contents
|
15
|
+
|
16
|
+
- [Features](#features)
|
17
|
+
- [Requirements](#requirements)
|
18
|
+
- [Setup](#setup)
|
19
|
+
- [Usage](#usage)
|
20
|
+
- [Unordered List (simple)](#unordered-list-simple)
|
21
|
+
- [Unordered List (with attributes)](#unordered-list-with-attributes)
|
22
|
+
- [Unordered List (with multiple data attributes)](#unordered-list-with-multiple-data-attributes)
|
23
|
+
- [Nav (with links)](#nav-with-links)
|
24
|
+
- [Foundation Menu](#foundation-menu)
|
25
|
+
- [Bootstrap Dropdown](#bootstrap-dropdown)
|
26
|
+
- [Menu Helpers](#menu-helpers)
|
27
|
+
- [Customization](#customization)
|
28
|
+
- [Tests](#tests)
|
29
|
+
- [Versioning](#versioning)
|
30
|
+
- [Code of Conduct](#code-of-conduct)
|
31
|
+
- [Contributions](#contributions)
|
32
|
+
- [License](#license)
|
33
|
+
- [History](#history)
|
34
|
+
- [Credits](#credits)
|
35
35
|
|
36
36
|
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
37
37
|
|
38
|
-
|
38
|
+
## Features
|
39
39
|
|
40
40
|
- Provides a DSL for building navigation menus.
|
41
41
|
- Supports auto-detection/highlighting of active menu items based on current path (customizable for
|
@@ -68,12 +68,12 @@ Enhances Rails with a DSL for menu navigation.
|
|
68
68
|
- Provides `link`, `image`, and `item` convenience methods for succinct ways to build commonly used
|
69
69
|
menu elements.
|
70
70
|
|
71
|
-
|
71
|
+
## Requirements
|
72
72
|
|
73
73
|
0. [Ruby 2.4.x](https://www.ruby-lang.org).
|
74
74
|
0. [Ruby on Rails 5.x.x](http://rubyonrails.org).
|
75
75
|
|
76
|
-
|
76
|
+
## Setup
|
77
77
|
|
78
78
|
For a secure install, type the following from the command line (recommended):
|
79
79
|
|
@@ -92,11 +92,11 @@ Add the following to your Gemfile:
|
|
92
92
|
|
93
93
|
gem "navigator"
|
94
94
|
|
95
|
-
|
95
|
+
## Usage
|
96
96
|
|
97
97
|
The following are examples using the navigation view helper:
|
98
98
|
|
99
|
-
|
99
|
+
### Unordered List (simple)
|
100
100
|
|
101
101
|
Code:
|
102
102
|
|
@@ -112,7 +112,7 @@ Result:
|
|
112
112
|
<li><a href="/posts">Posts</a></li>
|
113
113
|
</ul>
|
114
114
|
|
115
|
-
|
115
|
+
### Unordered List (with attributes)
|
116
116
|
|
117
117
|
Code:
|
118
118
|
|
@@ -128,7 +128,7 @@ Result:
|
|
128
128
|
<li><a href="/posts">Posts</a></li>
|
129
129
|
</ul>
|
130
130
|
|
131
|
-
|
131
|
+
### Unordered List (with multiple data attributes)
|
132
132
|
|
133
133
|
Code:
|
134
134
|
|
@@ -145,7 +145,7 @@ Result:
|
|
145
145
|
*TIP: Nested data-- attributes can be applied to any menu item in the same manner as Rails view
|
146
146
|
helpers.*
|
147
147
|
|
148
|
-
|
148
|
+
### Nav (with links)
|
149
149
|
|
150
150
|
Code:
|
151
151
|
|
@@ -161,7 +161,7 @@ Result:
|
|
161
161
|
<a href="/posts">Posts</a>
|
162
162
|
</nav>
|
163
163
|
|
164
|
-
|
164
|
+
### Foundation Menu
|
165
165
|
|
166
166
|
Code:
|
167
167
|
|
@@ -215,7 +215,7 @@ Result:
|
|
215
215
|
</section>
|
216
216
|
</nav>
|
217
217
|
|
218
|
-
|
218
|
+
### Bootstrap Dropdown
|
219
219
|
|
220
220
|
Code:
|
221
221
|
|
@@ -248,7 +248,7 @@ Result:
|
|
248
248
|
</li>
|
249
249
|
</ul>
|
250
250
|
|
251
|
-
|
251
|
+
### Menu Helpers
|
252
252
|
|
253
253
|
There are several convenience methods, in addition to the standard HTML tags, that can make for
|
254
254
|
shorter lines of code. The following describes each:
|
@@ -294,7 +294,7 @@ When building menu items, the default is:
|
|
294
294
|
These are just a few, simple, examples of what can be achieved. See the specs for additional usage
|
295
295
|
and customization.
|
296
296
|
|
297
|
-
|
297
|
+
## Customization
|
298
298
|
|
299
299
|
The `navigation` view helper can accept an optional `Navigator::TagActivator` instance. Example:
|
300
300
|
|
@@ -382,7 +382,7 @@ Assuming either the `Addresses` or `Emails` menu item was clicked, the `Profile`
|
|
382
382
|
active due to the regular expression (i.e. `/^profile.+/`) matching one of the the `profile/*`
|
383
383
|
paths.
|
384
384
|
|
385
|
-
|
385
|
+
## Tests
|
386
386
|
|
387
387
|
To test, run:
|
388
388
|
|
@@ -393,34 +393,34 @@ To test the dummy application, run:
|
|
393
393
|
cd spec/dummy
|
394
394
|
bin/rails server
|
395
395
|
|
396
|
-
|
396
|
+
## Versioning
|
397
397
|
|
398
398
|
Read [Semantic Versioning](http://semver.org) for details. Briefly, it means:
|
399
399
|
|
400
|
-
- Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
401
|
-
- Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
402
400
|
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
401
|
+
- Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
402
|
+
- Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
403
403
|
|
404
|
-
|
404
|
+
## Code of Conduct
|
405
405
|
|
406
406
|
Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
|
407
407
|
participating in this project you agree to abide by its terms.
|
408
408
|
|
409
|
-
|
409
|
+
## Contributions
|
410
410
|
|
411
411
|
Read [CONTRIBUTING](CONTRIBUTING.md) for details.
|
412
412
|
|
413
|
-
|
413
|
+
## License
|
414
414
|
|
415
415
|
Copyright (c) 2012 [Alchemists](https://www.alchemists.io).
|
416
416
|
Read [LICENSE](LICENSE.md) for details.
|
417
417
|
|
418
|
-
|
418
|
+
## History
|
419
419
|
|
420
420
|
Read [CHANGES](CHANGES.md) for details.
|
421
421
|
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
422
422
|
|
423
|
-
|
423
|
+
## Credits
|
424
424
|
|
425
425
|
Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
|
426
426
|
[Alchemists](https://www.alchemists.io).
|
data/lib/navigator/identity.rb
CHANGED
data/lib/navigator/menu.rb
CHANGED
@@ -3,11 +3,17 @@
|
|
3
3
|
module Navigator
|
4
4
|
# Renders a HTML menu.
|
5
5
|
class Menu
|
6
|
+
# rubocop:disable Metrics/LineLength
|
6
7
|
def self.allowed_methods
|
7
8
|
/^(div|section|header|h[1-6]|nav|ul|li|a|img|b|em|s|small|span|strong|sub|sup|form|label|select|option|input|button)$/
|
8
9
|
end
|
9
10
|
|
10
|
-
def initialize template,
|
11
|
+
def initialize template,
|
12
|
+
tag: "ul",
|
13
|
+
attributes: {},
|
14
|
+
activator: Navigator::TagActivator.new,
|
15
|
+
&block
|
16
|
+
|
11
17
|
@template = template
|
12
18
|
@tag = Navigator::Tag.new tag, attributes: attributes, activator: activator
|
13
19
|
@menu_activator = activator
|
@@ -36,12 +42,22 @@ module Navigator
|
|
36
42
|
add "img", attributes: modified_attributes, activator: activator
|
37
43
|
end
|
38
44
|
|
39
|
-
def item content = nil,
|
45
|
+
def item content = nil,
|
46
|
+
url,
|
47
|
+
item_attributes: {},
|
48
|
+
link_attributes: {},
|
49
|
+
activator: menu_activator,
|
50
|
+
&block
|
51
|
+
|
40
52
|
modified_item_attributes = item_attributes.clone
|
41
53
|
activate_item_attributes! modified_item_attributes, url, activator
|
42
54
|
|
43
55
|
add "li", attributes: modified_item_attributes, activator: activator do
|
44
|
-
link content,
|
56
|
+
link content,
|
57
|
+
url,
|
58
|
+
attributes: link_attributes,
|
59
|
+
activator: Navigator::TagActivator.new,
|
60
|
+
&block
|
45
61
|
end
|
46
62
|
end
|
47
63
|
|
@@ -72,7 +88,10 @@ module Navigator
|
|
72
88
|
|
73
89
|
def activate_item_attributes! attributes, url, activator
|
74
90
|
return unless url == activator.search_value
|
75
|
-
|
91
|
+
|
92
|
+
attributes[activator.target_key] = [attributes[activator.target_key], activator.target_value]
|
93
|
+
.compact
|
94
|
+
.join " "
|
76
95
|
end
|
77
96
|
end
|
78
97
|
end
|
@@ -13,6 +13,7 @@ module Navigator
|
|
13
13
|
@target_value = target_value
|
14
14
|
end
|
15
15
|
|
16
|
+
# :reek:TooManyStatements
|
16
17
|
def activatable? attributes = {}
|
17
18
|
return false unless search_value.present?
|
18
19
|
|
@@ -20,7 +21,8 @@ module Navigator
|
|
20
21
|
current_search_value = attributes[search_key]
|
21
22
|
|
22
23
|
if current_search_value.is_a?(Regexp) || search_value.is_a?(Regexp)
|
23
|
-
|
24
|
+
return false if current_search_value.blank?
|
25
|
+
current_search_value.match? search_value
|
24
26
|
else
|
25
27
|
current_search_value == search_value
|
26
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navigator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
n/LUZ1dKhIHzfKx1B4+TEIefArObGfkLIDM8+Dq1RX7TF1k81Men7iu4MgE9bYBn
|
31
31
|
3dE+xI3FdB5gWcdWxdtgRCmWjtXeYYyb4z6NQQ==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2017-
|
33
|
+
date: 2017-06-26 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rails
|
@@ -94,28 +94,28 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '0.
|
97
|
+
version: '0.21'
|
98
98
|
type: :development
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '0.
|
104
|
+
version: '0.21'
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: gemsmith
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
111
|
+
version: '10.0'
|
112
112
|
type: :development
|
113
113
|
prerelease: false
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
118
|
+
version: '10.0'
|
119
119
|
- !ruby/object:Gem::Dependency
|
120
120
|
name: pry
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,42 +206,42 @@ dependencies:
|
|
206
206
|
requirements:
|
207
207
|
- - "~>"
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version: '1.
|
209
|
+
version: '1.8'
|
210
210
|
type: :development
|
211
211
|
prerelease: false
|
212
212
|
version_requirements: !ruby/object:Gem::Requirement
|
213
213
|
requirements:
|
214
214
|
- - "~>"
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version: '1.
|
216
|
+
version: '1.8'
|
217
217
|
- !ruby/object:Gem::Dependency
|
218
218
|
name: rspec-rails
|
219
219
|
requirement: !ruby/object:Gem::Requirement
|
220
220
|
requirements:
|
221
221
|
- - "~>"
|
222
222
|
- !ruby/object:Gem::Version
|
223
|
-
version: '3.
|
223
|
+
version: '3.6'
|
224
224
|
type: :development
|
225
225
|
prerelease: false
|
226
226
|
version_requirements: !ruby/object:Gem::Requirement
|
227
227
|
requirements:
|
228
228
|
- - "~>"
|
229
229
|
- !ruby/object:Gem::Version
|
230
|
-
version: '3.
|
230
|
+
version: '3.6'
|
231
231
|
- !ruby/object:Gem::Dependency
|
232
232
|
name: capybara
|
233
233
|
requirement: !ruby/object:Gem::Requirement
|
234
234
|
requirements:
|
235
235
|
- - "~>"
|
236
236
|
- !ruby/object:Gem::Version
|
237
|
-
version: '2.
|
237
|
+
version: '2.14'
|
238
238
|
type: :development
|
239
239
|
prerelease: false
|
240
240
|
version_requirements: !ruby/object:Gem::Requirement
|
241
241
|
requirements:
|
242
242
|
- - "~>"
|
243
243
|
- !ruby/object:Gem::Version
|
244
|
-
version: '2.
|
244
|
+
version: '2.14'
|
245
245
|
- !ruby/object:Gem::Dependency
|
246
246
|
name: guard-rspec
|
247
247
|
requirement: !ruby/object:Gem::Requirement
|
@@ -256,34 +256,48 @@ dependencies:
|
|
256
256
|
- - "~>"
|
257
257
|
- !ruby/object:Gem::Version
|
258
258
|
version: '4.7'
|
259
|
+
- !ruby/object:Gem::Dependency
|
260
|
+
name: git-cop
|
261
|
+
requirement: !ruby/object:Gem::Requirement
|
262
|
+
requirements:
|
263
|
+
- - "~>"
|
264
|
+
- !ruby/object:Gem::Version
|
265
|
+
version: '1.1'
|
266
|
+
type: :development
|
267
|
+
prerelease: false
|
268
|
+
version_requirements: !ruby/object:Gem::Requirement
|
269
|
+
requirements:
|
270
|
+
- - "~>"
|
271
|
+
- !ruby/object:Gem::Version
|
272
|
+
version: '1.1'
|
259
273
|
- !ruby/object:Gem::Dependency
|
260
274
|
name: reek
|
261
275
|
requirement: !ruby/object:Gem::Requirement
|
262
276
|
requirements:
|
263
277
|
- - "~>"
|
264
278
|
- !ruby/object:Gem::Version
|
265
|
-
version: '4.
|
279
|
+
version: '4.7'
|
266
280
|
type: :development
|
267
281
|
prerelease: false
|
268
282
|
version_requirements: !ruby/object:Gem::Requirement
|
269
283
|
requirements:
|
270
284
|
- - "~>"
|
271
285
|
- !ruby/object:Gem::Version
|
272
|
-
version: '4.
|
286
|
+
version: '4.7'
|
273
287
|
- !ruby/object:Gem::Dependency
|
274
288
|
name: rubocop
|
275
289
|
requirement: !ruby/object:Gem::Requirement
|
276
290
|
requirements:
|
277
291
|
- - "~>"
|
278
292
|
- !ruby/object:Gem::Version
|
279
|
-
version: '0.
|
293
|
+
version: '0.49'
|
280
294
|
type: :development
|
281
295
|
prerelease: false
|
282
296
|
version_requirements: !ruby/object:Gem::Requirement
|
283
297
|
requirements:
|
284
298
|
- - "~>"
|
285
299
|
- !ruby/object:Gem::Version
|
286
|
-
version: '0.
|
300
|
+
version: '0.49'
|
287
301
|
- !ruby/object:Gem::Dependency
|
288
302
|
name: codeclimate-test-reporter
|
289
303
|
requirement: !ruby/object:Gem::Requirement
|
@@ -336,7 +350,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
350
|
version: '0'
|
337
351
|
requirements: []
|
338
352
|
rubyforge_project:
|
339
|
-
rubygems_version: 2.6.
|
353
|
+
rubygems_version: 2.6.12
|
340
354
|
signing_key:
|
341
355
|
specification_version: 4
|
342
356
|
summary: Enhances Rails with a DSL for menu navigation.
|
metadata.gz.sig
CHANGED
Binary file
|