simple-navigation 4.1.0 → 4.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 80fdb7f2e02862d983ad05c0fdfc0abba3e702e8
4
- data.tar.gz: 8b61d65bd217b32bea405141a7e5f5e212d79159
2
+ SHA256:
3
+ metadata.gz: 66e6c73b8c96a17a4730125ae741fc1f11f3c9495578cafdb2795223a251614c
4
+ data.tar.gz: 2b7e406ee541892f12e459eb2218a382f4f3ac26b89f11c382dfa92424146312
5
5
  SHA512:
6
- metadata.gz: 8171a0a34b62e9ca31f1c1d7fb6ab9ca838be0d566243cd0d11c106797d8279f2e53aeb634eeae79b01e9007da24b47bb706a776580ec010859bc9b74751d0e5
7
- data.tar.gz: 9cff271a844731db1151e6031dac06351d8592b3038327e92e0f7b245045f523974c741f9dd33332baeeb492cea9d474fd29f54fe6318517596d02222d5115fc
6
+ metadata.gz: 252b910e666cd652c25bc42823c3366d4d7f88b541684d6123b4644bcb121657ea22b59415c8333ffa0e69eff6586f2bee75c754426899ab4b8895f9e66a2814
7
+ data.tar.gz: c4b8fa52310cda2c367e24e88c0366d49d6cbfff41443be5c50092445a80fe14f27f014df47e08e19b4c75cf8d55d55678e606df9a7f2866feb7ea6d1f2e7859
data/.travis.yml CHANGED
@@ -3,6 +3,12 @@ before_install:
3
3
 
4
4
  matrix:
5
5
  include:
6
+ - rvm: 2.5.8
7
+ gemfile: gemfiles/rails-6-1-stable.gemfile
8
+ - rvm: 2.6.7
9
+ gemfile: gemfiles/rails-6-1-stable.gemfile
10
+ - rvm: 2.7.3
11
+ gemfile: gemfiles/rails-6-1-stable.gemfile
6
12
  - rvm: 2.5.3
7
13
  gemfile: gemfiles/rails-6-0-stable.gemfile
8
14
  - rvm: 2.6.0
@@ -15,4 +21,3 @@ matrix:
15
21
  gemfile: gemfiles/rails-4-1-stable.gemfile
16
22
  - rvm: 2.3.3
17
23
  gemfile: gemfiles/rails-3-2-stable.gemfile
18
-
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.4.0
4
+
5
+ * add options rendering to json renderer. Credits to Mikhail Kytyzov.
6
+
7
+ ## 4.3.0
8
+
9
+ * removed warnings from rspec. Thanks mgrunberg.
10
+ * add compatibility with rails 6.1. Credits to mgrunberg.
11
+ * run specs against 6.1. Credits to mgrunberg.
12
+
13
+ ## 4.2.0
14
+
15
+ * improvements to generator template. Credits to mgrunberg.
16
+ * be able to run 'rake spec:rails-6-0-stable'. Credits to mgrunberg.
17
+
3
18
  ## 4.1.0
4
19
 
5
20
  * Delay rails6 initialization using on_load (getting rid of deprecation warnings in rails 6). Credits to Markus Benning.
data/README.md CHANGED
@@ -60,4 +60,4 @@ In this situation `/Users/username/.rubies/ruby-2.2.3/bin/rake` is the command y
60
60
 
61
61
  ## License
62
62
 
63
- Copyright (c) 2019 codeplant GmbH, released under the MIT license
63
+ Copyright (c) 2022 codeplant GmbH, released under the MIT license
data/Rakefile CHANGED
@@ -16,6 +16,8 @@ namespace :spec do
16
16
  rails-4-1-stable
17
17
  rails-4-2-stable
18
18
  rails-5-2-stable
19
+ rails-6-0-stable
20
+ rails-6-1-stable
19
21
  ]
20
22
 
21
23
  mappers.each do |gemfile|
@@ -3,8 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'rake', '< 11.0'
4
4
 
5
5
  # not yet
6
- #gem 'railties', '~> 6.0.0'
7
- gem 'railties', '6.0.0.rc2'
6
+ gem 'railties', '~> 6.0.0'
8
7
  gem 'rspec-rails', '~> 3.8.2'
