Class: UnimatrixCLI::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/unimatrix_cli/config/configuration.rb

Class Method Summary collapse

Class Method Details

.access_tokenObject



28
29
30
31
32
# File 'lib/unimatrix_cli/config/configuration.rb', line 28

def access_token
  @access_token ||= begin
    File.read( access_token_file_path ).chomp if File.file?( access_token_file_path )
  end
end

.access_token_file_pathObject



51
52
53
54
55
# File 'lib/unimatrix_cli/config/configuration.rb', line 51

def access_token_file_path
  @access_token_file_path ||= begin
    File.join( unimatrix_directory_path, "/.access_token" )
  end
end

.default_configObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/unimatrix_cli/config/configuration.rb', line 8

def default_config
  @default_config ||= begin
    default_config_path = File.join( 
      File.dirname( __FILE__ ), "./#{ environment }.yml"
    )
    if File.file?( default_config_path ) && region.present?
      default_config_file = YAML.load_file( default_config_path )
      default_config_file[ region ]
    else
      {}
    end
  end
end

.environmentObject



22
23
24
25
26
# File 'lib/unimatrix_cli/config/configuration.rb', line 22

def environment
  @environment ||= begin
    File.read( environment_file_path ).chomp if File.file?( environment_file_path )
  end
end

.environment_file_pathObject



45
46
47
48
49
# File 'lib/unimatrix_cli/config/configuration.rb', line 45

def environment_file_path
  @environment_file_path ||= begin
    File.join( unimatrix_directory_path, "/.environment" )
  end
end

.regionObject



34
35
36
37
38
39
# File 'lib/unimatrix_cli/config/configuration.rb', line 34

def region
  @region ||= begin
    File.read( region_file_path ).chomp if File.file?( region_file_path ) || 
    ENV[ 'AWS_REGION' ]
  end
end

.region_file_pathObject



57
58
59
60
61
# File 'lib/unimatrix_cli/config/configuration.rb', line 57

def region_file_path
  @region_file_path ||= begin
    File.join( unimatrix_directory_path, "/.region" )
  end
end

.unimatrix_directory_pathObject



41
42
43
# File 'lib/unimatrix_cli/config/configuration.rb', line 41

def unimatrix_directory_path
  @unimatrix_directory_path ||= File.join( Dir.home, ".unimatrix" )
end