activemenu 0.4.0 → 0.5.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: 2f5aa010d8d62f74c8feaeae635875b296ed144f
4
- data.tar.gz: 247873f2e994ba74026223b77763f6fe595f18e2
3
+ metadata.gz: fbf35db6eda2918c4268dd8f9d994c130386ef83
4
+ data.tar.gz: 947b4011ef5522340901e06f73c4071d601d8239
5
5
  SHA512:
6
- metadata.gz: 176346f8915333413ec023f744680092bfedfa7707934a682c1f7c20e96f66aa9c02332ced6d3433c8bf8f374362e6d02dd2ad75f3c8ff522ace72ece19e18ad
7
- data.tar.gz: 75856397839244d9dc73fc64ebc0048fbdd9c4e07be4ddead72c9ff5e5204c45d81449bf7e4b67b6108c736f4f11fb1d17f5263a4d10d9ff33c645311bf5cbc5
6
+ metadata.gz: 0e99d1821a81b7cedbfa957de609431ea0a8e27724ecfd4fbd319cc52cb4caa1eb67abc01998dc04ac9fd27a06b980c9d47273caae27928bdc25e21bd61de4ee
7
+ data.tar.gz: f8f4d451c5cd0934f34d3e55d620cf2d0e823ec84b446b6beceadcea7337c66a6be9f48dbdae057301919ca132665be74bcdd3be698afdd360e8eea7adce3252
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # ActiveMenu
2
2
 
3
+ [![Build Status](https://travis-ci.org/sadjow/activemenu.png)](https://travis-ci.org/sadjow/activemenu)
4
+ [![Dependency Status](https://gemnasium.com/sadjow/activemenu.png)](https://gemnasium.com/sadjow/activemenu)
5
+ [![Code Climate](https://codeclimate.com/github/sadjow/activemenu.png)](https://codeclimate.com/github/sadjow/activemenu)
6
+
3
7
  A toolkit to create menus with multi level and a Domain Specific Lanague(DSL) for Menus.
4
8
  It's extremely Object Oriented. It still doesn't have code for render, but you can combine it with
5
9
  other renderer like simple-navigation or you own.
@@ -37,25 +41,43 @@ end
37
41
  ActiveMenu::exists?(:someid) # == true
38
42
  ActiveMenu::exists?(:this_id_doesnt_exists) # == false
39
43
  ```
40
-
41
44
 
42
- ### Set options to the menu
43
- These options are write to a hash, that you can use with other gem to render it.
45
+ ### Get the menu
46
+ You can retrieve the menu instance with the method get...
44
47
  ```ruby
48
+ #
45
49
  @menu = ActiveMenu::get(:someid)
46
- @menu.options[:tag] = :div
47
- @menu.options[:myoptions] = 'myvalue'
48
50
  ```
49
51
 
50
- ### Get the menu
52
+ or, you can use a block too and retrieve it as the first param.
53
+
51
54
  ```ruby
52
- # You can retrieve the menu instance with the method get but you can use a block too.
53
- @menu = ActiveMenu::get(:someid)
54
55
  ActiveMenu::get(:someid) do |menu|
55
56
  menu.id # The menu id
56
57
  end
57
58
  ```
58
59
 
60
+ ### Set options to the menu
61
+ These options are write to a hash, that you can use with other gem to render it.
62
+ ```ruby
63
+ @menu = ActiveMenu::get(:someid)
64
+ @menu.options[:tag] = :div
65
+ @menu.options[:myoptions] = 'myvalue'
66
+ ```
67
+
68
+ ## Standard DSL (Domain Specif Language) options
69
+
70
+ To facilitate the creating of menus, there are some methods to help you organize the options standard.
71
+
72
+ ### tag(tag_name=nil)
73
+ You can set the tag for the menu element or can retrieve it.
74
+ ```ruby
75
+ @menu = ActiveMenu::get(:my_menu)
76
+ @menu.tag :li
77
+ @menu.tag # --> :li
78
+ @menu.tag :div
79
+ @menu.tag # --> :div
80
+ ```
59
81
 
60
82
  ### Nested menus
61
83
  ```ruby
@@ -22,4 +22,13 @@ class ActiveMenu::Menu
22
22
  sm
23
23
  end
24
24
 
25
+ def tag(tag_name=nil)
26
+ if tag_name.nil?
27
+ @options[:tag]
28
+ else
29
+ tag_name = tag_name.to_sym
30
+ @options[:tag] = tag_name
31
+ end
32
+ end
33
+
25
34
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveMenu
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/activemenu.rb ADDED
@@ -0,0 +1 @@
1
+ require 'active_menu'
@@ -65,4 +65,16 @@ describe ActiveMenu::Menu do
65
65
  @menu.options[:tag].should == :ul
66
66
  end
67
67
 
68
+ it 'can add a tag as a option' do
69
+ @menu.tag :li
70
+ @menu.options[:tag].should == :li
71
+ end
72
+
73
+ it 'can add and retrieve the tag name with the #tag method' do
74
+ @menu.tag :li
75
+ @menu.tag.should == :li
76
+ @menu.tag :div
77
+ @menu.tag.should == :div
78
+ end
79
+
68
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemenu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadjow Medeiros Leão
@@ -56,6 +56,7 @@ files:
56
56
  - lib/active_menu/menu.rb
57
57
  - lib/active_menu/registry.rb
58
58
  - lib/active_menu/version.rb
59
+ - lib/activemenu.rb
59
60
  - spec/lib/active_menu/menu_spec.rb
60
61
  - spec/lib/active_menu/registry_spec.rb
61
62
  - spec/lib/active_menu_spec.rb