activemenu 0.4.0 → 0.5.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/README.md +30 -8
- data/lib/active_menu/menu.rb +9 -0
- data/lib/active_menu/version.rb +1 -1
- data/lib/activemenu.rb +1 -0
- data/spec/lib/active_menu/menu_spec.rb +12 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbf35db6eda2918c4268dd8f9d994c130386ef83
|
4
|
+
data.tar.gz: 947b4011ef5522340901e06f73c4071d601d8239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e99d1821a81b7cedbfa957de609431ea0a8e27724ecfd4fbd319cc52cb4caa1eb67abc01998dc04ac9fd27a06b980c9d47273caae27928bdc25e21bd61de4ee
|
7
|
+
data.tar.gz: f8f4d451c5cd0934f34d3e55d620cf2d0e823ec84b446b6beceadcea7337c66a6be9f48dbdae057301919ca132665be74bcdd3be698afdd360e8eea7adce3252
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# ActiveMenu
|
2
2
|
|
3
|
+
[](https://travis-ci.org/sadjow/activemenu)
|
4
|
+
[](https://gemnasium.com/sadjow/activemenu)
|
5
|
+
[](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
|
-
###
|
43
|
-
|
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
|
-
|
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
|
data/lib/active_menu/menu.rb
CHANGED
data/lib/active_menu/version.rb
CHANGED
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
|
+
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
|