tab: allow load from file content

This commit is contained in:
Xu Cheng 2015-05-23 18:08:07 +08:00
parent 296ca61510
commit ffd92a87c5

View File

@ -31,7 +31,11 @@ class Tab < OpenStruct
end end
def self.from_file path def self.from_file path
attributes = Utils::JSON.load(File.read(path)) from_file_content(File.read(path), path)
end
def self.from_file_content content, path
attributes = Utils::JSON.load(content)
attributes["tabfile"] = path attributes["tabfile"] = path
attributes["source"] ||= {} attributes["source"] ||= {}