Module: Doppler

Defined in:
lib/doppler.rb,
lib/doppler/client.rb,
lib/doppler/version.rb

Defined Under Namespace

Classes: Client

Constant Summary collapse

VERSION =
"1.0.3".freeze
@@host_url =

configure doppler host url

"https://deploy.doppler.com"
@@api_key =

configure api key

ENV["DOPPLER_API_KEY"]
@@pipeline =

configure pipeline

ENV["DOPPLER_PIPELINE"]
@@environment =

configure environment

ENV["DOPPLER_ENVIRONMENT"]
@@ignore_variables =

configure ignore variables

[]
@@backup_filepath =

configure backup file

nil
@@env_filepath =

configure env file

".env"

Class Method Summary collapse

Class Method Details

.api_keyObject



18
19
20
# File 'lib/doppler.rb', line 18

def self.api_key
  @@api_key
end

.api_key=(api_key) ⇒ Object



15
16
17
# File 'lib/doppler.rb', line 15

def self.api_key=(api_key)
  @@api_key = api_key
end

.backup_filepathObject



54
55
56
# File 'lib/doppler.rb', line 54

def self.backup_filepath
  @@backup_filepath
end

.backup_filepath=(backup_filepath) ⇒ Object



51
52
53
# File 'lib/doppler.rb', line 51

def self.backup_filepath=(backup_filepath)
  @@backup_filepath = backup_filepath
end

.configure {|_self| ... } ⇒ Object

helper to configure above variables.

Yields:

  • (_self)

Yield Parameters:

  • _self (Doppler)

    the object that the method was called on



88
89
90
91
92
93
94
95
# File 'lib/doppler.rb', line 88

def self.configure
  yield(self)
  
  env_file = self.read_env(self.env_filepath) || {}
  self.api_key = self.api_key || env_file["DOPPLER_API_KEY"]
  self.pipeline = self.pipeline || env_file["DOPPLER_PIPELINE"]
  self.environment = self.environment || env_file["DOPPLER_ENVIRONMENT"]
end

.env_filepathObject



63
64
65
# File 'lib/doppler.rb', line 63

def self.env_filepath
  @@env_filepath
end

.env_filepath=(env_filepath) ⇒ Object



60
61
62
# File 'lib/doppler.rb', line 60

def self.env_filepath=(env_filepath)
  @@env_filepath = env_filepath
end

.environmentObject



36
37
38
# File 'lib/doppler.rb', line 36

def self.environment
  @@environment
end

.environment=(environment) ⇒ Object



33
34
35
# File 'lib/doppler.rb', line 33

def self.environment=(environment)
  @@environment = environment
end

.host_urlObject



9
10
11
# File 'lib/doppler.rb', line 9

def self.host_url
  @@host_url
end

.host_url=(host) ⇒ Object



6
7
8
# File 'lib/doppler.rb', line 6

def self.host_url=(host)
  @@host_url = host_url
end

.ignore_variablesObject



45
46
47
# File 'lib/doppler.rb', line 45

def self.ignore_variables
  @@ignore_variables
end

.ignore_variables=(ignore_variables) ⇒ Object



42
43
44
# File 'lib/doppler.rb', line 42

def self.ignore_variables=(ignore_variables)
  @@ignore_variables = ignore_variables
end

.pipelineObject



27
28
29
# File 'lib/doppler.rb', line 27

def self.pipeline
  @@pipeline
end

.pipeline=(pipeline) ⇒ Object



24
25
26
# File 'lib/doppler.rb', line 24

def self.pipeline=(pipeline)
  @@pipeline = pipeline
end

.read_env(path) ⇒ Object

read env file



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/doppler.rb', line 68

def self.read_env(path)
  if path.nil? or !File.file?(path)
    return nil
  end
  
  keys = {}
  File.open(path, "r") do |file|
    file.each do |line|
      parts = line.strip.split("=")
      
      if parts.length == 2
        keys[parts[0].strip] = parts[1].strip
      end
    end
  end
  
  return keys
end