Sha256: cc07d4d143d6d9da6b4c84e97236d1e8eb61d0b6356abfde549c94fa14f04594

Contents?: true

Size: 735 Bytes

Versions: 27

Compression:

Stored size: 735 Bytes

Contents

require 'yaml'

def saveConfig(action, type, data)
  # Load the yaml file
  config_file = File.join(ENV['HOME'], ".negroku")
  config = getConfig

  # If I need to add some multiple values
  if action === :add
    newData = config[type] || []
    newData.push(data)
    newData.uniq!
    config = config.merge({ type => newData })
  elsif action === :remove
    #..
  elsif action === :replace
    #..
  end

  File.open(config_file, 'w') do |f|
    f.write config.to_yaml
  end
end

def getConfig
  # load config from file
  config_file = File.join(ENV['HOME'], ".negroku")

  # create an empty .negroku file
  unless File.exist?(config_file)
    %x(touch #{config_file})
  end

  # base config
  YAML.load_file(config_file) || {}
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
negroku-1.1.14 lib/negroku/config.rb
negroku-1.1.13 lib/negroku/config.rb
negroku-1.1.12 lib/negroku/config.rb
negroku-1.1.11 lib/negroku/config.rb
negroku-1.1.10 lib/negroku/config.rb
negroku-1.1.9 lib/negroku/config.rb
negroku-1.1.8 lib/negroku/config.rb
negroku-1.1.7 lib/negroku/config.rb
negroku-1.1.6 lib/negroku/config.rb
negroku-1.1.5 lib/negroku/config.rb
negroku-1.1.4 lib/negroku/config.rb
negroku-1.1.3 lib/negroku/config.rb
negroku-1.1.2 lib/negroku/config.rb
negroku-1.1.1 lib/negroku/config.rb
negroku-1.1.0 lib/negroku/config.rb
negroku-1.0.0 lib/negroku/config.rb
negroku-0.0.12 lib/negroku/config.rb
negroku-0.0.11 lib/negroku/config.rb
negroku-0.0.10 lib/negroku/config.rb
negroku-0.0.9 lib/negroku/config.rb