simple-navigation 3.11.0 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +6 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG +11 -0
  5. data/Gemfile +2 -16
  6. data/Guardfile +5 -0
  7. data/LICENSE +22 -0
  8. data/README.md +40 -0
  9. data/Rakefile +6 -39
  10. data/generators/navigation_config/templates/config/navigation.rb +7 -5
  11. data/init.rb +1 -0
  12. data/install.rb +5 -0
  13. data/lib/simple_navigation/adapters/rails.rb +5 -1
  14. data/lib/simple_navigation/core/configuration.rb +5 -1
  15. data/lib/simple_navigation/core/item.rb +2 -1
  16. data/lib/simple_navigation/core/item_adapter.rb +4 -4
  17. data/lib/simple_navigation/core/item_container.rb +6 -1
  18. data/lib/simple_navigation/rendering/renderer/breadcrumbs.rb +2 -2
  19. data/lib/simple_navigation/rendering/renderer/links.rb +2 -2
  20. data/lib/simple_navigation/rendering/renderer/list.rb +1 -1
  21. data/lib/simple_navigation/version.rb +3 -0
  22. data/lib/simple_navigation.rb +1 -0
  23. data/simple-navigation.gemspec +40 -0
  24. data/spec/initializers/have_css_matcher.rb +13 -0
  25. data/spec/lib/simple_navigation/adapters/padrino_spec.rb +23 -25
  26. data/spec/lib/simple_navigation/adapters/rails_spec.rb +276 -250
  27. data/spec/lib/simple_navigation/adapters/sinatra_spec.rb +64 -53
  28. data/spec/lib/simple_navigation/core/configuration_spec.rb +128 -106
  29. data/spec/lib/simple_navigation/core/item_adapter_spec.rb +144 -168
  30. data/spec/lib/simple_navigation/core/item_container_spec.rb +361 -339
  31. data/spec/lib/simple_navigation/core/item_spec.rb +571 -434
  32. data/spec/lib/simple_navigation/core/items_provider_spec.rb +35 -49
  33. data/spec/lib/simple_navigation/rails_controller_methods_spec.rb +194 -173
  34. data/spec/lib/simple_navigation/rendering/helpers_spec.rb +381 -225
  35. data/spec/lib/simple_navigation/rendering/renderer/base_spec.rb +205 -164
  36. data/spec/lib/simple_navigation/rendering/renderer/breadcrumbs_spec.rb +87 -67
  37. data/spec/lib/simple_navigation/rendering/renderer/json_spec.rb +52 -31
  38. data/spec/lib/simple_navigation/rendering/renderer/links_spec.rb +75 -48
  39. data/spec/lib/simple_navigation/rendering/renderer/list_spec.rb +62 -174
  40. data/spec/lib/simple_navigation/rendering/renderer/text_spec.rb +41 -28
  41. data/spec/lib/simple_navigation_spec.rb +207 -225
  42. data/spec/spec_helper.rb +53 -82
  43. data/uninstall.rb +1 -0
  44. metadata +100 -22
  45. data/README +0 -22
  46. data/VERSION +0 -1
data/spec/spec_helper.rb CHANGED
@@ -1,108 +1,79 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require 'rubygems'
3
- require 'rspec'
4
- require 'json_spec'
1
+ require 'initializers/have_css_matcher'
5
2
  require 'action_controller'
3
+ require 'coveralls'
4
+ require 'html/document'
6
5
 
7
- module Rails
8
- module VERSION
9
- MAJOR = 2
10
- end
11
- end unless defined? Rails
12
-
13
- $:.unshift File.dirname(__FILE__)
14
- $:.unshift File.join(File.dirname(__FILE__), '../lib')
6
+ Coveralls.wear!
15
7
 
16
- require 'simple_navigation'
8
+ # FIXME: actualize to make it 4 by default
9
+ unless defined? Rails
10
+ module Rails
11
+ module VERSION
12
+ MAJOR = 2
13
+ end
14
+ end
15
+ end
17
16
 
18
- # SimpleNavigation.root = './'
19
17
  RAILS_ROOT = './' unless defined?(RAILS_ROOT)
20
18
  RAILS_ENV = 'test' unless defined?(RAILS_ENV)
21
19
 
20
+ require 'simple_navigation'
22
21
 
