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.12.3 lib/etcd.rb
gogetit-0.12.2 lib/etcd.rb
gogetit-0.12.1 lib/etcd.rb
gogetit-0.12.0 lib/etcd.rb
gogetit-0.11.0 lib/etcd.rb
gogetit-0.10.0 lib/etcd.rb
gogetit-0.9.0 lib/etcd.rb
gogetit-0.8.0 lib/etcd.rb
gogetit-0.7.0 lib/etcd.rb
gogetit-0.6.0 lib/etcd.rb
gogetit-0.5.3 lib/etcd.rb
gogetit-0.5.2 lib/etcd.rb
gogetit-0.5.1 lib/etcd.rb
gogetit-0.5.0 lib/etcd.rb
gogetit-0.4.2 lib/etcd.rb
gogetit-0.4.1 lib/etcd.rb
gogetit-0.4.0 lib/etcd.rb
gogetit-0.3.0 lib/etcd.rb
gogetit-0.2.1 lib/etcd.rb
gogetit-0.2.0 lib/etcd.rb