class Filer::Command
Public Instance Methods
add_directory(dir)
click to toggle source
# File lib/filer.rb, line 50 def add_directory(dir) Settings[:directories].push(dir) save_settings end
configure_s3(key, secret, bucket)
click to toggle source
# File lib/filer.rb, line 67 def configure_s3(key, secret, bucket) Settings[:s3_key], Settings[:s3_secret], Settings[:s3_bucket] = key, secret, bucket save_settings end
directories()
click to toggle source
# File lib/filer.rb, line 43 def directories Settings[:directories].each_with_index do |dir, i| puts "#{i+1}) #{dir}" end end
remove_directory(i)
click to toggle source
# File lib/filer.rb, line 57 def remove_directory(i) Settings[:directories].delete_at(i.to_i-1) save_settings puts "Updated. New directories: " directories end
s3()
click to toggle source
# File lib/filer.rb, line 21 def s3 params = [:s3_key, :s3_secret, :s3_bucket].map {|m| Settings[m]} unless params.compact.size == 3 puts "Please run filer configure-s3 first" exit end @s3 ||= Filer::S3.new(*params) end
save_settings()
click to toggle source
# File lib/filer.rb, line 17 def save_settings Settings.save!(CONFIG) end
search(keywords)
click to toggle source
# File lib/filer.rb, line 74 def search(keywords) results = Filer::Filed.searchable(keywords).all if results.empty? puts "No results found" return end results.each_with_index do |r, i| puts "#{i+1}) #{r.key} - #{r.highlight["attachment"].join(" ... ")}" end ix = ask("Index of file to open (q to exit):") return unless ix.to_i > 0 && results[ix.to_i - 1] s3.open_file(results[ix.to_i - 1].key.first) end
start_watching()
click to toggle source
# File lib/filer.rb, line 32 def start_watching watcher.daemonize! watcher.start! end
stop_watching()
click to toggle source
# File lib/filer.rb, line 38 def stop_watching watcher.stop! end
watcher()
click to toggle source
# File lib/filer.rb, line 13 def watcher Watcher.instance(Settings) end