Class: Devup::DotenvLoadList

Inherits:
Object
  • Object
show all
Defined in:
lib/devup/dotenv_load_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(env: nil) ⇒ DotenvLoadList

Returns a new instance of DotenvLoadList.



3
4
5
# File 'lib/devup/dotenv_load_list.rb', line 3

def initialize(env: nil)
  @env = env&.to_sym
end

Instance Method Details

#env_defined?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/devup/dotenv_load_list.rb', line 35

def env_defined?
  !@env.nil?
end

#include?(val) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/devup/dotenv_load_list.rb', line 23

def include?(val)
  to_a.include? val
end

#index(val) ⇒ Object



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

def index(val)
  to_a.index val
end

#test?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/devup/dotenv_load_list.rb', line 31

def test?
  @env == :test
end

#to_aObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/devup/dotenv_load_list.rb', line 7

def to_a
  list = []

  list << ".env.#{@env}.local" if env_defined?

  # .env.local is ignored by dotenv-rails too. So behaviour is the same.
  # https://github.com/bkeepers/dotenv/blob/08f22148fb14019dce1e9b1d8ac1a74788e49e1b/lib/dotenv/rails.rb#L69
  list << ".env.local" unless test?

  list << ".env.services"
  list << ".env.#{@env}" if env_defined?
  list << ".env"

  list
end