Class: Feedcellar::Curses::Command

Inherits:
Thor
  • Object
show all
Defined in:
lib/feedcellar/curses/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Command

Returns a new instance of Command.



30
31
32
33
34
35
# File 'lib/feedcellar/curses/command.rb', line 30

def initialize(*args)
  super
  default_base_dir = File.join(File.expand_path("~"), ".feedcellar")
  @base_dir = ENV["FEEDCELLAR_HOME"] || default_base_dir
  @database_dir = File.join(@base_dir, "db")
end

Instance Attribute Details

#database_dirObject (readonly)

Returns the value of attribute database_dir.



28
29
30
# File 'lib/feedcellar/curses/command.rb', line 28

def database_dir
  @database_dir
end

Instance Method Details

#search(*words) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/feedcellar/curses/command.rb', line 49

def search(*words)
  if words.empty? &&
     (options["resource"].nil? || options["resource"].empty?)
    $stderr.puts "WARNING: required one of word or resource option."
    return 1
  end

  GroongaDatabase.new.open(@database_dir) do |database|
    sorted_feeds = GroongaSearcher.search(database, words, options)
    View.run(sorted_feeds)
  end
end

#versionObject



38
39
40
# File 'lib/feedcellar/curses/command.rb', line 38

def version
  puts VERSION
end