Skip to content

Commit

Permalink
App::midgen runtime support is here
Browse files Browse the repository at this point in the history
  • Loading branch information
azawawi committed May 16, 2014
1 parent 51e2577 commit b0f541f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/Farabi.pm
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ sub startup {
$route->post("/repl_eval")->to('editor#repl_eval');
$route->post("/ping")->to('editor#ping');
$route->post("/ack")->to('editor#ack');
$route->post("/midgen")->to('editor#midgen');

eval { $app->_setup_dirs };
if ($@) {
Expand Down Expand Up @@ -125,6 +126,7 @@ sub support_can_be_enabled {
'Perl::Strip' => '1.1',
'Spellunker' => '0.0.17',
'Code::CutNPaste' => '0.04',
'App::Midgen' => '0.32',
);

my $version = $REQUIRED_VERSION{$module};
Expand Down
24 changes: 23 additions & 1 deletion lib/Farabi/Editor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,16 @@ sub menus {
order => 7,
};
};


if($self->app->support_can_be_enabled('App::Midgen')) {
$actions{'action-midgen'} = {
name => 'Find package dependencies (midgen)',
help => 'Find package dependencies in the current lib folder and outputs a sample Makefile DSL',
menu => $tools_menu,
order => 7,
};
};

require File::Which;
if(defined File::Which::which('jshint')) {
$actions{'action-jshint'} = {
Expand Down Expand Up @@ -1147,6 +1156,19 @@ sub ack {
$self->render(json => $o);
}

# Check requires & test_requires of your package for CPAN inclusion.
sub midgen {
my $self = shift;

my $o = $self->_capture_cmd_output( 'midgen', [] );

# Remove ansi color sequences
$o->{stdout} =~ s/\e\[[\d;]*[a-zA-Z]//g;
$o->{stderr} =~ s/\e\[[\d;]*[a-zA-Z]//g;

$self->render(json => $o);
}

sub perl_strip {
my $self = shift;
my $source = $self->param('source');
Expand Down
31 changes: 28 additions & 3 deletions lib/Farabi/files/public/farabi.js
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,11 @@ $(function() {
if(result.length > 0) {
var $outputEditor = GetOutputEditor();
$outputEditor.setValue(JSON.stringify(result));

// Show output tab
$('a[href="#output-tab"]').tab('show');

outputEditor.refresh();
}
});
});
Expand All @@ -1020,9 +1025,7 @@ $(function() {
$.post('/ack', {text: selection}, function(result) {

var searchEditor = GetSearchEditor();

console.warn(result);


searchEditor.setValue('');

// Handle STDERR
Expand All @@ -1041,4 +1044,26 @@ $(function() {
});
});

$(document).on('action-midgen', function() {
$.post('/midgen', {}, function(result) {

var outputEditor = GetOutputEditor();

outputEditor.setValue('');

// Handle STDERR
if (result.stderr.length) {
outputEditor.setValue(result.stderr + "\n");
}

// Handle STDOUT
outputEditor.setValue(outputEditor.getValue() + result.stdout);

// Show output tab
$('a[href="#output-tab"]').tab('show');

outputEditor.refresh();
});
});

});

0 comments on commit b0f541f

Please sign in to comment.