lib/taskr/actions.rb in taskr-0.1.0 vs lib/taskr/actions.rb in taskr-0.2.0
- old
+ new
@@ -60,14 +60,17 @@
$LOG.info("Executing task #{self.task.name}")
execute
task.update_attribute(:last_triggered, Time.now)
task.update_attribute(:last_triggered_error, nil)
rescue => e
+ puts
$LOG.error(e)
- $LOG.debug(e.backtrace.to_s)
+ $LOG.debug(e.backtrace.join($/))
+ details = e.message
+ details += "\n\n#{$LAST_ERROR_BODY}" if $LAST_ERROR_BODY # dumb way of reading Restr errors... Restr needs to be fixed
task.update_attribute(:last_triggered, Time.now)
- task.update_attribute(:last_triggered_error, {:type => e.class.to_s, :message => e.message})
+ task.update_attribute(:last_triggered_error, {:type => e.class.to_s, :message => details})
raise e
end
end
end
@@ -208,23 +211,44 @@
Restr.do(parameters['method'], parameters['url'], parameters['params'], auth)
end
end
class Howlr < Rest
- self.parameters = ['url', 'from', 'recipients', 'subject', 'body', 'username', 'password']
+ self.parameters = ['url', 'from', 'recipients', 'subject', 'body', 'username', 'password', 'content_type']
self.description = "Send a message through a Howlr service."
def execute
+ content_type = parameters['content_type']
+ content_type = 'text/plain' if content_type.blank?
+
parameters['method'] = 'post'
parameters['params'] = {
+ 'content_type' => content_type,
'from' => parameters['from'],
'recipients' => parameters['recipients'],
'subject' => parameters['subject'],
'body' => parameters['body'],
'format' => 'XML'
}
super
+ end
+ end
+
+ class Taskr4rails < Base
+ self.parameters = ['url', 'auth', 'ruby_code']#, 'shell_command']
+ self.description = "Executes code on a remote Rails server via the taskr4rails plugin."
+
+ def execute
+ data = {
+ :auth => parameters['auth'],
+ :ruby_code => parameters['ruby_code']#,
+ #:shell_command => parameters['shell_command']
+ }
+
+
+ Restr.logger = $LOG
+ Restr.post(parameters['url'], data)
end
end
end
end
\ No newline at end of file