activemenu 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbf35db6eda2918c4268dd8f9d994c130386ef83
4
- data.tar.gz: 947b4011ef5522340901e06f73c4071d601d8239
3
+ metadata.gz: 51d11e38637d249f618d8dbf23bece1b45ae651a
4
+ data.tar.gz: 6807d881dd022660e1da7ef9c9dc54580bc7d04d
5
5
  SHA512:
6
- metadata.gz: 0e99d1821a81b7cedbfa957de609431ea0a8e27724ecfd4fbd319cc52cb4caa1eb67abc01998dc04ac9fd27a06b980c9d47273caae27928bdc25e21bd61de4ee
7
- data.tar.gz: f8f4d451c5cd0934f34d3e55d620cf2d0e823ec84b446b6beceadcea7337c66a6be9f48dbdae057301919ca132665be74bcdd3be698afdd360e8eea7adce3252
6
+ metadata.gz: 037342b6f525a12049b8a5c47755ed2d9b850fb9bfa0604da17b3abce1f4ff6b8c061c296d619c0d1e20211076ac57ede3920dc8df11468935912feb654d028e
7
+ data.tar.gz: 84e5c66118e5cf2d2fdd87bd314e1d696575cbc99a52c5a6b198a325aca51be0a1bdbcfc611bea727f87cb524a703d4730823fede5e32dcfe8fc78d9a1a4f165
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Dependency Status](https://gemnasium.com/sadjow/activemenu.png)](https://gemnasium.com/sadjow/activemenu)
5
5
  [![Code Climate](https://codeclimate.com/github/sadjow/activemenu.png)](https://codeclimate.com/github/sadjow/activemenu)
6
6
 
7
- A toolkit to create menus with multi level and a Domain Specific Lanague(DSL) for Menus.
7
+ A toolkit to create menus with multi level and a Domain Specific Language(DSL) for Menus.
8
8
  It's extremely Object Oriented. It still doesn't have code for render, but you can combine it with
9
9
  other renderer like simple-navigation or you own.
10
10
 
@@ -45,7 +45,6 @@ end
45
45
  ### Get the menu
46
46
  You can retrieve the menu instance with the method get...
47
47
  ```ruby
48
- #
49
48
  @menu = ActiveMenu::get(:someid)
50
49
  ```
51
50
 
@@ -65,7 +64,7 @@ These options are write to a hash, that you can use with other gem to render it.
65
64
  @menu.options[:myoptions] = 'myvalue'
66
65
  ```
67
66
 
68
- ## Standard DSL (Domain Specif Language) options
67
+ ## Standard DSL (Domain Specific Language) options
69
68
 
70
69
  To facilitate the creating of menus, there are some methods to help you organize the options standard.
71
70
 
@@ -1,33 +1,54 @@
1
1
  class ActiveMenu::Menu
2
2
 
3
- attr_accessor :id, :href, :content, :submenus, :parent, :options
3
+ attr_accessor :id, :submenus, :parent, :options
4
4
 
5
- def initialize(id, href = nil, content=nil, options={}, &block)
5
+ def initialize(id, options={}, &block)
6
6
  @id = id.to_sym
7
- @href = href
8
- @content = content
9
- @submenus = []
10
7
  @options = options
11
-
12
- #sets the parent
13
- submenus.each {|s| s.parent = self }
14
- @submenus = submenus
8
+ @submenus = []
15
9
  yield(self) if block_given?
16
10
  end
17
11
 
18
- def submenu(id, href, content=nil, options={}, &block)
19
- sm = self.class.new(id, href, content, options, &block)
12
+ def submenu(id, options={}, &block)
13
+ sm = self.class.new(id, options, &block)
20
14
  sm.parent = self
21
15
  @submenus << sm
22
16
  sm
23
17
  end
24
18
 
25
- def tag(tag_name=nil)
26
- if tag_name.nil?
19
+ def text(value = nil)
20
+ if value.nil?
21
+ @options[:text]
22
+ else
23
+ value = value.to_sym
24
+ @options[:text] = value
25
+ end
26
+ end
27
+
28
+ def text=(value)
29
+ self.text(value)
30
+ end
31
+
32
+ def href(value = nil)
33
+ if value.nil?
34
+ @options[:href]
35
+ else
36
+ value = value.to_sym
37
+ @options[:href] = value
38
+ end
39
+ end
40
+
41
+ def href=(value)
42
+ self.href(value)
43
+ end
44
+
45
+
46
+ def tag(value=nil)
47
+ if value.nil?
27
48
  @options[:tag]
28
49
  else
29
- tag_name = tag_name.to_sym
30
- @options[:tag] = tag_name
50
+ value = value.to_sym
51
+ @options[:tag] = value
31
52
  end
32
53
  end
33
54
 
@@ -8,8 +8,8 @@ class ActiveMenu::Registry
8
8
  @menus = []
9
9
  end
10
10
 
11
- def create(id, href, &block)
12
- menu = ActiveMenu::Menu.new(id, href=nil, &block)
11
+ def create(id, options={}, &block)
12
+ menu = ActiveMenu::Menu.new(id, options, &block)
13
13
  @menus << menu
14
14
  menu
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveMenu
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/active_menu.rb CHANGED
@@ -8,8 +8,8 @@ module ActiveMenu
8
8
  ActiveMenu::Registry.instance
9
9
  end
10
10
 
11
- def self.create(id, href=nil, &block)
12
- self.registry.create(id, href, &block)
11
+ def self.create(id, options={}, &block)
12
+ self.registry.create(id, options, &block)
13
13
  end
14
14
 
15
15
  def self.reset
@@ -5,36 +5,32 @@ describe ActiveMenu::Menu do
5
5
  subject {ActiveMenu::Menu.new(:idtest)}
6
6
 
7
7
  it {should respond_to(:id)}
8
- it {should respond_to(:href)}
9
- it {should respond_to(:content)}
10
8
  it {should respond_to(:submenus)}
11
9
  it {should respond_to(:parent)}
12
10
  it {should respond_to(:options)}
13
-
14
-
11
+
15
12
  its(:submenus) {should be_a(Array)}
16
13
 
17
-
18
14
  before :each do
19
- @menu = ActiveMenu::Menu.new(:idtest, "http://example.com", "My menu")
15
+ @menu = ActiveMenu::Menu.new(:idtest, href: "http://example.com", text: "My menu")
20
16
  end
21
17
 
22
18
  #it 'can spec'
23
19
 
24
20
  it 'has the right attributes values' do
25
- @menu.content.should == 'My menu'
21
+ @menu.text.should == 'My menu'
26
22
  @menu.id.should == :idtest
27
23
  @menu.href.should == "http://example.com"
28
24
  end
29
25
 
30
26
  it 'can add submenus' do
31
- @submenu = ActiveMenu::Menu.new(:mysubmenu, '#an_anchor', "My submenu")
27
+ @submenu = ActiveMenu::Menu.new(:mysubmenu, href: '#an_anchor', text: "My submenu")
32
28
  @menu.submenus << @submenu
33
29
  @menu.submenus.length.should == 1
34
30
  end
35
31
 
36
32
  it 'can add submenus directly' do
37
- submenu = @menu.submenu(:mysubmenu, '#an_anchor', "My submenu")
33
+ submenu = @menu.submenu(:mysubmenu, href: '#an_anchor', text: "My submenu")
38
34
  @menu.submenus.length.should == 1
39
35
  submenu.parent.should == @menu
40
36
  submenu.parent.id.should == @menu.id
@@ -42,12 +38,12 @@ describe ActiveMenu::Menu do
42
38
 
43
39
 
44
40
  it 'have a flexible DSL for menus' do
45
- @menu.submenu(:mysubmenu, "test") do |sm|
41
+ @menu.submenu(:mysubmenu, text: "test") do |sm|
46
42
  @sm = sm
47
- sm.content = 'My submenu'
48
- sm.submenu(:mysubsubmenu, 'test 2') do |ssm|
43
+ sm.text = 'My submenu'
44
+ sm.submenu(:mysubsubmenu, text: 'test 2') do |ssm|
49
45
  @ssm = ssm
50
- ssm.content == 'My subsubmenu'
46
+ ssm.text == 'My subsubmenu'
51
47
  end
52
48
  end
53
49
 
@@ -15,7 +15,7 @@ describe ActiveMenu do
15
15
  end
16
16
 
17
17
  it 'can create a menu directly' do
18
- ActiveMenu::create(:someid, 'http://example.com').should be_a_kind_of(ActiveMenu::Menu)
18
+ ActiveMenu::create(:someid, href: 'http://example.com').should be_a_kind_of(ActiveMenu::Menu)
19
19
  ActiveMenu::registry.menus.length.should == 1
20
20
  end
21
21
 
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadjow Medeiros Leão