very_simple_menu 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 654ee1bc2965cf8d9bc48b0c5302969c2523bcb6
4
- data.tar.gz: 900244f6dd3700c1397ef865699aee6ef85b0821
3
+ metadata.gz: 7e87e0608cfabd5bde188fed4cc151a23274d8e8
4
+ data.tar.gz: d3713643d06f7202f8e8bd30089ff1d96dd5e9aa
5
5
  SHA512:
6
- metadata.gz: 14cfd182057b8cb239579e1dda32d308f0f396a1d42784a1c19629a66942617419be06da61afa93558977b4221784f92489d97316ba774574862ebfaadeda57d
7
- data.tar.gz: 326b45b8d70e5e3d9efd56b003d91df8a11bec005b60445844db0c2a4a7230d47c7851441ff69c7d74cef1303f11305c10cb6cea9a8bc1fdf8f6dc7ec73e5920
6
+ metadata.gz: e97229aa7a9d9db8060ff9f80272568b42a42960585a381fd105fd2edda76748f4a4602ba9534d73bc224b1052ba7b79b05b2e893d7cb5b23b5fe4d7088aacd6
7
+ data.tar.gz: ca897d04d35b07989dc4a7f0f862eb395c225b8135a675e8019d784caa34a44080fe072ffdf9805ca857ef01e5b9bdce67906e9e3e1a71b7528cde79316a2694
@@ -1,6 +1,6 @@
1
1
  module SimpleMenu
2
2
  class Helper
3
-
3
+
4
4
  # can be initialized with the items passed through params
5
5
  def initialize(params = {})
6
6
  clear
@@ -8,12 +8,12 @@ module SimpleMenu
8
8
  add(key, options[0], options[1], options[2])
9
9
  end
10
10
  end
11
-
11
+
12
12
  def clear
13
13
  @items = ActiveSupport::OrderedHash.new
14
14
  self
15
15
  end
16
-
16
+
17
17
  def add(key, label = nil, url = nil, params = {})
18
18
  if key.kind_of? Hash
19
19
  key.each do |key, options|
@@ -24,47 +24,47 @@ module SimpleMenu
24
24
  if items.has_key? key
25
25
  raise("key #{key} has already been taken")
26
26
  end
27
-
28
- items[key] = [label, url, params]
27
+
28
+ items[key] = [label, url, params]
29
29
  end
30
-
30
+
31
31
  self
32
32
  end
33
-
33
+
34
34
  def items
35
35
  @items
36
36
  end
37
-
37
+
38
38
  def active=(key)
39
39
  if key
40
40
  @active = key.to_sym
41
41
  else
42
42
  @active = nil
43
43
  end
44
-
44
+
45
45
  self
46
46
  end
47
-
47
+
48
48
  def active
49
49
  @active
50
50
  end
51
-
51
+
52
52
  def to_s
53
53
  html = []
54
-
54
+
55
55
  items.each do |key, options|
56
56
  if key == active
57
57
  html << '<li class="active">'
58
58
  else
59
59
  html << '<li>'
60
60
  end
61
-
61
+
62
62
  html << "<a href=\"#{options[1]}\">#{options[0]}</a>"
63
63
  html << '</li>'
64
64
  end
65
-
65
+
66
66
  if html.length > 0
67
- "<ul>#{html.join('')}</ul>"
67
+ "<ul>#{html.join('')}</ul>".html_safe
68
68
  else
69
69
  ""
70
70
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleMenu
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: very_simple_menu
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
  - Marcelo Jacobus