navGATE 0.1.21 → 0.1.23

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/lib/navgate.rb +21 -6
  4. data/navGATE.gemspec +2 -2
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 291c99018a5fa97fdca58d16a220a62ef9452d03
4
- data.tar.gz: 3a417976c1eddccef98e4b3c68957a2be0867965
3
+ metadata.gz: cfffca90e5a8c00a84fd93e7a425e0bfdaae75c1
4
+ data.tar.gz: 6c41bbb8e738392546be1d2e7f28b28af562728e
5
5
  SHA512:
6
- metadata.gz: 7ca2989830edca020ee92519616d9cb73f90bd34a3aab6fce4fcbe307d190746e43c28d5caa63a10612a34a8b7dd1b6aac4b3de055df04ee98ac8661e477469f
7
- data.tar.gz: a0b04ce2a4a6c03aad7959013e072ad6e1f1c45f00babbf095cb75a459b1141c5b842f093ba37e4460a2197092cf7b5b17c6ef22a08100d18c5b680cace73e00
6
+ metadata.gz: e43a5e747a2a6205b6993289b732fe3e3fc0500910446c92cc00ace3dbaa717f21caae97cf524e1361d14a8212f6bb2c87f0d5f5a0657f72b96417aa6640ec05
7
+ data.tar.gz: e4aebc4c1a2e42989efc237dddfad22345da5d6e4cb3d50092ccb4ecfeee764d1935558cc32324ecb2539d42a1c2e6b0ca95b9c35f7c1ff52c0d6ede882d30f3
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake'
3
3
  require 'echoe'
4
4
 
5
5
 
6
- Echoe.new('navGATE','0.1.21') do |p|
6
+ Echoe.new('navGATE','0.1.23') 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"
@@ -125,7 +125,7 @@ class Navgate
125
125
 
126
126
 
127
127
  def render_nav selection, controller, options
128
- nav = select_nav(controller.split('/').last).render_it_with(options,selection).html_safe
128
+ nav = nav_cache(controller.split('/').last).render_it_with(options,selection).html_safe
129
129
  nav
130
130
  end
131
131
 
@@ -133,22 +133,37 @@ class Navgate
133
133
  if selection
134
134
  return selection
135
135
  else
136
-
137
- return select_nav(controller).default.to_s
136
+ return nav_cache(controller.split('/').last).default.to_s
138
137
  end
139
138
  end
140
139
  private
140
+
141
+ def nav_cache controller
142
+ if @selected_nav
143
+ if @selected_nav.controller.is_a?(Array)
144
+ return @selected_nav if @selected_nav.controller.include?(controller)
145
+ else
146
+ return @selected_nav unless @selected_nav.controller != controller
147
+ end
148
+ @selected_nav = nil
149
+ nav_cache(controller)
150
+ else
151
+ @selected_nav ||= select_nav(controller)
152
+ end
153
+ end
154
+
141
155
  def select_nav controller
156
+ nav_to_return = nil
142
157
  self.navs.each do |nav|
143
158
  if nav.controller.is_a?(String)
144
- return nav if (nav.controller) == controller.split('/').last
159
+ nav_to_return = nav if (nav.controller) == controller
145
160
  elsif nav.controller.is_a?(Array)
146
- return nav if nav.controller.include?(controller)
161
+ nav_to_return = nav if nav.controller.include?(controller)
147
162
  else
148
163
  raise TypeError, "expecting nav.controller to be a String or an Array, got #{nav.controller.class} "
149
164
  end
150
165
  end
151
- raise ArgumentError, "No matching controllers for #{controller}"
166
+ nav_to_return ? (return nav_to_return) : (raise ArgumentError, "No matching controllers for #{controller}")
152
167
  end
153
168
 
154
169
  def not_bad_type? navs
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "navGATE"
5
- s.version = "0.1.21"
5
+ s.version = "0.1.23"
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-18"
9
+ s.date = "2013-10-24"
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/base.rb", "lib/navgate/navgatehelpers.rb", "lib/readme.rdoc"]
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.21
4
+ version: 0.1.23
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-18 00:00:00.000000000 Z
11
+ date: 2013-10-24 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