redcar 0.7 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +42 -0
- data/README.md +5 -3
- data/Rakefile +39 -81
- data/bin/redcar +1 -1
- data/lib/redcar.rb +9 -6
- data/lib/redcar/installer.rb +1 -1
- data/lib/redcar/ruby_extensions.rb +19 -0
- data/lib/redcar/runner.rb +1 -1
- data/lib/redcar/usage.rb +3 -0
- data/lib/redcar_quick_start.rb +11 -11
- data/plugins/application/features/step_definitions/tree_steps.rb +22 -5
- data/plugins/application/features/step_definitions/window_steps.rb +9 -1
- data/plugins/application/features/support/env.rb +5 -2
- data/plugins/application/lib/application.rb +51 -46
- data/plugins/application/lib/application/window.rb +60 -30
- data/plugins/application_swt/lib/application_swt.rb +16 -16
- data/plugins/application_swt/lib/application_swt/window.rb +35 -7
- data/plugins/auto_completer/features/support/env.rb +0 -2
- data/plugins/auto_indenter/features/support/env.rb +0 -1
- data/plugins/auto_pairer/features/auto_pairer.feature +50 -45
- data/plugins/auto_pairer/features/support/env.rb +0 -1
- data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +11 -6
- data/plugins/clipboard-viewer/Screenshot.png +0 -0
- data/plugins/clipboard-viewer/lib/clipboard_viewer.rb +50 -0
- data/plugins/clipboard-viewer/lib/clipboard_viewer/browser_controller.rb +27 -0
- data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +67 -0
- data/plugins/clipboard-viewer/plugin.rb +9 -0
- data/plugins/clipboard-viewer/views/clipboard.html.erb +15 -0
- data/plugins/clipboard-viewer/views/default.css +43 -0
- data/plugins/clipboard-viewer/views/redcar_small_icon.png +0 -0
- data/plugins/comment/features/line_comment.feature +137 -0
- data/plugins/comment/features/selection_comment.feature +21 -0
- data/plugins/comment/features/step_definitions/comment_steps.rb +7 -0
- data/plugins/comment/lib/comment.rb +266 -0
- data/plugins/comment/plugin.rb +7 -0
- data/plugins/comment/vendor/comment_lib.json +47 -0
- data/plugins/declarations/lib/declarations.rb +1 -1
- data/plugins/document_search/features/replace.feature +10 -2
- data/plugins/document_search/features/support/env.rb +0 -1
- data/plugins/document_search/lib/document_search.rb +4 -1
- data/plugins/document_search/lib/document_search/replace.rb +11 -3
- data/plugins/document_search/lib/document_search/search_and_replace.rb +5 -2
- data/plugins/edit_view/features/case_change.feature +9 -9
- data/plugins/edit_view/features/cursor_navigation.feature +36 -0
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +63 -8
- data/plugins/edit_view/features/step_definitions/notebook_steps.rb +2 -0
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +8 -5
- data/plugins/edit_view/features/support/env.rb +8 -2
- data/plugins/edit_view/lib/edit_view.rb +16 -1
- data/plugins/edit_view/lib/edit_view/actions/cmd_enter.rb +11 -0
- data/plugins/edit_view/lib/edit_view/document.rb +27 -10
- data/plugins/edit_view/lib/edit_view/edit_tab.rb +17 -4
- data/plugins/edit_view/spec/edit_view/document_spec.rb +3 -0
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +42 -3
- data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +17 -15
- data/plugins/help/lib/help.rb +40 -0
- data/plugins/help/plugin.rb +8 -0
- data/plugins/html_view/features/step_definitions/html_view_steps.rb +6 -4
- data/plugins/line_tools/features/support/env.rb +0 -1
- data/plugins/macros/features/step_definitions/macro_steps.rb +0 -55
- data/plugins/macros/features/support/env.rb +0 -2
- data/plugins/open_default_app/lib/open_default_app.rb +35 -0
- data/plugins/open_default_app/plugin.rb +8 -0
- data/plugins/open_default_app/screenshot.png +0 -0
- data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +17 -3
- data/plugins/project/features/find_file.feature +3 -2
- data/plugins/project/features/highlight_focussed_tab.feature +8 -0
- data/plugins/project/features/move_and_rename_files.feature +25 -0
- data/plugins/project/features/open_and_save_files.feature +10 -1
- data/plugins/project/features/open_directory_tree.feature +32 -2
- data/plugins/project/features/step_definitions/directory_steps.rb +17 -0
- data/plugins/project/features/step_definitions/project_tree_steps.rb +3 -0
- data/plugins/project/features/sub_project.feature +14 -0
- data/plugins/project/features/support/env.rb +22 -3
- data/plugins/project/features/watch_for_modified_files.feature +32 -9
- data/plugins/project/lib/project.rb +53 -21
- data/plugins/project/lib/project/adapters/local.rb +21 -16
- data/plugins/project/lib/project/adapters/remote.rb +15 -13
- data/plugins/project/lib/project/commands.rb +37 -16
- data/plugins/project/lib/project/dir_controller.rb +41 -42
- data/plugins/project/lib/project/drb_service.rb +35 -21
- data/plugins/project/lib/project/file_list.rb +7 -1
- data/plugins/project/lib/project/manager.rb +28 -3
- data/plugins/project/lib/project/sub_project.rb +17 -0
- data/plugins/project/lib/project/support/recycle.js +2 -0
- data/plugins/project/lib/project/support/trash.rb +72 -0
- data/plugins/project/spec/fixtures/multi-byte-files/a/341/204/200/341/205/247/341/206/274/341/204/205/341/205/251/foo +1 -0
- data/plugins/project/spec/fixtures/multi-byte-files//341/204/220/341/205/246/341/204/211/341/205/263/341/204/220/341/205/263.py +1 -0
- data/plugins/project/spec/project/file_list_spec.rb +4 -0
- data/plugins/redcar/features/goto_line_command.feature +20 -0
- data/plugins/redcar/redcar.rb +107 -47
- data/plugins/repl/lib/repl.rb +20 -20
- data/plugins/repl/lib/repl/clojure_mirror.rb +50 -58
- data/plugins/repl/lib/repl/groovy_mirror.rb +22 -41
- data/plugins/repl/lib/repl/repl_mirror.rb +85 -14
- data/plugins/repl/lib/repl/ruby_mirror.rb +12 -39
- data/plugins/repl/spec/repl/groovy_mirror_spec.rb +1 -1
- data/plugins/repl/spec/repl/ruby_mirror_spec.rb +12 -12
- data/plugins/ruby/README +6 -0
- data/plugins/ruby/lib/syntax_check/ruby.rb +28 -0
- data/plugins/ruby/plugin.rb +7 -0
- data/plugins/runnables/features/command_tree.feature +9 -0
- data/plugins/runnables/features/file_runner_input.feature +20 -0
- data/plugins/runnables/features/run_alternate_command.feature +14 -0
- data/plugins/runnables/features/support/env.rb +42 -5
- data/plugins/runnables/lib/runnables.rb +67 -21
- data/plugins/runnables/lib/runnables/commands.rb +35 -18
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_group.rb +23 -37
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_type_group.rb +16 -18
- data/plugins/scm_svn/features/support/env.rb +0 -3
- data/plugins/snippets/features/snippets.feature +17 -2
- data/plugins/snippets/features/support/env.rb +0 -1
- data/plugins/snippets/lib/snippets/tab_handler.rb +51 -18
- data/plugins/swt/lib/swt/cucumber_patches.rb +13 -68
- data/plugins/swt/lib/swt/cucumber_runner.rb +2 -3
- data/plugins/syntax_check/README +6 -0
- data/plugins/syntax_check/lib/syntax_check.rb +16 -0
- data/plugins/syntax_check/lib/syntax_check/checker.rb +47 -0
- data/plugins/syntax_check/lib/syntax_check/error.rb +23 -0
- data/plugins/syntax_check/plugin.rb +7 -0
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +6 -0
- data/plugins/web_bookmarks/Screenshot.png +0 -0
- data/plugins/web_bookmarks/lib/web_bookmarks.rb +42 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +43 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/browser_bar.rb +70 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +111 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +67 -0
- data/plugins/web_bookmarks/lib/web_bookmarks/view_controller.rb +22 -0
- data/plugins/web_bookmarks/plugin.rb +11 -0
- data/plugins/web_bookmarks/views/index.html.erb +5 -0
- metadata +60 -10
@@ -10,7 +10,7 @@ class Redcar::REPL
|
|
10
10
|
|
11
11
|
def commit_test_text1
|
12
12
|
text = <<-RUBY
|
13
|
-
#
|
13
|
+
# Ruby REPL
|
14
14
|
|
15
15
|
>> $internal_repl_test = 707
|
16
16
|
RUBY
|
@@ -19,7 +19,7 @@ RUBY
|
|
19
19
|
|
20
20
|
def result_test_text1
|
21
21
|
(<<-RUBY).chomp
|
22
|
-
#
|
22
|
+
# Ruby REPL
|
23
23
|
|
24
24
|
>> $internal_repl_test = 707
|
25
25
|
=> 707
|
@@ -29,7 +29,7 @@ RUBY
|
|
29
29
|
|
30
30
|
def commit_test_text2
|
31
31
|
text = <<-RUBY
|
32
|
-
#
|
32
|
+
# Ruby REPL
|
33
33
|
|
34
34
|
>> $internal_repl_test = 707
|
35
35
|
=> 707
|
@@ -41,7 +41,7 @@ RUBY
|
|
41
41
|
|
42
42
|
def result_test_text2
|
43
43
|
(<<-RUBY).chomp
|
44
|
-
#
|
44
|
+
# Ruby REPL
|
45
45
|
|
46
46
|
>> $internal_repl_test = 707
|
47
47
|
=> 707
|
@@ -54,7 +54,7 @@ RUBY
|
|
54
54
|
|
55
55
|
def commit_no_input
|
56
56
|
text = <<-RUBY
|
57
|
-
#
|
57
|
+
# Ruby REPL
|
58
58
|
|
59
59
|
>>
|
60
60
|
RUBY
|
@@ -62,7 +62,7 @@ RUBY
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def prompt
|
65
|
-
"#
|
65
|
+
"# Ruby REPL\n\n"
|
66
66
|
end
|
67
67
|
|
68
68
|
describe "with no history" do
|
@@ -72,7 +72,7 @@ RUBY
|
|
72
72
|
|
73
73
|
it "should have a message and a prompt" do
|
74
74
|
@mirror.read.should == (<<-RUBY).chomp
|
75
|
-
#
|
75
|
+
# Ruby REPL
|
76
76
|
|
77
77
|
>>
|
78
78
|
RUBY
|
@@ -94,13 +94,13 @@ RUBY
|
|
94
94
|
|
95
95
|
it "should allow committing nothing as the first command" do
|
96
96
|
commit_no_input
|
97
|
-
@mirror.read.should == "#
|
97
|
+
@mirror.read.should == "# Ruby REPL\n\n>> \n=> nil\n>> "
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should allow committing nothing as an xth command" do
|
101
101
|
committed = commit_test_text2
|
102
102
|
@mirror.commit committed + "\n>> "
|
103
|
-
@mirror.read.should == "#
|
103
|
+
@mirror.read.should == "# Ruby REPL\n\n>> $internal_repl_test = 909\n=> 909\n>> \n=> nil\n>> "
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should emit changed event when text is executed" do
|
@@ -116,7 +116,7 @@ RUBY
|
|
116
116
|
it "should display errors" do
|
117
117
|
@mirror.commit(prompt + ">> nil.foo")
|
118
118
|
@mirror.read.should == (<<-RUBY).chomp
|
119
|
-
#
|
119
|
+
# Ruby REPL
|
120
120
|
|
121
121
|
>> nil.foo
|
122
122
|
x> NoMethodError: undefined method `foo' for nil:NilClass
|
@@ -164,7 +164,7 @@ RUBY
|
|
164
164
|
it "should execute inside a main object" do
|
165
165
|
@mirror.commit(prompt + ">> self")
|
166
166
|
@mirror.read.should == (<<-RUBY).chomp
|
167
|
-
#
|
167
|
+
# Ruby REPL
|
168
168
|
|
169
169
|
>> self
|
170
170
|
=> main
|
@@ -177,7 +177,7 @@ RUBY
|
|
177
177
|
@mirror.commit(sent)
|
178
178
|
@mirror.commit(sent + "\n>> a")
|
179
179
|
@mirror.read.should == (<<-RUBY).chomp
|
180
|
-
#
|
180
|
+
# Ruby REPL
|
181
181
|
|
182
182
|
>> a = 13
|
183
183
|
=> 13
|
data/plugins/ruby/README
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
module Redcar
|
4
|
+
module SyntaxCheck
|
5
|
+
class Ruby < Checker
|
6
|
+
supported_grammars "Ruby", "Ruby on Rails"
|
7
|
+
|
8
|
+
def check(*args)
|
9
|
+
path = manifest_path(doc)
|
10
|
+
file = File.basename(path)
|
11
|
+
runtime = org.jruby.Ruby.global_runtime
|
12
|
+
io = java.io.FileInputStream.new(java.io.File.new(path))
|
13
|
+
begin
|
14
|
+
runtime.parse_from_main(io, file)
|
15
|
+
rescue SyntaxError => e
|
16
|
+
create_syntax_error(doc, e.exception.message, file).annotate
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_syntax_error(doc, message, file)
|
21
|
+
message =~ /#{Regexp.escape(file)}:(\d+):(.*)/
|
22
|
+
line = $1.to_i - 1
|
23
|
+
message = $2
|
24
|
+
SyntaxCheck::Error.new(doc, line, message)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -13,6 +13,15 @@ Feature: Showing commands in a command tree
|
|
13
13
|
And I expand the tree row "fixture_runnables"
|
14
14
|
Then I should see "An app" in the tree
|
15
15
|
|
16
|
+
Scenario: Shows groups and subgroups by slash-separated type
|
17
|
+
When I open the runnables tree
|
18
|
+
And I expand the tree row "fixture_runnables"
|
19
|
+
Then I should see "first" in the tree
|
20
|
+
And I expand the tree row "first"
|
21
|
+
Then I should see "second" in the tree
|
22
|
+
And I expand the tree row "second"
|
23
|
+
Then I should see "A nested app" in the tree
|
24
|
+
|
16
25
|
Scenario: I can manually refresh the tree
|
17
26
|
When I open the runnables tree
|
18
27
|
And I change the command to "A changed app"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Feature: Using file properties in commands
|
2
|
+
As a user
|
3
|
+
I want to run commands that rely on the current edit view
|
4
|
+
So I don't have to write many similar commands
|
5
|
+
|
6
|
+
Background:
|
7
|
+
When I will choose "plugins/runnables/features/fixtures" from the "open_directory" dialog
|
8
|
+
And I open a directory
|
9
|
+
|
10
|
+
Scenario: Using the name of the current file in a command
|
11
|
+
Given I have opened "plugins/runnables/features/fixtures/name_app.rb"
|
12
|
+
And I run the command Redcar::Runnables::RunEditTabCommand
|
13
|
+
Then my active tab should be "Running name_app.rb"
|
14
|
+
And the HTML tab should say "name_app"
|
15
|
+
|
16
|
+
Scenario: Using the current line number in a command
|
17
|
+
Given I have opened "plugins/runnables/features/fixtures/line_app.rb"
|
18
|
+
And I run the command Redcar::Runnables::RunEditTabCommand
|
19
|
+
Then my active tab should be "Running line_app.rb"
|
20
|
+
And the HTML tab should say "1"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: Running an alternate file runner
|
2
|
+
As a user
|
3
|
+
I want to run tabs in different ways
|
4
|
+
So I need a separate terminal less often
|
5
|
+
|
6
|
+
Background:
|
7
|
+
When I will choose "plugins/runnables/features/fixtures" from the "open_directory" dialog
|
8
|
+
And I open a directory
|
9
|
+
|
10
|
+
Scenario: Getting the second match from a list of file runners
|
11
|
+
Given I have opened "plugins/runnables/features/fixtures/alternate.ruby"
|
12
|
+
And I run the command Redcar::Runnables::RunAlternateEditTabCommand
|
13
|
+
Then my active tab should be "Running alternate.ruby"
|
14
|
+
And the HTML tab should say "hello world"
|
@@ -1,7 +1,3 @@
|
|
1
|
-
RequireSupportFiles File.dirname(__FILE__) + "/../../../application/features/"
|
2
|
-
RequireSupportFiles File.dirname(__FILE__) + "/../../../edit_view/features/"
|
3
|
-
RequireSupportFiles File.dirname(__FILE__) + "/../../../html_view/features/"
|
4
|
-
RequireSupportFiles File.dirname(__FILE__) + "/../../../project/features/"
|
5
1
|
|
6
2
|
def runnable_fixtures
|
7
3
|
File.expand_path(File.dirname(__FILE__) + "/../fixtures")
|
@@ -22,10 +18,21 @@ def reset_runnable_fixtures
|
|
22
18
|
end
|
23
19
|
|
24
20
|
File.open("#{runnable_fixtures}/params_app.rb", 'w') do |f|
|
25
|
-
#f.puts "puts ARGV[0] +' '+ ARGV[1]"
|
26
21
|
f.puts "ARGV.each { |it| print it+' '}"
|
27
22
|
end
|
28
23
|
|
24
|
+
File.open("#{runnable_fixtures}/alternate.ruby", 'w') do |f|
|
25
|
+
f.puts "ARGV.each { |it| print it+' '}"
|
26
|
+
end
|
27
|
+
|
28
|
+
File.open("#{runnable_fixtures}/name_app.rb", 'w') do |f|
|
29
|
+
f.puts "ARGV.each { |it| println it}"
|
30
|
+
end
|
31
|
+
|
32
|
+
File.open("#{runnable_fixtures}/line_app.rb", 'w') do |f|
|
33
|
+
f.puts "ARGV.each { |it| println it}"
|
34
|
+
end
|
35
|
+
|
29
36
|
File.open(runnable_config, 'w') do |f|
|
30
37
|
f.print <<-EOS
|
31
38
|
{
|
@@ -61,14 +68,44 @@ def reset_runnable_fixtures
|
|
61
68
|
"name": "An appendable app",
|
62
69
|
"command": "jruby params_app.rb hello",
|
63
70
|
"description": "Runs an app that prints parameters"
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"name": "A nested app",
|
74
|
+
"command": "echo 'lo'",
|
75
|
+
"description": "A test for nesting",
|
76
|
+
"type": "first/second"
|
64
77
|
}
|
65
78
|
],
|
66
79
|
"file_runners":[
|
80
|
+
{
|
81
|
+
"regex": ".*\\\\name_app.rb",
|
82
|
+
"name": "Run as ruby",
|
83
|
+
"command": "jruby \\"__PATH__\\" __NAME__",
|
84
|
+
"type": "app/ruby"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"regex": ".*\\\\.ruby",
|
88
|
+
"name": "Run as ruby",
|
89
|
+
"command": "jruby \\"__PATH__\\" 1 2 3",
|
90
|
+
"type": "app/ruby"
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"regex": ".*\\\\line_app.rb",
|
94
|
+
"name": "Run as ruby",
|
95
|
+
"command": "jruby \\"__PATH__\\" __LINE__",
|
96
|
+
"type": "app/ruby"
|
97
|
+
},
|
67
98
|
{
|
68
99
|
"regex": ".*\\\\.rb",
|
69
100
|
"name": "Run as ruby",
|
70
101
|
"command": "jruby \\"__PATH__\\"",
|
71
102
|
"type": "app/ruby"
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"regex": ".*\\\\.ruby",
|
106
|
+
"name": "Run as ruby",
|
107
|
+
"command": "jruby \\"__PATH__\\" hello world",
|
108
|
+
"type": "app/ruby"
|
72
109
|
}
|
73
110
|
]
|
74
111
|
}
|
@@ -10,30 +10,22 @@ require 'runnables/tree_mirror/tree_mirror'
|
|
10
10
|
|
11
11
|
module Redcar
|
12
12
|
class Runnables
|
13
|
-
TREE_TITLE
|
14
|
-
PARAMS
|
15
|
-
DISPLAY_PARAMS
|
13
|
+
TREE_TITLE = "Runnables"
|
14
|
+
PARAMS = "__PARAMS__"
|
15
|
+
DISPLAY_PARAMS = "__?__"
|
16
16
|
DISPLAY_NEXT_PARAMS = "_____"
|
17
|
+
LINE_HOLDER = "__LINE__"
|
18
|
+
PATH_HOLDER = "__PATH__"
|
19
|
+
NAME_HOLDER = "__NAME__"
|
17
20
|
|
18
21
|
def self.run_process(path, command, title, output = "tab")
|
19
22
|
window = Redcar.app.focussed_window
|
20
|
-
|
21
|
-
|
22
|
-
msg = msg.gsub(PARAMS,DISPLAY_NEXT_PARAMS)
|
23
|
-
msg = "" if msg == DISPLAY_PARAMS
|
24
|
-
msg_title = "Enter Command Parameters"
|
25
|
-
out = Redcar::Application::Dialog.input(msg_title,msg)
|
26
|
-
params = out[:value] || ""
|
27
|
-
return if out[:button] == :cancel
|
28
|
-
command = command.sub(PARAMS,params)
|
29
|
-
end
|
23
|
+
command = Runnables.substitute_variables(window,command)
|
24
|
+
return unless command
|
30
25
|
if Runnables.storage['save_project_before_running'] == true
|
31
26
|
window.notebooks.each do |notebook|
|
32
27
|
notebook.tabs.each do |tab|
|
33
|
-
|
34
|
-
when EditTab
|
35
|
-
tab.edit_view.document.save! if tab.edit_view.document.modified?
|
36
|
-
end
|
28
|
+
tab.edit_view.document.save! if tab.is_a?(EditTab) and tab.edit_view.document.modified?
|
37
29
|
end
|
38
30
|
end
|
39
31
|
end
|
@@ -55,6 +47,52 @@ module Redcar
|
|
55
47
|
end
|
56
48
|
end
|
57
49
|
|
50
|
+
# Replaces placeholders in commands with values, like __PATH__,
|
51
|
+
# __LINE__, __NAME__ and __PARAMS__
|
52
|
+
def self.substitute_variables(window,command)
|
53
|
+
tab = window.focussed_notebook_tab
|
54
|
+
if tab and tab.is_a?(EditTab)
|
55
|
+
if command.include?(PATH_HOLDER)
|
56
|
+
path = tab.edit_view.document.path
|
57
|
+
command.gsub!(PATH_HOLDER, path)
|
58
|
+
if command.include?(LINE_HOLDER)
|
59
|
+
line = tab.edit_view.document.cursor_line + 1
|
60
|
+
command.gsub!(LINE_HOLDER, line.to_s)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
if command.include?(NAME_HOLDER)
|
64
|
+
name = File.basename(tab.edit_view.document.path)
|
65
|
+
idx = name.rindex(".") if name.include?(".")
|
66
|
+
name = name[0,idx] if idx
|
67
|
+
command.gsub!(NAME_HOLDER, name.to_s)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
while command.include?(PARAMS)
|
71
|
+
msg = command.sub(PARAMS,DISPLAY_PARAMS)
|
72
|
+
msg = msg.gsub(PARAMS,DISPLAY_NEXT_PARAMS)
|
73
|
+
msg = "" if msg == DISPLAY_PARAMS
|
74
|
+
msg_title = "Enter Command Parameters"
|
75
|
+
out = Redcar::Application::Dialog.input(msg_title,msg)
|
76
|
+
params = out[:value] || ""
|
77
|
+
return if out[:button] == :cancel
|
78
|
+
command = command.sub(PARAMS,params)
|
79
|
+
end
|
80
|
+
command
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.file_mappings(project)
|
84
|
+
file_runners = []
|
85
|
+
if project
|
86
|
+
runnable_file_paths = project.config_files("runnables/*.json")
|
87
|
+
runnable_file_paths.each do |path|
|
88
|
+
json = File.read(path)
|
89
|
+
this_file_runners = JSON(json)["file_runners"]
|
90
|
+
file_runners += this_file_runners || []
|
91
|
+
end
|
92
|
+
end
|
93
|
+
file_runners
|
94
|
+
end
|
95
|
+
|
58
96
|
def self.previous_tab_for(command)
|
59
97
|
Redcar.app.all_tabs.detect do |t|
|
60
98
|
t.respond_to?(:html_view) &&
|
@@ -64,19 +102,27 @@ module Redcar
|
|
64
102
|
end
|
65
103
|
|
66
104
|
def self.keymaps
|
67
|
-
|
105
|
+
linwin = Keymap.build("main", [:linux, :windows]) do
|
68
106
|
link "Ctrl+R", Runnables::RunEditTabCommand
|
107
|
+
link "Ctrl+Alt+R", Runnables::RunAlternateEditTabCommand
|
108
|
+
end
|
109
|
+
|
110
|
+
osx = Keymap.build("main", :osx) do
|
111
|
+
link "Cmd+R", Runnables::RunEditTabCommand
|
112
|
+
link "Cmd+Alt+R", Runnables::RunAlternateEditTabCommand
|
69
113
|
end
|
70
|
-
[
|
114
|
+
[linwin,osx]
|
71
115
|
end
|
72
116
|
|
73
117
|
def self.menus
|
74
118
|
Menu::Builder.build do
|
75
119
|
sub_menu "Project" do
|
76
120
|
group(:priority => 15) {
|
77
|
-
|
121
|
+
separator
|
78
122
|
item "Runnables", Runnables::ShowRunnables
|
79
123
|
item "Run Tab", Runnables::RunEditTabCommand
|
124
|
+
item "Alternate Run Tab", Runnables::RunAlternateEditTabCommand
|
125
|
+
separator
|
80
126
|
}
|
81
127
|
end
|
82
128
|
end
|
@@ -107,4 +153,4 @@ module Redcar
|
|
107
153
|
end
|
108
154
|
end
|
109
155
|
end
|
110
|
-
end
|
156
|
+
end
|
@@ -31,34 +31,51 @@ module Redcar
|
|
31
31
|
end
|
32
32
|
|
33
33
|
class RunEditTabCommand < Redcar::EditTabCommand
|
34
|
-
|
34
|
+
sensitize :open_project
|
35
|
+
def execute
|
35
36
|
project = Project::Manager.in_window(win)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
runnable_file_paths.each do |path|
|
40
|
-
json = File.read(path)
|
41
|
-
this_file_runners = JSON(json)["file_runners"]
|
42
|
-
file_runners += this_file_runners || []
|
37
|
+
f = Runnables.file_mappings(project).detect do |file_mapping|
|
38
|
+
regex = Regexp.new(file_mapping["regex"])
|
39
|
+
tab.edit_view.document.mirror.path =~ regex
|
43
40
|
end
|
44
|
-
|
41
|
+
run_tab(project.home_dir,tab, f) if f
|
42
|
+
end
|
43
|
+
|
44
|
+
def run_tab(project_path,tab, file_mapping)
|
45
|
+
command = file_mapping["command"]
|
46
|
+
output = file_mapping["output"]
|
47
|
+
path = tab.edit_view.document.mirror.path
|
48
|
+
output = "tab" if output.nil?
|
49
|
+
Runnables.run_process(project_path,command, "Running #{File.basename(path)}", output)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class RunAlternateEditTabCommand < RunEditTabCommand
|
54
|
+
sensitize :open_project
|
55
|
+
def initialize
|
56
|
+
@default = nil
|
57
|
+
@alternate = nil
|
45
58
|
end
|
46
59
|
|
47
60
|
def execute
|
48
61
|
project = Project::Manager.in_window(win)
|
49
|
-
|
50
|
-
|
62
|
+
i = 0
|
63
|
+
Runnables.file_mappings(project).each do |f|
|
64
|
+
regex = Regexp.new(f["regex"])
|
51
65
|
if tab.edit_view.document.mirror.path =~ regex
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
66
|
+
if i == 0
|
67
|
+
@default = f
|
68
|
+
elsif i == 1
|
69
|
+
@alternate = f
|
56
70
|
end
|
57
|
-
|
58
|
-
command = command_schema.gsub("__PATH__", path)
|
59
|
-
Runnables.run_process(project.home_dir,command, "Running #{File.basename(path)}", output)
|
71
|
+
i = i + 1 #increment only for matches
|
60
72
|
end
|
61
73
|
end
|
74
|
+
if @alternate
|
75
|
+
run_tab(project.home_dir,tab, @alternate)
|
76
|
+
elsif @default
|
77
|
+
run_tab(project.home_dir,tab, @default)
|
78
|
+
end
|
62
79
|
end
|
63
80
|
end
|
64
81
|
end
|