Class: ET::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_dir) ⇒ Config

Returns a new instance of Config.



8
9
10
# File 'lib/et/config.rb', line 8

def initialize(current_dir)
  @current_dir = current_dir
end

Instance Attribute Details

#current_dirObject (readonly)

Returns the value of attribute current_dir.



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

def current_dir
  @current_dir
end

Instance Method Details

#[](key) ⇒ Object



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

def [](key)
  options[key]
end

#exists?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/et/config.rb', line 32

def exists?
  !path.nil?
end

#hostObject



16
17
18
19
20
21
22
# File 'lib/et/config.rb', line 16

def host
  if options["host"].start_with?("http")
    options["host"]
  else
    "http://" + options["host"]
  end
end

#pathObject



12
13
14
# File 'lib/et/config.rb', line 12

def path
  @path ||= find_config_file(current_dir)
end

#save!(options) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/et/config.rb', line 40

def save!(options)
  if exists?
    File.write(path, options.to_yaml)
  else
    File.write(File.join(current_dir, ".et"), options.to_yaml)
  end
end

#tokenObject



28
29
30
# File 'lib/et/config.rb', line 28

def token
  options["token"]
end

#usernameObject



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

def username
  options["username"]
end