Class: Cline::Command
- Inherits:
-
Thor
- Object
- Thor
- Cline::Command
- Defined in:
- lib/cline/command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #collect ⇒ Object
- #init ⇒ Object
- #recent(limit = options[:limit] || 1) ⇒ Object
- #search(keyword = optoins[:query]) ⇒ Object
- #show(offset = options[:offset] || 0) ⇒ Object
- #status ⇒ Object
- #tick(offset = options[:offset] || 0, interval = options[:interval] || 60) ⇒ Object
- #version ⇒ Object
Class Method Details
Instance Method Details
#collect ⇒ Object
48 49 50 51 52 |
# File 'lib/cline/command.rb', line 48 def collect Cline.collectors.each &:collect clean_obsoletes end |
#init ⇒ Object
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 = [:limit] || 1) Notification.recent_notified.limit(limit).each do |notification| say notification. 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. end end |
#show(offset = options[:offset] || 0) ⇒ Object
20 21 22 |
# File 'lib/cline/command.rb', line 20 def show(offset = [:offset] || 0) Notification.display offset end |
#status ⇒ Object
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 = [:offset] || 0, interval = [:interval] || 60) loop do show offset sleep interval.to_i end end |