Created
September 11, 2010 14:45
-
-
Save anonymous/575243 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<textarea name="styled-results" id="rake"><%= @lines %></textarea> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def call_rake(task, os, options = {}) | |
options[:rails_env] ||= Rails.env | |
args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" } | |
system "/usr/bin/rake #{task} #{args.join(' ')} --trace" if os == 'linux' | |
system "START /B rake.bat #{task} #{args.join(' ')} --trace" if os == 'windows' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textarea#rake { | |
width: 550px; | |
height: 200px; | |
border: 3px solid #cccccc; | |
padding: 5px; | |
font-family: Tahoma, sans-serif; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Example Task to run manually" | |
task :example_task => :environment do | |
#************************************************************************************************ | |
# Perform an example task | |
#************************************************************************************************ | |
model_example = MyModel.find(:all) | |
File.open(RAKE_FILE_LOGS, "w") { |f| | |
f.puts "Rake File: My Example Task| #{Time.now}" | |
f.puts "_________________________________________________________________________" | |
model_example.each do |line| | |
f.puts "Row example data #{line.name}" | |
end | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="content" style="width:905px;"> | |
<div id="conttwothirds"> | |
<h3 style="clear:left;">Rake Tasks (In <%= Rails.env.to_s.capitalize %> Mode)</h3> | |
<p class="padding-left"><strong><%= link_to_remote( "Read Rake Results", :url =>{ :controller => "raketasks", :action => :call_render }) %></strong></p> | |
<div id="rake"></div> | |
</div> | |
<div id="contonethird"> | |
<h5 class="side" style="margin-top:20px;">My Rake Tasks</h5> | |
<ul> | |
<li><%= link_to "Example Rake Task", rake_example_task %></li> | |
</ul> | |
<h5 class="side" style="margin-top:20px;">Other Rake Tasks</h5> | |
<ul> | |
<li>Etc..</li> | |
<li>Etc..</li> | |
<li>Etc..</li> | |
</ul> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RaketasksController < ApplicationController | |
before_filter :login_required, :authorize | |
before_filter :set_pagetitle | |
def set_pagetitle | |
@pagetitle = "Raketasks" | |
end | |
def index | |
end | |
def rake_example_task | |
Rails.env == 'development' ? (call_rake :example_task, 'windows') : (call_rake :example_task, 'linux') | |
flash[:notice] = "Example task is running." | |
redirect_to raketasks_url | |
end | |
def call_render | |
@lines = "" | |
rakeread = IO.readlines(RAKE_FILE_LOGS) | |
rakeread.each do |line| | |
@lines << line | |
end | |
render :update do |page| | |
page.replace_html "rake", :partial => "rake_partial" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.resources :raketasks, :only => :index | |
map.rake_example_task '/rake_example_task', :controller => 'raketasks', :action => 'rake_example_task' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment