resources_nav 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +42 -0
- data/Rakefile +3 -0
- data/lib/resources_nav/mapper_extension.rb +17 -0
- data/lib/resources_nav/railtie.rb +4 -0
- data/lib/resources_nav/route_set_extension.rb +9 -0
- data/lib/resources_nav/version.rb +3 -0
- data/lib/resources_nav.rb +11 -0
- data/lib/tasks/resources_nav_tasks.rake +4 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 459488ee10d96008855c7cc9d8efe46e417769cc897378daa396ea6de3145f3e
|
4
|
+
data.tar.gz: 1f4021b95c510011e473445a4f794ef356e7c9ddd624edcd89670bcc168bd14e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3dd32c1f89525acc97b3e966187cea04f33d5b5144315896780264149022f8a8e51937aa02d3e8fa0cafa8148f9593cdc0460028a314636be8573e3912011e61
|
7
|
+
data.tar.gz: 2beec4d6bc3c9eb93bbdba6696649f64fa2ff069cb5338312feaa3fe89448f6b1b3c864fb8d2eb9adaab38637eb7627391716234ede14c827d359d7a5e6f45f0
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2022 Bruno Enten
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Resources Nav
|
2
|
+
Add a :nav option to Rails routes mapper 'resources' method, that adds the resource to an array.
|
3
|
+
It's convenient to populate a navigation menu.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
Just add a nav option to your resources route in config/routes.rb, like so:
|
7
|
+
```ruby
|
8
|
+
Rails.application.routes.draw do
|
9
|
+
resources :apples, nav: true
|
10
|
+
resources :oranges, nav: true
|
11
|
+
end
|
12
|
+
```
|
13
|
+
|
14
|
+
The resources array will then be accessible from Rails.application.routes.resources_nav:
|
15
|
+
```ruby
|
16
|
+
irb(main):001:0> Rails.application.routes.resources_nav
|
17
|
+
=> [:purchase_invoice_lines, :purchase_invoices, :journal_entries, :accounts, :companies]
|
18
|
+
```
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem "resources_nav"
|
26
|
+
```
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
```bash
|
30
|
+
$ bundle
|
31
|
+
```
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
```bash
|
35
|
+
$ gem install resources_nav
|
36
|
+
```
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
Feel free to submit issues or pull requests!
|
40
|
+
|
41
|
+
## License
|
42
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module ResourcesNav
|
2
|
+
module MapperExtension
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
alias_method :resources_orig, :resources
|
7
|
+
def resources(*resources, &block)
|
8
|
+
options = resources.extract_options!.dup
|
9
|
+
if options[:nav]
|
10
|
+
@set.resources_nav ||= []
|
11
|
+
@set.resources_nav << resources.first
|
12
|
+
end
|
13
|
+
resources_orig(*resources, &block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "resources_nav/version"
|
2
|
+
require "resources_nav/railtie"
|
3
|
+
|
4
|
+
require "resources_nav/route_set_extension"
|
5
|
+
require "resources_nav/mapper_extension"
|
6
|
+
module ResourcesNav
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
ActionDispatch::Routing::RouteSet.send :include, ResourcesNav::RouteSetExtension
|
11
|
+
ActionDispatch::Routing::Mapper.send :include, ResourcesNav::MapperExtension
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resources_nav
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bruno Enten
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 7.0.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 7.0.3
|
27
|
+
description: Add a :nav option to Rails routes mapper 'resources' method, that adds
|
28
|
+
the resource to an array. It can be used to populate a navigation menu.
|
29
|
+
email:
|
30
|
+
- bruno@enten.me
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- MIT-LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/resources_nav.rb
|
39
|
+
- lib/resources_nav/mapper_extension.rb
|
40
|
+
- lib/resources_nav/railtie.rb
|
41
|
+
- lib/resources_nav/route_set_extension.rb
|
42
|
+
- lib/resources_nav/version.rb
|
43
|
+
- lib/tasks/resources_nav_tasks.rake
|
44
|
+
homepage: https://github.com/brunoenten/resources_nav
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata:
|
48
|
+
homepage_uri: https://github.com/brunoenten/resources_nav
|
49
|
+
source_code_uri: https://github.com/brunoenten/resources_nav
|
50
|
+
changelog_uri: https://github.com/brunoenten/resources_nav/CHANGELOG.md
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.3.7
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Build your nav from resources routes
|
70
|
+
test_files: []
|