Class: Cline::Command

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.startObject



5
6
7
8
# File 'lib/cline/command.rb', line 5

def self.start(*)
  Cline.boot
  super
end

Instance Method Details

#collectObject



48
49
50
51
52
# File 'lib/cline/command.rb', line 48

def collect
  Cline.collectors.each &:collect

  clean_obsoletes
end

#initObject



55
56
57
58
59
60
61
# File 'lib/cline/command.rb', line 55

def init
  ActiveRecord::Base.connection.create_table(:notifications) do |t|
    t.text     :message, null: false, default: ''
    t.integer  :display_count, null: false, default: 0
    t.datetime :notified_at, null: false
  end
end

#recent(limit = options[:limit] || 1) ⇒ Object



65
66
67
68
69
# File 'lib/cline/command.rb', line 65

def recent(limit = options[:limit] || 1)
  Notification.recent_notified.limit(limit).each do |notification|
    say notification.display_message
  end
end

#search(keyword = optoins[:query]) ⇒ Object



35
36
37
38
39
# File 'lib/cline/command.rb', line 35

def search(keyword = optoins[:query])
  Notification.by_keyword(keyword).each do |notification|
    say notification.display_message
  end
end

#show(offset = options[:offset] || 0) ⇒ Object



20
21
22
# File 'lib/cline/command.rb', line 20

def show(offset = options[:offset] || 0)
  Notification.display offset
end

#statusObject



42
43
44
45
# File 'lib/cline/command.rb', line 42

def status
  say "displayed : #{Notification.displayed.count}", :green
  say "total     : #{Notification.count}", :cyan
end

#tick(offset = options[:offset] || 0, interval = options[:interval] || 60) ⇒ Object



26
27
28
29
30
31
# File 'lib/cline/command.rb', line 26

def tick(offset = options[:offset] || 0, interval = options[:interval] || 60)
  loop do
    show offset
    sleep interval.to_i
  end
end

#versionObject



72
73
74
# File 'lib/cline/command.rb', line 72

def version
  say "cline version #{Cline::VERSION}"
end