From 8378f0e44da2c1235a63f41dc875d823fcf447ea Mon Sep 17 00:00:00 2001 From: 21croissants Date: Mon, 4 Oct 2010 15:05:37 +0200 Subject: [PATCH] added Terminal action in order to automate the workflow and launch a Terminal the first pomodoro of the day and maybe use http://github.com/achiu/terminitor to configure which tabs to open --- actions/terminal.rb | 22 ++++++++++++++++++++++ config.rb.sample | 1 + spec/actions/terminal_spec.rb | 25 +++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 actions/terminal.rb create mode 100644 spec/actions/terminal_spec.rb diff --git a/actions/terminal.rb b/actions/terminal.rb new file mode 100644 index 0000000..ab8620a --- /dev/null +++ b/actions/terminal.rb @@ -0,0 +1,22 @@ +class Terminal < CapreseAction + include Appscript + config_schema [String] + + def start + unless Terminal.caprese_application.running? + Terminal.caprese_application.activate! + app = Terminal.caprese_application.handle + app.do_script(config, :in => app.windows.first) + end + end + + def stop + end + + class << self + def caprese_application + @@terminal ||= Application.new("Terminal") + end + end + +end \ No newline at end of file diff --git a/config.rb.sample b/config.rb.sample index 958b613..39b473e 100644 --- a/config.rb.sample +++ b/config.rb.sample @@ -38,6 +38,7 @@ BlockDomains( LaunchApplications "Campfire", "Pivotal Tracker", "Ruby Docs (and others)", "TextMate" QuitApplications "Google Calendar", "Remember the Milk", "Preview" QuitAndBlockApplications "GMail", "Google Reader", "Google Voice", "Colloquy", "Mail", "TweetDeck" +Terminal "cd Code;git pull" AdiumStatus( :away => "Pomodoro! Ends at #{stop_time.to_short_time}", diff --git a/spec/actions/terminal_spec.rb b/spec/actions/terminal_spec.rb new file mode 100644 index 0000000..7c8ded9 --- /dev/null +++ b/spec/actions/terminal_spec.rb @@ -0,0 +1,25 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe Terminal do + + before :each do + @action = Terminal.new(["echo 'hello world!'"]) + end + + describe "#start" do + it "launch a Terminal only if it isn't running already" do + @action.start + Terminal.caprese_application.should be_running + end + + it "should run the script in the first windows" do + # I don't know how to write a test for this! + end + + after :each do + Terminal.caprese_application.quit! + end + + end + +end \ No newline at end of file