Sha256: 50e9cc961ed1e671ca3e095fd20b41436bf0438562b89044021e8f58d2fe4085
Contents?: true
Size: 986 Bytes
Versions: 7
Compression:
Stored size: 986 Bytes
Contents
# -*- encoding : utf-8 -*- require 'json' module PhraseGem class 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 def api_port ENV.fetch("PHRASE_API_PORT", "443") end def api_host ENV.fetch("PHRASE_API_HOST", "phraseapp.com") end def api_path_prefix "/api/v1" end def api_use_ssl ENV.fetch("PHRASE_API_USE_SSL", "1") end private def config @config ||= {} end def save_config! File.open(".phrase", "w+") do |file| file.write(JSON.pretty_generate(config)) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems