simple-navigation 3.0.0.beta1 → 3.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ *3.0.0.beta2
2
+
3
+ * moving code for initializing plugin in sinatra to separate gem
4
+
1
5
  *3.0.0.beta1
2
6
 
3
7
  * moving deprecated rails controller methods (navigation, current_navigation) to separate file 'rails_controller_methods'. Deprecations removed. File can be required explicitly if controller methods should be still available.
data/Rakefile CHANGED
@@ -34,10 +34,10 @@ begin
34
34
  require 'jeweler'
35
35
  Jeweler::Tasks.new do |gemspec|
36
36
  gemspec.name = "simple-navigation"
37
- gemspec.summary = "Simple Navigation is a ruby library for creating navigations (with multiple levels) for your Ruby on Rails application."
37
+ gemspec.summary = "simple-navigation is a ruby library for creating navigations (with multiple levels) for your Rails2, Rails3, Sinatra or Padrino application."
38
38
  gemspec.email = "andreas.schacke@gmail.com"
39
39
  gemspec.homepage = "http://github.com/andi/simple-navigation"
40
- gemspec.description = "With the simple-navigation gem installed you can easily create multilevel navigations for your Ruby on Rails applications. The navigation is defined in a single configuration file. It supports automatic as well as explicit highlighting of the currently active navigation."
40
+ gemspec.description = "With the simple-navigation gem installed you can easily create multilevel navigations for your Rails, Sinatra or Padrino applications. The navigation is defined in a single configuration file. It supports automatic as well as explicit highlighting of the currently active navigation through regular expressions."
41
41
  gemspec.add_development_dependency('rspec', '>= 1.2.8')
42
42
  gemspec.add_dependency('activesupport', '>= 2.3.2')
43
43
  gemspec.authors = ["Andi Schacke"]
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.0.0
@@ -64,13 +64,3 @@ module SimpleNavigation
64
64
  end
65
65
  end
66
66
  end
67
-
68
- module SimpleNavigation
69
-
70
- # Adds registered method to SimpleNavigation. This is called when executing 'register SimpleNavigation'.
71
- def self.registered(app)
72
- register
73
- app.helpers Helpers
74
- end
75
-
76
- end
@@ -7,7 +7,7 @@ module SimpleNavigation
7
7
  include Singleton
8
8
 
9
9
  attr_accessor :renderer, :selected_class, :autogenerate_item_ids, :id_generator, :auto_highlight
10
- attr_reader :render_all_levels, :primary_navigation
10
+ attr_reader :primary_navigation
11
11
 
12
12
  class << self
13
13
 
@@ -32,12 +32,6 @@ module SimpleNavigation
32
32
  @auto_highlight = true
33
33
  end
34
34
 
35
- # Adds a deprecation warning when this options is set in the config file
36
- def render_all_levels=(do_it)
37
- ActiveSupport::Deprecation.warn("Setting render_all_levels in the config-file has been deprected. Please use render_navigation(:expand_all => true) instead")
38
- @render_all_levels = do_it
39
- end
40
-
41
35
  # This is the main method for specifying the navigation items. It can be used in two ways:
42
36
  #
43
37
  # 1. Declaratively specify your items in the config/navigation.rb file using a block. It then yields an SimpleNavigation::ItemContainer for adding navigation items.
@@ -31,10 +31,8 @@ module SimpleNavigation
31
31
  # will be loaded and used for rendering the navigation.
32
32
  # * <tt>:items</tt> - you can specify the items directly (e.g. if items are dynamically generated from database). See SimpleNavigation::ItemsProvider for documentation on what to provide as items.
33
33
  # * <tt>:renderer</tt> - specify the renderer to be used for rendering the navigation. Either provide the Class or a symbol matching a registered renderer. Defaults to :list (html list renderer).
34
- def render_navigation(*args)
35
- args = [Hash.new] if args.empty?
36
- options = extract_backwards_compatible_options(*args)
37
- options = {:context => :default, :level => :all}.merge(options)
34
+ def render_navigation(options={})
35
+ options = apply_defaults(options)
38
36
  ctx = options.delete(:context)
