rails-menu-manager 0.2.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4e581b735d3ae2594071364e8a3d4bc9e61ff41b
4
- data.tar.gz: d032d81ae6a24718579a8534f6b841e562f610a3
2
+ SHA256:
3
+ metadata.gz: 1c40996b44142d644d0acde8336e987c0c642bbfcda7033269f18d7db368cb39
4
+ data.tar.gz: 96db0e2948e9a287df8b40c64b468c2d78de94a78d3f7b7a26e54730f491dcd1
5
5
  SHA512:
6
- metadata.gz: 34fb992a4bb146cc75543e4f34c71fb22925e508a5cc4aeadbcb21d13f6b6be54b67a0548efcebd689eb8d4d52e7a413ee6679c910f9279f67a844ef549777e2
7
- data.tar.gz: 48f8d6f2e67b154833a93f1962c3463eb386cc56bca4c2284c73658fe9e0176778fc398b1c60ae0e69485d8904283ad9c4635446c40029428394c73e3ea0cd3b
6
+ metadata.gz: 9bf5c7b24567ee069e0874dbf66f37a674c93da3bd09022a7e1c6cacb370f692120f8dd565c775596b2208c9d680dce607abb977db8a806c6ba3d523e8791dd2
7
+ data.tar.gz: b7c85acb10c0e7a9d58fbc6ffa86563e48cdf66e87f7ddf690b75550e028b818df69b748fb19312726f717ea6515b5528a2c830ce48e0093a4d6c9240c792845
data/.gitignore CHANGED
@@ -1,9 +1,3 @@
1
- /.bundle/
2
- /.yardoc
1
+ /.bundle
3
2
  /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
