@@ -26,19 +26,57 @@ def tmuxinator_to_tmuxp(sconf):
2626
2727 tmuxp_config = {}
2828
29- tmuxp_config ['session_name' ] = None
29+ if 'project_name' in sconf :
30+ tmuxp_config ['session_name' ] = sconf ['project_name' ]
31+ else :
32+ tmuxp_config ['session_name' ] = None
33+
34+ if 'cli_args' in sconf :
35+ tmuxp_config ['config' ] = sconf ['cli_args' ]
36+
37+ if '-f' in tmuxp_config ['config' ]:
38+ tmuxp_config ['config' ] = tmuxp_config ['config' ].replace ('-f' , '' ).strip ()
39+
40+ if 'socket_name' in sconf :
41+ tmuxp_config ['socket_name' ] = sconf ['socket_name' ]
3042
3143 tmuxp_config ['windows' ] = []
44+ logger .error (sconf )
45+ if 'tabs' in sconf :
46+ sconf ['windows' ] = sconf .pop ('tabs' )
47+
48+ if 'pre' in sconf :
49+ if isinstance (sconf ['pre' ], basestring ):
50+ tmuxp_config ['shell_command_before' ] = [sconf ['pre' ]]
51+ else :
52+ tmuxp_config ['shell_command_before' ] = sconf ['pre' ]
53+
54+ if 'rbenv' in sconf :
55+ if 'shell_command_before' not in tmuxp_config :
56+ tmuxp_config ['shell_command_before' ] = []
57+ tmuxp_config ['shell_command_before' ].append (
58+ 'rbenv %s' % sconf ['rbenv' ]
59+ )
60+
3261 for w in sconf ['windows' ]:
3362 for k , v in w .items ():
3463
3564 windowdict = {}
3665
3766 windowdict ['window_name' ] = k
67+
68+ logger .error ('%s, %s' % (k , v ))
69+
70+ if isinstance (v , basestring ) or v is None :
71+ windowdict ['panes' ] = [v ]
72+ continue
73+
74+ if 'pre' in v :
75+ logger .error (v ['pre' ])
76+ windowdict ['shell_command_before' ] = v ['pre' ]
3877 if 'panes' in v :
3978 windowdict ['panes' ] = v ['panes' ]
40- if isinstance (v , basestring ):
41- windowdict ['panes' ] = [v ]
79+
4280 if 'layout' in v :
4381 windowdict ['layout' ] = v ['layout' ]
4482 tmuxp_config ['windows' ].append (windowdict )
@@ -111,7 +149,8 @@ def test_config_to_dict(self):
111149 yaml_to_dict = test_config .get ()
112150 self .assertDictEqual (yaml_to_dict , self .tmuxinator_dict )
113151
114- self .assertEqual (tmuxinator_to_tmuxp (yaml_to_dict ), self .tmuxp_dict )
152+ self .assertDictEqual (tmuxinator_to_tmuxp (yaml_to_dict ), self .tmuxp_dict )
153+
115154
116155class TmuxinatorDeprecationsTest (unittest .TestCase ):
117156
@@ -205,13 +244,96 @@ class TmuxinatorDeprecationsTest(unittest.TestCase):
205244 ]
206245 }
207246
247+ tmuxp_dict = {
248+ 'session_name' : 'sample' ,
249+ 'socket_name' : 'foo' ,
250+ 'config' : '~/.tmux.mac.conf' ,
251+ 'shell_command_before' : [
252+ 'sudo /etc/rc.d/mysqld start' ,
253+ 'rbenv 2.0.0-p247'
254+ ],
255+ 'windows' : [
256+ {
257+ 'window_name' : 'editor' ,
258+ 'shell_command_before' : [
259+ 'echo "I get run in each pane, before each pane command!"' ,
260+ None
261+ ],
262+ 'layout' : 'main-vertical' ,
263+ 'panes' : [
264+ 'vim' ,
265+ None ,
266+ 'top'
267+ ]
268+ },
269+ {
270+ 'window_name' : 'shell' ,
271+ 'layout' : 'layout' ,
272+ 'panes' : [
273+ 'git pull'
274+ ]
275+ },
276+ {
277+ 'window_name' : 'guard' ,
278+ 'layout' : 'tiled' ,
279+ 'shell_command_before' : [
280+ 'echo "I get run in each pane."' ,
281+ 'echo "Before each pane command!"'
282+ ],
283+ 'panes' : [
284+ None ,
285+ None ,
286+ None
287+ ]
288+ },
289+ {
290+ 'window_name' : 'database' ,
291+ 'panes' : [
292+ 'bundle exec rails db'
293+ ]
294+ },
295+ {
296+ 'window_name' : 'server' ,
297+ 'panes' : [
298+ 'bundle exec rails s'
299+ ]
300+ },
301+ {
302+ 'window_name' : 'logs' ,
303+ 'panes' : [
304+ 'tail -f log/development.log'
305+ ]
306+ },
307+ {
308+ 'window_name' : 'console' ,
309+ 'panes' : [
310+ 'bundle exec rails c'
311+ ]
312+ },
313+ {
314+ 'window_name' : 'capistrano' ,
315+ 'panes' : [
316+ None
317+ ]
318+ },
319+ {
320+ 'window_name' : 'server' ,
321+ 'panes' : [
322+ 'ssh user@example.com'
323+ ]
324+ }
325+ ]
326+ }
327+
208328 def test_config_to_dict (self ):
209329 self .maxDiff = None
210330 configparser = kaptan .Kaptan (handler = 'yaml' )
211331 test_config = configparser .import_config (self .tmuxinator_yaml )
212332 yaml_to_dict = test_config .get ()
213333 self .assertDictEqual (yaml_to_dict , self .tmuxinator_dict )
214334
335+ self .assertDictEqual (tmuxinator_to_tmuxp (yaml_to_dict ), self .tmuxp_dict )
336+
215337
216338class TmuxinatoriSampleTest (unittest .TestCase ):
217339
0 commit comments