Module: Engage::Helpers
- Included in:
- Runner
- Defined in:
- lib/engage/helpers.rb
Instance Method Summary collapse
- #default_sources ⇒ Object
- #file_path ⇒ Object
- #sources ⇒ Object
- #sources_table ⇒ Object
- #store(source) ⇒ Object
Instance Method Details
#default_sources ⇒ Object
16 17 18 |
# File 'lib/engage/helpers.rb', line 16 def default_sources ["[email protected]"] end |
#file_path ⇒ Object
4 5 6 |
# File 'lib/engage/helpers.rb', line 4 def file_path File.join(ENV["HOME"], ".engage.sources") end |
#sources ⇒ Object
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_table ⇒ Object
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 |