Sha256: 768c0fa34bb123e9f57360d9c60451cc77a5e503cafb3b0e2cccf44ff8c695cc

Contents?: true

Size: 802 Bytes

Versions: 11

Compression:

Stored size: 802 Bytes

Contents

require 'yaml'

module ConfigFileHelpers
  def config_file_location
    File.expand_path(File.join(aruba.current_directory, '.ey-core'))
  end

  def write_config_file(hash = {})
    c = File.open(config_file_location, 'w')
    c.write(hash.to_yaml)
    c.close
  end

  def read_config_file
    begin
      YAML.load_file(File.read(config_file_location))
    rescue
      {}
    end
  end

  def nuke_config_file
    FileUtils.rm_f(config_file_location) if File.exist?(config_file_location)
  end

  def add_config_option(hash = {})
    current = read_config_file
    write_config_file(current.merge(hash))
  end

  def remove_config_option(key)
    current = read_config_file
    current.delete(key)
    write_config_file(current)
  end
end

World(ConfigFileHelpers)

After do
  nuke_config_file
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
ey-core-3.6.0.autoscaling1 features/support/config_file_helpers.rb
ey-core-3.6.4 features/support/config_file_helpers.rb
ey-core-3.6.3 features/support/config_file_helpers.rb
ey-core-3.6.1 features/support/config_file_helpers.rb
groove-ey-core-3.6.3 features/support/config_file_helpers.rb
groove-ey-core-3.6.2 features/support/config_file_helpers.rb
groove-ey-core-3.6.1 features/support/config_file_helpers.rb
ey-core-3.5.0 features/support/config_file_helpers.rb
ey-core-3.4.4 features/support/config_file_helpers.rb
ey-core-3.4.2 features/support/config_file_helpers.rb
ey-core-3.4.1 features/support/config_file_helpers.rb