39
37
  SimpleNavigation.init_adapter_from self
40
38
  SimpleNavigation.load_config(ctx)
@@ -46,50 +44,11 @@ module SimpleNavigation
46
44
  active_item_container.render(options) unless active_item_container.nil?
47
45
  end
48
46
 
49
- # Deprecated. Renders the primary_navigation with the configured renderer. Calling render_navigation(:level => 0) has the same effect.
50
- def render_primary_navigation(options = {})
51
- ActiveSupport::Deprecation.warn("SimpleNavigation::Helpers.render_primary_navigation has been deprecated. Please use render_navigation(:level => 1) instead")
52
- render_navigation(options.merge(:level => 1))
53
- end
54
-
55
- # Deprecated. Renders the sub_navigation with the configured renderer. Calling render_navigation(:level => 1) has the same effect.
56
- def render_sub_navigation(options = {})
57
- ActiveSupport::Deprecation.warn("SimpleNavigation::Helpers.render_primary_navigation has been deprecated. Please use render_navigation(:level => 2) instead")
58
- render_navigation(options.merge(:level => 2))
59
- end
60
-
61
47
  private
62
48
 
63
- def extract_backwards_compatible_options(*args)
64
- case args.first
65
- when Hash
66
- options = args.first
67
- options[:level] = options.delete(:levels) if options[:levels]
68
- deprecated_api! if options[:level] == :primary || options[:level] == :secondary || options[:level] == :nested
69
- options[:level] = 1 if options[:level] == :primary
70
- options[:level] = 2 if options[:level] == :secondary
71
- options[:level] = :all if options[:level] == :nested
72
- when Symbol
73
- deprecated_api!
74
- raise ArgumentError, "Invalid arguments" unless [:primary, :secondary, :nested].include? args.first
75
- options = Hash.new
76
- options[:level] = args.first
77
- options[:level] = :all if options[:level] == :nested
78
- options[:level] = 1 if options[:level] == :primary
79
- options[:level] = 2 if options[:level] == :secondary
80
- options.merge!(args[1] || {})
81
- else
82
- raise ArgumentError, "Invalid arguments"
83
- end
84
- if options[:all_open]
85
- options[:expand_all] = options.delete(:all_open)
86
- ActiveSupport::Deprecation.warn("render_navigation(:all_open => true) has been deprecated, please use render_navigation(:expand_all => true) instead")
87
- end
88
- options
89
- end
90
-
91
- def deprecated_api!
92
- ActiveSupport::Deprecation.warn("You are using a deprecated API of SimpleNavigation::Helpers.render_navigation, please check the documentation on http://wiki.github.com/andi/simple-navigation")
49
+ def apply_defaults(options)
50
+ options[:level] = options.delete(:levels) if options[:levels]
51
+ {:context => :default, :level => :all}.merge(options)
93
52
  end
94
53
 
95
54
  end
@@ -106,15 +106,6 @@ describe SimpleNavigation::Configuration do
106
106
  end
107
107
  end
108
108
 
109
- describe 'render_all_levels=' do
110
- it "should set the instance var" do
111
- ActiveSupport::Deprecation.silence do
112
- @config.render_all_levels = true
113
- @config.render_all_levels.should be_true
114
- end
115
- end
116
- end
117
-
118
109
  describe 'loaded?' do
119
110
  it "should return true if primary_nav is set" do
120
111
  @config.instance_variable_set(:@primary_navigation, :bla)
@@ -74,6 +74,7 @@ describe SimpleNavigation::ItemContainer do
74
74
 
75
75
  describe 'selected_item' do
76
76
  before(:each) do
77
+ SimpleNavigation.stub!(:current_navigation_for => :nav)
77
78
  @item_container.stub!(:[] => nil)
78
79
  @item_1 = stub(:item, :selected? => false)
