helmsman 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17ffb3e2f06409546207afd53827fa0cb5e58dc8
4
- data.tar.gz: 70366137bfc394958f7cdfefa7c2ab6ee2af2fec
3
+ metadata.gz: 39eb0c7c962b24b062ec6c7a9217634e88b124db
4
+ data.tar.gz: 49af2470ce8b65ecb7aa49fcfe27fbdbc794fd55
5
5
  SHA512:
6
- metadata.gz: 659c202d87b8e499766eb522c8aa48c2ba9b34ea6cad192c10b620904cf3a25be422c3113574fd4e1ac7626d71f8265616ccd2726390753fbe9e81f8bcdb7f2f
7
- data.tar.gz: 15fa8c66a2d2d7a99cf1ffa86c42338f5b9019dcaae91886bae62e8a70ba9ff76ec0abcc8efb5775872e3cc9f5807906ea67dbde2e5910f4ccc81b7b35fe0597
6
+ metadata.gz: 6ca5a07f8950ed5ebd90a89f891a4cdce1b9fb20739d013a5706dbcd9e3fd0ef2d8126ccc061e0e92961ee2a7d9dfbcae27bfc906c6940724c9626ac00ccf38c
7
+ data.tar.gz: 2bfb3024e28ca8fb1351daf6f8c9511aef4fb944b58bea7dcae332e99fbeae1cb273258895f311380713ea3f0e4bc3e205fff6cadcbb5cff00ad14e03c06c491
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  rvm:
2
- - 1.9.2
3
2
  - 1.9.3
4
3
  - 2.0.0
5
4
 
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: ('current-menu-item' if current?) }
34
+ { class: (Helmsman.current_css_class if current?) }
35
35
  else
36
- { rel: 'tooltip', title: disabled_title, class: 'disabled-menu-item', data: { placement: 'bottom' } }
36
+ { rel: 'tooltip', title: disabled_title, class: Helmsman.disabled_css_class, data: { placement: 'bottom' } }
37
37
  end
38
38
  end
39
39
 
@@ -1,3 +1,3 @@
1
1
  module Helmsman
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Helmsman::Helm do
4
+ it 'is always html_safe' do
5
+ Helmsman::Helm.new.should be_html_safe
6
+ end
7
+ 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-menu-item'
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.1
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