twterm 2.5.1 → 2.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab9d82295e341b326b39878474c7610dc3091d35f8f58a12c40882562c693240
4
- data.tar.gz: d305b9a55f9aba8c83ac21999483ccd0450fc0e40e302a2a6f8b074a984a8b21
3
+ metadata.gz: 5edeb8383924ffcd0cd837dad84d60637bfdae3de7a4edf00a0a9bb9aeaf6a7e
4
+ data.tar.gz: f707dc76ada2cdf2082e6d7aeec9d8a890056fdde114fa90b3b69aaa28ea257f
5
5
  SHA512:
6
- metadata.gz: c66d15babe4005dec88320e1221dde230a7bfaa7eaa2d662a0449157647faf183cf5a4077a7f1cc208fd45e44e9fc44a80e38ee8488438aa77595a3bfff416f7
7
- data.tar.gz: 9b04ae6462a7a084bedf6e67111ba5495eddf752bef818c4e61767e4843e7aacec4de88733a9a23d7d8b0b23030f869905f35c97dc4f2422680d556a6b8b0071
6
+ metadata.gz: d92d30135cd6793a117ecb2b1f4a8648ade22e5759c2dadf7c7b39afea0ac72e3622da83d0577a3acb2f96b63d1976928a228e756544a9c694e7eddfd2eb79a2
7
+ data.tar.gz: f488de8b0fed4655ed95ff767910b136bcd7deeded6258fbffa561f9699b55a3404315ecaf19144a1eed096348559753f1ef78d176976a77109cf946c2590527
data/lib/twterm/app.rb CHANGED
@@ -89,8 +89,6 @@ module Twterm
89
89
 
90
90
  publish(Event::Screen::Refresh.new)
91
91
 
92
- client.connect_user_stream
93
-
94
92
  reset_interruption_handler
95
93
 
96
94
  Signal.trap(:WINCH) { on_resize }
data/lib/twterm/client.rb CHANGED
@@ -1,10 +1,8 @@
1
1
  require 'twterm/rest_client'
2
- require 'twterm/streaming_client'
3
2
 
4
3
  module Twterm
5
4
  class Client
6
5
  include RESTClient
7
- include StreamingClient
8
6
 
9
7
  attr_reader :user_id, :screen_name
10
8
 
@@ -1,5 +1,4 @@
1
1
  require 'twterm/subscriber'
2
- require 'twterm/event/status/timeline'
3
2
  require 'twterm/tab/statuses/abstract_statuses_tab'
4
3
  require 'twterm/utils'
5
4
 
@@ -21,8 +20,6 @@ module Twterm
21
20
  def initialize(app, client)
22
21
  super(app, client)
23
22
 
24
- subscribe(Event::Status::Timeline) { |e| prepend(e.status) }
25
-
26
23
  reload.then do
27
24
  initially_loaded!
28
25
  scroller.move_to_top
@@ -1,4 +1,5 @@
1
1
  require 'twterm/tab/statuses/abstract_statuses_tab'
2
+ require 'twterm/event/status/mention'
2
3
 
3
4
  module Twterm
4
5
  module Tab
@@ -1,3 +1,3 @@
1
1
  module Twterm
2
- VERSION = '2.5.1'
2
+ VERSION = '2.6.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twterm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Kameoka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-16 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -259,7 +259,6 @@ files:
259
259
  - lib/twterm/event/screen/resize.rb
260
260
  - lib/twterm/event/status/abstract_status_event.rb
261
261
  - lib/twterm/event/status/mention.rb
262
- - lib/twterm/event/status/timeline.rb
263
262
  - lib/twterm/event/status_deleted.rb
264
263
  - lib/twterm/event/status_garbage_collected.rb
265
264
  - lib/twterm/event/user_garbage_collected.rb
@@ -320,7 +319,6 @@ files:
320
319
  - lib/twterm/screen.rb
321
320
  - lib/twterm/search_query_window.rb
322
321
  - lib/twterm/status.rb
323
- - lib/twterm/streaming_client.rb
324
322
  - lib/twterm/subscriber.rb
325
323
  - lib/twterm/tab/abstract_tab.rb
326
324
  - lib/twterm/tab/direct_message/conversation.rb
