helmsman 0.1.0 → 0.2.0
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 +4 -4
- data/lib/helmsman/helm.rb +15 -20
- data/lib/helmsman/version.rb +1 -1
- data/lib/helmsman/view_helper.rb +2 -1
- data/spec/lib/helmsman/helm_spec.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1792233498d44724d3e061d1cfa99eaf4a2bb39
|
4
|
+
data.tar.gz: 0ff9e3e373ff25f839461e29bc2bbe5318426445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9223fe900a265d83bf69336a2ea9463b677b4c69b0fe0114793659a7cc53911c39c9ac8a950903b7f5790771dfd5020ded77f4be6ab12f22ccfd8f510f2d6fb8
|
7
|
+
data.tar.gz: 402ff239debea17d776b9054f953d8470547caa40008c54eac7a765a21d589941c91e33c3b00d740163ee44ce91a1cd658fd1c3db4dda8c5fb759081f7b04947
|
data/lib/helmsman/helm.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Helmsman
|
2
2
|
class Helm
|
3
|
-
attr_accessor :url, :additional, :i18n_key, :i18n_scope
|
3
|
+
attr_accessor :url, :additional, :i18n_key, :i18n_scope, :tooltip
|
4
4
|
attr_writer :name
|
5
5
|
|
6
6
|
include ActionView::Helpers::TagHelper
|
@@ -14,6 +14,7 @@ module Helmsman
|
|
14
14
|
@i18n_scope = options.fetch(:i18n_scope)
|
15
15
|
@i18n_key = options.fetch(:i18n_key)
|
16
16
|
@url = options[:url]
|
17
|
+
@tooltip = options.fetch(:tooltip) { '' }
|
17
18
|
end
|
18
19
|
|
19
20
|
def to_s
|
@@ -44,26 +45,20 @@ module Helmsman
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def li_options
|
47
|
-
|
48
|
-
li_class
|
49
|
-
|
50
|
-
li_class << Helmsman.current_css_class
|
51
|
-
end
|
52
|
-
end
|
53
|
-
{
|
54
|
-
class: li_class
|
55
|
-
}
|
56
|
-
else
|
57
|
-
li_class = configure_li_class do |li_class|
|
58
|
-
li_class << Helmsman.disabled_css_class
|
59
|
-
end
|
60
|
-
{
|
61
|
-
rel: 'tooltip',
|
62
|
-
title: disabled_title,
|
63
|
-
class: li_class,
|
64
|
-
data: { placement: 'bottom' }
|
65
|
-
}
|
48
|
+
li_class = configure_li_class do |li_class|
|
49
|
+
li_class << Helmsman.current_css_class if current? && enabled?
|
50
|
+
li_class << Helmsman.disabled_css_class if disabled?
|
66
51
|
end
|
52
|
+
{class: li_class}.merge tooltip_options
|
53
|
+
end
|
54
|
+
|
55
|
+
def tooltip_options
|
56
|
+
return {} if enabled? and tooltip.blank?
|
57
|
+
{
|
58
|
+
title: (enabled? ? tooltip : disabled_title),
|
59
|
+
rel: 'tooltip',
|
60
|
+
data: { placement: 'bottom' }
|
61
|
+
}
|
67
62
|
end
|
68
63
|
|
69
64
|
def name
|
data/lib/helmsman/version.rb
CHANGED
data/lib/helmsman/view_helper.rb
CHANGED
@@ -66,5 +66,31 @@ describe Helmsman::Helm do
|
|
66
66
|
expect(helm.li_options[:class]).to respond_to :to_str
|
67
67
|
expect(helm.li_options[:class]).to eq 'bar foo'
|
68
68
|
end
|
69
|
+
|
70
|
+
it 'contains the given tooltip' do
|
71
|
+
helm = Helmsman::Helm.new(
|
72
|
+
i18n_scope: 'helmsman.',
|
73
|
+
i18n_key: 'key',
|
74
|
+
tooltip: "Hello! I'm a tooltip"
|
75
|
+
)
|
76
|
+
expect(helm.li_options[:title]).to eq "Hello! I'm a tooltip"
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'contains not tooltip options if tooltip is blank' do
|
80
|
+
helm = Helmsman::Helm.new(
|
81
|
+
i18n_scope: 'helmsman.',
|
82
|
+
i18n_key: 'key',
|
83
|
+
tooltip: ''
|
84
|
+
)
|
85
|
+
expect(helm.li_options).not_to have_key :title
|
86
|
+
expect(helm.li_options[:rel]).not_to eq 'tooltip'
|
87
|
+
|
88
|
+
helm = Helmsman::Helm.new(
|
89
|
+
i18n_scope: 'helmsman.',
|
90
|
+
i18n_key: 'key',
|
91
|
+
)
|
92
|
+
expect(helm.li_options).not_to have_key :title
|
93
|
+
expect(helm.li_options[:rel]).not_to eq 'tooltip'
|
94
|
+
end
|
69
95
|
end
|
70
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helmsman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Opper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|