activemenu 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 064b9400c39ced780b52cbf91e507fb5272e61f9
4
+ data.tar.gz: cd6552caec20c59f466266d533f8e60998504954
5
+ SHA512:
6
+ metadata.gz: 8265774e404472788b6ad1b34cabc612b9395df43c86d25e7e62fd59cb671bfee97bee0c3b756a22c3b096be61e46969b19532b29b81cac4b77e7c2c203a1f0d
7
+ data.tar.gz: 0bb1467581f53e55ef79155cbe28576c04c7540f07c3551372c4d7f50d904df6f4940bc2eeb34850e165bcdd1a94c6c99fbce53fb9730314e7c120dbb5b8a48e
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activemenu.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem "rspec"
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sadjow
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # ActiveMenu
2
+
3
+ A toolkit to create menus with multi level and a Domain Specific Lanague(DSL) for Menus.
4
+ It's extremely Object Oriented. It still doesn't have code for render, but you can combine it with
5
+ other renderer like simple-navigation or you own.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'activemenu'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install activemenu
20
+
21
+ ## Usage
22
+ ```ruby
23
+ @menu = ActiveMenu::Menu.new(:mainmenu, 'http://example.com') # def initialize(id, href, content=nil, submenus=[], parent=nil, &block) .... yield(self) if block_given?
24
+ @menu.submenu(:mysubmenu, "test") do |sm|
25
+ sm.content = 'My submenu'
26
+ sm.submenu(:mysubsubmenu, 'test 2') do |ssm|
27
+ ssm.content == 'My subsubmenu'
28
+ end
29
+ end
30
+ # Let's improve this DSL, contribute please.
31
+ ```
32
+
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'active_menu/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "activemenu"
8
+ spec.version = ActiveMenu::VERSION
9
+ spec.authors = ["Sadjow Medeiros Leão"]
10
+ spec.email = ["sadjow@gmail.com"]
11
+ spec.description = "A toolkit for menus."
12
+ spec.summary = "A toolkit for menus."
13
+ spec.homepage = "https://github.com/sadjow/activemenu"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ end
@@ -0,0 +1,5 @@
1
+ require "active_menu/version"
2
+ require "active_menu/menu"
3
+
4
+ module ActiveMenu
5
+ end
@@ -0,0 +1,24 @@
1
+ class ActiveMenu::Menu
2
+
3
+ attr_accessor :id, :href, :content, :submenus, :parent
4
+
5
+ def initialize(id, href, content=nil, submenus=[], parent=nil, &block)
6
+ @id = id
7
+ @href = href
8
+ @submenus = []
9
+ @content = content
10
+
11
+ #sets the parent
12
+ submenus.each {|s| s.parent = self }
13
+ @submenus = submenus
14
+ @parent = parent
15
+ yield(self) if block_given?
16
+ end
17
+
18
+ def submenu(id, href, content=nil, submenus=[], &block)
19
+ sm = self.class.new(id, href, content, submenus, self, &block)
20
+ @submenus << sm
21
+ sm
22
+ end
23
+
24
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveMenu
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe ActiveMenu::Menu do
5
+ subject {ActiveMenu::Menu.new(:idtest, "http://example.com")}
6
+
7
+ it {should respond_to(:id)}
8
+ it {should respond_to(:href)}
9
+ it {should respond_to(:content)}
10
+ it {should respond_to(:submenus)}
11
+ it {should respond_to(:parent)}
12
+
13
+ its(:submenus) {should be_a(Array)}
14
+
15
+
16
+ before :each do
17
+ @menu = ActiveMenu::Menu.new(:idtest, "http://example.com", "My menu")
18
+ end
19
+
20
+ it 'has the right attributes values' do
21
+ @menu.content.should == 'My menu'
22
+ @menu.id.should == :idtest
23
+ @menu.href.should == "http://example.com"
24
+ end
25
+
26
+ it 'can add submenus' do
27
+ @submenu = ActiveMenu::Menu.new(:mysubmenu, '#an_anchor', "My submenu")
28
+ @menu.submenus << @submenu
29
+ @menu.submenus.length.should == 1
30
+ end
31
+
32
+ it 'can add submenus directly' do
33
+ submenu = @menu.submenu(:mysubmenu, '#an_anchor', "My submenu")
34
+ @menu.submenus.length.should == 1
35
+ submenu.parent.should == @menu
36
+ submenu.parent.id.should == @menu.id
37
+ end
38
+
39
+
40
+ it 'have a flexible DSL for menus' do
41
+ @menu.submenu(:mysubmenu, "test") do |sm|
42
+ @sm = sm
43
+ sm.content = 'My submenu'
44
+ sm.submenu(:mysubsubmenu, 'test 2') do |ssm|
45
+ @ssm = ssm
46
+ ssm.content == 'My subsubmenu'
47
+ end
48
+ end
49
+
50
+ @menu.submenus.length.should == 1
51
+ @sm.submenus.length.should == 1
52
+ @ssm.submenus.length.should == 0
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,20 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ #
8
+ require 'active_menu'
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activemenu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sadjow Medeiros Leão
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A toolkit for menus.
42
+ email:
43
+ - sadjow@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .rspec
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - activemenu.gemspec
55
+ - lib/active_menu.rb
56
+ - lib/active_menu/menu.rb
57
+ - lib/active_menu/version.rb
58
+ - spec/lib/active_menu/menu_spec.rb
59
+ - spec/spec_helper.rb
60
+ homepage: https://github.com/sadjow/activemenu
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.0.0
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: A toolkit for menus.
84
+ test_files:
85
+ - spec/lib/active_menu/menu_spec.rb
86
+ - spec/spec_helper.rb