class Satisfaction::Persist

Public Class Methods

default_path() click to toggle source
# File lib/satisfaction/persist.rb, line 10
def default_path
  File.join(File.dirname(__FILE__), "../../data")
end
sentiment_path(sha) click to toggle source
# File lib/satisfaction/persist.rb, line 14
def sentiment_path(sha)
  sentiment = "#{default_path}/#{Time.now.strftime("%m_%d_%Y")}/"
  FileUtils.mkdir_p sentiment
  "#{sentiment}/#{sha}.json"
end
store(schema, payload, sha) click to toggle source
# File lib/satisfaction/persist.rb, line 6
def store(schema, payload, sha)
  File.open(sentiment_path(sha), "w") {|file| file.write(payload.to_json)} if Satisfaction::Validator.valid?(schema, payload)
end