navigasmic 1.0.4 → 1.0.5
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.
- data/lib/generators/navigasmic/install/templates/initializer.rb +1 -1
- data/lib/navigasmic/core/item.rb +24 -23
- data/lib/navigasmic/version.rb +1 -1
- data/spec/builders/list_builder_spec.rb +3 -3
- data/spec/core/item_spec.rb +20 -6
- data/spec/dummy/config/application.rb +2 -0
- data/spec/dummy/config/environments/development.rb +1 -2
- data/spec/dummy/config/environments/test.rb +1 -2
- data/spec/dummy/config/routes.rb +1 -1
- metadata +4 -36
@@ -133,7 +133,7 @@ Navigasmic.setup do |config|
|
|
133
133
|
if has_nested
|
134
134
|
link = '#'
|
135
135
|
label << "<b class='caret'></b>"
|
136
|
-
|
136
|
+
link_options.merge!(class: 'dropdown-toggle', data: {toggle: 'dropdown'})
|
137
137
|
end
|
138
138
|
link_to(label, link, link_options)
|
139
139
|
end
|
data/lib/navigasmic/core/item.rb
CHANGED
@@ -22,39 +22,40 @@ class Navigasmic::Item
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def highlights_on?(path, params)
|
25
|
+
return false unless @rules.any?
|
25
26
|
params = clean_unwanted_keys(params)
|
26
|
-
result = false
|
27
|
-
|
28
27
|
@rules.each do |rule|
|
29
|
-
highlighted = true
|
30
|
-
|
31
28
|
case rule
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
when String
|
30
|
+
return false unless path == rule
|
31
|
+
when Regexp
|
32
|
+
return false unless path.match(rule)
|
33
|
+
when TrueClass
|
34
|
+
# no-op
|
35
|
+
when FalseClass
|
36
|
+
return false
|
37
|
+
when Hash
|
38
|
+
clean_unwanted_keys(rule).each do |key, value|
|
39
|
+
value.gsub(/^\//, '') if key == :controller
|
40
|
+
return false unless value == params[key].to_s
|
41
|
+
end
|
42
|
+
else
|
43
|
+
raise ArgumentError, 'Highlighting rules should be an array containing any of/or a Boolean, String, Regexp, Hash or Proc'
|
42
44
|
end
|
43
|
-
|
44
|
-
result |= highlighted
|
45
45
|
end
|
46
|
-
|
47
|
-
result
|
46
|
+
true
|
48
47
|
end
|
49
48
|
|
50
49
|
private
|
51
50
|
|
52
51
|
def calculate_highlighting_rules(rules)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
[].tap do |highlighting_rules|
|
53
|
+
if rules.nil?
|
54
|
+
highlighting_rules << @link if link?
|
55
|
+
else
|
56
|
+
highlighting_rules.concat Array(rules)
|
57
|
+
end
|
58
|
+
end
|
58
59
|
end
|
59
60
|
|
60
61
|
def clean_unwanted_keys(hash)
|
data/lib/navigasmic/version.rb
CHANGED
@@ -45,13 +45,13 @@ describe 'Navigasmic::Builder::ListBuilder', type: :helper do
|
|
45
45
|
html = <<-HTML
|
46
46
|
<ul class="nav nav-pills" id="primary">
|
47
47
|
<li class="group dropdown">
|
48
|
-
<a
|
48
|
+
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Group<b class='caret'></b></a>
|
49
49
|
<ul class="dropdown-menu">
|
50
50
|
<li><a href="/path"><span>Label</span></a></li>
|
51
51
|
</ul>
|
52
52
|
</li>
|
53
53
|
<li class="item dropdown">
|
54
|
-
<a
|
54
|
+
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Level 1<b class='caret'></b></a>
|
55
55
|
<ul class="dropdown-menu">
|
56
56
|
<li><span>Level 2</span></li>
|
57
57
|
</ul>
|
@@ -71,7 +71,7 @@ describe 'Navigasmic::Builder::ListBuilder', type: :helper do
|
|
71
71
|
html = <<-HTML
|
72
72
|
<ul class="semantic-navigation" id="primary">
|
73
73
|
<li class="item">
|
74
|
-
<a href="level1.html"
|
74
|
+
<a class="dialog" href="level1.html">
|
75
75
|
<span>Level 1</span>
|
76
76
|
</a>
|
77
77
|
</li>
|
data/spec/core/item_spec.rb
CHANGED
@@ -5,7 +5,6 @@ describe Navigasmic::Item do
|
|
5
5
|
subject { Navigasmic::Item }
|
6
6
|
|
7
7
|
describe "#hidden?" do
|
8
|
-
|
9
8
|
it "returns true when it's not visible" do
|
10
9
|
item = subject.new 'Label', {controller: 'controller'}, false
|
11
10
|
item.hidden?.should be(true)
|
@@ -15,11 +14,9 @@ describe Navigasmic::Item do
|
|
15
14
|
item = subject.new 'Label', {controller: 'controller'}, true
|
16
15
|
item.hidden?.should be(false)
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
20
18
|
|
21
19
|
describe "#disabled?" do
|
22
|
-
|
23
20
|
it "returns true when it's disabled" do
|
24
21
|
item = subject.new 'Label', {controller: 'controller'}, true, disabled_if: true
|
25
22
|
item.disabled?.should be(true)
|
@@ -29,11 +26,9 @@ describe Navigasmic::Item do
|
|
29
26
|
item = subject.new 'Label', {controller: 'controller'}, true, disabled_if: false
|
30
27
|
item.disabled?.should be(false)
|
31
28
|
end
|
32
|
-
|
33
29
|
end
|
34
30
|
|
35
31
|
describe "#link?" do
|
36
|
-
|
37
32
|
it "returns true when there's a link" do
|
38
33
|
item = subject.new 'Label', 'url', true
|
39
34
|
item.link?.should be(true)
|
@@ -48,11 +43,24 @@ describe Navigasmic::Item do
|
|
48
43
|
item = subject.new 'Label', nil, true, disabled_if: true
|
49
44
|
item.link?.should be(false)
|
50
45
|
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#calculate_highlighting_rules" do
|
49
|
+
it "uses the item's link when no rules given" do
|
50
|
+
item = subject.new 'Label', 'url', true
|
51
|
+
item.send(:calculate_highlighting_rules, nil).should eq(['url'])
|
52
|
+
end
|
51
53
|
|
54
|
+
it "uses the given rules if any given" do
|
55
|
+
item = subject.new 'Label', 'url', true, :highlights_on => false
|
56
|
+
item.send(:calculate_highlighting_rules, false).should eq([false])
|
57
|
+
|
58
|
+
item = subject.new 'Label', 'url', true, :highlights_on => false
|
59
|
+
item.send(:calculate_highlighting_rules, ["/a", "/b"]).should eq(["/a", "/b"])
|
60
|
+
end
|
52
61
|
end
|
53
62
|
|
54
63
|
describe "#highlights_on?" do
|
55
|
-
|
56
64
|
it "uses it's own link (as a string)" do
|
57
65
|
item = subject.new 'Label', '/path', true
|
58
66
|
item.highlights_on?('/path', {}).should be(true)
|
@@ -86,5 +94,11 @@ describe Navigasmic::Item do
|
|
86
94
|
item.highlights_on?('/path', {}).should be(false)
|
87
95
|
item.highlights_on?('/other_path', {}).should be(false)
|
88
96
|
end
|
97
|
+
|
98
|
+
it "leaves controller paths alone (bug fix)" do
|
99
|
+
item = subject.new 'Label', {controller: '/foo'}, true
|
100
|
+
item.highlights_on?('/path', {})
|
101
|
+
item.link.should == {controller: '/foo'}
|
102
|
+
end
|
89
103
|
end
|
90
104
|
end
|
@@ -6,8 +6,7 @@ Dummy::Application.configure do
|
|
6
6
|
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
|
-
|
10
|
-
config.whiny_nils = true
|
9
|
+
config.eager_load = false
|
11
10
|
|
12
11
|
# Show full error reports and disable caching
|
13
12
|
config.consider_all_requests_local = true
|
@@ -11,8 +11,7 @@ Dummy::Application.configure do
|
|
11
11
|
config.serve_static_assets = true
|
12
12
|
config.static_cache_control = "public, max-age=3600"
|
13
13
|
|
14
|
-
|
15
|
-
config.whiny_nils = true
|
14
|
+
config.eager_load = false
|
16
15
|
|
17
16
|
# Show full error reports and disable caching
|
18
17
|
config.consider_all_requests_local = true
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -2,7 +2,7 @@ Dummy::Application.routes.draw do
|
|
2
2
|
|
3
3
|
root to: 'application#welcome'
|
4
4
|
|
5
|
-
|
5
|
+
get '/my_awesome_blog' => 'blog/posts#index', as: :my_awesome_blog
|
6
6
|
namespace :blog do
|
7
7
|
resources :posts
|
8
8
|
resources :links
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navigasmic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,39 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-10-02 00:00:00.000000000 Z
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: railties
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '3.2'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.2'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rspec-rails
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
13
|
+
dependencies: []
|
46
14
|
description: Use semantic structures to to build beautifully simple navigation structures
|
47
15
|
in Rails
|
48
16
|
email:
|
@@ -121,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
89
|
version: '0'
|
122
90
|
segments:
|
123
91
|
- 0
|
124
|
-
hash: -
|
92
|
+
hash: -2345431105268640909
|
125
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
94
|
none: false
|
127
95
|
requirements:
|
@@ -130,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
98
|
version: '0'
|
131
99
|
segments:
|
132
100
|
- 0
|
133
|
-
hash: -
|
101
|
+
hash: -2345431105268640909
|
134
102
|
requirements: []
|
135
103
|
rubyforge_project:
|
136
104
|
rubygems_version: 1.8.24
|