3
+ /pkg
@@ -0,0 +1,130 @@
1
+ stages:
2
+ - build
3
+ - test
4
+ - codequality
5
+ - security
6
+
7
+ build:
8
+ stage: build
9
+ image: ruby:2.6
10
+ script:
11
+ - gem install bundler --no-document
12
+ - bundle update
13
+ artifacts:
14
+ paths:
15
+ - Gemfile.lock
16
+
17
+ .rspec: &rspec
18
+ stage: test
19
+ before_script:
20
+ - ruby -v
21
+ - echo "${RSPEC_RAILS_VERSION}"
22
+ - gem install bundler -v "~>${BUNDLER_VERSION:-2.0}" --no-document
23
+ - export BUNDLE_GEMFILE="spec/Gemfile"
24
+ - bundle install --jobs=$(nproc) --path="../cache/bundle"
25
+ - bundle list
26
+ script:
27
+ - bundle exec rake spec
28
+ cache:
29
+ key: "$CI_JOB_NAME"
30
+ paths:
31
+ - cache/
32
+
33
+ rspec-ruby2.4-rails4.2:
34
+ <<: *rspec
35
+ image: ruby:2.4
36
+ variables:
37
+ BUNDLER_VERSION: '1.7'
38
+ RSPEC_RAILS_VERSION: '4.2'
39
+
40
+ rspec-ruby2.5-rails4.2:
41
+ <<: *rspec
42
+ image: ruby:2.5
43
+ variables:
44
+ BUNDLER_VERSION: '1.7'
45
+ RSPEC_RAILS_VERSION: '4.2'
46
+
47
+ rspec-ruby2.4-rails5.0:
48
+ <<: *rspec
49
+ image: ruby:2.4
50
+ variables:
51
+ RSPEC_RAILS_VERSION: '5.0'
52
+
53
+ rspec-ruby2.5-rails5.0:
54
+ <<: *rspec
55
+ image: ruby:2.5
56
+ variables:
57
+ RSPEC_RAILS_VERSION: '5.0'
58
+
59
+ rspec-ruby2.6-rails5.0:
60
+ <<: *rspec
61
+ image: ruby:2.6
62
+ variables:
63
+ RSPEC_RAILS_VERSION: '5.0'
64
+
65
+ rspec-ruby2.4-rails5.1:
66
+ <<: *rspec
67
+ image: ruby:2.4
68
+ variables:
69
+ RSPEC_RAILS_VERSION: '5.1'
70
+
71
+ rspec-ruby2.5-rails5.1:
72
+ <<: *rspec
73
+ image: ruby:2.5
74
+ variables:
75
+ RSPEC_RAILS_VERSION: '5.1'
76
+
77
+ rspec-ruby2.6-rails5.1:
78
+ <<: *rspec
79
+ image: ruby:2.6
80
+ variables:
81
+ RSPEC_RAILS_VERSION: '5.1'
82
+
83
+ rspec-ruby2.4-rails5.2:
84
+ <<: *rspec
85
+ image: ruby:2.4
86
+ variables:
87
+ RSPEC_RAILS_VERSION: '5.2'
88
+
89
+ rspec-ruby2.5-rails5.2:
90
+ <<: *rspec
91
+ image: ruby:2.5
92
+ variables:
93
+ RSPEC_RAILS_VERSION: '5.2'
94
+
95
+ rspec-ruby2.6-rails5.2:
96
+ <<: *rspec
97
+ image: ruby:2.6
98
+ variables:
99
+ RSPEC_RAILS_VERSION: '5.2'
100
+
101
+ rspec-ruby2.5-rails6.0:
102
+ <<: *rspec
103
+ image: ruby:2.5
104
+ variables:
105
+ RSPEC_RAILS_VERSION: '6.0'
106
+
107
+ rspec-ruby2.6-rails6.0:
108
+ <<: *rspec
109
+ image: ruby:2.6
110
+ variables:
111
+ RSPEC_RAILS_VERSION: '6.0'
112
+
113
+ rspec-ruby2.5-rails6.1:
114
+ <<: *rspec
115
+ image: ruby:2.5
116
+ variables:
117
+ RSPEC_RAILS_VERSION: '6.1'
118
+
119
+ rspec-ruby2.6-rails6.1:
120
+ <<: *rspec
121
+ image: ruby:2.6
122
+ variables:
123
+ RSPEC_RAILS_VERSION: '6.1'
124
+
125
+ rubocop:
126
+ stage: codequality
127
+ image: ruby:2.6
128
+ script:
129
+ - gem install rubocop rubocop-performance --no-document
130
+ - rubocop
@@ -0,0 +1,16 @@
1
+ require:
2
+ - rubocop-performance
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.4
6
+
7
+ Layout/HashAlignment:
8
+ EnforcedHashRocketStyle: table
9
+ EnforcedColonStyle: table
10
+
11
+ Metrics/LineLength:
12
+ Max: 120
13
+
14
+ Naming/FileName:
15
+ Exclude:
16
+ - 'lib/rails-menu-manager.rb'
@@ -1,7 +1,54 @@
1
- # Change Log
1
+ # Changelog
2
2
 
3
- ## 0.2.0 (2015-04-20) (initial release)
4
- ### Changes
5
- - Renamed namespace from Rails::Menu::Manager to RailsMenuManager
3
+ All notable changes to this project will be documented in this file.
6
4
 
