consular-iterm 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "consular-iterm"
6
- s.version = "1.0.1"
6
+ s.version = "1.0.2"
7
7
  s.authors = ["Arthur Chiu"]
8
8
  s.email = ["mr.arthur.chiu@gmail.com"]
9
9
  s.homepage = "http://www.github.com/achiu/consular-iterm"
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency 'consular'
21
21
  s.add_dependency 'rb-appscript'
22
22
  s.add_development_dependency 'minitest'
23
+ s.add_development_dependency 'mocha'
23
24
 
24
25
  # specify any dependencies here; for example:
25
26
  # s.add_development_dependency "rspec"
@@ -13,7 +13,7 @@ module Consular
13
13
 
14
14
  class << self
15
15
 
16
- # Checks to see if the current system is darwin and
16
+ # Checks to see if the current system is darwin and
17
17
  # if $TERM_PROGRAM is iTerm.app
18
18
  #
19
19
  # @api public
@@ -80,15 +80,14 @@ module Consular
80
80
 
81
81
  # Prepend a title setting command prior to the other commands.
82
82
  #
83
- # @param [String] title
84
- # The title to set for the context of the commands.
85
- # @param [Array<String>] commands
86
- # The context of commands to preprend to.
83
+ # @param [String]
84
+ # The tab title.
85
+ # @param [Appscript::Reference]
86
+ # The tab instance resulting from #open_tab.
87
87
  #
88
88
  # @api public
89
- def set_title(title, commands)
90
- cmd = "PS1=\"$PS1\\[\\e]2;#{title}\\a\\]\""
91
- title ? commands.insert(0, cmd) : commands
89
+ def set_title(title, tab)
90
+ tab.name.set(title) if title
92
91
  end
93
92
 
94
93
  # Executes the commands for each designated window.
@@ -117,31 +116,31 @@ module Consular
117
116
  # @api public
118
117
  def execute_window(content, options = {})
119
118
  window_options = content[:options]
120
- _contents = content[:tabs]
121
- _first_run = true
119
+ tab_contents = content[:tabs]
120
+ first_run = true
122
121
 
123
- _contents.keys.sort.each do |key|
124
- _content = _contents[key]
125
- _options = content[:options]
126
- _name = options[:name]
122
+ tab_contents.keys.sort.each do |key|
123
+ tab_content = tab_contents[key]
124
+ tab_options = tab_content[:options] || {}
125
+ tab_name = tab_options[:name]
127
126
 
128
- _tab =
129
- if _first_run && !options[:default]
130
- open_window options.merge(window_options)
131
- else
132
- key == 'default' ? active_tab : open_tab(_options) && active_tab
133
- end
127
+ tab =
128
+ if first_run && !options[:default]
129
+ open_window options.merge(window_options)
130
+ else
131
+ key == 'default' ? active_tab : open_tab(tab_options) && active_tab
132
+ end
133
+ set_title tab_name, tab
134
134
 
135
- _first_run = false
136
- commands = prepend_befores _content[:commands], content[:before]
137
- commands = set_title _name, commands
135
+ first_run = false
136
+ commands = prepend_befores tab_content[:commands], content[:before]
138
137
 
139
138
  if content.key? :panes
140
- commands.each { |cmd| execute_command cmd, :in => _tab }
139
+ commands.each { |cmd| execute_command cmd, :in => tab }
141
140
  execute_panes content
142
141
  content.delete :panes
143
142
  else
144
- commands.each { |cmd| execute_command cmd, :in => _tab }
143
+ commands.each { |cmd| execute_command cmd, :in => tab }
145
144
  end
146
145
  end
147
146
  end
@@ -233,7 +232,7 @@ module Consular
233
232
 
234
233
  # to select panes; iTerm's Appscript select method does not work
235
234
  # as expected, we have to select via menu instead
236
- #
235
+ #
237
236
  # @param [String] direction
238
237
  # Direction to split the pane. The valid directions are:
239
238
  # 'Above', 'Below', 'Left', 'Right'
data/spec/iterm_spec.rb CHANGED
@@ -23,9 +23,16 @@ describe Consular::ITerm do
23
23
  assert_equal ['ls'], @core.prepend_befores(['ls'])
24
24
  end
25
25
 
26
- it "should set .set_title" do
27
- assert_equal ["PS1=\"$PS1\\[\\e]2;hey\\a\\]\"",'ls'], @core.set_title('hey', ['ls'])
28
- assert_equal ['ls'], @core.set_title(nil, ['ls'])
26
+ it "should set the title of the tab if one given" do
27
+ (name = Object.new).expects(:set)
28
+ (tab = Object.new).stubs(:name).returns(name)
29
+ @core.set_title('the title', tab)
30
+ end
31
+
32
+ it "should not bother setting the tab title if not one given" do
33
+ (name = Object.new).expects(:set).never
34
+ (tab = Object.new).stubs(:name).returns(name)
35
+ @core.set_title(nil, tab)
29
36
  end
30
37
 
31
38
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  gem 'minitest'
3
3
  require 'minitest/autorun'
4
+ require 'mocha'
4
5
  require File.expand_path('../../lib/consular/iterm', __FILE__)
5
6
 
6
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consular-iterm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-17 00:00:00.000000000Z
12
+ date: 2011-12-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: consular
16
- requirement: &2168686940 !ruby/object:Gem::Requirement
16
+ requirement: &2152532600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2168686940
24
+ version_requirements: *2152532600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rb-appscript
27
- requirement: &2168686220 !ruby/object:Gem::Requirement
27
+ requirement: &2152532160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2168686220
35
+ version_requirements: *2152532160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
38
- requirement: &2168685680 !ruby/object:Gem::Requirement
38
+ requirement: &2152531740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,18 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2168685680
46
+ version_requirements: *2152531740
47
+ - !ruby/object:Gem::Dependency
48
+ name: mocha
49
+ requirement: &2152485220 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2152485220
47
58
  description: Terminal Automation for ITerm via Consular
48
59
  email:
49
60
  - mr.arthur.chiu@gmail.com