9
8
 
10
9
  gemspec path: '../'
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake', '< 11.0'
4
+
5
+ # not yet
6
+ gem 'railties', '~> 6.1.0'
7
+ gem 'rspec-rails', '~> 3.8.2'
8
+
9
+ gemspec path: '../'
@@ -24,7 +24,7 @@ SimpleNavigation::Configuration.run do |navigation|
24
24
  # If you need to add custom html around item names, you can define a proc that
25
25
  # will be called with the name you pass in to the navigation.
26
26
  # The example below shows how to wrap items spans.
27
- #navigation.name_generator = Proc.new {|name, item| "<span>#{name}</span>"}
27
+ #navigation.name_generator = Proc.new {|name, item| tag.span(name) }
28
28
 
29
29
  # Specify if the auto highlight feature is turned on (globally, for the whole navigation). Defaults to true
30
30
  #navigation.auto_highlight = true
@@ -45,6 +45,7 @@ SimpleNavigation::Configuration.run do |navigation|
45
45
  # url - the address that the generated item links to. You can also use url_helpers (named routes, restful routes helper, url_for etc.)
46
46
  # options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.)
47
47
  # some special options that can be set:
48
+ # :html - Specifies html attributes that will be included in the rendered navigation item
48
49
  # :if - Specifies a proc to call to determine if the item should
49
50
  # be rendered (e.g. <tt>if: -> { current_user.admin? }</tt>). The
50
51
  # proc should evaluate to a true or false value and is evaluated in the context of the view.
@@ -67,7 +68,7 @@ SimpleNavigation::Configuration.run do |navigation|
67
68
  # You can also specify a condition-proc that needs to be fullfilled to display an item.
68
69
  # Conditions are part of the options. They are evaluated in the context of the views,
69
70
  # thus you can use all the methods and vars you have available in the views.
70
- primary.item :key_3, 'Admin', url, class: 'special', if: -> { current_user.admin? }
71
+ primary.item :key_3, 'Admin', url, html: { class: 'special' }, if: -> { current_user.admin? }
71
72
  primary.item :key_4, 'Account', url, unless: -> { logged_in? }
72
73
 
73
74
  # you can also specify html attributes to attach to this particular level
@@ -5,7 +5,8 @@ module SimpleNavigation
5
5
  attr_reader :key,
6
6
  :name,
7
7
  :sub_navigation,
8
- :url
8
+ :url,
9
+ :options
9
10
 
10
11
  # see ItemContainer#item
11
12
  #
@@ -121,13 +122,13 @@ module SimpleNavigation
121
122
 
122
123
  private
123
124
 
124
- attr_accessor :container,
125
- :options
125
+ attr_accessor :container
126
126
 
127
127
  attr_writer :key,
128
128
  :name,
129
129
  :sub_navigation,
130
- :url
130
+ :url,
131
+ :options
131
132
 
132
133
  def config
133
134
  SimpleNavigation.config
@@ -20,7 +20,8 @@ module SimpleNavigation
20
20
  items: hash_render(item.sub_navigation),
21
21
  name: item.name,
22
22
  selected: item.selected?,
23
- url: item.url
23
+ url: item.url,
24
+ options: item.options
24
25
  }
25
26
  end
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleNavigation
2
- VERSION = '4.1.0'
2
+ VERSION = '4.4.0'
3
3
  end
@@ -186,7 +186,7 @@ module SimpleNavigation
186
186
  before { adapter.instance_variable_set(:@template, nil) }
187
187
 
188
188
  it 'raises an exception' do
189
- expect{ adapter.context_for_eval }.to raise_error
189
+ expect{ adapter.context_for_eval }.to raise_error(RuntimeError, 'no context set for evaluation the config file')
190
190
  end
191
191
  end
192
192
  end
@@ -9,7 +9,7 @@ describe SimpleNavigation::Adapters::Sinatra do
9
9
  context "when adapter's context is not set" do
10
10
  it 'raises an exception' do
11
11
  allow(adapter).to receive_messages(context: nil)
12
- expect{ adapter.context_for_eval }.to raise_error
12
+ expect{ adapter.context_for_eval }.to raise_error(RuntimeError, 'no context set for evaluation the config file')
13
13
  end
