rails-menu-manager 0.3.1 → 0.4.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: b21bf6c2eedd8d5e888b0c0d5189dbd281099b07
4
- data.tar.gz: 844d88a9f6569104fd0c73765c105b8f212beb97
2
+ SHA256:
3
+ metadata.gz: 32ba8c074a0917f592047bf6d51fbb8e42b7580292a4ab85e4793de279cd00a8
4
+ data.tar.gz: d7c7aafc1f8ae8f59352d846347f2f6f00c3c43f92799550dc6f56fc6b72a9d7
5
5
  SHA512:
6
- metadata.gz: a4f26b5100435b389ebf6850848d3477c8ec7a218d0d0e26b7efebae7b07a2b699dee2cb4d47ba617aaab3a2b0c5420a32f18798d888edb789cc8f7a84cebf80
7
- data.tar.gz: 65eed75f15bbdea85c4362dbe36249385720a3f925596ec5f007b8cfbc27ecefdf9206f1a79112aaf8b197b53dd4dda86adf9bbb1cea9e32a06c32eea4d1ab44
6
+ metadata.gz: 4cd5efd614a28e8fc3d4a2220004586f771ab619af4c2be9c639f53f9530fac2535cf8eab0e406c8030977d34b96f502c0497f9c8380289da075190e211824d5
7
+ data.tar.gz: f2671172290ddcd6c966255acd13f6d266f62700dbcfdd1efb19439d7944fd04a739d08ae9718b402afab202a0b7e415a2ca158316c174dd75f1ff1c6c2436f5
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,139 @@
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
+ rubocop:
114
+ stage: codequality
115
+ image: ruby:2.6
116
+ script:
117
+ - gem install rubocop rubocop-performance --no-document
118
+ - rubocop
119
+
120
+ dependency_scanning:
121
+ stage: security
122
+ dependencies:
123
+ - build
124
+ image: docker:stable
125
+ variables:
126
+ DOCKER_DRIVER: overlay2
127
+ allow_failure: true
128
+ services:
129
+ - docker:stable-dind
130
+ script:
131
+ - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
132
+ - docker run
133
+ --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
134
+ --volume "$PWD:/code"
135
+ --volume /var/run/docker.sock:/var/run/docker.sock
136
+ "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
137
+ artifacts:
138
+ paths:
139
+ - gl-dependency-scanning-report.json
@@ -0,0 +1,16 @@
1
+ require:
2
+ - rubocop-performance
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.4
6
+
7
+ Layout/AlignHash:
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,15 +1,27 @@
1
- # Change Log
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
2
3
 
3
- ## 0.3.1 (2016-09-26)
4
- ### Fixes
5
- - Prevent menu items from being highlighted which have the same last path element as other menu items
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## 0.3.0 (2016-07-07)
8
- ### Changes
9
- - Rails 5.0 support
7
+ ## [Unreleased]
10
8
 
11
- ## 0.2.0 (2015-04-20) (initial release)
12
- ### Changes
13
- - Renamed namespace from Rails::Menu::Manager to RailsMenuManager
9
+ ## [0.4.0] - 2019-08-22
10
+ ### Added
11
+ - support for Rails 6.0
12
+ ### Removed
13
+ - support for Rails 4.0 and 4.1
14
14
 
15
- ## 0.1.0 (2015-04-20) (initial release)
15
+ ## [0.3.1] - 2016-09-26
16
+ ### Fixed
17
+ - prevent menu items from being highlighted which have the same last path element as other menu items
18
+
19
+ ## [0.3.0] - 2016-07-07
20
+ ### Changed
21
+ - rails 5.0 support
22
+
23
+ ## [0.2.0] - 2015-04-20
24
+ ### Changed
25
+ - renamed namespace from Rails::Menu::Manager to RailsMenuManager
26
+
27
+ ## [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,7 +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.any? { |m| m.in?(*args) }
20
+ rails_menu_manger_items.any? { |m| m.in?(*args) }
18
21
  end
19
22
 
20
23
  # Adds a menu
@@ -22,23 +25,24 @@ module RailsMenuManager
22
25
  #
23
26
  # @param [Array/Hash] Menu path and options.
24
27
  def menu(*args)
25
- _add_menu_setting(*args)
28
+ rails_menu_manger_add_menu_setting(*args)
26
29
  end
27
30
 
28
31
  private
29
32
 
30
- def _menu_items
31
- @_menu_items ||= []
33
+ def rails_menu_manger_items
34
+ @rails_menu_manger_items ||= []
32
35
  end
