semantic_navigation 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.editorconfig +14 -0
  2. data/.gitignore +2 -0
  3. data/.travis.yml +10 -2
  4. data/Appraisals +7 -0
  5. data/Gemfile +1 -1
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +31 -20
  8. data/Rakefile +2 -1
  9. data/TODO +14 -0
  10. data/gemfiles/3.2.gemfile +7 -0
  11. data/gemfiles/3.2.gemfile.lock +112 -0
  12. data/gemfiles/4.0.gemfile +7 -0
  13. data/gemfiles/4.0.gemfile.lock +107 -0
  14. data/lib/generators/semantic_navigation/breadcrumb_renderer/templates/breadcrumb_renderer.rb +5 -5
  15. data/lib/generators/semantic_navigation/list_renderer/list_renderer_generator.rb +0 -1
  16. data/lib/generators/semantic_navigation/list_renderer/templates/list_renderer.rb +4 -4
  17. data/lib/semantic_navigation.rb +30 -0
  18. data/lib/semantic_navigation/configuration.rb +8 -9
  19. data/lib/semantic_navigation/core.rb +8 -6
  20. data/lib/semantic_navigation/core/leaf.rb +2 -2
  21. data/lib/semantic_navigation/core/mix_in/name_methods.rb +24 -0
  22. data/lib/semantic_navigation/core/mix_in/url_methods.rb +25 -0
  23. data/lib/semantic_navigation/core/navigation.rb +8 -2
  24. data/lib/semantic_navigation/core/node.rb +2 -2
  25. data/lib/semantic_navigation/deprecations/renderers/acts_as_breadcrumb.rb +14 -0
  26. data/lib/semantic_navigation/deprecations/renderers/acts_as_list.rb +12 -0
  27. data/lib/semantic_navigation/deprecations/renderers/render_helpers.rb +14 -0
  28. data/lib/semantic_navigation/helper_methods.rb +8 -4
  29. data/lib/semantic_navigation/railtie.rb +9 -19
  30. data/lib/semantic_navigation/renderers.rb +15 -8
  31. data/lib/semantic_navigation/renderers/bread_crumb.rb +6 -6
  32. data/lib/semantic_navigation/renderers/list.rb +6 -6
  33. data/lib/semantic_navigation/renderers/mix_in/acts_as_breadcrumb.rb +43 -0
  34. data/lib/semantic_navigation/renderers/mix_in/acts_as_list.rb +49 -0
  35. data/lib/semantic_navigation/renderers/mix_in/render_helpers.rb +110 -0
  36. data/lib/semantic_navigation/twitter_bootstrap/breadcrumb.rb +5 -5
  37. data/lib/semantic_navigation/twitter_bootstrap/list.rb +2 -2
  38. data/lib/semantic_navigation/twitter_bootstrap/tabs.rb +2 -2
  39. data/lib/semantic_navigation/version.rb +1 -1
  40. data/semantic_navigation.gemspec +3 -2
  41. data/spec/lib/semantic_navigation/configuration_spec.rb +29 -24
  42. data/spec/lib/semantic_navigation/core/leaf_spec.rb +121 -114
  43. data/spec/lib/semantic_navigation/core/navigation_spec.rb +81 -76
  44. data/spec/lib/semantic_navigation/core/node_spec.rb +52 -49
  45. data/spec/lib/semantic_navigation/helper_methods_spec.rb +47 -42
  46. data/spec/lib/semantic_navigation/renderers/bread_crumb_spec.rb +191 -187
  47. data/spec/lib/semantic_navigation/renderers/deprecations_spec.rb +67 -0
  48. data/spec/lib/semantic_navigation/renderers/list_spec.rb +260 -258
  49. data/spec/lib/semantic_navigation/twitter_bootstrap/breadcrumb_spec.rb +163 -159
  50. data/spec/lib/semantic_navigation/twitter_bootstrap/list_spec.rb +263 -262
  51. data/spec/lib/semantic_navigation/twitter_bootstrap/tabs_spec.rb +269 -266
  52. data/spec/spec_helper.rb +6 -0
  53. metadata +41 -13
  54. data/gemfiles/rails3 +0 -7
  55. data/lib/semantic_navigation/core/name_methods.rb +0 -24
  56. data/lib/semantic_navigation/core/url_methods.rb +0 -24
  57. data/lib/semantic_navigation/renderers/acts_as_breadcrumb.rb +0 -42
  58. data/lib/semantic_navigation/renderers/acts_as_list.rb +0 -48
  59. data/lib/semantic_navigation/renderers/render_helpers.rb +0 -109
