Class: CTT::Cli::Suites

Inherits:
Object show all
Defined in:
lib/cli/suites.rb

Constant Summary collapse

SUITES_CONFIG_FILE =
File.absolute_path(File.join(ENV["HOME"], ".tac/suites.yml"))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSuites

Returns a new instance of Suites.



13
14
15
16
# File 'lib/cli/suites.rb', line 13

def initialize
  load
  save
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



11
12
13
# File 'lib/cli/suites.rb', line 11

def file
  @file
end

#suitesObject

Returns the value of attribute suites.



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

def suites
  @suites
end

Instance Method Details

#loadObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cli/suites.rb', line 18

def load
  @file = SUITES_CONFIG_FILE
  unless Dir.exists?(File.dirname(@file))
    Dir.mkdir(File.dirname(@file))
  end

  if File.exists?(@file)
    @suites = YAML.load_file(@file)
  else
    @suites = {"suites" => {}}
  end
end

#saveObject



31
32
33
# File 'lib/cli/suites.rb', line 31

def save
  File.open(@file, "w") { |f| f.write YAML.dump(@suites) }
end