Module: Fiveruns::Dash::Store::File

Included in:
Update
Defined in:
lib/fiveruns/dash/store/file.rb

Instance Method Summary collapse

Instance Method Details

#filename(directory) ⇒ Object



16
17
18
19
20
# File 'lib/fiveruns/dash/store/file.rb', line 16

def filename(directory)
  kind = payload.class.name =~ /(\w+)Payload/
  name = kind ? $1 : 'unknown'
  ::File.join(directory, "#{guid}.#{name}.json")
end

#store_file(*uris) ⇒ Object



5
6
7
8
9
10
# File 'lib/fiveruns/dash/store/file.rb', line 5

def store_file(*uris)
  uris.each do |uri|
    directory = uri.path
    write_to filename(directory)
  end
end

#write_to(path) ⇒ Object



12
13
14
# File 'lib/fiveruns/dash/store/file.rb', line 12

def write_to(path)
  ::File.open(path, 'w') { |f| f.write @payload.to_fjson }
end