14
14
  end
15
15
 
@@ -23,7 +23,7 @@ module SimpleNavigation
23
23
 
24
24
  context 'and no navigation.rb file is found in the paths' do
25
25
  it 'raises an exception' do
26
- expect{ finder.find(context) }.to raise_error
26
+ expect { finder.find(context) }.to raise_error(RuntimeError, /Config file 'navigation.rb' not found in path\(s\)/)
27
27
  end
28
28
  end
29
29
  end
@@ -41,7 +41,7 @@ module SimpleNavigation
41
41
 
42
42
  context 'and no other_navigation.rb file is found in the paths' do
43
43
  it 'raise an exception' do
44
- expect{ finder.find(context) }.to raise_error
44
+ expect{ finder.find(context) }.to raise_error(RuntimeError, /Config file 'other_navigation.rb' not found in path\(s\)/)
45
45
  end
46
46
  end
47
47
  end
@@ -89,7 +89,7 @@ module SimpleNavigation
89
89
  let(:provider) { double(:provider) }
90
90
 
91
91
  it 'raises an exception' do
92
- expect{ config.items(provider) {} }.to raise_error
92
+ expect{ config.items(provider) {} }.to raise_error(RuntimeError, 'please specify either items_provider or block, but not both')
93
93
  end
94
94
  end
95
95
 
@@ -139,7 +139,7 @@ module SimpleNavigation
139
139
 
140
140
  context 'when items_provider is not specified' do
141
141
  it "raises an exception" do
142
- expect{ config.items }.to raise_error
142
+ expect{ config.items }.to raise_error(RuntimeError, 'please specify either items_provider or block, but not both')
143
143
  end
144
144
  end
145
145
  end
@@ -382,7 +382,7 @@ module SimpleNavigation
382
382
  it 'raises an exception' do
383
383
  expect{
384
384
  controller.render_navigation(level: :invalid)
385
- }.to raise_error
385
+ }.to raise_error(ArgumentError, 'Invalid navigation level: invalid')
386
386
  end
387
387
  end
388
388
  end
@@ -408,7 +408,7 @@ module SimpleNavigation
408
408
  before { allow(SimpleNavigation).to receive_messages(primary_navigation: nil) }
409
409
 
410
410
  it 'raises an exception' do
411
- expect{controller.render_navigation}.to raise_error
411
+ expect{controller.render_navigation}.to raise_error(RuntimeError, 'no primary navigation defined, either use a navigation config file or pass items directly to render_navigation')
412
412
  end
413
413
  end
414
414
 
@@ -435,7 +435,7 @@ module SimpleNavigation
435
435
  it 'raises an error' do
436
436
  expect{
437
437
  item_container.item('key', 'name', 'url', { if: 'text' })
438
- }.to raise_error
438
+ }.to raise_error(ArgumentError, ':if or :unless must be procs or lambdas')
439
439
  end
440
440
  end
441
441
  end
@@ -346,7 +346,7 @@ module SimpleNavigation
346
346
  let(:options) {{ highlights_on: :hello }}
347
347
 
348
348
  it 'raises an exception' do
349
- expect{ item.selected? }.to raise_error
349
+ expect{ item.selected? }.to raise_error(ArgumentError, ':highlights_on must be a Regexp, Proc or :subpath')
350
350
  end
351
351
  end
352
352
  end
@@ -36,7 +36,7 @@ module SimpleNavigation
36
36
  let(:provider) { double(:provider) }
37
37
 
38
38
  it 'raises an exception' do
39
- expect{ items_provider.items }.to raise_error
39
+ expect{ items_provider.items }.to raise_error(RuntimeError, /items_provider either must be a symbol .*, an object .* or an enumerable/)
40
40
  end
41
41
  end
42
42
  end
@@ -32,7 +32,7 @@ module SimpleNavigation
32
32
 
33
33
  describe '#render' do
34
34
  it "raise an exception to indicate it's a subclass responsibility" do
35
- expect{ base.render(:container) }.to raise_error
35
+ expect{ base.render(:container) }.to raise_error(NotImplementedError, 'subclass responsibility')
36
36
  end
