Sha256: fae88d95c3bcc12ffd7268c886f465ca3b8020150e46d38c7e082680bf2968e1
Contents?: true
Size: 648 Bytes
Versions: 8
Compression:
Stored size: 648 Bytes
Contents
# -*- encoding : utf-8 -*- require 'phrase' require 'json' class Phrase::ToolConfig def initialize if File.exist?(".phrase") begin contents = File.read(".phrase") @config = JSON.parse(contents) rescue JSON::ParserError => err $stderr.puts "Could not parse config file: #{err}" end end end def secret config["secret"] end def secret=(new_secret) config["secret"] = new_secret save_config! end private def config @config ||= {} end def save_config! File.open(".phrase", "w+") do |file| file.write(JSON.pretty_generate(config)) end end end
Version data entries
8 entries across 8 versions & 1 rubygems