Module: FirefoxJson::Session
- Defined in:
- lib/firefox-json/session.rb
Defined Under Namespace
Modules: Collection
Classes: Base, Entry, Session, Tab, Window
Constant Summary
collapse
- BAD_ARG =
'Not Firefox session data'.freeze
Class Method Summary
collapse
Class Method Details
.default(path) ⇒ Object
291
292
293
294
295
296
|
# File 'lib/firefox-json/session.rb', line 291
def self.default(path)
file = Session.file(path) || Session.recovery_file(path)
raise "No session file found under #{path}" if !file
load_file file
end
|
.load(string, path = nil) ⇒ Object
279
280
281
282
283
284
285
|
# File 'lib/firefox-json/session.rb', line 279
def self.load string, path=nil
data = JsFile.load(string)
raise ArgumentError, BAD_ARG unless data.is_a?(Hash)
klass = Base.choose_for(data)
raise RuntimeError, BAD_ARG unless klass
klass.new(data, path: path)
end
|
.load_file(path) ⇒ Object
287
288
289
|
# File 'lib/firefox-json/session.rb', line 287
def self.load_file(path)
load IO.read(path), path
end
|
.recovery(path) ⇒ Object
298
299
300
|
# File 'lib/firefox-json/session.rb', line 298
def self.recovery(path)
load_file Session.recovery_file(path)
end
|