Teamocil::Layout#initialize now takes a layout, not a file

This commit is contained in:
Rémi Prévost 2011-10-08 10:31:03 -04:00
parent 514a13a35d
commit e6b5f04396
2 changed files with 9 additions and 6 deletions

View File

@ -24,7 +24,8 @@ module Teamocil
system("$EDITOR \"#{file}\"") system("$EDITOR \"#{file}\"")
else else
bail "There is no file \"#{file}\"" unless File.exists?(file) bail "There is no file \"#{file}\"" unless File.exists?(file)
layout = Teamocil::Layout.new(file, @options) parsed_layout = YAML.load_file(file)
layout = Teamocil::Layout.new(parsed_layout, @options)
layout.to_tmux layout.to_tmux
end end
end # }}} end # }}}

View File

@ -2,12 +2,12 @@ module Teamocil
# This class act as a wrapper around a tmux YAML layout file. # This class act as a wrapper around a tmux YAML layout file.
class Layout class Layout
# Initialize a new layout from a file # Initialize a new layout from a hash
# #
# @param file [String] the complete layout file path # @param layout [Hash] the parsed layout
# @param options [Hash] # @param options [Hash] some options
def initialize(file, options) # {{{ def initialize(layout, options) # {{{
@layout = YAML.load_file(file) @layout = layout
@options = options @options = options
end # }}} end # }}}
@ -18,6 +18,8 @@ module Teamocil
end # }}} end # }}}
# Generate tmux commands based on the data found in the layout file # Generate tmux commands based on the data found in the layout file
#
# @return [Array] an array of shell commands to send
def generate_commands # {{{ def generate_commands # {{{
output = [] output = []