organized_routes 1.0.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 +15 -0
- data/LICENSE +20 -0
- data/README.md +41 -0
- data/lib/organized_routes.rb +27 -0
- data/lib/organized_routes/version.rb +3 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Yjc2MWRiMmRkMTFmNGU3NzIzZTJmZGE0MmE0ZWUwNWRmOTM1N2Q1OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTQ1ODhlYjYzODg0MmY0NjliMTVjMDcxOGJlYzYxOGYzODAzOTMzMQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjQ2MjkyYzNhOWRhODUyMDA3M2I3MTI3ZDExYTAwYzY0ZDBmNTFkNzA2NmYx
|
10
|
+
ZWM5N2U1MTFjYTc5MGE0OWUxOGZjZjEyY2M0NmRjOWJmMGYxOTVlM2JiNjkz
|
11
|
+
NjkwMjE4Njg1NjMyMzU5NmZkNTg2OTMzODZjYTE5YzgzMmUyMzg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTgyZDFiY2EyNTJjMDczOTNiMWNiOWE0ZTBmZTkwMGIxZDE2MjVkNTBhZjVh
|
14
|
+
NGY3NTE0N2EwYWFjMzI3M2Q1ZDk4NzZhNWMzNjdiOThiYjc1NzY3MDBiNmQ2
|
15
|
+
NGU5MWU0MTVhZmYxODQzMWJiZmE3ZjI5MzAyNWU3YmMxZjI2NWY=
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 Kumu
|
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,41 @@
|
|
1
|
+
# OrganizedRoutes
|
2
|
+
|
3
|
+
Tired of huge `routes.rb` files in your Rails apps? Then read on!
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
The `organized_routes` gem allows you to break your routes up into logical
|
8
|
+
groups, organized in separate files.
|
9
|
+
|
10
|
+
Step 1) Add the library to your app
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
# Gemfile
|
14
|
+
gem "organized_routes", "~> 1.0.0"
|
15
|
+
```
|
16
|
+
|
17
|
+
Step 2) Define your routes under the `config/routes` directory
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# config/routes/api.rb
|
21
|
+
OrganizedRoutes.define(:api) do
|
22
|
+
namespace :api do
|
23
|
+
resources :users
|
24
|
+
end
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
Step 3) Include your routes by name in `routes.rb`
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
# config/routes/api.rb
|
32
|
+
Example::Application.routes.draw do
|
33
|
+
organize_routes
|
34
|
+
routes_for :api
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
That's all there is to it! Make sure to restart your app after any route changes.
|
39
|
+
|
40
|
+
Note: If anyone has suggestions for ways to avoid the `organize_routes` call
|
41
|
+
I'm all ears.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module OrganizedRoutes
|
2
|
+
@routes = {}
|
3
|
+
|
4
|
+
# use load so we pick up any changes
|
5
|
+
def self.load_routes
|
6
|
+
Dir["#{Rails.root}/config/routes/**/*.rb"].each {|file| load file}
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.define(key, &block)
|
10
|
+
@routes[key] = block
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.draw(key, context)
|
14
|
+
context.instance_exec &@routes[key] || raise("Unknown routes: #{key}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module ActionDispatch::Routing::Mapper::Base
|
19
|
+
# TODO: find a way to have this happen automatically each time routes.rb is reloaded
|
20
|
+
def organize_routes
|
21
|
+
OrganizedRoutes.load_routes
|
22
|
+
end
|
23
|
+
|
24
|
+
def routes_for(key)
|
25
|
+
OrganizedRoutes.draw(key, self)
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: organized_routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Mohr @rymohr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Enough with massive routes.rb files already. Organize your routes into
|
14
|
+
separate files instead!
|
15
|
+
email:
|
16
|
+
- ryan@kumu.io
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
23
|
+
- lib/organized_routes.rb
|
24
|
+
- lib/organized_routes/version.rb
|
25
|
+
homepage: https://github.com/kumu/organized_routes
|
26
|
+
licenses: []
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.2.2
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Organize your rails routes into separate files
|
48
|
+
test_files: []
|