helmsman 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22ea9eb486378b8fdd42100f7a4a0394846eb9c1
4
- data.tar.gz: 95755650dd2099182189afdd695932049f3b2ef9
3
+ metadata.gz: a1792233498d44724d3e061d1cfa99eaf4a2bb39
4
+ data.tar.gz: 0ff9e3e373ff25f839461e29bc2bbe5318426445
5
5
  SHA512:
6
- metadata.gz: dc2261720f3961c2b79c19de1de6d7f2d22df3e6d8f5a929937bd26929223aff0d3e796c7a3e0eb8069c3cf4846545c14a897f75dac781f7112c0c3dc60442c9
7
- data.tar.gz: 9b9ae038b5bfbc3489fcdba587f5b66c7363828a0b5f897c7e09c83b0aea144538e88b32958e3562b50330ba87e6c70130760497aa30c943049e990b851bac7e
6
+ metadata.gz: 9223fe900a265d83bf69336a2ea9463b677b4c69b0fe0114793659a7cc53911c39c9ac8a950903b7f5790771dfd5020ded77f4be6ab12f22ccfd8f510f2d6fb8
7
+ data.tar.gz: 402ff239debea17d776b9054f953d8470547caa40008c54eac7a765a21d589941c91e33c3b00d740163ee44ce91a1cd658fd1c3db4dda8c5fb759081f7b04947
@@ -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
- if enabled?
48
- li_class = configure_li_class do |li_class|
49
- if current?
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
@@ -1,3 +1,3 @@
1
1
  module Helmsman
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -71,7 +71,8 @@ module Helmsman
71
71
  i18n_key: key,
72
72
  i18n_scope: i18n_scope,
73
73
  url: url,
74
- li_class: options[:li_class]
74
+ li_class: options[:li_class],
75
+ tooltip: options[:tooltip],
75
76
  )
76
77
 
77
78
  entry.additional = capture(entry, &block) if block_given?
@@ -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.1.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-04-10 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails