add a binary runner and support for iTermfile

This commit is contained in:
John Bintz 2011-07-12 11:31:16 -04:00
parent 8e5ea076d6
commit 9ad331f7ca
4 changed files with 23 additions and 0 deletions

6
bin/iterm-window Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env ruby
require 'iterm_window'
ItermWindow.run_file(File.read('iTermfile'))

View File

@ -9,6 +9,7 @@ Gem::Specification.new do |s|
s.files = ['README.rdoc', 'LICENSE', 'lib/iterm_window.rb']
s.require_paths = ["lib"]
s.has_rdoc = true
s.executables << "iterm-window"
s.add_development_dependency 'rspec', '~> 2.6.0'
s.add_development_dependency 'fakefs'

View File

@ -100,6 +100,10 @@ class ItermWindow
@default_tab = nil
end
def self.run_file(file)
instance_eval(file)
end
# Creates a new terminal window, runs the block on it
def self.open(options = {}, &block)
self.new.run(:new, options, &block)

View File

@ -27,6 +27,18 @@ describe ItermWindow do
end
end
describe '.run_file' do
it "should read the file and create a window" do
ItermWindow.expects(:new).returns(@window)
@window.expects(:run).with(:new, {})
ItermWindow.run_file(<<-FILE)
open do
open_tab :test
end
FILE
end
end
describe "opening a tab (example 1)" do
before(:each) do
ItermWindow.expects(:new).returns(@window)