navGATE 0.1.13 → 0.1.16
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/Rakefile +1 -1
- data/lib/navgate/base.rb +3 -8
- data/lib/navgate.rb +8 -5
- data/lib/readme.rdoc +16 -14
- data/navGATE.gemspec +3 -3
- metadata +2 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75bfae6a68b290373587be91e83178deabafb639
|
4
|
+
data.tar.gz: 41a5167fc956a2c2be7ac00aa908123ce0f0df5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c13b3accfe0897c0dbd362c52a47680510ecd5a3ea43474f7009b622588d2d11d9882d088b653707cc0f683647c3bb8c1f1123525e998b977a06f35242b10e2
|
7
|
+
data.tar.gz: 1db9f9b64b41732f5edd3f3140345a7162d18671b2facf6b9bc65f70a6d1cc7bef56e22062fa046abf8124a8bfbd2dae454d7334ed34149d0a0a5d84142e6871
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake'
|
|
3
3
|
require 'echoe'
|
4
4
|
|
5
5
|
|
6
|
-
Echoe.new('navGATE','0.1.
|
6
|
+
Echoe.new('navGATE','0.1.16') do |p|
|
7
7
|
p.summary = "Allows the easy creation of navigation with config files"
|
8
8
|
p.description = "Can create navigation from objects using the nav builder,from database tables or from a yaml file"
|
9
9
|
p.url = "https://github.com/Thermatix/navGATE"
|
data/lib/navgate/base.rb
CHANGED
@@ -1,22 +1,17 @@
|
|
1
1
|
class Base
|
2
|
-
attr_accessor :selection, :default, :
|
2
|
+
attr_accessor :selection, :default, :prefix, :controller, :by_id, :css_class
|
3
3
|
|
4
4
|
def initialize(&block)
|
5
|
-
options = {selection: nil,default: nil, controller: nil,
|
5
|
+
options = {selection: nil,default: nil, controller: nil, css_class: nil}
|
6
6
|
yield(options)
|
7
7
|
self.selection = pull_data(options[:selection])
|
8
8
|
self.default = options[:default] || self.selection.first
|
9
|
-
self.namespace = options[:namespace]
|
10
9
|
self.prefix = options[:prefix]
|
11
|
-
self.controller =
|
10
|
+
self.controller = options[:controller]
|
12
11
|
self.by_id = pull_data({options[:selection].to_a.first.first => :id }) if options[:by_id]
|
13
12
|
self.css_class = options[:css_class]
|
14
13
|
end
|
15
14
|
private
|
16
|
-
def namespace?
|
17
|
-
self.namespace ? "#{self.namespace}/" : ""
|
18
|
-
end
|
19
|
-
|
20
15
|
def pull_data selection
|
21
16
|
if selection.is_a?(Array)
|
22
17
|
output = selection
|
data/lib/navgate.rb
CHANGED
@@ -52,9 +52,7 @@ class Navgate
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def path_for link_to
|
55
|
-
if self.
|
56
|
-
return "/#{self.namespace}/#{link_to}"
|
57
|
-
elsif self.prefix
|
55
|
+
if self.prefix
|
58
56
|
return "/#{self.prefix}/#{link_to}"
|
59
57
|
else
|
60
58
|
return "/#{link_to}"
|
@@ -90,7 +88,6 @@ class Navgate
|
|
90
88
|
temp.push(Navgate::Builder.new do |options|
|
91
89
|
options[:selection] = menu[1]['selection'].split(" ")
|
92
90
|
options[:default] = menu[1]['default'] || nill
|
93
|
-
options[:namespace] = menu[1]['namespace'] || nil
|
94
91
|
options[:prefix] = menu[1]['prefix'] || nil
|
95
92
|
options[:controller] = menu[1]['controller'] || nil
|
96
93
|
options[:by_id] = menu[1]['by_id'] || nil
|
@@ -116,7 +113,13 @@ class Navgate
|
|
116
113
|
private
|
117
114
|
def select_nav controller
|
118
115
|
self.navs.each do |nav|
|
119
|
-
|
116
|
+
if nav.controller.is_a?(String)
|
117
|
+
return nav if (nav.controller) == controller.split('/').last
|
118
|
+
elsif nav.controller.is_a?(Array)
|
119
|
+
return nav if nav.controller.include?(controller.split('/').last)
|
120
|
+
else
|
121
|
+
raise TypeError, "expecting nav.controller to be a String or an Array, got #{nav.controller.class} "
|
122
|
+
end
|
120
123
|
end
|
121
124
|
end
|
122
125
|
|
data/lib/readme.rdoc
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
= navGATE
|
2
2
|
|
3
|
-
This gem is provided as is
|
3
|
+
This gem is provided as is.
|
4
|
+
|
5
|
+
This gem allows for the ease of navigation building, from preset lists, from active model databases (eg, categories), from yaml files; but it's not just
|
6
|
+
for the ease of use it's also that you can have multiple navigation menus for differant controllers, or the same menu for differant controllers.
|
7
|
+
Whatever you want is up to you.
|
4
8
|
|
5
9
|
This gem was built with Rails in mind.
|
6
10
|
|
@@ -21,11 +25,9 @@ There are two ways to use this, the first is to use an array of strings containi
|
|
21
25
|
|
22
26
|
<b>Default</b>: This is used to give the menu a default selection for when the user has not selected anything. Pass a string containing the name of the default selection, if no string is passed then the first item from selection is used.
|
23
27
|
|
24
|
-
<b>prefix</b>: This is used when you have a prefix before the target in the URL, eg: if your links render out as "host.com/books" without a prefix; with a prefix of 'shelf' it will render out as "host.com/shelf/books".
|
25
|
-
|
26
|
-
<b>namespace</b>: This is used for when you have name spacing. It works like prefix however unlike prefix it will also search for the controller within the namespace unlike prefix, which doesn't.
|
28
|
+
<b>prefix</b>: This is used when you have a prefix before the target in the URL, eg: if your links render out as "host.com/books" without a prefix; with a prefix of 'shelf' it will render out as "host.com/shelf/books". Namespacing is ignored within this gem, it only looks at the controller's name and nothing else when controller mathing.
|
27
29
|
|
28
|
-
<b>controller</b>: This is used to match the menu to a controller, when deciding which menu to render, it
|
30
|
+
<b>controller</b>: This is used to match the menu to a controller, when deciding which menu to render, it can also be an array of strings; it matches this attribute to the current controller.
|
29
31
|
|
30
32
|
<b>by_id</b>: This is used when you are using a database model to build the menu and you want to link with IDs rather then the selection list. To use it simply set it to true.
|
31
33
|
|
@@ -39,7 +41,7 @@ The default option doesn't have to be the first in the selection list.
|
|
39
41
|
build.navs = [ Navgate::Builder.new do |options|
|
40
42
|
options[:selection] = %w(selection site_settings users images misc)
|
41
43
|
options[:default] = 'users'
|
42
|
-
options[:
|
44
|
+
options[:prefix] = = 'admin'
|
43
45
|
options[:controller] = 'admin_panel'
|
44
46
|
options[:css_class] = 'nav button'
|
45
47
|
end
|
@@ -47,13 +49,14 @@ The default option doesn't have to be the first in the selection list.
|
|
47
49
|
end
|
48
50
|
|
49
51
|
===Building menu object from database fields
|
50
|
-
Be sure to pass it as {model_name: :field}
|
52
|
+
Be sure to pass it as {model_name: :field}.
|
53
|
+
Also note you can pass an array of controllers as well as just a string of one controller which in this case is done via a split command, %w() also works
|
51
54
|
|
52
55
|
NAVGATE = Navgate.new do |build|
|
53
56
|
build.navs = [ Navgate::Builder.new do |options|
|
54
57
|
options[:selection] = {categories: :title }
|
55
58
|
options[:prefix] = 'shop_category'
|
56
|
-
options[:controller] =
|
59
|
+
options[:controller] = "front_page side_page about_page".split(" ")
|
57
60
|
options[:by_id] = true
|
58
61
|
end
|
59
62
|
]
|
@@ -61,11 +64,11 @@ Be sure to pass it as {model_name: :field}
|
|
61
64
|
===Building multiple menus
|
62
65
|
|
63
66
|
NAVGATE = Navgate.new do |build|
|
64
|
-
build.navs = [
|
67
|
+
build.navs = [
|
65
68
|
Navgate::Builder.new do |options|
|
66
69
|
options[:selection] = %w(selection site_settings users images misc)
|
67
70
|
options[:default] = 'users'
|
68
|
-
options[:
|
71
|
+
options[:prefix] = = 'admin'
|
69
72
|
options[:controller] = 'admin_panel'
|
70
73
|
options[:css_class] = 'nav button'
|
71
74
|
end,
|
@@ -92,12 +95,11 @@ The yaml file:
|
|
92
95
|
selection: welcome about_us gallery
|
93
96
|
default: welcome
|
94
97
|
prefix: main
|
95
|
-
namespace: front_end
|
96
98
|
controller: front_page
|
97
99
|
nav_2:
|
98
100
|
selection: settings users misc
|
99
101
|
default: settings
|
100
|
-
|
102
|
+
preix: back_end
|
101
103
|
controller: admin_panel
|
102
104
|
|
103
105
|
|
@@ -134,11 +136,11 @@ routes.rb
|
|
134
136
|
|
135
137
|
front_page/index.html.erb
|
136
138
|
<%= render @selected %>
|
137
|
-
|
139
|
+
|
138
140
|
resulting url
|
139
141
|
host.com/books
|
140
142
|
host.com/games
|
141
|
-
|
143
|
+
|
142
144
|
routes to the root but the paritals rendered would be respectively
|
143
145
|
_books.html.erb
|
144
146
|
_games.html.erb
|
data/navGATE.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "navGATE"
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.16"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Martin Becker"]
|
9
|
-
s.date = "2013-10-
|
9
|
+
s.date = "2013-10-16"
|
10
10
|
s.description = "Can create navigation from objects using the nav builder,from database tables or from a yaml file"
|
11
11
|
s.email = "mbeckerwork@gmail.com"
|
12
12
|
s.extra_rdoc_files = ["lib/navgate.rb", "lib/navgate/application_controller.rb", "lib/navgate/base.rb", "lib/readme.rdoc"]
|
13
13
|
s.files = ["Manifest", "Rakefile", "config/build_menu.yml", "config/initializers/build_menu.rb", "init.rb", "lib/navgate.rb", "lib/navgate/application_controller.rb", "lib/navgate/base.rb", "lib/readme.rdoc", "navGATE.gemspec"]
|
14
14
|
s.homepage = "https://github.com/Thermatix/navGATE"
|
15
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "navGATE"
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "navGATE"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = "navgate"
|
18
18
|
s.rubygems_version = "2.0.6"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navGATE
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Becker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Can create navigation from objects using the nav builder,from database
|
14
14
|
tables or from a yaml file
|
@@ -40,8 +40,6 @@ rdoc_options:
|
|
40
40
|
- --inline-source
|
41
41
|
- --title
|
42
42
|
- navGATE
|
43
|
-
- --main
|
44
|
-
- readme.rdoc
|
45
43
|
require_paths:
|
46
44
|
- lib
|
47
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|