rails-route-checker 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03ed64e49d9050509ae5295e0316b36bd8adce8c
4
- data.tar.gz: b80c5b8fb5b74f8e1bde7d1a01be06181adec0c2
3
+ metadata.gz: c2ee3366805e8dbc68755df5f5ce5e1342f5be11
4
+ data.tar.gz: 9ce06f8c42d7f2940ee45ab82ad491afce95f2fa
5
5
  SHA512:
6
- metadata.gz: 56169fb79ebacfde4bb198192315fb66b291f3d06691f8c53160568b45abe9d417063954bc7746403268de5770fca148c696285353b2acdcf93bedc7e25a6d9b
7
- data.tar.gz: c8a8c3f3427e635bc3bfa93a783cfd1de93bd773731e0f0b2f7b614cbb22e71325f7bb5d43f8d2b11f3d7b933e7d0c773191b37279bb9c75e931244959c505bb
6
+ metadata.gz: da784f02dd0cb29e448fb698e89196709a2b7be7b080b4d7e9c8770bf11bc66ec158907da3f51e9ff81fc3ebdf355dad4d047aebdb80675b4953038a0355ee3f
7
+ data.tar.gz: 87d43f4feca31e8f58820570439fddbe97be9499ea5828a8111b9439e9e75df068c2d0bf5ae085c91b43dc1d3a452e548b996daeefd7b314489e5710233b311d
@@ -42,13 +42,14 @@ module RailsRouteChecker
42
42
  end
43
43
 
44
44
  def generate_undef_view_path_calls_erb
45
- files = `find app -type f -iregex '.*\\.erb'`.split("\n")
45
+ files = Dir['app/**/*.erb']
46
46
  return [] if files.none?
47
47
 
48
48
  RailsRouteChecker::Parsers::Loader.load_parser(:erb)
49
49
 
50
50
  files.map do |filename|
51
51
  controller = controller_from_view_file(filename)
52
+ next unless controller # controller will be nil if it's an ignored controller
52
53
 
53
54
  filter = lambda do |path_or_url|
54
55
  return false if match_in_whitelist?(filename, path_or_url)
@@ -61,7 +62,7 @@ module RailsRouteChecker
61
62
  end
62
63
 
63
64
  def generate_undef_view_path_calls_haml
64
- files = `find app -type f -iregex '.*\\.haml'`.split("\n")
65
+ files = Dir['app/**/*.haml']
65
66
  return [] if files.none?
66
67
 
67
68
  unless RailsRouteChecker::Parsers::Loader.haml_available?
@@ -74,6 +75,7 @@ module RailsRouteChecker
74
75
 
75
76
  files.map do |filename|
76
77
  controller = controller_from_view_file(filename)
78
+ next unless controller # controller will be nil if it's an ignored controller
77
79
 
78
80
  filter = lambda do |path_or_url|
79
81
  return false if match_in_whitelist?(filename, path_or_url)
@@ -86,7 +88,7 @@ module RailsRouteChecker
86
88
  end
87
89
 
88
90
  def generate_undef_controller_path_calls
89
- files = `find app/controllers -type f -iregex '.*\\.rb'`.split("\n")
91
+ files = Dir['app/controllers/**/*.rb']
90
92
  return [] if files.none?
91
93
 
92
94
  RailsRouteChecker::Parsers::Loader.load_parser(:ruby)
@@ -127,20 +129,23 @@ module RailsRouteChecker
127
129
  split_path = filename.split('/')
128
130
  possible_controller_path = split_path[(split_path.index('app') + 2)..-2]
129
131
 
130
- controller = nil
131
- while controller.nil? && possible_controller_path.any?
132
- if controller_information.include?(possible_controller_path.join('/'))
133
- controller = controller_information[possible_controller_path.join('/')]
134
- else
135
- possible_controller_path = possible_controller_path[0..-2]
136
- end
132
+ while possible_controller_path.any?
133
+ controller_name = possible_controller_path.join('/')
134
+ return controller_information[controller_name] if controller_exists?(controller_name)
135
+ possible_controller_path = possible_controller_path[0..-2]
137
136
  end
138
- controller || controller_information['application']
137
+ controller_information['application']
139
138
  end
140
139
 
141
140
  def controller_from_ruby_file(filename)
142
- controller_name = (filename.match(%r{app/controllers/(.*)_controller.rb}) || [])[1] || 'application'
143
- controller_information[controller_name]
141
+ controller_name = (filename.match(%r{app/controllers/(.*)_controller.rb}) || [])[1]
142
+ return controller_information[controller_name] if controller_exists?(controller_name)
143
+ controller_information['application']
144
+ end
145
+
146
+ def controller_exists?(controller_name)
147
+ return false unless controller_name
148
+ File.exists?("app/controllers/#{controller_name}_controller.rb")
144
149
  end
145
150
  end
146
151
  end
@@ -1,3 +1,3 @@
1
1
  module RailsRouteChecker
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-route-checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Allie