router-visualizer 1.0.0 → 1.0.1

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
2
  SHA1:
3
- metadata.gz: 40a124d4a262fb535e51473aa9741cf290e33bee
4
- data.tar.gz: 381ebf9600b5465bd465604e53a06d4d49bfe664
3
+ metadata.gz: 149c7448fa0192374da733d531a7632b04a8679d
4
+ data.tar.gz: cfaa8998fe6b05516f456f2ccbad511a387581a1
5
5
  SHA512:
6
- metadata.gz: fee7978538572b4c3eaea1e5bf6e473c26fd21b600e513d8602d07ac1e037de6b44c9192895c0657e765de1cc084d9613a7d788c7ee0ba665c7d24be7ef790e0
7
- data.tar.gz: 4e33cf8f4d1f33a2900d58b2c0ea2649aed7364c0618dbe0c91c8df0c546baffd2e34a289b02e30e29ca874dd7b5c169ece7a60787aa44c2a090b2aac9ce9afc
6
+ metadata.gz: 67a3e846083e93ddadc3bbd20fa284bb41907aa9ac09735e188ce9a7cf94e95e668ac921b0926e0e8c82d293625bb2cccf98a208cff2ff1d8dc85c3ebbedab35
7
+ data.tar.gz: b5ce4232f7f77ac03d908b98469b22bd4e21d93eee73fab315c9cca0f8dcfe796200698f629634f86b1652e899dd83584406ae55bd422bbef8af067b7125d363
@@ -1,4 +1,4 @@
1
- require 'router-visualizer/engine'
1
+ require 'router-visualizer/mapper'
2
2
 
3
3
  module RouterVisualizer
4
4
  end
@@ -0,0 +1,25 @@
1
+ require 'router-visualizer/engine'
2
+
3
+ module ActionDispatch
4
+ module Routing
5
+ class Mapper
6
+ def visualize(options = {})
7
+ groups = options.delete(:groups) { ['development'] }
8
+ at = options.delete(:at) { '/routes' }
9
+
10
+ if matching_group? groups
11
+ mount RouterVisualizer::Engine, at: at
12
+ end
13
+ self
14
+ end
15
+
16
+ private
17
+ def matching_group?(groups)
18
+ groups.each do |group|
19
+ return true if Rails.env.send("#{group}?")
20
+ end
21
+ false
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module RouterVisualizer
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/readme.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This gem allows you to see a visualization of the router of your Rails 4 application.
4
4
 
5
- This visualization is generated by the Rails Journey router. It was written by [tenderlove](http://tenderlove.github.io) back before Journey was incorporated into Rails. Calling `Rails.application.routes.router.visualizer` from your application will return the text of an html file titled "Routes FSM with NFA simulation". This gem just wraps this functionality into a simple engine that you can mount at some route.
5
+ This visualization is generated by the Rails Journey router. It was written by [tenderlove](http://tenderlove.github.io) back before Journey was incorporated into Rails. Calling `Rails.application.routes.router.visualizer` from your application will return the text of an html file titled "Routes FSM with NFA simulation". This gem just wraps this functionality into a simple engine that gets mounted by the `visualize` method.
6
6
 
7
7
  The visualizer also shows a list of all of your application's routes. It doesn't list the REST methods associated with the routes.
8
8
 
@@ -31,17 +31,58 @@ $ brew install gprof2dot
31
31
 
32
32
  Rails.application.routes.draw do
33
33
  # ...
34
+ visualize
35
+ # ...
36
+ end
37
+ ```
34
38
 
35
- if Rails.env.development?
36
- mount RouterVisualizer::Engine, at: "/routes"
37
- end
39
+ Then you can navigate to `localhost:3000/routes` to see the visualization.
40
+
41
+ You can mount the visualizer at whatever route you want:
38
42
 
43
+ ```ruby
44
+ Rails.application.routes.draw do
45
+ # ...
46
+ visualize at: 'nfa_visualization'
39
47
  # ...
40
48
  end
41
49
  ```
42
50
 
43
- Then you can navigate to `localhost:3000/routes` to see the visualization.
51
+ By default, the visualization route will only be defined in development. If for some reason you want the route to be defined in other environments, you can use `groups` option:
52
+
53
+ ```ruby
54
+ Rails.application.routes.draw do
55
+ # ...
56
+ visualize groups: ['development', 'staging']
57
+ # ...
58
+ end
59
+ ```
44
60
 
45
61
  ## What is the point of this?
46
62
 
47
- I want to learn to write gems and rails engines. This is a simple starting point.
63
+ I want to learn to write gems and rails engines. This is a simple starting point.
64
+
65
+ ## License
66
+
67
+ Copyright (c) 2015 Joseph Tibbertsma
68
+
69
+ MIT License
70
+
71
+ Permission is hereby granted, free of charge, to any person obtaining
72
+ a copy of this software and associated documentation files (the
73
+ "Software"), to deal in the Software without restriction, including
74
+ without limitation the rights to use, copy, modify, merge, publish,
75
+ distribute, sublicense, and/or sell copies of the Software, and to
76
+ permit persons to whom the Software is furnished to do so, subject to
77
+ the following conditions:
78
+
79
+ The above copyright notice and this permission notice shall be
80
+ included in all copies or substantial portions of the Software.
81
+
82
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
83
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
84
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
85
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
86
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
87
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
88
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -17,5 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.files = `git ls-files`.split($/)
18
18
  gem.require_paths = ['lib']
19
19
 
20
- gem.add_dependency 'railties', '>= 4.0'
20
+ gem.add_dependency 'rails', '>= 4.0'
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: router-visualizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Tibbertsma
@@ -11,7 +11,7 @@ cert_chain: []
11
11
  date: 2015-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: railties
14
+ name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -41,6 +41,7 @@ files:
41
41
  - config/routes.rb
42
42
  - lib/router-visualizer.rb
43
43
  - lib/router-visualizer/engine.rb
44
+ - lib/router-visualizer/mapper.rb
44
45
  - lib/router-visualizer/version.rb
45
46
  - readme.md
46
47
  - router-visualizer.gemspec