dynamic_menu 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -1,4 +1,4 @@
1
- README.rdoc
1
+ README.md
2
2
  Rakefile
3
3
  lib/dynamic_menu.rb
4
4
  Manifest
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Dynamic Menu
2
+
3
+ This gem provides an easy way to generate a menu that changes according to the controller
4
+ action. It stores everything in an array which can later be accessed via the view.
5
+
6
+ #Getting Help
7
+
8
+ *Email me directly at support@pessetto.com and I will see what I can do
9
+
10
+ #Installation
11
+
12
+ The latest version, and probably the best to use, is 2.0.0 which no longer requires you to
13
+ manually declare the array. To install just put the following in your Gemfile and run
14
+ bundle install or bundle update:
15
+
16
+ ```ruby
17
+ gem 'dynamic_menu','~>2.0.0'
18
+ ```
19
+
20
+ Note: This gem was developed for Rails 3 and will most not work with anything under Rails 3.
21
+
22
+ ##Getting Started
23
+
24
+ This gem features an engine that will automatically load it into your controllers. However,
25
+ you will need to include in your views
26
+
27
+ ```erb
28
+ <% @actionMenuItems.each do |menuitem|%>
29
+
30
+ <%= menuitem %>
31
+
32
+ <%end%>
33
+ ```
34
+
35
+ Note: your array must be @actionMenuItems, do not define this in the controller, the Gem will
36
+ do it automatically for you unless you are using a pre-2.0 release.
37
+
38
+ To add a link in your menu from your controller it is just a matter of using newmenuitem()
39
+ Example
40
+
41
+ ```ruby
42
+ def index
43
+
44
+ #...code here
45
+
46
+ newmenuitem("New Thing",new_thing_path)
47
+
48
+ #...code here
49
+ ```
50
+
51
+ ##Functions
52
+ There is only one function, newmenuitem, that this gem currently has, but can have various
53
+ values sent to it.
54
+
55
+ * newmenuitem(<string>name,<string>link) provides a regular get link to to link and displays name on the menu
56
+ * newmenuitem(<string>name,<string>link,:delete,<string>confirm) will send a delete request to link with the confirmation message of confirm
57
+ * newmenuitem(<string>name,:submit) will create a link to submit the form on the page assumming you don't want the regular button and listen for an enter via JavaScript
data/dynamic_menu.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{dynamic_menu}
5
- s.version = "1.0.2"
5
+ s.version = "2.0.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{Travis Pessettto}]
9
9
  s.date = %q{2011-08-12}
10
10
  s.description = %q{Allow the creation of Menus}
11
11
  s.email = %q{travis@pessetto.com}
12
- s.extra_rdoc_files = [%q{README.rdoc}, %q{lib/dynamic_menu.rb}]
13
- s.files = [%q{README.rdoc}, %q{Rakefile}, %q{lib/dynamic_menu.rb},%q{lib/engine.rb}, %q{Manifest}, %q{dynamic_menu.gemspec}]
12
+ s.extra_rdoc_files = [%q{README.md}, %q{lib/dynamic_menu.rb}]
13
+ s.files = [%q{README.md}, %q{Rakefile}, %q{lib/dynamic_menu.rb},%q{lib/engine.rb}, %q{Manifest}, %q{dynamic_menu.gemspec}]
14
14
  s.homepage = %q{http://pessetto.com}
15
15
  s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Dynamic_menu}, %q{--main}, %q{README.rdoc}]
16
16
  s.require_paths = [%q{lib}]
data/lib/dynamic_menu.rb CHANGED
@@ -3,6 +3,9 @@ module DynamicMenu
3
3
 
4
4
  module MenuItems
5
5
  def newmenuitem(name,link,method=:get,confirm="Are you sure?")
6
+ if !defined?(@actionMenuItems)
7
+ @actionMenuItems = Array.new
8
+ end
6
9
  genlink = ""
7
10
 
8
11
  if method==:delete
@@ -31,10 +34,9 @@ module DynamicMenu
31
34
  else
32
35
  genlink = "<a href=\"#{link}\">#{name}</a>".html_safe
33
36
  end
34
- return genlink
37
+ @actionMenuItems << genlink
35
38
  end
36
39
 
37
40
 
38
-
39
41
  end
40
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,10 +16,10 @@ email: travis@pessetto.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files:
19
- - README.rdoc
19
+ - README.md
20
20
  - lib/dynamic_menu.rb
21
21
  files:
22
- - README.rdoc
22
+ - README.md
23
23
  - Rakefile
24
24
  - lib/dynamic_menu.rb
25
25
  - lib/engine.rb
data/README.rdoc DELETED
@@ -1,30 +0,0 @@
1
- =DYNAMIC MENU
2
-
3
- Dynamic Menu is a Gem that provides a way to make it easy to create a menu that changes according
4
- to the controller action. The controller passes in information into an array which is accessed by
5
- the view.
6
-
7
- ==Installation
8
- While pre-1.0 releases exits we recommend not using them as the code in them is not the best
9
- and will not auto-load into your controller, they will not be commented on here.
10
-
11
- In your Gemfile make sure you have
12
-
13
- gem 'dynamic_menu','~>1.0.0'
14
-
15
- then run bundle install
16
-
17
- ==How to use
18
- To use DynamicMenu you need to create an array such as @MenuItems and store items in it.
19
- So in your controller in each method you can do something like:
20
-
21
- @MenuItems = Array.new
22
-
23
- @MenuItems << newmenuitem("name","link")
24
-
25
- newmenuitem() is the method you need to use to add a menu-item.
26
-
27
- newmenuitem has the arguments of name, link, method, and confirm. Method and confirm only
28
- need to be specified if you are using anything other than get. Link may use :submit which
29
- will submit a form when clicked and add a JavaScript method to listen for the enter key to
30
- submit the form. Name and Link are the only required fields and are both Strings...