navigasmic 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
@@ -34,7 +34,8 @@ module Navigasmic
34
34
  group = template.content_tag(@@group_tag, buffer)
35
35
  label = label_for_group(label) unless label.blank?
36
36
 
37
- template.content_tag(@@item_tag, label.to_s + group, options.delete(:html))
37
+ visible = options[:hidden_unless].blank? ? true : options[:hidden_unless].is_a?(Proc) ? options[:hidden_unless].call : options[:hidden_unless]
38
+ visible ? template.content_tag(@@item_tag, label.to_s + group, options.delete(:html)) : ''
38
39
  end
39
40
 
40
41
  def item(label, options = {}, &proc)
@@ -51,7 +52,7 @@ module Navigasmic
51
52
  label = label_for_item(label)
52
53
  label = template.link_to(label, item.link, options.delete(:link_html)) unless item.link.empty? || item.disabled?
53
54
 
54
- template.content_tag(@@item_tag, label + buffer, options.delete(:html))
55
+ item.hidden? ? '' : template.content_tag(@@item_tag, label + buffer, options.delete(:html))
55
56
  end
56
57
 
57
58
  def label_for_group(label)
@@ -29,8 +29,9 @@ module Navigasmic
29
29
  raise ArgumentError, "Missing block" unless block_given?
30
30
 
31
31
  buffer = template.capture(self, &proc)
32
- template.concat(template.content_tag(@@group_tag, buffer))
33
- ''
32
+
33
+ visible = options[:hidden_unless].blank? ? true : options[:hidden_unless].is_a?(Proc) ? options[:hidden_unless].call : options[:hidden_unless]
34
+ visible ? template.concat(template.content_tag(@@group_tag, buffer)) : ''
34
35
  end
35
36
 
36
37
  def item(label, options = {}, &proc)
@@ -42,9 +43,8 @@ module Navigasmic
42
43
  contents << template.content_tag(:changefreq, options[:changefreq] || @changefreq)
43
44
  contents << template.content_tag(:lastmod, options[:lastmod]) if options[:lastmod]
44
45
  contents << template.content_tag(:priority, options[:priority]) if options[:priority]
45
-
46
- template.concat(template.content_tag(@@item_tag, contents + buffer, options.delete(:xml)))
47
- ''
46
+
47
+ item.hidden? ? '' : template.concat(template.content_tag(@@item_tag, contents + buffer, options.delete(:xml)))
48
48
  end
49
49
 
50
50
  end
data/lib/navigasmic.rb CHANGED
@@ -73,6 +73,7 @@ module Navigasmic #:nodoc:
73
73
  @link ||= {}
74
74
 
75
75
  @disabled_conditions = options[:disabled_if] || proc { false }
76
+ @visible = options[:hidden_unless].blank? ? true : options[:hidden_unless].is_a?(Proc) ? options[:hidden_unless].call : options[:hidden_unless]
76
77
 
77
78
  options[:highlights_on] = [options[:highlights_on]] if options[:highlights_on].kind_of?(Hash)
78
79
  @highlights_on = options[:highlights_on] || []
@@ -87,6 +88,10 @@ module Navigasmic #:nodoc:
87
88
  @disabled_conditions.call
88
89
  end
89
90
 
91
+ def hidden?
92
+ !@visible
93
+ end
94
+
90
95
  def highlighted?(path, params = {})
91
96
  params = clean_unwanted_keys(params)
92
97
  result = false
data/navigasmic.gemspec CHANGED
@@ -1,43 +1,41 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{navigasmic}
8
- s.version = "0.4.1"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeremy Jackson"]
12
- s.date = %q{2010-07-06}
12
+ s.date = %q{2010-12-13}
13
13
  s.description = %q{Semantic navigation; a semantic way to build beautifully simple navigation structures in Rails.}
14
14
  s.email = %q{jejacks0n@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.textile"
17
+ "README.textile"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.textile",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/builders/html_builder.rb",
27
- "lib/builders/xml_builder.rb",
28
- "lib/navigasmic.rb",
29
- "navigasmic.gemspec",
30
- "test/navigasmic_test.rb",
31
- "test/test_helper.rb"
21
+ "LICENSE",
22
+ "README.textile",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/builders/html_builder.rb",
26
+ "lib/builders/xml_builder.rb",
27
+ "lib/navigasmic.rb",
28
+ "navigasmic.gemspec",
29
+ "test/navigasmic_test.rb",
30
+ "test/test_helper.rb"
32
31
  ]
33
32
  s.homepage = %q{http://github.com/jejacks0n/navigasmic}
34
- s.rdoc_options = ["--charset=UTF-8"]
35
33
  s.require_paths = ["lib"]
36
34
  s.rubygems_version = %q{1.3.7}
37
35
  s.summary = %q{Semantic navigation for Rails}
38
36
  s.test_files = [
39
37
  "test/navigasmic_test.rb",
40
- "test/test_helper.rb"
38
+ "test/test_helper.rb"
41
39
  ]
42
40
 
43
41
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: navigasmic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 1
10
- version: 0.4.1
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Jackson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-06 00:00:00 -06:00
18
+ date: 2010-12-13 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -43,7 +43,6 @@ extra_rdoc_files:
43
43
  - README.textile
44
44
  files:
45
45
  - .document
46
- - .gitignore
47
46
  - LICENSE
48
47
  - README.textile
49
48
  - Rakefile
@@ -59,8 +58,8 @@ homepage: http://github.com/jejacks0n/navigasmic
59
58
  licenses: []
60
59
 
61
60
  post_install_message:
62
- rdoc_options:
63
- - --charset=UTF-8
61
+ rdoc_options: []
62
+
64
63
  require_paths:
65
64
  - lib
66
65
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- pkg