kurin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4da2e05a2fb1373c2aa8ae355d639f70adead398
4
+ data.tar.gz: 1b1c7211f2c1a2428a02b4b7f7d1c7c9dd159115
5
+ SHA512:
6
+ metadata.gz: 63518aecc17f5c37dfc75d3cc4474edad6400a43f2e4ee9a6811527d850705b3d92c90ed6e8e4859f9f53de6ba833e29c12544725cdbf7fb6ed25384aeae0441
7
+ data.tar.gz: 862a3a9ef7e0721753f37f6da7a1cfb7544fdb8d1987994947de6f15e30b871cdc78717263d75c2c16975db95ac659aa543ff1b037bc3e1d90aca75c591552b8
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2014 Joshua Kendall <me@joshuakendall.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Kurin
2
+
3
+ A Squeaky Clean Routing task for Rails
4
+
5
+ [[![Code Climate](https://codeclimate.com/github/jtkendall/kurin/badges/gpa.svg)](https://codeclimate.com/github/jtkendall/kurin) [![Gem Version](https://badge.fury.io/rb/kurin.svg)](https://badge.fury.io/rb/kurin) [![Dependency Status](https://gemnasium.com/jtkendall/kurin.svg)](https://gemnasium.com/jtkendall/kurin)
6
+
7
+ ## Installation
8
+
9
+ gem install kurin
10
+
11
+ or in your Gemfile
12
+
13
+ gem 'kurin'
14
+
15
+
16
+ ## Documentation
17
+
18
+ [rdoc.info/github/jtkendall/kurin](http://rdoc.info/github/jtkendall/kurin)
19
+
20
+ ## Usage
21
+
22
+ rake kurin:routes
23
+
24
+ ![Kurin Example](https://raw.github.com/jtkendall/kurin/master/example.png)
25
+
26
+
27
+ ## Contributing & Development
28
+
29
+ $ git clone https://github.com/jtkendall/kurin && cd kurin
30
+ $ bundle install
31
+
32
+ * Fork the project.
33
+ * Make your feature addition or bug fix..
34
+ * Commit, do not mess with version, or history. If you want to have your own version, that is fine but bump version in a commit by itself in another branch so a maintainer ignores it when your pull request is merged.
35
+ * Send a pull request. Bonus points for topic branches.
36
+
37
+ ## License & Copyright
38
+
39
+ See LICENSE for details.
@@ -0,0 +1,94 @@
1
+ module Kurin
2
+ # This class outputs Rails routes into a clean and organized format.
3
+ # @author Joshua Kendall
4
+ class Formatter
5
+ def initialize
6
+ @buffer = []
7
+ lines
8
+ end
9
+
10
+ def result
11
+ lines
12
+ @buffer.join("\n")
13
+ end
14
+
15
+ def section_title(title)
16
+ @buffer << "\n#{title}:"
17
+ end
18
+
19
+ def header(routes)
20
+ controller, action, verb, name, path = widths(routes)
21
+ @buffer << [
22
+ 'Controller'.ljust(controller),
23
+ 'Action'.ljust(action),
24
+ 'Verb'.ljust(verb),
25
+ 'Prefix'.ljust(name),
26
+ 'URI Pattern'.ljust(path)
27
+ ].join(' ')
28
+ lines
29
+ end
30
+
31
+ def section(routes)
32
+ routes.each do |route|
33
+ @buffer << make_route(route, widths(routes)).join(' ')
34
+ end
35
+ end
36
+
37
+ def no_routes
38
+ @buffer << <<-MESSAGE.strip_heredoc
39
+ You don't have any routes defined!
40
+ Please add some routes in config/routes.rb.
41
+ For more information about routes, see the
42
+ Rails guide: http://guides.rubyonrails.org/routing.html.
43
+ MESSAGE
44
+ end
45
+
46
+ private
47
+
48
+ def lines
49
+ @buffer << Array.new(140) { '-' }.join('')
50
+ end
51
+
52
+ def make_route(route, width)
53
+ name, verb, path, reqs, _regexp = route.values
54
+ controller, action = reqs.split('#')
55
+ [
56
+ controller.ljust(width[0]),
57
+ action.ljust(width[1]),
58
+ verb.ljust(width[2]),
59
+ name.ljust(width[3]),
60
+ path.ljust(width[4])
61
+ ]
62
+ end
63
+
64
+ def widths(routes)
65
+ [
66
+ controller_width(routes),
67
+ action_width(routes),
68
+ verb_width(routes),
69
+ name_width(routes),
70
+ path_width(routes)
71
+ ]
72
+ end
73
+
74
+ def controller_width(routes)
75
+ routes.map { |r| r[:reqs].split('#').first.length + 5 }.max || 0
76
+ end
77
+
78
+ def action_width(routes)
79
+ routes.map { |r| r[:reqs].split('#').last.length + 5 }.max || 0
80
+ end
81
+
82
+ def verb_width(routes)
83
+ routes.map { |r| r[:verb].length + 5 }.max || 0
84
+ end
85
+
86
+ def name_width(routes)
87
+ routes.map { |r| r[:name].length + 5 }.max || 0
88
+ end
89
+
90
+ def path_width(routes)
91
+ routes.map { |r| r[:path].length }.max || 0
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails'
2
+
3
+ module Kurin
4
+ # This class defines the Kurin Railtie
5
+ # @author Joshua Kendall
6
+ class Railtie < Rails::Railtie
7
+ railtie_name :kurin
8
+
9
+ rake_tasks do
10
+ load 'kurin/tasks/routes.rake'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ namespace :kurin do
2
+ desc 'Print out all defined routes in a clean fashion.'
3
+ task routes: :environment do
4
+ all_routes = Rails.application.routes.routes
5
+ require 'action_dispatch/routing/inspector'
6
+ inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
7
+ puts inspector.format(Kurin::Formatter.new, ENV['CONTROLLER'])
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module Kurin
3
+ VERSION = '0.0.1'.freeze
4
+ end
data/lib/kurin.rb ADDED
@@ -0,0 +1,5 @@
1
+ # Kurin - Squeaky Clean Routing
2
+ module Kurin
3
+ require 'kurin/railtie' if defined?(Rails)
4
+ require 'kurin/formatter' if defined?(Rails)
5
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kurin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh Kendall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: coveralls
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.36'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.36'
97
+ description: A Rails gem that presents routes in a clean way.
98
+ email: me@joshuakendall.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - LICENSE
104
+ - README.md
105
+ - lib/kurin.rb
106
+ - lib/kurin/formatter.rb
107
+ - lib/kurin/railtie.rb
108
+ - lib/kurin/tasks/routes.rake
109
+ - lib/kurin/version.rb
110
+ homepage: http://github.com/jtkendall/kurin
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.5.1
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: A Squeaky Clean Routing task for Rails
134
+ test_files: []
135
+ has_rdoc: