twterm 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +4 -1
  3. data/lib/twterm.rb +1 -1
  4. data/lib/twterm/abstract_persistable_configuration.rb +118 -0
  5. data/lib/twterm/app.rb +21 -1
  6. data/lib/twterm/environment.rb +38 -0
  7. data/lib/twterm/event/message/abstract_message.rb +23 -0
  8. data/lib/twterm/event/message/error.rb +10 -0
  9. data/lib/twterm/event/message/info.rb +10 -0
  10. data/lib/twterm/event/message/success.rb +10 -0
  11. data/lib/twterm/event/message/warning.rb +10 -0
  12. data/lib/twterm/event/notification/abstract_notification.rb +17 -12
  13. data/lib/twterm/event/notification/direct_message.rb +30 -0
  14. data/lib/twterm/event/notification/favorite.rb +35 -0
  15. data/lib/twterm/event/notification/follow.rb +33 -0
  16. data/lib/twterm/event/notification/list_member_added.rb +33 -0
  17. data/lib/twterm/event/notification/mention.rb +35 -0
  18. data/lib/twterm/event/notification/quote.rb +35 -0
  19. data/lib/twterm/event/notification/retweet.rb +35 -0
  20. data/lib/twterm/key_mapper/abstract_key_mapper.rb +4 -4
  21. data/lib/twterm/list.rb +2 -1
  22. data/lib/twterm/message_window.rb +81 -0
  23. data/lib/twterm/notification_backend/abstract_notification_backend.rb +16 -0
  24. data/lib/twterm/notification_backend/inline_backend.rb +20 -0
  25. data/lib/twterm/notification_backend/terminal_notifier_backend.rb +23 -0
  26. data/lib/twterm/notification_backend/tmux_backend.rb +17 -0
  27. data/lib/twterm/notification_dispatcher.rb +36 -0
  28. data/lib/twterm/persistable_configuration_proxy.rb +82 -0
  29. data/lib/twterm/preferences.rb +66 -0
  30. data/lib/twterm/repository/abstract_expirable_entity_repository.rb +1 -1
  31. data/lib/twterm/rest_client.rb +12 -14
  32. data/lib/twterm/scheduler.rb +1 -1
  33. data/lib/twterm/screen.rb +1 -1
  34. data/lib/twterm/search_query_window.rb +2 -2
  35. data/lib/twterm/streaming_client.rb +54 -17
  36. data/lib/twterm/tab/base.rb +2 -3
  37. data/lib/twterm/tab/new/list.rb +2 -4
  38. data/lib/twterm/tab/new/start.rb +10 -0
  39. data/lib/twterm/tab/new/user.rb +2 -2
  40. data/lib/twterm/tab/preferences/index.rb +74 -0
  41. data/lib/twterm/tab/preferences/notification_backend.rb +85 -0
  42. data/lib/twterm/tab/scrollable.rb +0 -1
  43. data/lib/twterm/tab/searchable.rb +7 -7
  44. data/lib/twterm/tab/user_list_management.rb +3 -3
  45. data/lib/twterm/tab/user_tab.rb +6 -8
  46. data/lib/twterm/tab_manager.rb +4 -4
  47. data/lib/twterm/tweetbox.rb +1 -1
  48. data/lib/twterm/uri_opener.rb +2 -2
  49. data/lib/twterm/user.rb +2 -1
  50. data/lib/twterm/version.rb +1 -1
  51. data/twterm.gemspec +4 -2
  52. metadata +59 -14
  53. data/lib/twterm/event/favorite.rb +0 -18
  54. data/lib/twterm/event/follow.rb +0 -17
  55. data/lib/twterm/event/notification/error.rb +0 -13
  56. data/lib/twterm/event/notification/info.rb +0 -13
  57. data/lib/twterm/event/notification/success.rb +0 -13
  58. data/lib/twterm/event/notification/warning.rb +0 -13
  59. 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
@@ -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
@@ -1,13 +0,0 @@
1
- require 'twterm/event/notification/abstract_notification'
2
-
3
- module Twterm
4
- module Event
5
- module Notification
6
- class Error < AbstractNotification
7
- def color
8
- [:white, :red]
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require 'twterm/event/notification/abstract_notification'
2
-
3
- module Twterm
4
- module Event
5
- module Notification
6
- class Info < AbstractNotification
7
- def color
8
- [:black, :cyan]
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require 'twterm/event/notification/abstract_notification'
2
-
3
- module Twterm
4
- module Event
5
- module Notification
6
- class Success < AbstractNotification
7
- def color
8
- [:black, :green]
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require 'twterm/event/notification/abstract_notification'
2
-
3
- module Twterm
4
- module Event
5
- module Notification
6
- class Warning < AbstractNotification
7
- def color
8
- [:black, :yellow]
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -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