Sha256: 4dfa097f23774b8eadec6d21abd88a41792d6bffaf45df61c87fbcbd74261d2e

Contents?: true

Size: 763 Bytes

Versions: 24

Compression:

Stored size: 763 Bytes

Contents

require 'json'
require 'etcd'

module Etcd
  class Etcd
    attr_reader :etcd_conn

    include Gogetit::Util

    def initialize(config)
      @etcd_conn = Etcd::Client.connect(uris: config[:etcd_url]).connect
    end

    def env_name
      if etcd_conn.get('env_name') == nil or etcd_conn.get('env_name') == ''
        etcd_conn.set('env_name', recognize_env)
        etcd_conn.get('env_name')
      else
        etcd_conn.get('env_name')
      end
    end

    def import_env
      file = File.read('lib/env/'+env_name+'.json')
      env_data = JSON.parse(file)
      etcd_conn.set('env', env_data.to_json)
    end

    def env
      if ! etcd_conn.get('env')
        import_env
      else
        JSON.parse(etcd_conn.get('env'))
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
gogetit-0.1.19 lib/etcd.rb
gogetit-0.1.18 lib/etcd.rb
gogetit-0.1.17 lib/etcd.rb
gogetit-0.1.16 lib/etcd.rb