Module: Engage::Helpers

Included in:
Runner
Defined in:
lib/engage/helpers.rb

Instance Method Summary collapse

Instance Method Details

#default_sourcesObject



16
17
18
# File 'lib/engage/helpers.rb', line 16

def default_sources
  ["[email protected]"]
end

#file_pathObject



4
5
6
# File 'lib/engage/helpers.rb', line 4

def file_path
  File.join(ENV["HOME"], ".engage.sources")
end

#sourcesObject



8
9
10
# File 'lib/engage/helpers.rb', line 8

def sources
  File.exists?(file_path) ? YAML.load_file(file_path) : default_sources
end

#sources_tableObject



12
13
14
# File 'lib/engage/helpers.rb', line 12

def sources_table
  sources.each_with_index.to_a.map { |line| line.reverse }
end

#store(source) ⇒ Object



20
21
22
23
24
25
# File 'lib/engage/helpers.rb', line 20

def store(source)
  list = sources
  return false if list.include?(source)
  list << source
  File.open(file_path, 'w') { |f| f.write(YAML.dump(list.compact)) }
end