79
80
  @item_2 = stub(:item, :selected? => false)
@@ -43,10 +43,8 @@ describe 'explicit navigation in rails' do
43
43
  describe 'navigation' do
44
44
 
45
45
  def call_navigation(key1, key2=nil)
46
- ActiveSupport::Deprecation.silence do
47
- @controller.class_eval do
48
- navigation key1, key2
49
- end
46
+ @controller.class_eval do
47
+ navigation key1, key2
50
48
  end
51
49
  end
52
50
 
@@ -78,11 +76,11 @@ describe 'explicit navigation in rails' do
78
76
 
79
77
  describe 'current_navigation' do
80
78
  it "should set the sn_current_navigation_args as specified" do
81
- ActiveSupport::Deprecation.silence {@controller.current_navigation(:first)}
79
+ @controller.current_navigation(:first)
82
80
  @controller.instance_variable_get(:@sn_current_navigation_args).should == [:first]
83
81
  end
84
82
  it "should set the sn_current_navigation_args as specified" do
85
- ActiveSupport::Deprecation.silence {@controller.current_navigation(:first, :second)}
83
+ @controller.current_navigation(:first, :second)
86
84
  @controller.instance_variable_get(:@sn_current_navigation_args).should == [:first, :second]
87
85
  end
88
86
  end
@@ -89,14 +89,6 @@ describe SimpleNavigation::Helpers do
89
89
  end
90
90
 
91
91
  context 'primary' do
92
- it "should call render on the primary_navigation" do
93
- @primary_navigation.should_receive(:render)
94
- ActiveSupport::Deprecation.silence {@controller.render_navigation(:primary)}
95
- end
96
- it "should call render on the primary_navigation (specifying level through options)" do
97
- @primary_navigation.should_receive(:render)
98
- ActiveSupport::Deprecation.silence {@controller.render_navigation(:level => :primary)}
99
- end
100
92
  it "should call render on the primary_navigation (specifying level through options)" do
101
93
  @primary_navigation.should_receive(:render).with(:level => 1)
102
94
  @controller.render_navigation(:level => 1)
@@ -111,11 +103,7 @@ describe SimpleNavigation::Helpers do
111
103
  end
112
104
  it "should find the selected sub_navigation for the specified level" do
113
105
  SimpleNavigation.should_receive(:active_item_container_for).with(2)
114
- ActiveSupport::Deprecation.silence {@controller.render_navigation(:secondary)}
115
- end
116
- it "should find the selected sub_navigation for the specified level" do
117
- SimpleNavigation.should_receive(:active_item_container_for).with(2)
118
- ActiveSupport::Deprecation.silence {@controller.render_navigation(:level => :secondary)}
106
+ @controller.render_navigation(:level => 2)
119
107
  end
120
108
  it "should find the selected sub_navigation for the specified level" do
121
109
  SimpleNavigation.should_receive(:active_item_container_for).with(1)
@@ -123,7 +111,7 @@ describe SimpleNavigation::Helpers do
123
111
  end
124
112
  it "should call render on the active item_container" do
125
113
  @selected_item_container.should_receive(:render).with(:level => 2)
126
- ActiveSupport::Deprecation.silence {@controller.render_navigation(:secondary)}
114
+ @controller.render_navigation(:level => 2)
127
115
  end
128
116
  end
129
117
  context 'without an active item_container set' do
@@ -131,47 +119,16 @@ describe SimpleNavigation::Helpers do
131
119
  SimpleNavigation.stub!(:active_item_container_for => nil)
132
120
  end
133
121
  it "should not raise an error" do
134
- lambda{ActiveSupport::Deprecation.silence {@controller.render_navigation(:secondary)}}.should_not raise_error
122
+ lambda {@controller.render_navigation(:level => 2)}.should_not raise_error
135
123
  end
136
124
  end
137
125
 
138
126
  end
139
127
 
