action_not_found 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
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.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = ActionNotFound
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'ActionNotFound'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
@@ -0,0 +1,8 @@
1
+ module ActionNotFound
2
+ class Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ load "action_not_found/tasks.rake"
5
+ end
6
+ end
7
+ end
8
+
@@ -0,0 +1,11 @@
1
+ task :load_controllers => :environment do
2
+ Rails.application.reload_routes!
3
+ end
4
+
5
+ desc "Show all not actions"
6
+ task :action_not_found, [ :path ] => :load_controllers do |task, args|
7
+ all_routes = Rails.application.routes.routes
8
+ base_path = Rails.root.join('app').join('controllers')
9
+ not_defined_acitons = ActionNotFound.process(all_routes, base_path)
10
+ puts not_defined_acitons
11
+ end
@@ -0,0 +1,3 @@
1
+ module ActionNotFound
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,39 @@
1
+ require 'action_not_found/railtie.rb'
2
+
3
+ module ActionNotFound
4
+ extend self
5
+
6
+ def process(all_routes, base_path)
7
+ formatted = case Rails.version
8
+ when /^3\.2/
9
+ process_rails_3_2(all_routes)
10
+ else
11
+ process_rails_4(all_routes)
12
+ end
13
+ formatted_action_not_found(formatted, base_path)
14
+ end
15
+
16
+ def formatted_action_not_found(formatted, base_path)
17
+ formatted.each do |route|
18
+ route =~ /\)\s(.*?)#(.*?)$/
19
+ controller_path = base_path.join("#{$1}_controller.rb")
20
+ begin
21
+ unless File.readlines(controller_path).grep(/def\s#{$2}/).size > 0
22
+ route << " #=> not found action"
23
+ end
24
+ rescue
25
+ route << " #=> not found controller file"
26
+ end
27
+ end
28
+ end
29
+
30
+ def process_rails_3_2(all_routes)
31
+ require 'rails/application/route_inspector'
32
+ Rails::Application::RouteInspector.new.format(all_routes)
33
+ end
34
+
35
+ def process_rails_4(all_routes)
36
+ require 'action_dispatch/routing/inspector'
37
+ ActionDispatch::Routing::RoutesInspector.new.format(all_routes)
38
+ end
39
+ end
@@ -0,0 +1,4 @@
1
+ desc "show not found actions "
2
+ task :action_not_found do
3
+ puts "hogehoge"
4
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: action_not_found
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Satoshi Honda
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.9
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.9
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: sqlite3
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: This is a Rails plugin to see not found action
63
+ email:
64
+ - bin.honda@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - lib/action_not_found/railtie.rb
70
+ - lib/action_not_found/tasks.rake
71
+ - lib/action_not_found/version.rb
72
+ - lib/action_not_found.rb
73
+ - lib/tasks/action_not_found_tasks.rake
74
+ - MIT-LICENSE
75
+ - Rakefile
76
+ - README.rdoc
77
+ homepage: https://github.com/honbin/action_not_found
78
+ licenses: []
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ segments:
90
+ - 0
91
+ hash: -1869290247761311816
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ segments:
99
+ - 0
100
+ hash: -1869290247761311816
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 1.8.24
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Rails plugin to see not found action
107
+ test_files: []