@@ -0,0 +1,14 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.md]
12
+ indent_size = 4
13
+ trim_trailing_whitespace = false
14
+
data/.gitignore CHANGED
@@ -6,3 +6,5 @@ pkg/*
6
6
  nbproject/*
7
7
 
8
8
  coverage/
9
+
10
+ .DS_Store
@@ -1,7 +1,15 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 1.9.2
4
+ - 1.9.3
5
5
  - ruby-head
6
6
  gemfile:
7
- - gemfiles/rails3
7
+ - gemfiles/3.2.gemfile
8
+ - gemfiles/4.0.gemfile
9
+ matrix:
10
+ exclude:
11
+ - rvm: 1.9.2
12
+ gemfile: gemfiles/4.0.gemfile
13
+ - rvm: ruby-head
14
+ gemfile: gemfiles/4.0.gemfile
15
+
@@ -0,0 +1,7 @@
1
+ appraise "3.2" do
2
+ gem 'rails', '~> 3.2.0'
3
+ end
4
+
5
+ appraise "4.0" do
6
+ gem 'rails', '4.0.0rc1'
7
+ end
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in semantic_navigation.gemspec
4
4
  gemspec
@@ -0,0 +1,20 @@
1
+ Copyright 2010-2013 Gribovski Sergey
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,11 +1,16 @@
1
- This is semantic_navigation gem
1
+ # semantic_navigation [![Gem Version](https://badge.fury.io/rb/semantic_navigation.png)](http://badge.fury.io/rb/semantic_navigation) [![Build Status](https://travis-ci.org/fr33z3/semantic_navigation.png)](https://travis-ci.org/fr33z3/semantic_navigation)
2
+
3
+ Simple navigation menus implementation for Rails 3 application with multiple and nesting menus.
4
+
5
+ ## Purpose
2
6
 
3
- ###Purpose
4
7
  Forget fat layouts, views and controllers. This gem will do all the menu staff for you.
5
8
  You simply just have to generate configuration file, fill it with your menu hierarchy and renderer it wherever you want.
6
9
 
7
10
  Simply and customizable it will make for you all the routins you were spending a lot of time before.
8
11
 
12
+ ### Features
13
+
9
14
  * semantic_navigation supports defining as many separate menus as you want and they can be as deep as you need.
10
15
  * supports different styles of url definitions ('route#like', :symbols, 'strings', {hash: 'like'})
11
16
  * supports and array of urls for one item
@@ -16,28 +21,30 @@ Simply and customizable it will make for you all the routins you were spending a
16
21
  * supports controller default styles overriding both - from configuration and view file
17
22
  * supports custom renderers
18
23
 
19
- ###How to install
24
+ ## How to install
20
25
 
21
26
  Write the gem dependency in your Gemfile:
22
- <pre><code>
27
+
28
+ ```ruby
23
29
  gem 'semantic_navigation'
24
- </code></pre>
30
+ ```
25
31
 
26
32
  Make the install by bundler
27
- <pre><code>
33
+
34
+ ```bash
28
35
  $ bundle install
29
- </code></pre>
36
+ ```
30
37
 
31
38
  Generate the config file:
32
- <pre><code>
39
+ ```bash
33
40
  $ rails generate semantic_navigation:install
34
- </code></pre>
41
+ ```
35
42
 
36
- ###Quick start
43
+ ## Quick start
37
44
 
38
- Configure your navigation in config/initializers/semantic_navigation.rb
45
+ Configure your navigation in `config/initializers/semantic_navigation.rb`:
39
46
 
40
- <pre><code>
47
+ ```ruby
41
48
  SemanticNavigation::Configuration.run do
42
49
  navigate :root_menu do
43
50
  header :header_item, :name => 'Header'
@@ -46,24 +53,28 @@ SemanticNavigation::Configuration.run do
46
53
  item :second_item, '#', :name => 'Second Item', :ico => :user
47
54
  end
48
55
  end
49
- </code></pre>
56
+ ```
50
57
 
51
58
  And try to render it in your layout(code in haml):
52
- <pre><code>
59
+
60
+ ```haml
53
61
  .well
54
62
  = navigation_for :root_menu, :as => :bootstrap_list
55
- </code></pre>
63
+ ```
64
+
56
65
  or
57
- <pre><code>
66
+
67
+ ```haml
58
68
  .well
59
69
  = bootstrap_list_for :root_menu
60
- </code></pre>
70
+ ```
61
71
 
62
72
  Render the navigation using the semantic_navigation helper methods and options for them.
63
73
 
64
- For the information of how to configure and render your navigation read the <a href='https://github.com/fr33z3/semantic_navigation/wiki'>Wiki</a>
74
+ For the information of how to configure and render your navigation read the [Wiki](https://github.com/fr33z3/semantic_navigation/wiki).
65
75
 
66
- Dependence:
76
+ ### Dependencies
67
77
 
68
78
  * Ruby >= 1.9.2
69
- * Rails >= 3.0.0
79
+ * Rails >= 3.2.0
80
+
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rspec/core/rake_task'
2
- require "bundler/gem_tasks"
2
+ require 'bundler/gem_tasks'
3
+ require 'appraisal'
3
4
 
4
5
  RSpec::Core::RakeTask.new('spec')
5
6
 
data/TODO ADDED
@@ -0,0 +1,14 @@
1
+ ActiveSupport helper methods:
2
+ - Write specs for active_item_for if it getting block
3
+ - Write wiki about that
4
+
5
+ Concept:
6
+ - Rewrite leaf/node concept
7
+ - Add possible to define renderers as templates
8
+ - Add renderers for other template frameworks
9
+ - Move bootstrap renderers to bootstrap version 4.0.0
10
+ - Possible to make dynamic items in menu (database or something else)
11
+
12
+ Convention over configuration:
13
+ - Move menu definitions outside the initializers folder
14
+ - Leave menu configuration options in initalizers folder
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 3.2.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,112 @@
1
+ PATH
2
+ remote: /mnt/code/github/semantic_navigation
3
+ specs:
4
+ semantic_navigation (0.1.2)
5
+ rails (>= 3.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.13)
11
+ actionpack (= 3.2.13)
12
+ mail (~> 2.5.3)
13
+ actionpack (3.2.13)
14
+ activemodel (= 3.2.13)
15
+ activesupport (= 3.2.13)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.5)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.2.1)
23
+ activemodel (3.2.13)
24
+ activesupport (= 3.2.13)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.13)
27
+ activemodel (= 3.2.13)
28
+ activesupport (= 3.2.13)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.13)
32
+ activemodel (= 3.2.13)
33
+ activesupport (= 3.2.13)
34
+ activesupport (3.2.13)
35
+ i18n (= 0.6.1)
36
+ multi_json (~> 1.0)
37
+ appraisal (0.5.2)
38
+ bundler
39
+ rake
40
+ arel (3.0.2)
41
+ builder (3.0.4)
42
+ diff-lcs (1.2.4)
43
+ erubis (2.7.0)
44
+ hike (1.2.2)
45
+ i18n (0.6.1)
46
+ journey (1.0.4)
47
+ json (1.7.7)
48
+ mail (2.5.3)
49
+ i18n (>= 0.4.0)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ mime-types (1.23)
53
+ multi_json (1.7.2)
54
+ polyglot (0.3.3)
55
+ rack (1.4.5)
56
+ rack-cache (1.2)
57
+ rack (>= 0.4)
58
+ rack-ssl (1.3.3)
59
+ rack
60
+ rack-test (0.6.2)
61
+ rack (>= 1.0)
62
+ rails (3.2.13)
63
+ actionmailer (= 3.2.13)
64
+ actionpack (= 3.2.13)
65
+ activerecord (= 3.2.13)
66
+ activeresource (= 3.2.13)
67
+ activesupport (= 3.2.13)
68
+ bundler (~> 1.0)
69
+ railties (= 3.2.13)
70
+ railties (3.2.13)
71
+ actionpack (= 3.2.13)
72
+ activesupport (= 3.2.13)
73
+ rack-ssl (~> 1.3.2)
74
+ rake (>= 0.8.7)
75
+ rdoc (~> 3.4)
76
+ thor (>= 0.14.6, < 2.0)
77
+ rake (10.0.4)
78
+ rdoc (3.12.2)
79
+ json (~> 1.4)
80
+ rspec (2.13.0)
81
+ rspec-core (~> 2.13.0)
82
+ rspec-expectations (~> 2.13.0)
83
+ rspec-mocks (~> 2.13.0)
84
+ rspec-core (2.13.1)
85
+ rspec-expectations (2.13.0)
86
+ diff-lcs (>= 1.1.3, < 2.0)
87
+ rspec-mocks (2.13.1)
88
+ simplecov (0.7.1)
89
+ multi_json (~> 1.0)
90
+ simplecov-html (~> 0.7.1)
91
+ simplecov-html (0.7.1)
92
+ sprockets (2.2.2)
93
+ hike (~> 1.2)
94
+ multi_json (~> 1.0)
95
+ rack (~> 1.0)
96
+ tilt (~> 1.1, != 1.3.0)
97
+ thor (0.18.1)
98
+ tilt (1.4.0)
99
+ treetop (1.4.12)
100
+ polyglot
101
+ polyglot (>= 0.3.1)
102
+ tzinfo (0.3.37)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ appraisal
109
+ rails (~> 3.2.0)
110
+ rspec (>= 2.0.1)
111
+ semantic_navigation!
112
+ simplecov
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "4.0.0rc1"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,107 @@
1
+ PATH
2
+ remote: /mnt/code/github/semantic_navigation
3
+ specs:
4
+ semantic_navigation (0.1.2)
5
+ rails (>= 3.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.0.0.rc1)
11
+ actionpack (= 4.0.0.rc1)
12
+ mail (~> 2.5.3)
13
+ actionpack (4.0.0.rc1)
14
+ activesupport (= 4.0.0.rc1)
15
+ builder (~> 3.1.0)
16
+ erubis (~> 2.7.0)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ activemodel (4.0.0.rc1)
20
+ activesupport (= 4.0.0.rc1)
21
+ builder (~> 3.1.0)
22
+ activerecord (4.0.0.rc1)
23
+ activemodel (= 4.0.0.rc1)
24
+ activerecord-deprecated_finders (~> 1.0.2)
25
+ activesupport (= 4.0.0.rc1)
26
+ arel (~> 4.0.0)
27
+ activerecord-deprecated_finders (1.0.2)
28
+ activesupport (4.0.0.rc1)
29
+ i18n (~> 0.6, >= 0.6.4)
30
+ minitest (~> 4.2)
31
+ multi_json (~> 1.3)
32
+ thread_safe (~> 0.1)
33
+ tzinfo (~> 0.3.37)
34
+ appraisal (0.5.2)
35
+ bundler
36
+ rake
37
+ arel (4.0.0)
38
+ atomic (1.1.8)
39
+ builder (3.1.4)
40
+ diff-lcs (1.2.4)
41
+ erubis (2.7.0)
42
+ hike (1.2.2)
43
+ i18n (0.6.4)
44
+ mail (2.5.3)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mime-types (1.23)
49
+ minitest (4.7.3)
50
+ multi_json (1.7.2)
51
+ polyglot (0.3.3)
52
+ rack (1.5.2)
53
+ rack-test (0.6.2)
54
+ rack (>= 1.0)
55
+ rails (4.0.0.rc1)
56
+ actionmailer (= 4.0.0.rc1)
57
+ actionpack (= 4.0.0.rc1)
58
+ activerecord (= 4.0.0.rc1)
59
+ activesupport (= 4.0.0.rc1)
60
+ bundler (>= 1.3.0, < 2.0)
61
+ railties (= 4.0.0.rc1)
62
+ sprockets-rails (~> 2.0.0.rc4)
63
+ railties (4.0.0.rc1)
64
+ actionpack (= 4.0.0.rc1)
65
+ activesupport (= 4.0.0.rc1)
66
+ rake (>= 0.8.7)
67
+ thor (>= 0.18.1, < 2.0)
68
+ rake (10.0.4)
69
+ rspec (2.13.0)
70
+ rspec-core (~> 2.13.0)
71
+ rspec-expectations (~> 2.13.0)
72
+ rspec-mocks (~> 2.13.0)
73
+ rspec-core (2.13.1)
74
+ rspec-expectations (2.13.0)
75
+ diff-lcs (>= 1.1.3, < 2.0)
76
+ rspec-mocks (2.13.1)
77
+ simplecov (0.7.1)
78
+ multi_json (~> 1.0)
79
+ simplecov-html (~> 0.7.1)
80
+ simplecov-html (0.7.1)
81
+ sprockets (2.9.3)
82
+ hike (~> 1.2)
83
+ multi_json (~> 1.0)
84
+ rack (~> 1.0)
85
+ tilt (~> 1.1, != 1.3.0)
86
+ sprockets-rails (2.0.0.rc4)
87
+ actionpack (>= 3.0)
88
+ activesupport (>= 3.0)
89
+ sprockets (~> 2.8)
90
+ thor (0.18.1)
91
+ thread_safe (0.1.0)
92
+ atomic
93
+ tilt (1.4.0)
94
+ treetop (1.4.12)
95
+ polyglot
96
+ polyglot (>= 0.3.1)
97
+ tzinfo (0.3.37)
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ appraisal
104
+ rails (= 4.0.0rc1)
105
+ rspec (>= 2.0.1)
106
+ semantic_navigation!
107
+ simplecov
@@ -1,8 +1,8 @@
1
1
  class Renderers::<%= class_name %>
2
- #Default render helpers. Do not delete this if don't want to write your own.
3
- include RenderHelpers
2
+ #Default render helpers. Do not delete this if don't want to write your own.
3
+ include SemanticNavigation::Renderers::MixIn::RenderHelpers
4
4
  #The default list rendering logic. Do not delete if don't want to write your own.
5
- include ActsAsBreadcrumb
5
+ include SemanticNavigation::Renderers::MixIn::ActsAsBreadcrumb
6
6
  style_accessor :last_as_link => false,
7
7
  :breadcrumb_separator => '/'
8
8
 
@@ -25,7 +25,7 @@ class Renderers::<%= class_name %>
25
25
  navigation_default_classes ['<%= file_name %>']
26
26
  node_default_classes ['<%= file_name %>']
27
27
  leaf_default_classes ['<%= file_name %>']
28
- link_default_classes ['<%= file_name %>']
28
+ link_default_classes ['<%= file_name %>']
29
29
 
30
30
  private
31
31
 
@@ -59,4 +59,4 @@ class Renderers::<%= class_name %>
59
59
  end
60
60
  end
61
61
  end
62
- end
62
+ end