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
- #open(alias_string = options[:hint]) ⇒ 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
62 63 64 65 66 |
# File 'lib/cline/command.rb', line 62 def collect Cline.collectors.each &:collect clean_obsoletes end |
#init ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/cline/command.rb', line 69 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 |
#open(alias_string = options[:hint]) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/cline/command.rb', line 45 def open(alias_string = [:hint]) notification = Notification.by_alias_string(alias_string).last if notification && url = notification.detect_url Launchy.open url else say 'No URL found', :red end end |
#recent(limit = options[:limit] || 1) ⇒ Object
79 80 81 82 83 |
# File 'lib/cline/command.rb', line 79 def recent(limit = [:limit] || 1) Notification.recent_notified.limit(limit).each do |notification| say notification. end end |
#search(keyword = optoins[:query]) ⇒ Object
37 38 39 40 41 |
# File 'lib/cline/command.rb', line 37 def search(keyword = optoins[:query]) Notification.by_keyword(keyword).each do |notification| say notification. end end |
#show(offset = options[:offset] || 0) ⇒ Object
22 23 24 |
# File 'lib/cline/command.rb', line 22 def show(offset = [:offset] || 0) Notification.display offset end |
#status ⇒ Object
56 57 58 59 |
# File 'lib/cline/command.rb', line 56 def status say "displayed : #{Notification.displayed.count}", :green say "total : #{Notification.count}", :cyan end |
#tick(offset = options[:offset] || 0, interval = options[:interval] || 60) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/cline/command.rb', line 28 def tick(offset = [:offset] || 0, interval = [:interval] || 60) loop do show offset sleep interval.to_i end end |