33
36
 
34
- def _add_menu_setting(*args)
37
+ def rails_menu_manger_add_menu_setting(*args)
35
38
  opts = args.extract_options!
36
39
 
37
- path = args.map { |p| p.to_sym }
40
+ path = args.map(&:to_sym)
38
41
 
39
- _menu_items << MenuItem.new(path, opts)
42
+ rails_menu_manger_items << MenuItem.new(path, opts)
40
43
  end
41
44
 
45
+ # Class methods for ActionController
42
46
  module ClassMethods
43
47
  def menu(*args)
44
48
  opts = args.extract_options!
@@ -51,7 +55,7 @@ module RailsMenuManager
51
55
  }
52
56
 
53
57
  before_action before_action_opts do
54
- _add_menu_setting(*args, opts)
58
+ rails_menu_manger_add_menu_setting(*args, opts)
55
59
  end
56
60
  end
57
61
  end
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsMenuManager
4
+ # Representation of a single menu item
2
5
  class MenuItem
3
6
  PATH_SEPARATOR = 0x1F.chr
4
7
 
@@ -12,7 +15,7 @@ module RailsMenuManager
12
15
  def in?(*args)
13
16
  return false if path.nil?
14
17
 
15
- !!(path_as_string(path) =~ /\A#{path_as_string(args)}/i)
18
+ (path_as_string(path) =~ /\A#{path_as_string(args)}/i)
16
19
  end
17
20
 
18
21
  private
@@ -1,7 +1,10 @@
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
10
  ::ActionController::Base.send(:include, RailsMenuManager::ActionController)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsMenuManager
2
- VERSION = '0.3.1'
4
+ VERSION = '0.4.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,10 +9,9 @@ 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
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -19,10 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency 'railties', '>= 4.0', '< 6.0'
22
+ spec.add_dependency 'railties', '>= 4.2', '<= 6.0'
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.9'
25
- spec.add_development_dependency 'rake', '~> 10.0'
26
- spec.add_development_dependency 'rspec', '~> 3.2'
27
- spec.add_development_dependency 'yard', '~> 0.8'
24
+ spec.add_development_dependency 'bundler'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'rubocop-performance'
28
29
  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.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Schwab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-26 00:00:00.000000000 Z
11
+ date: 2019-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -16,8 +16,8 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
20
- - - "<"
19
+ version: '4.2'
20
+ - - "<="
21
21
  - !ruby/object:Gem::Version
22
22
  version: '6.0'
23
23
  type: :runtime
@@ -26,66 +26,80 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '4.0'
30
- - - "<"
29
+ version: '4.2'
30
+ - - "<="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '6.0'
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
66
  - !ruby/object:Gem::Version
67
- version: '3.2'
67
+ version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '3.2'
74
+ version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: yard
76
+ name: rubocop
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '0.8'
81
+ version: '0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop-performance
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
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,24 +108,21 @@ 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
- - gemfiles/rails50
108
119
  - lib/rails-menu-manager.rb
109
120
  - lib/rails_menu_manager/action_controller.rb
110
121
  - lib/rails_menu_manager/menu_item.rb
111
122
  - lib/rails_menu_manager/railtie.rb
112
123
  - lib/rails_menu_manager/version.rb
113
124
  - rails-menu-manager.gemspec
114
- homepage: https://github.com/ydkn/rails-menu-manager
125
+ homepage: https://gitlab.com/ydkn/rails-menu-manager
115
126
  licenses:
116
127
  - MIT
117
128
  metadata: {}
@@ -130,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
141
  - !ruby/object:Gem::Version
131
142
  version: '0'
132
143
  requirements: []
133
- rubyforge_project:
134
- rubygems_version: 2.5.1
144
+ rubygems_version: 3.0.3
135
145
  signing_key:
136
146
  specification_version: 4
137
147
  summary: Simple menu manager for Rails.
@@ -1,18 +0,0 @@
1
- sudo: false
2
-
3
- language: ruby
4
-
5
- rvm:
6
- - 2.2.5
7
- - 2.3.1
8
-
9
- gemfile:
10
- - gemfiles/rails40
11
- - gemfiles/rails41
12
- - gemfiles/rails42
13
- - gemfiles/rails50
14
-
15
- script: bundle exec rake spec
16
-
17
- before_install:
18
- - gem install bundler -v '~> 1.12'
@@ -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'
@@ -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', '~> 5.0'