23
- RSpec.configure do |config|
24
- # == Mock Framework
25
- #
26
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
27
- #
28
- # config.mock_with :mocha
29
- # config.mock_with :flexmock
30
- # config.mock_with :rr
31
- config.mock_with :rspec
32
- config.include JsonSpec::Helpers
22
+ def setup_adapter_for(framework)
23
+ adapter = case framework
24
+ when :rails
25
+ context = double(:context, view_context: ActionView::Base.new)
26
+ SimpleNavigation::Adapters::Rails.new(context)
27
+ end
28
+ SimpleNavigation.stub(adapter: adapter)
29
+ adapter
33
30
  end
34
31
 
35
- # spec helper methods
36
- def sub_items
37
- [
38
- [:subnav1, 'subnav1', 'subnav1_url'],
39
- [:subnav2, 'subnav2', 'subnav2_url']
40
- ]
32
+ def setup_renderer(renderer_class, options)
33
+ renderer_class.new(options)
41
34
  end
42
35
 
43
- def primary_items
44
- [
45
- [:users, 'users', 'first_url', {:id => 'my_id', :link => {:id => 'my_link_id'}}],
46
- [:invoices, 'invoices', 'second_url'],
47
- [:accounts, 'accounts', 'third_url', {:style => 'float:right', :link => {:style => 'float:left'}}],
48
- [:miscellany, 'miscellany']
49
- ]
36
+ def primary_navigation
37
+ # TODO
38
+ primary_container
50
39
  end
51
40
 
52
- def primary_container
53
- containers.first
41
+ def select_an_item(item)
42
+ item.stub(selected?: true)
54
43
  end
55
44
 
56
- def containers
45
+ def setup_container(dom_id, dom_class)
57
46
  container = SimpleNavigation::ItemContainer.new(1)
58
- container.dom_id = 'nav_dom_id'
59
- container.dom_class = 'nav_dom_class'
60
- @items = primary_items.map {|params| SimpleNavigation::Item.new(container, *params)}
61
- @items.each {|i| i.stub!(:selected? => false, :selected_by_condition? => false)}
62
- container.instance_variable_set(:@items, @items)
63
- sub_container = subnav_container
64
- primary_item(:invoices) {|item| item.instance_variable_set(:@sub_navigation, sub_container)}
65
- [container,sub_container]
66
- end
67
-
68
- def primary_item(key)
69
- item = @items.find {|i| i.key == key}
70
- block_given? ? yield(item) : item
47
+ container.dom_id = dom_id
48
+ container.dom_class = dom_class
49
+ container
71
50
  end
72
51
 
73
- def sub_item(key)
74
- primary_item(:invoices).instance_variable_get(:@sub_navigation).items.find { |i| i.key == key}
52
+ def setup_navigation(dom_id, dom_class)
53
+ setup_adapter_for :rails
54
+ container = setup_container(dom_id, dom_class)
55
+ setup_items(container)
56
+ container
75
57
  end
76
58
 
77
- def select_item(key)
78
- if(key == :subnav1)
79
- select_item(:invoices)
80
- primary_item(:invoices) do |item|
81
- item.instance_variable_get(:@sub_navigation).items.find { |i| i.key == key}.stub!(:selected? => true, :selected_by_condition? => true)
82
- end
83
- else
84
- primary_item(key) {|item| item.stub!(:selected? => true) unless item.frozen?}
59
+ # FIXME: adding the :link option for the list renderer messes up the other
60
+ # renderers
61
+ def setup_items(container)
62
+ container.item :users, 'Users', '/users', id: 'users_id', link: { id: 'users_link_id' }
63
+ container.item :invoices, 'Invoices', '/invoices' do |invoices|
64
+ invoices.item :paid, 'Paid', '/invoices/paid'
65
+ invoices.item :unpaid, 'Unpaid', '/invoices/unpaid'
85
66
  end
86
- end
87
-
88
- def subnav_container
89
- container = SimpleNavigation::ItemContainer.new(2)
90
- items = sub_items.map {|params| SimpleNavigation::Item.new(container, *params)}
91
- items.each {|i| i.stub!(:selected? => false, :selected_by_condition? => false)}
92
- container.instance_variable_set(:@items, items)
93
- container
94
- end
67
+ container.item :accounts, 'Accounts', '/accounts', style: 'float:right', link: { style: 'float:left' }
68
+ container.item :miscellany, 'Miscellany'
95
69
 