140
- context 'nested' do
141
- it "should call render on the primary navigation with the :level => :all option set" do
142
- @primary_navigation.should_receive(:render).with(:level => :all)
143
- ActiveSupport::Deprecation.silence {@controller.render_navigation(:nested)}
144
- end
145
- end
146
-
147
128
  context 'unknown level' do
148
- it "should raise an error" do
149
- lambda {ActiveSupport::Deprecation.silence {@controller.render_navigation(:unknown)}}.should raise_error(ArgumentError)
150
- end
151
129
  it "should raise an error" do
152
130
  lambda {@controller.render_navigation(:level => :unknown)}.should raise_error(ArgumentError)
153
131
  end
154
- it "should raise an error" do
155
- lambda {@controller.render_navigation('level')}.should raise_error(ArgumentError)
156
- end
157
- end
158
- end
159
-
160
- describe 'render_primary_navigation' do
161
- it "should delegate to render_navigation(:level => 1)" do
162
- ActiveSupport::Deprecation.silence do
163
- @controller.should_receive(:render_navigation).with(:level => 1)
164
- @controller.render_primary_navigation
165
- end
166
- end
167
- end
168
-
169
- describe 'render_sub_navigation' do
170
- it "should delegate to render_navigation(:level => 2)" do
171
- ActiveSupport::Deprecation.silence do
172
- @controller.should_receive(:render_navigation).with(:level => 2)
173
- @controller.render_sub_navigation
174
- end
175
132
  end
176
133
  end
177
134
 
@@ -186,11 +143,4 @@ describe SimpleNavigation::Helpers do
186
143
  end
187
144
  end
188
145
 
189
- describe 'option all_open should work as expand_all' do
190
- it "should call render on the primary navigation with the include_subnavigation option set" do
191
- @primary_navigation.should_receive(:render).with(:level => :all, :expand_all => true)
192
- ActiveSupport::Deprecation.silence {@controller.render_navigation(:level => :all, :all_open => true)}
193
- end
194
- end
195
-
196
146
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 3
7
7
  - 0
8
8
  - 0
9
- - beta1
10
- version: 3.0.0.beta1
9
+ - beta2
10
+ version: 3.0.0.beta2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andi Schacke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-01 00:00:00 +02:00
18
+ date: 2010-09-02 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: 2.3.2
47
47
  type: :runtime
48
48
  version_requirements: *id002
49
- description: With the simple-navigation gem installed you can easily create multilevel navigations for your Ruby on Rails applications. The navigation is defined in a single configuration file. It supports automatic as well as explicit highlighting of the currently active navigation.
49
+ description: With the simple-navigation gem installed you can easily create multilevel navigations for your Rails, Sinatra or Padrino applications. The navigation is defined in a single configuration file. It supports automatic as well as explicit highlighting of the currently active navigation through regular expressions.
50
50
  email: andreas.schacke@gmail.com
51
51
  executables: []
52
52
 
@@ -58,7 +58,7 @@ files:
58
58
  - CHANGELOG
59
59
  - README
60
60
  - Rakefile
61
- - VERSION.yml
61
+ - VERSION
62
62
  - generators/navigation_config/USAGE
63
63
  - generators/navigation_config/navigation_config_generator.rb
64
64
  - generators/navigation_config/templates/config/navigation.rb
@@ -130,7 +130,7 @@ rubyforge_project: andi
130
130
  rubygems_version: 1.3.6
131
131
  signing_key:
132
132
  specification_version: 3
133
- summary: Simple Navigation is a ruby library for creating navigations (with multiple levels) for your Ruby on Rails application.
133
+ summary: simple-navigation is a ruby library for creating navigations (with multiple levels) for your Rails2, Rails3, Sinatra or Padrino application.
134
134
  test_files:
135
135
  - spec/lib/simple_navigation/adapters/padrino_spec.rb
136
136
  - spec/lib/simple_navigation/adapters/rails_spec.rb
data/VERSION.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- :major: 3
3
- :minor: 0
4
- :patch: 0