Sha256: e804ef217ba53f62e66a50dfbab426a88b88068b81062c1a9c0db4abaf522e0c

Contents?: true

Size: 823 Bytes

Versions: 2

Compression:

Stored size: 823 Bytes

Contents

require "voltos/version"

require "curb"
require "json"

module Voltos
  class << self
    attr_accessor :configuration
  end

  def self.configure
    self.configuration ||= Configuration.new
    yield(configuration)
  end
  
  def self.foobar
    puts "API key is: #{Voltos.configuration.api_key}"
  end
  
  def self.load
    env_str = Curl.get("https://voltos.online/v1/credentials") do |http|
      http.headers["Authorization"] = "Token token=#{Voltos.configuration.api_key}"
    end
    Voltos.configuration.envs = JSON.parse(env_str.body_str)
  end
  
  def self.keys
    Voltos.configuration.envs.keys
  end
  
  def self.key(env_key)
    Voltos.configuration.envs[env_key]
  end
  
  class Configuration
    attr_accessor :api_key
    attr_accessor :envs

    def initialize
      @api_key = ""
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
voltos-0.0.6 lib/voltos.rb
voltos-0.0.5 lib/voltos.rb