twterm 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +4 -1
- data/lib/twterm.rb +1 -1
- data/lib/twterm/abstract_persistable_configuration.rb +118 -0
- data/lib/twterm/app.rb +21 -1
- data/lib/twterm/environment.rb +38 -0
- data/lib/twterm/event/message/abstract_message.rb +23 -0
- data/lib/twterm/event/message/error.rb +10 -0
- data/lib/twterm/event/message/info.rb +10 -0
- data/lib/twterm/event/message/success.rb +10 -0
- data/lib/twterm/event/message/warning.rb +10 -0
- data/lib/twterm/event/notification/abstract_notification.rb +17 -12
- data/lib/twterm/event/notification/direct_message.rb +30 -0
- data/lib/twterm/event/notification/favorite.rb +35 -0
- data/lib/twterm/event/notification/follow.rb +33 -0
- data/lib/twterm/event/notification/list_member_added.rb +33 -0
- data/lib/twterm/event/notification/mention.rb +35 -0
- data/lib/twterm/event/notification/quote.rb +35 -0
- data/lib/twterm/event/notification/retweet.rb +35 -0
- data/lib/twterm/key_mapper/abstract_key_mapper.rb +4 -4
- data/lib/twterm/list.rb +2 -1
- data/lib/twterm/message_window.rb +81 -0
- data/lib/twterm/notification_backend/abstract_notification_backend.rb +16 -0
- data/lib/twterm/notification_backend/inline_backend.rb +20 -0
- data/lib/twterm/notification_backend/terminal_notifier_backend.rb +23 -0
- data/lib/twterm/notification_backend/tmux_backend.rb +17 -0
- data/lib/twterm/notification_dispatcher.rb +36 -0
- data/lib/twterm/persistable_configuration_proxy.rb +82 -0
- data/lib/twterm/preferences.rb +66 -0
- data/lib/twterm/repository/abstract_expirable_entity_repository.rb +1 -1
- data/lib/twterm/rest_client.rb +12 -14
- data/lib/twterm/scheduler.rb +1 -1
- data/lib/twterm/screen.rb +1 -1
- data/lib/twterm/search_query_window.rb +2 -2
- data/lib/twterm/streaming_client.rb +54 -17
- data/lib/twterm/tab/base.rb +2 -3
- data/lib/twterm/tab/new/list.rb +2 -4
- data/lib/twterm/tab/new/start.rb +10 -0
- data/lib/twterm/tab/new/user.rb +2 -2
- data/lib/twterm/tab/preferences/index.rb +74 -0
- data/lib/twterm/tab/preferences/notification_backend.rb +85 -0
- data/lib/twterm/tab/scrollable.rb +0 -1
- data/lib/twterm/tab/searchable.rb +7 -7
- data/lib/twterm/tab/user_list_management.rb +3 -3
- data/lib/twterm/tab/user_tab.rb +6 -8
- data/lib/twterm/tab_manager.rb +4 -4
- data/lib/twterm/tweetbox.rb +1 -1
- data/lib/twterm/uri_opener.rb +2 -2
- data/lib/twterm/user.rb +2 -1
- data/lib/twterm/version.rb +1 -1
- data/twterm.gemspec +4 -2
- metadata +59 -14
- data/lib/twterm/event/favorite.rb +0 -18
- data/lib/twterm/event/follow.rb +0 -17
- data/lib/twterm/event/notification/error.rb +0 -13
- data/lib/twterm/event/notification/info.rb +0 -13
- data/lib/twterm/event/notification/success.rb +0 -13
- data/lib/twterm/event/notification/warning.rb +0 -13
- data/lib/twterm/notifier.rb +0 -82
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'twterm/client'
|
2
|
-
require 'twterm/event/base'
|
3
|
-
require 'twterm/user'
|
4
|
-
require 'twterm/status'
|
5
|
-
|
6
|
-
module Twterm
|
7
|
-
module Event
|
8
|
-
class Favorite < Base
|
9
|
-
def fields
|
10
|
-
{
|
11
|
-
source: ::Twterm::User,
|
12
|
-
target: ::Twterm::Status,
|
13
|
-
authenticating_user: ::Twterm::Client
|
14
|
-
}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/twterm/event/follow.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'twterm/client'
|
2
|
-
require 'twterm/event/base'
|
3
|
-
require 'twterm/user'
|
4
|
-
|
5
|
-
module Twterm
|
6
|
-
module Event
|
7
|
-
class Follow < Base
|
8
|
-
def fields
|
9
|
-
{
|
10
|
-
source: ::Twterm::User,
|
11
|
-
target: ::Twterm::User,
|
12
|
-
authenticating_user: ::Twterm::Client
|
13
|
-
}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/twterm/notifier.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'twterm/subscriber'
|
2
|
-
require 'twterm/event/favorite'
|
3
|
-
require 'twterm/event/notification/abstract_notification'
|
4
|
-
require 'twterm/event/screen/resize'
|
5
|
-
|
6
|
-
module Twterm
|
7
|
-
class Notifier
|
8
|
-
include Singleton
|
9
|
-
include Curses
|
10
|
-
include Subscriber
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@window = stdscr.subwin(1, stdscr.maxx, stdscr.maxy - 2, 0)
|
14
|
-
@queue = Queue.new
|
15
|
-
|
16
|
-
subscribe(Event::Favorite) do |e|
|
17
|
-
next if e.source.id == e.authenticating_user.user_id
|
18
|
-
|
19
|
-
msg = '@%s has favorited your tweet: %s' % [
|
20
|
-
e.source.screen_name, e.target.text
|
21
|
-
]
|
22
|
-
show_info(msg)
|
23
|
-
end
|
24
|
-
|
25
|
-
subscribe(Event::Notification::AbstractNotification) do |e|
|
26
|
-
queue(e)
|
27
|
-
end
|
28
|
-
|
29
|
-
subscribe(Event::Screen::Resize, :resize)
|
30
|
-
|
31
|
-
Thread.new do
|
32
|
-
while notification = @queue.pop
|
33
|
-
show(notification)
|
34
|
-
sleep 3
|
35
|
-
show
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def show_info(message)
|
41
|
-
notification = Event::Notification::Info.new(message)
|
42
|
-
@queue.push(notification)
|
43
|
-
self
|
44
|
-
end
|
45
|
-
|
46
|
-
def show(notification = nil)
|
47
|
-
loop do
|
48
|
-
break unless closed?
|
49
|
-
sleep 0.5
|
50
|
-
end
|
51
|
-
|
52
|
-
@window.clear
|
53
|
-
|
54
|
-
if notification.is_a?(Event::Notification::AbstractNotification)
|
55
|
-
fg_color, bg_color = notification.color
|
56
|
-
|
57
|
-
@window.with_color(fg_color, bg_color) do
|
58
|
-
@window.setpos(0, 0)
|
59
|
-
@window.addstr(' ' * @window.maxx)
|
60
|
-
@window.setpos(0, 1)
|
61
|
-
time = notification.time.strftime('[%H:%M:%S]')
|
62
|
-
message = notification.message.gsub("\n", ' ')
|
63
|
-
@window.addstr("#{time} #{message}")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
@window.refresh
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def queue(notification)
|
73
|
-
@queue.push(notification)
|
74
|
-
self
|
75
|
-
end
|
76
|
-
|
77
|
-
def resize(event)
|
78
|
-
@window.resize(1, stdscr.maxx)
|
79
|
-
@window.move(stdscr.maxy - 2, 0)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|