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}\"")
else
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
end
end # }}}

View File

@ -2,12 +2,12 @@ module Teamocil
# This class act as a wrapper around a tmux YAML layout file.
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 options [Hash]
def initialize(file, options) # {{{
@layout = YAML.load_file(file)
# @param layout [Hash] the parsed layout
# @param options [Hash] some options
def initialize(layout, options) # {{{
@layout = layout
@options = options
end # }}}
@ -18,6 +18,8 @@ module Teamocil
end # }}}
# Generate tmux commands based on the data found in the layout file
#
# @return [Array] an array of shell commands to send
def generate_commands # {{{
output = []