7
- ## 0.1.0 (2015-04-20) (initial release)
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.5.0] - 2020-12-12
11
+
12
+ ### Added
13
+
14
+ - support for Rails 6.1
15
+
16
+ ## [0.4.1] - 2019-11-06
17
+
18
+ ### Changed
19
+
20
+ - set supported ruby versions to >= 2.4.0
21
+
22
+ ### Fixed
23
+
24
+ - support for Rails 6.0.X
25
+
26
+ ## [0.4.0] - 2019-08-22
27
+
28
+ ### Added
29
+
30
+ - support for Rails 6.0
31
+
32
+ ### Removed
33
+
34
+ - support for Rails 4.0 and 4.1
35
+
36
+ ## [0.3.1] - 2016-09-26
37
+
38
+ ### Fixed
39
+
40
+ - prevent menu items from being highlighted which have the same last path element as other menu items
41
+
42
+ ## [0.3.0] - 2016-07-07
43
+
44
+ ### Changed
45
+
46
+ - rails 5.0 support
47
+
48
+ ## [0.2.0] - 2015-04-20
49
+
50
+ ### Changed
51
+
52
+ - renamed namespace from Rails::Menu::Manager to RailsMenuManager
53
+
54
+ ## [0.1.0] - 2015-04-20
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in rails-menu-manager.gemspec
data/README.md CHANGED
@@ -1,8 +1,3 @@
1
- [![Gem Version](https://img.shields.io/gem/v/rails-menu-manager.svg)](https://rubygems.org/gems/rails-menu-manager)
2
- [![Dependencies](https://img.shields.io/gemnasium/ydkn/rails-menu-manager.svg)](https://gemnasium.com/ydkn/rails-menu-manager)
3
- [![Travis CI](https://img.shields.io/travis/ydkn/rails-menu-manager.svg)](https://travis-ci.org/ydkn/rails-menu-manager)
4
- [![Code Climate](https://img.shields.io/codeclimate/github/ydkn/rails-menu-manager.svg)](https://codeclimate.com/github/ydkn/rails-menu-manager)
5
-
6
1
  # Rails Menu Manager
7
2
 
8
3
  Simple menu manager for Rails.
@@ -47,11 +42,3 @@ link_to 'users', users_path, class: in_menu?(:main, :users) ? 'active' : nil
47
42
 
48
43
  link_to 'users', users_path, class: in_menu?(:sidebar, :users) ? 'active' : nil
49
44
  ```
50
-
51
- ## Contributing
52
-
53
- 1. Fork it ( https://github.com/ydkn/rails-menu-manager/fork )
54
- 2. Create your feature branch (`git checkout -b my-new-feature`)
55
- 3. Commit your changes (`git commit -am 'Add some feature'`)
56
- 4. Push to the branch (`git push origin my-new-feature`)
57
- 5. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
5
  require 'rspec/core/rake_task'
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails_menu_manager/version'
2
4
  require 'rails_menu_manager/railtie'
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/concern'
2
4
  require 'rails_menu_manager/menu_item'
3
5
 
4
6
  module RailsMenuManager
7
+ # Menu methods for ActionController
5
8
  module ActionController
6
9
  extend ActiveSupport::Concern
7
10
 
@@ -14,11 +17,7 @@ module RailsMenuManager
14
17
  # @param [Array] Menu path to check
15
18
  # @return [Boolean] Boolean indicating if at least one menu item is in path
16
19
  def in_menu?(*args)
17
- _menu_items.each do |menu|
18
- return true if menu.in?(*args)
19
- end
20
-
21
- false
20
+ rails_menu_manger_items.any? { |m| m.in?(*args) }
22
21
  end
23
22
 
24
23
  # Adds a menu
@@ -26,23 +25,24 @@ module RailsMenuManager
26
25
  #
27
26
  # @param [Array/Hash] Menu path and options.
28
27
  def menu(*args)
29
- _add_menu_setting(*args)
28
+ rails_menu_manger_add_menu_setting(*args)
30
29
  end
31
30
 
32
31
  private
33
32
 
34
- def _menu_items
35
- @_menu_items ||= []
33
+ def rails_menu_manger_items
34
+ @rails_menu_manger_items ||= []
36
35
  end
37
36
 
38
- def _add_menu_setting(*args)
37
+ def rails_menu_manger_add_menu_setting(*args)
39
38
  opts = args.extract_options!
40
39
 
41
- path = args.map { |p| p.to_sym }
40
+ path = args.map(&:to_sym)
42
41
 
43
- _menu_items << MenuItem.new(path, opts)
42
+ rails_menu_manger_items << MenuItem.new(path, opts)
44
43
  end
45
44
 
45
+ # Class methods for ActionController
46
46
  module ClassMethods
47
47
  def menu(*args)
48
48
  opts = args.extract_options!
@@ -55,7 +55,7 @@ module RailsMenuManager
55
55
  }
56
56
 
57
57
  before_action before_action_opts do
58
- _add_menu_setting(*args, opts)
58
+ rails_menu_manger_add_menu_setting(*args, opts)
59
59
  end
60
60
  end
61
61
  end
@@ -1,17 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsMenuManager
4
+ # Representation of a single menu item
2
5
  class MenuItem
6
+ PATH_SEPARATOR = 0x1F.chr
7
+
3
8
  attr_reader :path, :options
4
9
 
5
10
  def initialize(path, options = {})
6
- @path = path
7
- @path_str = path.join('#')
8
- @options = options
11
+ @path = path
12
+ @options = options
9
13
  end
10
14
 
11
15
  def in?(*args)
12
16
  return false if path.nil?
13
17
 
14
- !!(@path_str =~ /\A#{args.join('#')}/i)
18
+ (path_as_string(path) =~ /\A#{path_as_string(args)}/i)
19
+ end
20
+
21
+ private
22
+
23
+ def path_as_string(path)
24
+ path.join(PATH_SEPARATOR) + PATH_SEPARATOR
15
25
  end
16
26
  end
17
27
  end
@@ -1,10 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/railtie'
2
4
  require 'rails_menu_manager/action_controller'
3
5
 
4
6
  module RailsMenuManager
7
+ # Railtie which will register and set up the menu manager
5
8
  class Railtie < Rails::Railtie
6
9
  initializer 'rails-menu-manager' do
7
- ::ActionController::Base.send(:include, RailsMenuManager::ActionController)
10
+ ::ActionController::Base.include(RailsMenuManager::ActionController)
8
11
  end
9
12
  end
10
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsMenuManager
2
- VERSION = '0.2.0'
4
+ VERSION = '0.5.0'
3
5
  end
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'rails_menu_manager/version'
5
6
 
@@ -8,20 +9,23 @@ Gem::Specification.new do |spec|
8
9
  spec.version = RailsMenuManager::VERSION
9
10
  spec.authors = ['Florian Schwab']
10
11
  spec.email = ['me@ydkn.de']
11
-
12
- spec.summary = %q{Simple menu manager for Rails.}
13
- spec.description = %q{Simple menu manager for Rails.}
14
- spec.homepage = 'https://github.com/ydkn/rails-menu-manager'
12
+ spec.summary = 'Simple menu manager for Rails.'
13
+ spec.description = 'Simple menu manager for Rails.'
14
+ spec.homepage = 'https://gitlab.com/ydkn/rails-menu-manager'
15
+ spec.license = 'MIT'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
18
  spec.bindir = 'bin'
18
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
20
  spec.require_paths = ['lib']
20
21
 
21
- spec.add_dependency 'railties', '>= 4.0', '< 5.0'
22
+ spec.required_ruby_version = '>= 2.4.0'
23
+
24
+ spec.add_dependency 'railties', '>= 4.2', '< 6.2'
22
25
 
23
- spec.add_development_dependency 'bundler', '~> 1.9'
24
- spec.add_development_dependency 'rake', '~> 10.0'
25
- spec.add_development_dependency 'rspec', '~> 3.2'
26
- spec.add_development_dependency 'yard', '~> 0.8'
26
+ spec.add_development_dependency 'bundler'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rspec'
29
+ spec.add_development_dependency 'rubocop'
30
+ spec.add_development_dependency 'rubocop-performance'
27
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-menu-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Schwab
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-22 00:00:00.000000000 Z
11
+ date: 2020-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -16,76 +16,90 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.0'
22
+ version: '6.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '4.0'
29
+ version: '4.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.0'
32
+ version: '6.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '1.9'
39
+ version: '0'
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '1.9'
46
+ version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '10.0'
53
+ version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '10.0'
60
+ version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
66
80
  - !ruby/object:Gem::Version
67
- version: '3.2'
81
+ version: '0'
68
82
  type: :development
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
- - - "~>"
86
+ - - ">="
73
87
  - !ruby/object:Gem::Version
74
- version: '3.2'
88
+ version: '0'
75
89
  - !ruby/object:Gem::Dependency
76
- name: yard
90
+ name: rubocop-performance
77
91
  requirement: !ruby/object:Gem::Requirement
78
92
  requirements:
79
- - - "~>"
93
+ - - ">="
80
94
  - !ruby/object:Gem::Version
81
- version: '0.8'
95
+ version: '0'
82
96
  type: :development
83
97
  prerelease: false
84
98
  version_requirements: !ruby/object:Gem::Requirement
85
99
  requirements:
86
- - - "~>"
100
+ - - ">="
87
101
  - !ruby/object:Gem::Version
88
- version: '0.8'
102
+ version: '0'
89
103
  description: Simple menu manager for Rails.
90
104
  email:
91
105
  - me@ydkn.de
@@ -94,26 +108,25 @@ extensions: []
94
108
  extra_rdoc_files: []
95
109
  files:
96
110
  - ".gitignore"
111
+ - ".gitlab-ci.yml"
97
112
  - ".rspec"
98
- - ".travis.yml"
113
+ - ".rubocop.yml"
99
114
  - CHANGELOG.md
100
115
  - Gemfile
101
116
  - LICENSE.txt
102
117
  - README.md
103
118
  - Rakefile
104
- - gemfiles/rails40
105
- - gemfiles/rails41
106
- - gemfiles/rails42
107
119
  - lib/rails-menu-manager.rb
108
120
  - lib/rails_menu_manager/action_controller.rb
109
121
  - lib/rails_menu_manager/menu_item.rb
110
122
  - lib/rails_menu_manager/railtie.rb
111
123
  - lib/rails_menu_manager/version.rb
112
124
  - rails-menu-manager.gemspec
113
- homepage: https://github.com/ydkn/rails-menu-manager
114
- licenses: []
125
+ homepage: https://gitlab.com/ydkn/rails-menu-manager
126
+ licenses:
127
+ - MIT
115
128
  metadata: {}
116
- post_install_message:
129
+ post_install_message:
117
130
  rdoc_options: []
118
131
  require_paths:
119
132
  - lib
@@ -121,17 +134,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
134
  requirements:
122
135
  - - ">="
123
136
  - !ruby/object:Gem::Version
124
- version: '0'
137
+ version: 2.4.0
125
138
  required_rubygems_version: !ruby/object:Gem::Requirement
126
139
  requirements:
127
140
  - - ">="
128
141
  - !ruby/object:Gem::Version
129
142
  version: '0'
130
143
  requirements: []
131
- rubyforge_project:
132
- rubygems_version: 2.4.6
133
- signing_key:
144
+ rubygems_version: 3.1.4
145
+ signing_key:
134
146
  specification_version: 4
135
147
  summary: Simple menu manager for Rails.
136
148
  test_files: []
137
- has_rdoc:
@@ -1,15 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.1.5
5
- - 2.2.2
6
-
7
- gemfile:
8
- - gemfiles/rails40
9
- - gemfiles/rails41
10
- - gemfiles/rails42
11
-
12
- script: bundle exec rake spec
13
-
14
- before_install:
15
- - gem install bundler -v '~> 1.9'
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rails-menu-manager.gemspec
4
- gemspec path: '..'
5
-
6
-
7
- gem 'railties', '~> 4.0'
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rails-menu-manager.gemspec
4
- gemspec path: '..'
5
-
6
-
7
- gem 'railties', '~> 4.1'
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in rails-menu-manager.gemspec
4
- gemspec path: '..'
5
-
6
-
7
- gem 'railties', '~> 4.2'