-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julian Fischer
committed
Jan 14, 2012
0 parents
commit 0c0adcd
Showing
12 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
*.gem | ||
.bundle | ||
Gemfile.lock | ||
pkg/* | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
coverage | ||
InstalledFiles | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp | ||
|
||
# YARD artifacts | ||
.yardoc | ||
_yardoc | ||
doc/ | ||
.DS_Store | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear on external disk | ||
.Spotlight-V100 | ||
.Trashes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--format progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in very_nice_menu.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
h1. Very Nice Menu | ||
|
||
This is a Ruby lib to create a tree of menus. Very nice. Really! | ||
BTW this document is written with a certain portion of humor (insanity). | ||
|
||
h2. Test | ||
|
||
Before your dirty hands touch a single line of code be sure to run the tests by invoking | ||
|
||
bc. rspec | ||
|
||
Otherwise we'll find and punish you! Promised. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'bundler/gem_tasks' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "very_nice_menu/version" | ||
require "very_nice_menu/menu" | ||
require "very_nice_menu/entry" | ||
|
||
module VeryNiceMenu | ||
def self.build(name, options = {}) | ||
VeryNiceMenu::Menu.new(name, options) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module VeryNiceMenu | ||
class Entry | ||
attr_accessor :name, :options | ||
|
||
def initialize(name, options = {}) | ||
@name = name | ||
@options = options | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module VeryNiceMenu | ||
class Menu | ||
attr_accessor :name, :options | ||
attr_reader :submenus | ||
attr_reader :entries | ||
|
||
def initialize(name, options = {}) | ||
@name = name | ||
@options = options | ||
@submenus = [] | ||
@entries = [] | ||
end | ||
|
||
def submenu(name, options = {}, &block) | ||
menu = Menu.new(name, options) | ||
yield(menu) | ||
@submenus << menu | ||
end | ||
|
||
def entry(name, options = {}) | ||
@entries << VeryNiceMenu::Entry.new(name, options) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module VeryNiceMenu | ||
VERSION = "0.0.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'very_nice_menu' | ||
|
||
# This file was generated by the `rspec --init` command. Conventionally, all | ||
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. | ||
# Require this file using `require "spec_helper.rb"` to ensure that it is only | ||
# loaded once. | ||
# | ||
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration | ||
RSpec.configure do |config| | ||
config.treat_symbols_as_metadata_keys_with_true_values = true | ||
config.run_all_when_everything_filtered = true | ||
config.filter_run :focus | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'spec_helper' | ||
|
||
describe VeryNiceMenu::Menu do | ||
|
||
context "Basics" do | ||
it "should create a single menu instance" do | ||
main_menu = VeryNiceMenu.build('Main Menu') | ||
main_menu.should be_instance_of(VeryNiceMenu::Menu) | ||
main_menu.name.should eql("Main Menu") | ||
end | ||
|
||
it "should create a single menu instance" do | ||
main_menu = VeryNiceMenu.build('Main Menu', :description => "This is a very nice menu") | ||
main_menu.should be_instance_of(VeryNiceMenu::Menu) | ||
main_menu.options[:description].should eql("This is a very nice menu") | ||
end | ||
|
||
it "should create a menu with a single menu entry" do | ||
main_menu = VeryNiceMenu.build('Main Menu') | ||
main_menu.entry("Nice Entry") | ||
main_menu.entries.should have(1).item | ||
main_menu.entries.first.should be_instance_of(VeryNiceMenu::Entry) | ||
end | ||
end | ||
|
||
context "Simple Nesting" do | ||
it "should create a simple nested menu" do | ||
main_menu = VeryNiceMenu.build('Main Menu') | ||
|
||
main_menu.submenu("Main Menu - Submenu 1") do |submenu| | ||
end | ||
|
||
main_menu.submenus.should have(1).item | ||
main_menu.submenus.first.should be_instance_of(VeryNiceMenu::Menu) | ||
end | ||
|
||
it "should create a simple nested menu with a menu entry at submenu level" do | ||
main_menu = VeryNiceMenu.build('Main Menu') | ||
|
||
main_menu.submenu("Main Menu - Submenu 1") do |submenu| | ||
submenu.entry("Nice Entry") | ||
end | ||
|
||
main_menu.submenus.first.entries.should have(1).items | ||
main_menu.submenus.first.entries.first.should be_instance_of(VeryNiceMenu::Entry) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "very_nice_menu/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "very_nice_menu" | ||
s.version = VeryNiceMenu::VERSION | ||
s.authors = ["Julian Fischer"] | ||
s.email = ["[email protected]"] | ||
s.homepage = "" | ||
s.summary = %q{TODO: Write a gem summary} | ||
s.description = %q{TODO: Write a gem description} | ||
|
||
s.rubyforge_project = "very_nice_menu" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
|
||
s.add_development_dependency "rspec" | ||
end |