module Shelr
Constants
- API_KEY_CFG
- API_URL_CFG
- APP_NAME
- BACKEND_CFG
- CONFIG_DIR
- DATA_DIR
- VERSION
- XDG_CONFIG_DIR
- XDG_DATA_DIR
Public Class Methods
api_key()
click to toggle source
# File lib/shelr.rb, line 23 def api_key return false unless File.exist?(API_KEY_CFG) @api_key ||= File.read(API_KEY_CFG).strip end
api_key=(key)
click to toggle source
# File lib/shelr.rb, line 28 def api_key=(key) ensure_config_dir_exist File.open(API_KEY_CFG, 'w+') { |f| f.puts(key.strip) } end
api_url()
click to toggle source
# File lib/shelr.rb, line 33 def api_url return ENV['SHELR_LOCAL'] ? 'http://localhost:3000' : 'http://shelr.tv' unless File.exist?(API_URL_CFG) @api_url ||= File.read(API_URL_CFG).strip end
api_url=(url)
click to toggle source
# File lib/shelr.rb, line 38 def api_url=(url) ensure_config_dir_exist File.open(API_URL_CFG, 'w+') { |f| f.puts(url.strip) } end
backend()
click to toggle source
# File lib/shelr.rb, line 43 def backend @backend ||= File.exist?(BACKEND_CFG) ? File.read(BACKEND_CFG).strip : 'script' end
backend=(bin)
click to toggle source
# File lib/shelr.rb, line 47 def backend=(bin) unless ['script', 'ttyrec'].include?(bin) puts "Backend should be either `script` or `ttyrec`" exit 1 end ensure_config_dir_exist File.open(BACKEND_CFG, 'w+') { |f| f.puts(bin.strip) } end
data_dir(record_id)
click to toggle source
# File lib/shelr.rb, line 56 def data_dir(record_id) id = record_id.strip == 'last' ? last_id : record_id.to_s File.join(DATA_DIR, id) end
last_id()
click to toggle source
# File lib/shelr.rb, line 61 def last_id File.basename(Dir[File.join(DATA_DIR, '*')].sort.last) end
terminal()
click to toggle source
# File lib/shelr.rb, line 65 def terminal @terminal ||= Shelr::Terminal.new end
Private Class Methods
ensure_config_dir_exist()
click to toggle source
# File lib/shelr.rb, line 71 def ensure_config_dir_exist FileUtils.mkdir_p(CONFIG_DIR) unless File.exist?(CONFIG_DIR) end