@@ -1,10 +0,0 @@
1
- require 'twterm/event/status/abstract_status_event'
2
-
3
- module Twterm
4
- module Event
5
- module Status
6
- class Timeline < AbstractStatusEvent
7
- end
8
- end
9
- end
10
- end
@@ -1,146 +0,0 @@
1
- require 'twterm/event/message/error'
2
- require 'twterm/event/message/info'
3
- require 'twterm/event/notification/direct_message'
4
- require 'twterm/event/notification/favorite'
5
- require 'twterm/event/notification/follow'
6
- require 'twterm/event/notification/list_member_added'
7
- require 'twterm/event/notification/mention'
8
- require 'twterm/event/notification/quote'
9
- require 'twterm/event/notification/retweet'
10
- require 'twterm/event/status/mention'
11
- require 'twterm/event/status/timeline'
12
- require 'twterm/publisher'
13
-
14
- module Twterm
15
- module StreamingClient
16
- include Publisher
17
-
18
- CONSUMER_KEY = 'vLNSVFgXclBJQJRZ7VLMxL9lA'.freeze
19
- CONSUMER_SECRET = 'OFLKzrepRG2p1hq0nUB9j2S9ndFQoNTPheTpmOY0GYw55jGgS5'.freeze
20
-
21
- def connect_user_stream
22
- return if user_stream_connected?
23
-
24
- @streaming_thread = Thread.new do
25
- begin
26
- publish(Event::Message::Info.new('Trying to connect to Twitter...'))
27
- streaming_client.user do |event|
28
- keep_alive!
29
-
30
- case event
31
- when Twitter::Tweet
32
- status = status_repository.create(event)
33
- user = user_repository.create(event.user)
34
-
35
- publish(Event::Status::Timeline.new(status))
36
-
37
- if !status.retweet? && status.text.include?('@%s' % screen_name)
38
- publish(Event::Status::Mention.new(status))
39
-
40
- notification = Event::Notification::Mention.new(status, user)
41
- publish(notification)
42
- end
43
-
44
- if status.retweet? && event.retweeted_status.user.id == user_id
45
- retweeted_status = status_repository.create(event.retweeted_status)
46
- notification = Event::Notification::Retweet.new(retweeted_status, user)
47
- publish(notification)
48
- end
49
- when Twitter::Streaming::Event
50
- case event.name
51
- when :favorite
52
- next if event.source.id == user_id
53
- user = user_repository.create(event.source)
54
- status = status_repository.create(event.target_object)
55
- notification = Event::Notification::Like.new(status, user)
56
- publish(notification)
57
- when :follow
58
- next if event.source.id == user_id
59
-
60
- user = user_repository.create(event.source)
61
- notification = Event::Notification::Follow.new(user)
62
- publish(notification)
63
- when :list_member_added
64
- next if event.source.id == user_id
65
-
66
- list = list_repository.create(event.target_object)
67
- notification = Event::Notification::ListMemberAdded.new(list)
68
- publish(notification)
69
- when :quoted_tweet
70
- next if event.source.id == user_id
71
-
72
- status = status_repository.create(event.target_object)
73
- user = user_repository.create(event.source)
74
- notification = Event::Notification::Quote.new(status, user)
75
- publish(notification)
76
- end
77
- when Twitter::DirectMessage
78
- next if event.sender.id == user_id
79
-
80
- user = user_repository.create(event.sender)
81
- message = DirectMessage.new(event)
82
- notification = Event::Notification::DirectMessage.new(message, user)
83
- publish(notification)
84
- when Twitter::Streaming::FriendList
85
- user_stream_connected!
86
- when Twitter::Streaming::DeletedTweet
87
- publish(Event::StatusDeleted.new(event.id))
88
- end
89
- end
90
- rescue Twitter::Error::TooManyRequests
91
- publish(Event::Message::Error.new('Rate limit exceeded'))
92
- sleep 120
93
- retry
94
- rescue Errno::ENETUNREACH, Errno::ETIMEDOUT, Resolv::ResolvError
95
- publish(Event::Message::Error.new('Network is unavailable'))
96
- sleep 30
97
- retry
98
- rescue Twitter::Error => e
99
- publish(Event::Message::Error.new(e.message))
100
- end
101
- end
102
- end
103
-
104
- private
105
-
106
- def keep_alive!
107
- @keep_alive_timer.kill if @keep_alive_timer.is_a?(Thread)
108
- @keep_alive_timer = Thread.new do
109
- sleep(120)
110
- @user_stream_connected = false
111
- @streaming_thread.kill
112
- connect_user_stream
113
- end
114
- end
115
-
116
- def streaming_client
117
- @streaming_client ||= Twitter::Streaming::Client.new do |config|
118
- config.consumer_key = CONSUMER_KEY
119
- config.consumer_secret = CONSUMER_SECRET
120
- config.access_token = @access_token
121
- config.access_token_secret = @access_token_secret
122
- end
123
- end
124
-
125
- def user_stream_connected?
126
- @user_stream_connected || false
127
- end
128
-
129
- def user_stream_connected!
130
- publish(Event::Message::Info.new('Connection established')) unless user_stream_connected?
131
- @user_stream_connected = true
132
- end
133
-
134
- def user_stream_disconnected!
135
- @user_stream_connected = false
136
- end
137
-
138
- def user_stream_initialized?
139
- @user_stream_initialized || false
140
- end
141
-
142
- def user_stream_initialized!
143
- @user_stream_initialized = true
144
- end
145
- end
146
- end