ayadn 3.0 → 4.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 +4 -4
- data/.travis.yml +1 -4
- data/CHANGELOG.md +12 -4
- data/README.md +2 -5
- data/ayadn.gemspec +0 -2
- data/doc/01-index.md +0 -3
- data/doc/02-install.md +0 -4
- data/doc/06-post.md +0 -16
- data/doc/{18-contact.md → 16-contact.md} +0 -0
- data/doc/{19-examples.md → 17-examples.md} +0 -0
- data/doc/18-develop.md +165 -0
- data/lib/ayadn/action.rb +206 -396
- data/lib/ayadn/alias.rb +1 -1
- data/lib/ayadn/annotations.rb +15 -27
- data/lib/ayadn/api.rb +39 -28
- data/lib/ayadn/app.rb +19 -29
- data/lib/ayadn/authorize.rb +22 -13
- data/lib/ayadn/blacklist.rb +6 -19
- data/lib/ayadn/channel_object.rb +75 -0
- data/lib/ayadn/check.rb +19 -11
- data/lib/ayadn/cnx.rb +9 -15
- data/lib/ayadn/databases.rb +15 -27
- data/lib/ayadn/debug.rb +9 -9
- data/lib/ayadn/descriptions.rb +1 -99
- data/lib/ayadn/diagnostics.rb +16 -15
- data/lib/ayadn/endpoints.rb +18 -22
- data/lib/ayadn/errors.rb +1 -1
- data/lib/ayadn/fileops.rb +12 -12
- data/lib/ayadn/filtered_post_object.rb +11 -0
- data/lib/ayadn/ids.rb +0 -3
- data/lib/ayadn/logs.rb +4 -4
- data/lib/ayadn/mark.rb +34 -30
- data/lib/ayadn/nicerank.rb +7 -7
- data/lib/ayadn/nowplaying.rb +8 -22
- data/lib/ayadn/pinboard.rb +8 -12
- data/lib/ayadn/post.rb +18 -18
- data/lib/ayadn/post_object.rb +118 -0
- data/lib/ayadn/preferences_object.rb +290 -0
- data/lib/ayadn/profile.rb +2 -2
- data/lib/ayadn/scroll.rb +58 -67
- data/lib/ayadn/search.rb +22 -15
- data/lib/ayadn/set.rb +93 -83
- data/lib/ayadn/settings.rb +25 -33
- data/lib/ayadn/status.rb +24 -26
- data/lib/ayadn/stream.rb +68 -66
- data/lib/ayadn/stream_object.rb +56 -0
- data/lib/ayadn/switch.rb +2 -2
- data/lib/ayadn/user_object.rb +116 -0
- data/lib/ayadn/version.rb +1 -1
- data/lib/ayadn/view.rb +255 -278
- data/lib/ayadn/workers.rb +172 -174
- data/spec/integration/action_spec.rb +55 -34
- data/spec/mock/ayadn.sqlite +0 -0
- data/spec/unit/annotations_spec.rb +54 -41
- data/spec/unit/api_spec.rb +78 -7
- data/spec/unit/blacklistworkers_spec.rb +92 -20
- data/spec/unit/databases_spec.rb +117 -36
- data/spec/unit/endpoints_spec.rb +82 -10
- data/spec/unit/nicerank_spec.rb +56 -27
- data/spec/unit/post_spec.rb +94 -21
- data/spec/unit/set_spec.rb +141 -210
- data/spec/unit/view_spec.rb +105 -32
- data/spec/unit/workers_spec.rb +143 -52
- metadata +12 -37
- data/doc/16-movie.md +0 -39
- data/doc/17-tvshow.md +0 -46
- data/lib/ayadn/nowwatching.rb +0 -118
- data/lib/ayadn/tvshow.rb +0 -162
@@ -0,0 +1,118 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Ayadn
|
3
|
+
|
4
|
+
class PostSourceObject
|
5
|
+
|
6
|
+
attr_reader :input, :link, :name, :client_id
|
7
|
+
|
8
|
+
def initialize hash
|
9
|
+
@input = hash["source"]
|
10
|
+
@link = @input["link"]
|
11
|
+
@name = @input["name"]
|
12
|
+
@client_id = @input["client_id"]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class PostLinkObject
|
17
|
+
|
18
|
+
attr_reader :input, :url, :text, :pos, :len, :amended_len
|
19
|
+
|
20
|
+
def initialize hash
|
21
|
+
@input = hash
|
22
|
+
@url = @input["url"]
|
23
|
+
@text = @input["text"]
|
24
|
+
@pos = @input["pos"]
|
25
|
+
@len = @input["len"]
|
26
|
+
@amended_len = @input["amended_len"]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class PostMentionObject
|
31
|
+
|
32
|
+
attr_reader :input, :is_leading, :pos, :id, :len, :name, :amended_len
|
33
|
+
|
34
|
+
def initialize hash
|
35
|
+
@input = hash
|
36
|
+
@is_leading = @input["is_leading"]
|
37
|
+
@pos = @input["pos"]
|
38
|
+
@id = @input["id"]
|
39
|
+
@len = @input["len"]
|
40
|
+
@name = @input["name"]
|
41
|
+
@amended_len = @input["amended_len"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class PostHashtagObject
|
46
|
+
|
47
|
+
attr_reader :input, :name, :len, :pos, :amended_len
|
48
|
+
|
49
|
+
def initialize hash
|
50
|
+
@input = hash
|
51
|
+
@name = @input["name"]
|
52
|
+
@len = @input["len"]
|
53
|
+
@pos = @input["pos"]
|
54
|
+
@amended_len = @input["amended_len"]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class EntitiesObject
|
59
|
+
|
60
|
+
attr_reader :input, :mentions, :hashtags, :links
|
61
|
+
|
62
|
+
def initialize hash
|
63
|
+
@input = hash["entities"].nil? ? {} : hash["entities"]
|
64
|
+
mentions = @input["mentions"].nil? ? [] : @input["mentions"]
|
65
|
+
@mentions = mentions.map { |hash| PostMentionObject.new(hash) }
|
66
|
+
hashtags = @input["hashtags"].nil? ? [] : @input["hashtags"]
|
67
|
+
@hashtags = hashtags.map { |hash| PostHashtagObject.new(hash) }
|
68
|
+
links = @input["links"].nil? ? [] : @input["links"]
|
69
|
+
@links = links.map { |hash| PostLinkObject.new(hash) }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class PostAnnotationObject
|
74
|
+
|
75
|
+
attr_reader :input, :type, :value
|
76
|
+
|
77
|
+
def initialize hash
|
78
|
+
@input = hash
|
79
|
+
@type = @input["type"]
|
80
|
+
@value = @input["value"]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class PostObject # also works for messages
|
85
|
+
|
86
|
+
attr_reader :input, :num_stars, :num_reposts, :num_replies, :text, :created_at, :id, :canonical_url, :machine_only, :you_reposted, :you_starred, :thread_id, :pagination_id, :source, :user, :annotations, :entities, :repost_of, :reply_to, :is_deleted, :channel_id
|
87
|
+
attr_accessor :view
|
88
|
+
|
89
|
+
def initialize hash
|
90
|
+
@input = hash
|
91
|
+
@num_stars = @input["num_stars"]
|
92
|
+
@num_reposts = @input["num_reposts"]
|
93
|
+
@num_replies = @input["num_replies"]
|
94
|
+
@text = @input["text"]
|
95
|
+
@created_at = @input["created_at"]
|
96
|
+
@id = @input["id"]
|
97
|
+
@canonical_url = @input["canonical_url"]
|
98
|
+
@machine_only = @input["machine_only"]
|
99
|
+
@you_reposted = @input["you_reposted"]
|
100
|
+
@you_starred = @input["you_starred"]
|
101
|
+
@thread_id = @input["thread_id"]
|
102
|
+
@pagination_id = @input["pagination_id"]
|
103
|
+
@source = PostSourceObject.new(@input)
|
104
|
+
@entities = EntitiesObject.new(@input)
|
105
|
+
@user = UserObject.new(@input["user"])
|
106
|
+
if !@input["annotations"].nil?
|
107
|
+
@annotations = @input["annotations"].map { |hash| PostAnnotationObject.new(hash) }
|
108
|
+
else
|
109
|
+
@annotations = []
|
110
|
+
end
|
111
|
+
@repost_of = PostObject.new(@input["repost_of"]) if !@input["repost_of"].blank?
|
112
|
+
@reply_to = @input["reply_to"]
|
113
|
+
@is_deleted = @input["is_deleted"]
|
114
|
+
@channel_id = @input["channel_id"]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
@@ -0,0 +1,290 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Ayadn
|
3
|
+
|
4
|
+
class PreferencesFormatsList
|
5
|
+
attr_accessor :reverse
|
6
|
+
def initialize hash
|
7
|
+
@reverse = hash[:reverse]
|
8
|
+
end
|
9
|
+
def to_h
|
10
|
+
{ reverse: @reverse }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class PreferencesFormatsTable
|
15
|
+
attr_accessor :width, :borders
|
16
|
+
def initialize hash
|
17
|
+
@width = hash[:width]
|
18
|
+
@borders = hash[:borders]
|
19
|
+
end
|
20
|
+
def to_h
|
21
|
+
{
|
22
|
+
width: @width,
|
23
|
+
borders: @borders
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class PreferencesFormats
|
29
|
+
attr_accessor :table, :list
|
30
|
+
def initialize hash
|
31
|
+
@table = PreferencesFormatsTable.new(hash[:table])
|
32
|
+
@list = PreferencesFormatsList.new(hash[:list])
|
33
|
+
end
|
34
|
+
def to_h
|
35
|
+
{
|
36
|
+
table: @table.to_h,
|
37
|
+
list: @list.to_h
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class PreferencesCounts
|
43
|
+
attr_accessor :default, :unified, :global, :checkins, :conversations, :photos, :trending, :mentions, :convo, :posts, :messages, :search, :whoreposted, :whostarred, :whatstarred, :files
|
44
|
+
def initialize hash
|
45
|
+
@default = hash[:default]
|
46
|
+
@unified = hash[:unified]
|
47
|
+
@global = hash[:global]
|
48
|
+
@checkins = hash[:checkins]
|
49
|
+
@conversations = hash[:conversations]
|
50
|
+
@photos = hash[:photos]
|
51
|
+
@trending = hash[:trending]
|
52
|
+
@mentions = hash[:mentions]
|
53
|
+
@convo = hash[:convo]
|
54
|
+
@posts = hash[:posts]
|
55
|
+
@messages = hash[:messages]
|
56
|
+
@search = hash[:search]
|
57
|
+
@whoreposted = hash[:whoreposted]
|
58
|
+
@whostarred = hash[:whostarred]
|
59
|
+
@whatstarred = hash[:whatstarred]
|
60
|
+
@files = hash[:files]
|
61
|
+
end
|
62
|
+
def to_h
|
63
|
+
{
|
64
|
+
default: @default,
|
65
|
+
unified: @unified,
|
66
|
+
global: @global,
|
67
|
+
checkins: @checkins,
|
68
|
+
conversations: @conversations,
|
69
|
+
photos: @photos,
|
70
|
+
trending: @trending,
|
71
|
+
mentions: @mentions,
|
72
|
+
convo: @convo,
|
73
|
+
posts: @posts,
|
74
|
+
messages: @messages,
|
75
|
+
search: @search,
|
76
|
+
whoreposted: @whoreposted,
|
77
|
+
whostarred: @whostarred,
|
78
|
+
whatstarred: @whatstarred,
|
79
|
+
files: @files
|
80
|
+
}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class PreferencesMarker
|
85
|
+
attr_accessor :messages
|
86
|
+
def initialize hash
|
87
|
+
@messages = hash[:messages]
|
88
|
+
end
|
89
|
+
def to_h
|
90
|
+
{messages: @messages}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class PreferencesTimeline
|
95
|
+
attr_accessor :directed, :source, :symbols, :name, :date, :debug, :compact
|
96
|
+
def initialize hash
|
97
|
+
@directed = hash[:directed]
|
98
|
+
@source = hash[:source]
|
99
|
+
@symbols = hash[:symbols]
|
100
|
+
@name = hash[:name]
|
101
|
+
@date = hash[:date]
|
102
|
+
@debug = hash[:debug]
|
103
|
+
@compact = hash[:compact]
|
104
|
+
end
|
105
|
+
def to_h
|
106
|
+
{
|
107
|
+
directed: @directed,
|
108
|
+
source: @source,
|
109
|
+
symbols: @symbols,
|
110
|
+
name: @name,
|
111
|
+
date: @date,
|
112
|
+
debug: @debug,
|
113
|
+
compact: @compact
|
114
|
+
}
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
class PreferencesChannels
|
119
|
+
attr_accessor :links
|
120
|
+
def initialize hash
|
121
|
+
@links = hash[:links]
|
122
|
+
end
|
123
|
+
def to_h
|
124
|
+
{ links: @links }
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class PreferencesColors
|
129
|
+
attr_accessor :id, :index, :username, :name, :date, :link, :dots, :hashtags, :mentions, :source, :symbols, :unread, :debug, :excerpt
|
130
|
+
def initialize hash
|
131
|
+
@index = hash[:index]
|
132
|
+
@username = hash[:username]
|
133
|
+
@name = hash[:name]
|
134
|
+
@date = hash[:date]
|
135
|
+
@link = hash[:link]
|
136
|
+
@dots = hash[:dots]
|
137
|
+
@hashtags = hash[:hashtags]
|
138
|
+
@mentions = hash[:mentions]
|
139
|
+
@source = hash[:source]
|
140
|
+
@symbols = hash[:symbols]
|
141
|
+
@unread = hash[:unread]
|
142
|
+
@debug = hash[:debug]
|
143
|
+
@excerpt = hash[:excerpt]
|
144
|
+
@id = hash[:id]
|
145
|
+
end
|
146
|
+
def to_h
|
147
|
+
{
|
148
|
+
id: @id,
|
149
|
+
index: @index,
|
150
|
+
username: @username,
|
151
|
+
name: @name,
|
152
|
+
date: @date,
|
153
|
+
link: @link,
|
154
|
+
dots: @dots,
|
155
|
+
hashtags: @hashtags,
|
156
|
+
mentions: @mentions,
|
157
|
+
source: @source,
|
158
|
+
symbols: @symbols,
|
159
|
+
unread: @unread,
|
160
|
+
debug: @debug,
|
161
|
+
excerpt: @excerpt
|
162
|
+
}
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
class PreferencesBackup
|
167
|
+
attr_accessor :posts, :messages, :lists
|
168
|
+
def initialize hash
|
169
|
+
@posts = hash[:posts]
|
170
|
+
@messages = hash[:messages]
|
171
|
+
@lists = hash[:lists]
|
172
|
+
end
|
173
|
+
def to_h
|
174
|
+
{
|
175
|
+
posts: @posts,
|
176
|
+
messages: @messages,
|
177
|
+
lists: @lists
|
178
|
+
}
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
class PreferencesScroll
|
183
|
+
attr_accessor :spinner, :timer, :date
|
184
|
+
def initialize hash
|
185
|
+
@spinner = hash[:spinner]
|
186
|
+
@timer = hash[:timer]
|
187
|
+
@date = hash[:date]
|
188
|
+
end
|
189
|
+
def to_h
|
190
|
+
{
|
191
|
+
spinner: @spinner,
|
192
|
+
timer: @timer,
|
193
|
+
date: @date
|
194
|
+
}
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
class PreferencesNicerank
|
199
|
+
attr_accessor :threshold, :filter, :unranked
|
200
|
+
def initialize hash
|
201
|
+
@threshold = hash[:threshold]
|
202
|
+
@filter = hash[:filter]
|
203
|
+
@unranked = hash[:unranked]
|
204
|
+
end
|
205
|
+
def to_h
|
206
|
+
{
|
207
|
+
threshold: @threshold,
|
208
|
+
filter: @filter,
|
209
|
+
unranked: @unranked
|
210
|
+
}
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
class PreferencesBlacklist
|
215
|
+
attr_accessor :active
|
216
|
+
def initialize hash
|
217
|
+
@active = hash[:active]
|
218
|
+
end
|
219
|
+
def to_h
|
220
|
+
{ active: @active }
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
class Preferences
|
225
|
+
attr_accessor :source_hash, :timeline, :marker, :counts, :formats, :channels, :colors, :backup, :scroll, :nicerank, :nowplaying, :blacklist
|
226
|
+
|
227
|
+
def initialize hash
|
228
|
+
@source_hash = hash
|
229
|
+
@timeline = PreferencesTimeline.new(hash[:timeline])
|
230
|
+
@marker = PreferencesMarker.new(hash[:marker])
|
231
|
+
@counts = PreferencesCounts.new(hash[:counts])
|
232
|
+
@formats = PreferencesFormats.new(hash[:formats])
|
233
|
+
@channels = PreferencesChannels.new(hash[:channels])
|
234
|
+
@colors = PreferencesColors.new(hash[:colors])
|
235
|
+
@backup = PreferencesBackup.new(hash[:backup])
|
236
|
+
@scroll = PreferencesScroll.new(hash[:scroll])
|
237
|
+
@nicerank = PreferencesNicerank.new(hash[:nicerank])
|
238
|
+
@nowplaying = {}
|
239
|
+
@blacklist = PreferencesBlacklist.new(hash[:blacklist])
|
240
|
+
end
|
241
|
+
|
242
|
+
def to_h
|
243
|
+
{
|
244
|
+
timeline: @timeline.to_h,
|
245
|
+
marker: @marker.to_h,
|
246
|
+
counts: @counts.to_h,
|
247
|
+
formats: @formats.to_h,
|
248
|
+
channels: @channels.to_h,
|
249
|
+
colors: @colors.to_h,
|
250
|
+
backup: @backup.to_h,
|
251
|
+
scroll: @scroll.to_h,
|
252
|
+
nicerank: @nicerank.to_h,
|
253
|
+
blacklist: @blacklist.to_h,
|
254
|
+
nowplaying: @nowplaying
|
255
|
+
}
|
256
|
+
end
|
257
|
+
|
258
|
+
def to_table
|
259
|
+
table = Terminal::Table.new do |t|
|
260
|
+
if @formats.table.borders
|
261
|
+
t.style = { :width => @formats.table.width, border_x: '—', border_i: '+', border_y: '|' }
|
262
|
+
else
|
263
|
+
t.style = { :width => @formats.table.width, border_x: ' ', border_i: ' ', border_y: ' ' }
|
264
|
+
end
|
265
|
+
t.title = "Current Ayadn settings".color(:cyan)
|
266
|
+
t.headings = [ "Category".color(:red), "Parameter".color(:red), "Value(s)".color(:red) ]
|
267
|
+
self.to_h.each_with_index do |(k, v), index|
|
268
|
+
v.each do |x,y|
|
269
|
+
t << :separator if index >= 1 && !@timeline.compact
|
270
|
+
unless y.is_a?(Hash)
|
271
|
+
t << [ k.to_s.color(:cyan), x.to_s.color(:yellow), y.to_s.color(:green) ]
|
272
|
+
else
|
273
|
+
y.each do |c|
|
274
|
+
yk = c[0]
|
275
|
+
tempv = c[1].to_s
|
276
|
+
if tempv.size > 10
|
277
|
+
yv = "#{tempv[0..7]}..."
|
278
|
+
else
|
279
|
+
yv = tempv
|
280
|
+
end
|
281
|
+
t << [ k.to_s.color(:cyan), x.to_s.color(:yellow), "#{yk} = #{yv}".color(:green) ]
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
table
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
data/lib/ayadn/profile.rb
CHANGED
@@ -6,7 +6,7 @@ module Ayadn
|
|
6
6
|
|
7
7
|
def initialize options
|
8
8
|
if options.empty?
|
9
|
-
|
9
|
+
Status.new.profile_options
|
10
10
|
exit
|
11
11
|
end
|
12
12
|
@options = options
|
@@ -27,7 +27,7 @@ module Ayadn
|
|
27
27
|
writer = Post.new
|
28
28
|
input = writer.compose()
|
29
29
|
@text = input.join("\n")
|
30
|
-
writer.post_size_error(@text) if writer.post_size_ok?(@text)
|
30
|
+
writer.post_size_error(@text) if !writer.post_size_ok?(@text)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
data/lib/ayadn/scroll.rb
CHANGED
@@ -10,70 +10,59 @@ module Ayadn
|
|
10
10
|
at_exit { @view.show_cursor }
|
11
11
|
end
|
12
12
|
|
13
|
-
def method_missing(meth,
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def method_missing(meth, *args)
|
14
|
+
options = if args.size > 1
|
15
|
+
args[1]
|
16
|
+
else
|
17
|
+
args[0]
|
18
|
+
end
|
19
|
+
case meth
|
20
|
+
when :trending, :photos, :checkins, :replies, :global, :unified
|
21
|
+
scroll_explore_stream(meth.to_s, options)
|
22
|
+
when :mentions, :posts
|
23
|
+
scroll_user_stream(args[0], meth.to_s, options)
|
17
24
|
else
|
18
25
|
super
|
19
26
|
end
|
20
27
|
end
|
21
28
|
|
22
|
-
def
|
23
|
-
Settings.global
|
29
|
+
def scroll_explore_stream target, options
|
30
|
+
Settings.global.scrolling = true
|
24
31
|
options = check_raw(options)
|
25
32
|
orig_target = target
|
26
33
|
@nr = NiceRank.new
|
27
34
|
loop do
|
28
35
|
begin
|
29
|
-
|
30
|
-
|
31
|
-
Debug.stream
|
36
|
+
stream_object = StreamObject.new(get(target, options))
|
37
|
+
stream_object.posts.empty? ? niceranks = {} : niceranks = @nr.get_ranks(stream_object)
|
38
|
+
Debug.stream stream_object, options, target
|
32
39
|
target = "explore:#{target}" if explore?(target) # explore but not global
|
33
|
-
clear() if Settings.options
|
34
|
-
show_if_new(
|
40
|
+
clear() if Settings.options.scroll.spinner
|
41
|
+
show_if_new(stream_object, options, target, niceranks)
|
35
42
|
target = orig_target if target =~ /explore/
|
36
|
-
options = save_then_return(
|
37
|
-
countdown
|
38
|
-
print "..." if Settings.options[:scroll][:spinner] == true
|
39
|
-
rescue Interrupt
|
40
|
-
canceled
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def mentions(username, options)
|
46
|
-
Settings.global[:scrolling] = true
|
47
|
-
options = check_raw(options)
|
48
|
-
id = @api.get_user(username)['data']['id']
|
49
|
-
loop do
|
50
|
-
begin
|
51
|
-
stream = @api.get_mentions(username, options)
|
52
|
-
Debug.stream stream, options, username
|
53
|
-
clear() if Settings.options[:scroll][:spinner] == true
|
54
|
-
show_if_new(stream, options, "mentions:#{id}")
|
55
|
-
options = save_then_return(stream, options, "mentions:#{id}")
|
43
|
+
options = save_then_return(stream_object, options, target)
|
56
44
|
countdown
|
57
|
-
print "..." if Settings.options
|
45
|
+
print "..." if Settings.options.scroll.spinner
|
58
46
|
rescue Interrupt
|
59
47
|
canceled
|
60
48
|
end
|
61
49
|
end
|
62
50
|
end
|
63
51
|
|
64
|
-
def
|
65
|
-
Settings.global
|
52
|
+
def scroll_user_stream username, type, options
|
53
|
+
Settings.global.scrolling = true
|
66
54
|
options = check_raw(options)
|
67
|
-
id = @api.get_user(username)['data']['id']
|
55
|
+
id = @api.get_user(username)['data']['id']
|
68
56
|
loop do
|
69
57
|
begin
|
70
|
-
stream = @api.
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
58
|
+
stream = @api.send("get_#{type}".to_sym, username, options)
|
59
|
+
stream_object = StreamObject.new(stream)
|
60
|
+
Debug.stream stream_object, options, username
|
61
|
+
clear() if Settings.options.scroll.spinner
|
62
|
+
show_if_new(stream_object, options, "#{type}:#{id}")
|
63
|
+
options = save_then_return(stream_object, options, "#{type}:#{id}")
|
75
64
|
countdown
|
76
|
-
print "..." if Settings.options
|
65
|
+
print "..." if Settings.options.scroll.spinner
|
77
66
|
rescue Interrupt
|
78
67
|
canceled
|
79
68
|
end
|
@@ -81,17 +70,18 @@ module Ayadn
|
|
81
70
|
end
|
82
71
|
|
83
72
|
def convo(post_id, options)
|
84
|
-
Settings.global
|
73
|
+
Settings.global.scrolling = true
|
85
74
|
options = check_raw(options)
|
86
75
|
loop do
|
87
76
|
begin
|
88
77
|
stream = @api.get_convo(post_id, options)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
78
|
+
stream_object = StreamObject.new(stream)
|
79
|
+
Debug.stream stream_object, options, post_id
|
80
|
+
clear() if Settings.options.scroll.spinner
|
81
|
+
show_if_new(stream_object, options, "replies:#{post_id}")
|
82
|
+
options = save_then_return(stream_object, options, "replies:#{post_id}")
|
93
83
|
countdown
|
94
|
-
print "..." if Settings.options
|
84
|
+
print "..." if Settings.options.scroll.spinner
|
95
85
|
rescue Interrupt
|
96
86
|
canceled
|
97
87
|
end
|
@@ -99,26 +89,27 @@ module Ayadn
|
|
99
89
|
end
|
100
90
|
|
101
91
|
def messages(channel_id, options)
|
102
|
-
Settings.global
|
92
|
+
Settings.global.scrolling = true
|
103
93
|
options = check_raw(options)
|
104
94
|
loop do
|
105
95
|
begin
|
106
96
|
stream = @api.get_messages(channel_id, options)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
97
|
+
stream_object = StreamObject.new(stream)
|
98
|
+
Debug.stream stream_object, options, channel_id
|
99
|
+
clear() if Settings.options.scroll.spinner
|
100
|
+
show_if_new(stream_object, options, "channel:#{channel_id}")
|
101
|
+
if Settings.options.marker.messages
|
102
|
+
unless stream_object.meta.max_id.nil?
|
103
|
+
marked = @api.update_marker("channel:#{channel_id}", stream_object.meta.max_id)
|
113
104
|
updated = JSON.parse(marked)
|
114
105
|
if updated['meta']['code'] != 200
|
115
106
|
Errors.warn "couldn't update channel #{channel_id} as read"
|
116
107
|
end
|
117
108
|
end
|
118
109
|
end
|
119
|
-
options = save_then_return(
|
110
|
+
options = save_then_return(stream_object, options, "channel:#{channel_id}")
|
120
111
|
countdown
|
121
|
-
print "..." if Settings.options
|
112
|
+
print "..." if Settings.options.scroll.spinner
|
122
113
|
rescue Interrupt
|
123
114
|
canceled
|
124
115
|
end
|
@@ -128,7 +119,7 @@ module Ayadn
|
|
128
119
|
private
|
129
120
|
|
130
121
|
def countdown
|
131
|
-
Settings.options
|
122
|
+
Settings.options.scroll.spinner ? waiting : pause
|
132
123
|
end
|
133
124
|
|
134
125
|
def clear
|
@@ -171,11 +162,11 @@ module Ayadn
|
|
171
162
|
end
|
172
163
|
|
173
164
|
def waiting
|
174
|
-
(Settings.options
|
165
|
+
(Settings.options.scroll.timer * 10).times { spin }
|
175
166
|
end
|
176
167
|
|
177
168
|
def pause
|
178
|
-
sleep Settings.options
|
169
|
+
sleep Settings.options.scroll.timer
|
179
170
|
end
|
180
171
|
|
181
172
|
def show_if_new(stream, options, target, niceranks = {})
|
@@ -183,7 +174,7 @@ module Ayadn
|
|
183
174
|
end
|
184
175
|
|
185
176
|
def save_then_return(stream, options, name = 'unknown')
|
186
|
-
unless stream
|
177
|
+
unless stream.meta.max_id.nil?
|
187
178
|
Databases.save_max_id(stream, name)
|
188
179
|
return options_hash(stream, options)
|
189
180
|
end
|
@@ -192,13 +183,13 @@ module Ayadn
|
|
192
183
|
|
193
184
|
def check_raw(options)
|
194
185
|
if options[:raw]
|
195
|
-
if options[:filter]
|
186
|
+
if options[:filter]
|
196
187
|
{count: 200, since_id: nil, raw: true, scroll: true, filter: true}
|
197
188
|
else
|
198
189
|
{count: 200, since_id: nil, raw: true, scroll: true}
|
199
190
|
end
|
200
191
|
else
|
201
|
-
if options[:filter]
|
192
|
+
if options[:filter]
|
202
193
|
{count: 200, since_id: nil, scroll: true, filter: true}
|
203
194
|
else
|
204
195
|
{count: 200, since_id: nil, scroll: true}
|
@@ -207,18 +198,18 @@ module Ayadn
|
|
207
198
|
end
|
208
199
|
|
209
200
|
def options_hash(stream, options)
|
210
|
-
if options[:filter]
|
211
|
-
{:count => 50, :since_id => stream
|
201
|
+
if options[:filter]
|
202
|
+
{:count => 50, :since_id => stream.meta.max_id, scroll: true, filter: true}
|
212
203
|
else
|
213
|
-
{:count => 50, :since_id => stream
|
204
|
+
{:count => 50, :since_id => stream.meta.max_id, scroll: true}
|
214
205
|
end
|
215
206
|
end
|
216
207
|
|
217
208
|
def show(stream, options, niceranks)
|
218
209
|
if options[:raw]
|
219
|
-
jj stream
|
210
|
+
jj stream.input
|
220
211
|
else
|
221
|
-
@view.show_posts(stream
|
212
|
+
@view.show_posts(stream, options, niceranks)
|
222
213
|
end
|
223
214
|
end
|
224
215
|
|