Class: Zed::Rails::Jumper::CLI
- Inherits:
-
Thor
- Object
- Thor
- Zed::Rails::Jumper::CLI
show all
- Defined in:
- lib/zed/rails/jumper/cli.rb
Defined Under Namespace
Classes: ControllerFinder, ViewFinder
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
16
17
18
|
# File 'lib/zed/rails/jumper/cli.rb', line 16
def self.exit_on_failure?
true
end
|
.start ⇒ Object
9
10
11
12
13
14
|
# File 'lib/zed/rails/jumper/cli.rb', line 9
def self.start(*)
super
rescue Thor::InvocationError, ArgumentError, Errno::ENOENT, IOError => exc
warn String(exc)
exit(1)
end
|
Instance Method Details
#controller ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/zed/rails/jumper/cli.rb', line 44
def controller
view_file = options[:path]
rails_root = options[:root]
controller_finder = ControllerFinder.new(view_file, rails_root)
result = controller_finder.find_controller_and_action
if result
system("zed", result[:controller_file])
else
warn "No corresponding controller/action found"
exit 1
end
end
|
#lookup ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/zed/rails/jumper/cli.rb', line 24
def lookup
current_file = options[:path]
rails_root = options[:root]
current_line = options[:line]
view_finder = ViewFinder.new(current_file, rails_root, current_line)
associated_views = view_finder.find_associated_views
if associated_views.any?
system("zed", associated_views.first)
else
warn "No associated views found"
exit 1
end
end
|