96
- def setup_renderer_for(renderer_class, framework, options)
97
- setup_adapter_for framework
98
- @renderer = renderer_class.new(options)
99
- end
70
+ container.items.each do |item|
71
+ item.stub(selected?: false, selected_by_condition?: false)
100
72
 
101
- def setup_adapter_for(framework)
102
- adapter = case framework
103
- when :rails
104
- SimpleNavigation::Adapters::Rails.new(stub(:context, :view_context => ActionView::Base.new))
73
+ if item.sub_navigation
74
+ item.sub_navigation.items.each do |item|
75
+ item.stub(selected?: false, selected_by_condition?: false)
76
+ end
77
+ end
105
78
  end
106
- SimpleNavigation.stub!(:adapter => adapter)
107
- adapter
108
79
  end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-navigation
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.12.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-05 00:00:00.000000000 Z
13
+ date: 2014-02-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -29,13 +29,13 @@ dependencies:
29
29
  - !ruby/object:Gem::Version
30
30
  version: 2.3.2
31
31
  - !ruby/object:Gem::Dependency
32
- name: rspec
32
+ name: actionpack
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  none: false
35
35
  requirements:
36
36
  - - ! '>='
37
37
  - !ruby/object:Gem::Version
38
- version: 2.0.1
38
+ version: 2.3.2
39
39
  type: :development
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,55 @@ dependencies:
43
43
  requirements:
44
44
  - - ! '>='
45
45
  - !ruby/object:Gem::Version
46
- version: 2.0.1
46
+ version: 2.3.2
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '1.5'
63
+ - !ruby/object:Gem::Dependency
64
+ name: coveralls
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: '0.7'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: '0.7'
79
+ - !ruby/object:Gem::Dependency
80
+ name: guard-rspec
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: '4.2'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: '4.2'
47
95
  - !ruby/object:Gem::Dependency
48
96
  name: json_spec
49
97
  requirement: !ruby/object:Gem::Requirement
@@ -51,7 +99,7 @@ dependencies:
51
99
  requirements:
52
100
  - - ~>
53
101
  - !ruby/object:Gem::Version
54
- version: 1.1.1
102
+ version: '1.1'
55
103
  type: :development
56
104
  prerelease: false
57
105
  version_requirements: !ruby/object:Gem::Requirement
@@ -59,7 +107,7 @@ dependencies:
59
107
  requirements:
60
108
  - - ~>
61
109
  - !ruby/object:Gem::Version
62
- version: 1.1.1
110
+ version: '1.1'
63
111
  - !ruby/object:Gem::Dependency
64
112
  name: rake
65
113
  requirement: !ruby/object:Gem::Requirement
@@ -93,39 +141,45 @@ dependencies:
93
141
  - !ruby/object:Gem::Version
94
142
  version: '0'
95
143
  - !ruby/object:Gem::Dependency
96
- name: jeweler
144
+ name: rspec
97
145
  requirement: !ruby/object:Gem::Requirement
98
146
  none: false
99
147
  requirements:
100
- - - ! '>='
148
+ - - ~>
101
149
  - !ruby/object:Gem::Version
102
- version: '0'
150
+ version: '2.0'
103
151
  type: :development
104
152
  prerelease: false
105
153
  version_requirements: !ruby/object:Gem::Requirement
106
154
  none: false
107
155
  requirements:
108
- - - ! '>='
156
+ - - ~>
109
157
  - !ruby/object:Gem::Version
110
- version: '0'
158
+ version: '2.0'
111
159
  description: With the simple-navigation gem installed you can easily create multilevel
112
160
  navigations for your Rails, Sinatra or Padrino applications. The navigation is defined
113
161
  in a single configuration file. It supports automatic as well as explicit highlighting
114
162
  of the currently active navigation through regular expressions.
115
- email: andreas.schacke@gmail.com
163
+ email:
164
+ - andi@codeplant.ch
116
165
  executables: []
117
166
  extensions: []
118
- extra_rdoc_files:
119
- - README
167
+ extra_rdoc_files: []
120
168
  files:
169
+ - .gitignore
170
+ - .rspec
171
+ - .travis.yml
121
172
  - CHANGELOG
122
173
  - Gemfile
123
- - README
174
+ - Guardfile
175
+ - LICENSE
176
+ - README.md
124
177
  - Rakefile
125
- - VERSION
126
178
  - generators/navigation_config/USAGE
127
179
  - generators/navigation_config/navigation_config_generator.rb
128
180
  - generators/navigation_config/templates/config/navigation.rb