37
37
  end
38
38
 
@@ -20,12 +20,15 @@ module SimpleNavigation
20
20
  end
21
21
  end
22
22
 
23
- # FIXME: not sure if :as_hash returning an array makes sense...
24
23
  context 'when the :as_hash option is true' do
25
24
  let(:options) {{ level: :all, as_hash: true }}
26
25
 
27
- it 'returns a hash' do
26
+ it 'returns every item as a hash' do
28
27
  expect(output).to be_an Array
28
+
29
+ output.each do |item|
30
+ expect(item).to be_an Hash
31
+ end
29
32
  end
30
33
 
31
34
  it 'renders the selected page' do
@@ -34,6 +37,14 @@ module SimpleNavigation
34
37
  end
35
38
  end
36
39
 
40
+ context 'with options' do
41
+ it 'should render options for each item' do
42
+ parsed_output.each do |item|
43
+ expect(item).to have_key('options')
44
+ end
45
+ end
46
+ end
47
+
37
48
  context 'when a sub navigation item is selected' do
38
49
  let(:invoices_item) do
39
50
  parsed_output.find { |item| item['name'] == 'Invoices' }
@@ -104,7 +104,7 @@ describe SimpleNavigation do
104
104
 
105
105
  context "when the config file for the context doesn't exists" do
106
106
  it 'raises an exception' do
107
- expect{ subject.load_config }.to raise_error
107
+ expect{ subject.load_config }.to raise_error(RuntimeError, /Config file 'navigation.rb' not found in path\(s\)/)
108
108
  end
109
109
  end
110
110
  end
@@ -152,7 +152,7 @@ describe SimpleNavigation do
152
152
  it 'raises an exception' do
153
153
  expect{
154
154
  subject.active_item_container_for('something else')
155
- }.to raise_error
155
+ }.to raise_error(ArgumentError, 'Invalid navigation level: something else')
156
156
  end
157
157
  end
158
158
  end
data/spec/spec_helper.rb CHANGED
@@ -24,7 +24,10 @@ end
24
24
 
25
25
  def setup_adapter_for(framework, context = double(:context))
26
26
  if framework == :rails
27
- allow(context).to receive_messages(view_context: ActionView::Base.new)
27
+ # Rails 6.0 and 6.1 provide ActionView::Base.empty method that creates ActionView with an empty LookupContext.
28
+ # The method is not available on older versions
29
+ view_context = ActionView::Base.respond_to?(:empty) ? ActionView::Base.empty : ActionView::Base.new
30
+ allow(context).to receive_messages(view_context: view_context)
28
31
  end
29
32
 
30
33
  allow(SimpleNavigation).to receive_messages(framework: framework)
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-navigation
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andi Schacke
8
8
  - Mark J. Titorenko
9
9
  - Simon Courtois
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-17 00:00:00.000000000 Z
13
+ date: 2022-05-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -177,6 +177,7 @@ files:
177
177
  - gemfiles/rails-4-2-stable.gemfile
178
178
  - gemfiles/rails-5-2-stable.gemfile
179
179
  - gemfiles/rails-6-0-stable.gemfile
180
+ - gemfiles/rails-6-1-stable.gemfile
180
181
  - generators/navigation_config/USAGE
181
182
  - generators/navigation_config/navigation_config_generator.rb
182
183
  - generators/navigation_config/templates/config/navigation.rb
@@ -241,7 +242,7 @@ homepage: http://github.com/codeplant/simple-navigation
241
242
  licenses:
242
243
  - MIT
243
244
  metadata: {}
244
- post_install_message:
245
+ post_install_message:
245
246
  rdoc_options:
246
247
  - "--inline-source"
247
248
  - "--charset=UTF-8"
@@ -258,9 +259,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
259
  - !ruby/object:Gem::Version
259
260
  version: '0'
260
261
  requirements: []
261
- rubyforge_project:
262
- rubygems_version: 2.6.14
263
- signing_key:
262
+ rubygems_version: 3.2.3
263
+ signing_key:
264
264
  specification_version: 4
265
265
  summary: simple-navigation is a ruby library for creating navigations (with multiple
266
266
  levels) for your Rails, Sinatra or Padrino application.