add_command support, make things even tighter
This commit is contained in:
parent
00566d7de5
commit
622c2c1bb4
12
README.md
12
README.md
@ -63,6 +63,18 @@ In a nutshell:
|
|||||||
|
|
||||||
* `:dir` changes all tabs to the given directory before executing commands.
|
* `:dir` changes all tabs to the given directory before executing commands.
|
||||||
|
|
||||||
|
### Adding commands that tabs can execute
|
||||||
|
|
||||||
|
You can define your own tab commands with `ItermWindow.add_command`:
|
||||||
|
|
||||||
|
``` ruby
|
||||||
|
ItermWindow.add_command :guard do |group = nil|
|
||||||
|
command = "bundle exec guard"
|
||||||
|
command << " -g #{group}" if group
|
||||||
|
write_text command
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
More docs coming soon! Also, look at `lib/iterm_window.rb` for more usage examples.
|
More docs coming soon! Also, look at `lib/iterm_window.rb` for more usage examples.
|
||||||
|
|
||||||
* Developed March 17, 2008 by Chris Powers
|
* Developed March 17, 2008 by Chris Powers
|
||||||
|
@ -81,6 +81,10 @@ class ItermWindow
|
|||||||
def colors
|
def colors
|
||||||
@colors
|
@colors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_command(name, &block)
|
||||||
|
ItermWindow::Tab.send(:define_method, name, block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ItermWindow.colors = {
|
ItermWindow.colors = {
|
||||||
|
@ -39,6 +39,24 @@ FILE
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.add_command' do
|
||||||
|
before do
|
||||||
|
ItermWindow::Tab.send(:remove_method, :test) rescue nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should define a method on the Tab class' do
|
||||||
|
ItermWindow.add_command :test do |params|
|
||||||
|
params
|
||||||
|
end
|
||||||
|
|
||||||
|
ItermWindow::Tab.should have_a_method_named(:test, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
ItermWindow::Tab.send(:remove_method, :test) rescue nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "opening a tab (example 1)" do
|
describe "opening a tab (example 1)" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
ItermWindow.expects(:new).returns(@window)
|
ItermWindow.expects(:new).returns(@window)
|
||||||
|
@ -2,3 +2,9 @@ RSpec.configure do |c|
|
|||||||
c.mock_with :mocha
|
c.mock_with :mocha
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RSpec::Matchers.define :have_a_method_named do |name, arity|
|
||||||
|
match do |mod|
|
||||||
|
mod.method_defined?(name).should be_true
|
||||||
|
mod.instance_method(name).arity.should == arity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user