181
+ - init.rb
182
+ - install.rb
129
183
  - lib/generators/navigation_config/navigation_config_generator.rb
130
184
  - lib/simple-navigation.rb
131
185
  - lib/simple_navigation.rb
@@ -150,7 +204,10 @@ files:
150
204
  - lib/simple_navigation/rendering/renderer/links.rb
151
205
  - lib/simple_navigation/rendering/renderer/list.rb
152
206
  - lib/simple_navigation/rendering/renderer/text.rb
207
+ - lib/simple_navigation/version.rb
153
208
  - rails/init.rb
209
+ - simple-navigation.gemspec
210
+ - spec/initializers/have_css_matcher.rb
154
211
  - spec/lib/simple_navigation/adapters/padrino_spec.rb
155
212
  - spec/lib/simple_navigation/adapters/rails_spec.rb
156
213
  - spec/lib/simple_navigation/adapters/sinatra_spec.rb
@@ -169,8 +226,10 @@ files:
169
226
  - spec/lib/simple_navigation/rendering/renderer/text_spec.rb
170
227
  - spec/lib/simple_navigation_spec.rb
171
228
  - spec/spec_helper.rb
172
- homepage: http://github.com/andi/simple-navigation
173
- licenses: []
229
+ - uninstall.rb
230
+ homepage: http://github.com/codeplant/simple-navigation
231
+ licenses:
232
+ - MIT
174
233
  post_install_message:
175
234
  rdoc_options:
176
235
  - --inline-source
@@ -190,10 +249,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
249
  - !ruby/object:Gem::Version
191
250
  version: '0'
192
251
  requirements: []
193
- rubyforge_project: andi
252
+ rubyforge_project:
194
253
  rubygems_version: 1.8.24
195
254
  signing_key:
196
255
  specification_version: 3
197
256
  summary: simple-navigation is a ruby library for creating navigations (with multiple
198
- levels) for your Rails2, Rails3, Sinatra or Padrino application.
199
- test_files: []
257
+ levels) for your Rails2, Rails3, Rails4, Sinatra or Padrino application.
258
+ test_files:
259
+ - spec/initializers/have_css_matcher.rb
260
+ - spec/lib/simple_navigation/adapters/padrino_spec.rb
261
+ - spec/lib/simple_navigation/adapters/rails_spec.rb
262
+ - spec/lib/simple_navigation/adapters/sinatra_spec.rb
263
+ - spec/lib/simple_navigation/core/configuration_spec.rb
264
+ - spec/lib/simple_navigation/core/item_adapter_spec.rb
265
+ - spec/lib/simple_navigation/core/item_container_spec.rb
266
+ - spec/lib/simple_navigation/core/item_spec.rb
267
+ - spec/lib/simple_navigation/core/items_provider_spec.rb
268
+ - spec/lib/simple_navigation/rails_controller_methods_spec.rb
269
+ - spec/lib/simple_navigation/rendering/helpers_spec.rb
270
+ - spec/lib/simple_navigation/rendering/renderer/base_spec.rb
271
+ - spec/lib/simple_navigation/rendering/renderer/breadcrumbs_spec.rb
272
+ - spec/lib/simple_navigation/rendering/renderer/json_spec.rb
273
+ - spec/lib/simple_navigation/rendering/renderer/links_spec.rb
274
+ - spec/lib/simple_navigation/rendering/renderer/list_spec.rb
275
+ - spec/lib/simple_navigation/rendering/renderer/text_spec.rb
276
+ - spec/lib/simple_navigation_spec.rb
277
+ - spec/spec_helper.rb
data/README DELETED
@@ -1,22 +0,0 @@
1
-
2
- == Simple Navigation
3
-
4
- Simple Navigation is a ruby library for creating navigations (with multiple levels) for your Rails 2, Rails 3, Sinatra or Padrino applications.
5
-
6
- Source code:
7
- git://github.com/andi/simple-navigation.git
8
-
9
- Documentation:
10
- http://wiki.github.com/andi/simple-navigation
11
-
12
- RDoc:
13
- Please checkout the repository and execute 'rake rdoc'.
14
-
15
- Online Demo:
16
- http://simple-navigation-demo.andischacke.com
17
-
18
- Discussion Group for Feedback and Questions
19
- http://groups.google.com/group/simple-navigation
20
-
21
- Copyright (c) 2012 Andi Schacke, released under the MIT license
22
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 3.11.0