helmsman 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/README.md +10 -2
- data/lib/helmsman/helm.rb +6 -6
- data/lib/helmsman/version.rb +1 -1
- data/lib/helmsman.rb +11 -0
- data/spec/lib/helmsman/helm_spec.rb +7 -0
- data/spec/lib/helmsman/view_helper_spec.rb +1 -1
- data/spec/lib/helmsman_spec.rb +29 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39eb0c7c962b24b062ec6c7a9217634e88b124db
|
4
|
+
data.tar.gz: 49af2470ce8b65ecb7aa49fcfe27fbdbc794fd55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca5a07f8950ed5ebd90a89f891a4cdce1b9fb20739d013a5706dbcd9e3fd0ef2d8126ccc061e0e92961ee2a7d9dfbcae27bfc906c6940724c9626ac00ccf38c
|
7
|
+
data.tar.gz: 2bfb3024e28ca8fb1351daf6f8c9511aef4fb944b58bea7dcae332e99fbeae1cb273258895f311380713ea3f0e4bc3e205fff6cadcbb5cff00ad14e03c06c491
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Helmsman
|
2
2
|
|
3
|
-
[![Build Status](https://secure.travis-ci.org/xijo/helmsman.png?branch=master)](https://travis-ci.org/xijo/helmsman) [![Gem Version](https://badge.fury.io/rb/helmsman.png)](http://badge.fury.io/rb/helmsman)
|
3
|
+
[![Build Status](https://secure.travis-ci.org/xijo/helmsman.png?branch=master)](https://travis-ci.org/xijo/helmsman) [![Gem Version](https://badge.fury.io/rb/helmsman.png)](http://badge.fury.io/rb/helmsman) [![Code Climate](https://codeclimate.com/repos/523f6d34c7f3a34a75017842/badges/af7056196f756e73e540/gpa.png)](https://codeclimate.com/repos/523f6d34c7f3a34a75017842/feed)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -122,6 +122,15 @@ admin_sidebar_entry :pictures, disabled: true, current: false do |entry|
|
|
122
122
|
end
|
123
123
|
```
|
124
124
|
|
125
|
+
### Configuration
|
126
|
+
|
127
|
+
In an initializer you can customize the css classes to use.
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
Helmsman.current_css_class = 'current-menu-item'
|
131
|
+
Helmsman.disabled_css_class = 'disabled-menu-item'
|
132
|
+
```
|
133
|
+
|
125
134
|
## Compatibility
|
126
135
|
|
127
136
|
Helmsman is working for rails 3 & 4 and for any ruby >= 1.9.3
|
@@ -137,4 +146,3 @@ Helmsman is working for rails 3 & 4 and for any ruby >= 1.9.3
|
|
137
146
|
## TODO
|
138
147
|
|
139
148
|
1. configure helper name
|
140
|
-
2. configure current/disabled class
|
data/lib/helmsman/helm.rb
CHANGED
@@ -5,10 +5,10 @@ module Helmsman
|
|
5
5
|
include ActionView::Helpers::UrlHelper
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
|
-
@disabled = options.fetch(:disabled)
|
9
|
-
@visible = options.fetch(:visible)
|
10
|
-
@current = options.fetch(:current)
|
11
|
-
@i18n_key = options.fetch(:i18n_key)
|
8
|
+
@disabled = options.fetch(:disabled) { false }
|
9
|
+
@visible = options.fetch(:visible) { true }
|
10
|
+
@current = options.fetch(:current) { false }
|
11
|
+
@i18n_key = options.fetch(:i18n_key) { 'helmsman.helm.fallback' }
|
12
12
|
@url = options[:url]
|
13
13
|
end
|
14
14
|
|
@@ -31,9 +31,9 @@ module Helmsman
|
|
31
31
|
|
32
32
|
def li_options
|
33
33
|
if enabled?
|
34
|
-
{ class: (
|
34
|
+
{ class: (Helmsman.current_css_class if current?) }
|
35
35
|
else
|
36
|
-
{ rel: 'tooltip', title: disabled_title, class:
|
36
|
+
{ rel: 'tooltip', title: disabled_title, class: Helmsman.disabled_css_class, data: { placement: 'bottom' } }
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
data/lib/helmsman/version.rb
CHANGED
data/lib/helmsman.rb
CHANGED
@@ -8,4 +8,15 @@ require 'helmsman/view_helper'
|
|
8
8
|
require 'helmsman/railtie' if defined?(Rails)
|
9
9
|
|
10
10
|
module Helmsman
|
11
|
+
class << self
|
12
|
+
attr_writer :current_css_class, :disabled_css_class
|
13
|
+
|
14
|
+
def current_css_class
|
15
|
+
@current_css_class || 'active'
|
16
|
+
end
|
17
|
+
|
18
|
+
def disabled_css_class
|
19
|
+
@disabled_css_class || 'disabled'
|
20
|
+
end
|
21
|
+
end
|
11
22
|
end
|
@@ -45,7 +45,7 @@ describe Helmsman::ViewHelper do
|
|
45
45
|
it 'passing disabled option disables the link' do
|
46
46
|
result = helper.helm(:pictures, disabled: true)
|
47
47
|
result.to_s.should_not include '<a href'
|
48
|
-
result.to_s.should include 'disabled
|
48
|
+
result.to_s.should include 'disabled'
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'adds block results to the result' do
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Helmsman do
|
4
|
+
describe '#current_css_class' do
|
5
|
+
after { Helmsman.current_css_class = 'active' }
|
6
|
+
|
7
|
+
it 'defaults to active' do
|
8
|
+
Helmsman.current_css_class.should eq 'active'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'is settable and gettable' do
|
12
|
+
Helmsman.current_css_class = 'foo'
|
13
|
+
Helmsman.current_css_class.should eq 'foo'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#disabled_css_class' do
|
18
|
+
after { Helmsman.disabled_css_class = 'disabled' }
|
19
|
+
|
20
|
+
it 'defaults to disabled' do
|
21
|
+
Helmsman.disabled_css_class.should eq 'disabled'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'is settable and gettable' do
|
25
|
+
Helmsman.disabled_css_class = 'foo'
|
26
|
+
Helmsman.disabled_css_class.should eq 'foo'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helmsman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Opper
|
@@ -101,7 +101,9 @@ files:
|
|
101
101
|
- lib/helmsman/railtie.rb
|
102
102
|
- lib/helmsman/version.rb
|
103
103
|
- lib/helmsman/view_helper.rb
|
104
|
+
- spec/lib/helmsman/helm_spec.rb
|
104
105
|
- spec/lib/helmsman/view_helper_spec.rb
|
106
|
+
- spec/lib/helmsman_spec.rb
|
105
107
|
- spec/spec_helper.rb
|
106
108
|
homepage: http://github.com/xijo/helmsman
|
107
109
|
licenses:
|
@@ -128,5 +130,7 @@ signing_key:
|
|
128
130
|
specification_version: 4
|
129
131
|
summary: Steers your navigation through the ocean of your application
|
130
132
|
test_files:
|
133
|
+
- spec/lib/helmsman/helm_spec.rb
|
131
134
|
- spec/lib/helmsman/view_helper_spec.rb
|
135
|
+
- spec/lib/helmsman_spec.rb
|
132
136
|
- spec/spec_helper.rb
|