traceroute 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in traceroute.gemspec
4
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,81 @@
1
+ = Traceroute
2
+
3
+ A Rake task that helps you find the dead routes and actions for your Rails 3 app
4
+
5
+
6
+ == Features
7
+
8
+ This Rake task investigates your Rails 3 application's routes definition, then tells you unused routes and unreachable action methods.
9
+
10
+
11
+ == Supported versions
12
+
13
+ * Ruby 1.8.7, 1.9.2, 1.9.3 (trunk)
14
+
15
+ * Rails 3.0.x, 3.1 (edge)
16
+
17
+
18
+ == Install
19
+
20
+ Put this line in your Gemfile:
21
+ gem 'traceroute'
22
+
23
+ Then bundle:
24
+ % bundle
25
+
26
+
27
+ == Usage
28
+
29
+ Just run the following command in your Rails app directory.
30
+ % rake traceroute
31
+
32
+
33
+ == What's gonna happen then?
34
+
35
+ Consider you have the following routes.rb and a controller:
36
+
37
+ # config/routes.rb
38
+ YourRailsApp::Application.routes.draw do
39
+ resources :users, :only => [:index, :show, :new, :create]
40
+ match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
41
+ end
42
+
43
+ # app/controllers/users_controller.rb
44
+ class UsersController < ApplicationController
45
+ def index
46
+ @users = User.page(params[:page])
47
+ end
48
+
49
+ def index2
50
+ end
51
+
52
+ def show
53
+ @user = User.find(params[:id])
54
+ end
55
+ end
56
+
57
+ Running the Rake task will print something like this for you:
58
+
59
+ Unused routes:
60
+ users#create
61
+ users#new
62
+ catalog#purchase
63
+ Unreachable action methods:
64
+ users#index2
65
+
66
+ OMG super helpful, isn't it?
67
+
68
+
69
+ == Questions, Feedback
70
+
71
+ Feel free to message me on Github (amatsuda) or Twitter (@a_matsuda) ☇3☇3☇3
72
+
73
+
74
+ == Contributing to Traceroute
75
+
76
+ * Fork, fix, then send me a pull request.
77
+
78
+
79
+ == Copyright
80
+
81
+ Copyright (c) 2011 Akira Matsuda. See LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ desc 'Prints out unused routes and unreachable action methods'
2
+ task :traceroute => :environment do
3
+ Rails.application.eager_load!
4
+ Rails.application.reload_routes!
5
+ routes = Rails.application.routes.routes.reject! {|r| r.path =~ %r{/rails/info/properties}} # Skip the route if it's internal info route
6
+
7
+ defined_action_methods = ApplicationController.descendants.map {|controller|
8
+ controller.action_methods.reject {|a| (a =~ /\A(_conditional)?_callback_/) || (a == '_layout_from_proc')}.map do |action|
9
+ "#{controller.controller_path}##{action}"
10
+ end
11
+ }.flatten
12
+
13
+ routed_actions = routes.map do |r|
14
+ "#{r.requirements[:controller]}##{r.requirements[:action]}"
15
+ end
16
+
17
+ puts 'Unused routes:'
18
+ (routed_actions - defined_action_methods).each {|a| puts " #{a}"}
19
+ puts 'Unreachable action methods:'
20
+ (defined_action_methods - routed_actions).each {|a| puts " #{a}"}
21
+ end
data/lib/traceroute.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Traceroute
2
+ class Railtie < ::Rails::Railtie
3
+ rake_tasks do
4
+ load File.join(File.dirname(__FILE__), 'tasks/traceroute.rake')
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Traceroute
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "traceroute/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "traceroute"
7
+ s.version = Traceroute::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Akira Matsuda']
10
+ s.email = ['ronnie@dio.jp']
11
+ s.homepage = 'https://github.com/amatsuda/traceroute'
12
+ s.summary = 'A Rake task that helps you find the dead routes and actions for your Rails 3 app'
13
+ s.description = "This Rake task investigates the application's routes definition, then tells you unused routes and unreachable action methods"
14
+
15
+ s.rubyforge_project = 'traceroute'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.extra_rdoc_files = ['README.rdoc']
21
+ s.require_paths = ['lib']
22
+
23
+ s.licenses = ['MIT']
24
+
25
+ s.add_dependency 'rails', ['>= 3.0.0']
26
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: traceroute
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Akira Matsuda
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-05 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rails
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
33
+ version: 3.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: This Rake task investigates the application's routes definition, then tells you unused routes and unreachable action methods
37
+ email:
38
+ - ronnie@dio.jp
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README.rdoc
45
+ files:
46
+ - .gitignore
47
+ - Gemfile
48
+ - README.rdoc
49
+ - Rakefile
50
+ - lib/tasks/traceroute.rake
51
+ - lib/traceroute.rb
52
+ - lib/traceroute/version.rb
53
+ - traceroute.gemspec
54
+ homepage: https://github.com/amatsuda/traceroute
55
+ licenses:
56
+ - MIT
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project: traceroute
83
+ rubygems_version: 1.8.0
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: A Rake task that helps you find the dead routes and actions for your Rails 3 app
87
+ test_files: []
88
+