From 9ad331f7ca37f9cc70593f6ba092dd78dfd20db8 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 12 Jul 2011 11:31:16 -0400 Subject: [PATCH] add a binary runner and support for iTermfile --- bin/iterm-window | 6 ++++++ iterm_window.gemspec | 1 + lib/iterm_window.rb | 4 ++++ spec/iterm_window_spec.rb | 12 ++++++++++++ 4 files changed, 23 insertions(+) create mode 100755 bin/iterm-window diff --git a/bin/iterm-window b/bin/iterm-window new file mode 100755 index 0000000..20d5596 --- /dev/null +++ b/bin/iterm-window @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +require 'iterm_window' + +ItermWindow.run_file(File.read('iTermfile')) + diff --git a/iterm_window.gemspec b/iterm_window.gemspec index ad82edc..535fca5 100644 --- a/iterm_window.gemspec +++ b/iterm_window.gemspec @@ -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' diff --git a/lib/iterm_window.rb b/lib/iterm_window.rb index 637d235..49b0b52 100755 --- a/lib/iterm_window.rb +++ b/lib/iterm_window.rb @@ -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) diff --git a/spec/iterm_window_spec.rb b/spec/iterm_window_spec.rb index 0b4bc6a..bafcb97 100644 --- a/spec/iterm_window_spec.rb +++ b/spec/iterm_window_spec.rb @@ -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)