ayadn 3.0 → 4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/unit/set_spec.rb
CHANGED
@@ -2,89 +2,116 @@ require 'spec_helper'
|
|
2
2
|
require 'helpers'
|
3
3
|
|
4
4
|
def init_stubs
|
5
|
-
Ayadn::Settings.stub(:options).and_return(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
5
|
+
Ayadn::Settings.stub(:options).and_return(
|
6
|
+
Ayadn::Preferences.new(
|
7
|
+
{
|
8
|
+
timeline: {
|
9
|
+
directed: true,
|
10
|
+
source: true,
|
11
|
+
symbols: true,
|
12
|
+
name: true,
|
13
|
+
date: true,
|
14
|
+
debug: false,
|
15
|
+
compact: false
|
16
|
+
},
|
17
|
+
marker: {
|
18
|
+
messages: true
|
19
|
+
},
|
20
|
+
counts: {
|
21
|
+
default: 50,
|
22
|
+
unified: 50,
|
23
|
+
global: 50,
|
24
|
+
checkins: 50,
|
25
|
+
conversations: 50,
|
26
|
+
photos: 50,
|
27
|
+
trending: 50,
|
28
|
+
mentions: 50,
|
29
|
+
convo: 50,
|
30
|
+
posts: 50,
|
31
|
+
messages: 20,
|
32
|
+
search: 200,
|
33
|
+
whoreposted: 20,
|
34
|
+
whostarred: 20,
|
35
|
+
whatstarred: 100,
|
36
|
+
files: 50
|
37
|
+
},
|
38
|
+
formats: {
|
39
|
+
table: {
|
40
|
+
width: 75,
|
41
|
+
borders: true
|
42
|
+
},
|
43
|
+
list: {
|
44
|
+
reverse: true
|
45
|
+
}
|
46
|
+
},
|
47
|
+
channels: {
|
48
|
+
links: true
|
49
|
+
},
|
50
|
+
colors: {
|
51
|
+
id: :blue,
|
52
|
+
index: :red,
|
53
|
+
username: :green,
|
54
|
+
name: :magenta,
|
55
|
+
date: :cyan,
|
56
|
+
link: :yellow,
|
57
|
+
dots: :blue,
|
58
|
+
hashtags: :cyan,
|
59
|
+
mentions: :red,
|
60
|
+
source: :cyan,
|
61
|
+
symbols: :green,
|
62
|
+
unread: :cyan,
|
63
|
+
debug: :red,
|
64
|
+
excerpt: :green
|
65
|
+
},
|
66
|
+
backup: {
|
67
|
+
posts: false,
|
68
|
+
messages: false,
|
69
|
+
lists: false
|
70
|
+
},
|
71
|
+
scroll: {
|
72
|
+
spinner: true,
|
73
|
+
timer: 3,
|
74
|
+
date: false
|
75
|
+
},
|
76
|
+
nicerank: {
|
77
|
+
threshold: 2.1,
|
78
|
+
filter: true,
|
79
|
+
unranked: false
|
80
|
+
},
|
81
|
+
nowplaying: {},
|
82
|
+
blacklist: {
|
83
|
+
active: true
|
84
|
+
}
|
85
|
+
}))
|
86
|
+
require 'json'
|
87
|
+
require 'ostruct'
|
88
|
+
obj =
|
89
|
+
{
|
90
|
+
identity: {
|
91
|
+
username: 'test',
|
92
|
+
handle: '@test'
|
93
|
+
},
|
94
|
+
post_max_length: 256,
|
95
|
+
message_max_length: 2048,
|
96
|
+
version: 'wee',
|
97
|
+
paths: {
|
98
|
+
db: 'spec/mock/',
|
99
|
+
log: 'spec/mock'
|
100
|
+
},
|
101
|
+
platform: 'shoes',
|
102
|
+
ruby: '0',
|
103
|
+
locale: 'gibberish'
|
73
104
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
db: 'spec/mock/',
|
85
|
-
log: 'spec/mock'
|
86
|
-
}
|
87
|
-
})
|
105
|
+
Ayadn::Settings.stub(:config).and_return(
|
106
|
+
JSON.parse(obj.to_json, object_class: OpenStruct)
|
107
|
+
)
|
108
|
+
global_hash = {
|
109
|
+
scrolling: false,
|
110
|
+
force: false
|
111
|
+
}
|
112
|
+
Ayadn::Settings.stub(:global).and_return(
|
113
|
+
JSON.parse(global_hash.to_json, object_class: OpenStruct)
|
114
|
+
)
|
88
115
|
Ayadn::Settings.stub(:user_token).and_return('XYZ')
|
89
116
|
Ayadn::Settings.stub(:load_config)
|
90
117
|
Ayadn::Settings.stub(:get_token)
|
@@ -99,59 +126,37 @@ describe Ayadn::SetScroll do
|
|
99
126
|
|
100
127
|
describe "#timer" do
|
101
128
|
it "creates a default value" do
|
102
|
-
expect(Ayadn::Settings.options
|
129
|
+
expect(Ayadn::Settings.options.scroll.timer).to eq 3
|
103
130
|
Ayadn::SetScroll.new.timer('2')
|
104
|
-
expect(Ayadn::Settings.options
|
131
|
+
expect(Ayadn::Settings.options.scroll.timer).to eq 2
|
105
132
|
Ayadn::SetScroll.new.timer('4.2')
|
106
|
-
expect(Ayadn::Settings.options
|
133
|
+
expect(Ayadn::Settings.options.scroll.timer).to eq 4
|
107
134
|
Ayadn::SetScroll.new.timer('0')
|
108
|
-
expect(Ayadn::Settings.options
|
135
|
+
expect(Ayadn::Settings.options.scroll.timer).to eq 3
|
109
136
|
Ayadn::SetScroll.new.timer('johnson')
|
110
|
-
expect(Ayadn::Settings.options
|
137
|
+
expect(Ayadn::Settings.options.scroll.timer).to eq 3
|
111
138
|
end
|
112
139
|
end
|
113
140
|
|
114
141
|
describe "#spinner" do
|
115
142
|
it "creates a default value" do
|
116
143
|
Ayadn::SetScroll.new.spinner('true')
|
117
|
-
expect(Ayadn::Settings.options
|
144
|
+
expect(Ayadn::Settings.options.scroll.spinner).to eq true
|
118
145
|
Ayadn::SetScroll.new.spinner('false')
|
119
|
-
expect(Ayadn::Settings.options
|
146
|
+
expect(Ayadn::Settings.options.scroll.spinner).to eq false
|
120
147
|
Ayadn::SetScroll.new.spinner('0')
|
121
|
-
expect(Ayadn::Settings.options
|
148
|
+
expect(Ayadn::Settings.options.scroll.spinner).to eq false
|
122
149
|
end
|
123
150
|
end
|
124
151
|
|
125
152
|
describe "#date" do
|
126
153
|
it "creates a default value" do
|
127
154
|
Ayadn::SetScroll.new.date('true')
|
128
|
-
expect(Ayadn::Settings.options
|
155
|
+
expect(Ayadn::Settings.options.scroll.date).to eq true
|
129
156
|
Ayadn::SetScroll.new.date('false')
|
130
|
-
expect(Ayadn::Settings.options
|
157
|
+
expect(Ayadn::Settings.options.scroll.date).to eq false
|
131
158
|
Ayadn::SetScroll.new.date('0')
|
132
|
-
expect(Ayadn::Settings.options
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
after do
|
137
|
-
File.delete('spec/mock/ayadn.log')
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe Ayadn::SetColor do
|
142
|
-
before do
|
143
|
-
init_stubs
|
144
|
-
end
|
145
|
-
|
146
|
-
describe "#" do
|
147
|
-
it "creates a default value" do
|
148
|
-
colors_list = %w{red green magenta cyan yellow blue white black}
|
149
|
-
%w{id index username name date link dots hashtags mentions source symbols debug}.each do |meth|
|
150
|
-
command = meth.to_sym
|
151
|
-
color = colors_list.sample
|
152
|
-
Ayadn::SetColor.new.send(command, color)
|
153
|
-
expect(Ayadn::Settings.options[:colors][command]).to eq color.to_sym
|
154
|
-
end
|
159
|
+
expect(Ayadn::Settings.options.scroll.date).to eq false
|
155
160
|
end
|
156
161
|
end
|
157
162
|
|
@@ -168,22 +173,22 @@ describe Ayadn::SetFormats do
|
|
168
173
|
describe "#table" do
|
169
174
|
it "creates a default table width" do
|
170
175
|
Ayadn::SetFormats.new.send(:table, ['width', '80'])
|
171
|
-
expect(Ayadn::Settings.options
|
176
|
+
expect(Ayadn::Settings.options.formats.table.width).to eq 80
|
172
177
|
end
|
173
178
|
it "creates a default table width" do
|
174
179
|
Ayadn::SetFormats.new.send(:table, ['width', '33'])
|
175
|
-
expect(Ayadn::Settings.options
|
180
|
+
expect(Ayadn::Settings.options.formats.table.width).to eq 75
|
176
181
|
end
|
177
182
|
it "creates a default table width" do
|
178
183
|
Ayadn::SetFormats.new.send(:table, ['width', 'yolo'])
|
179
|
-
expect(Ayadn::Settings.options
|
184
|
+
expect(Ayadn::Settings.options.formats.table.width).to eq 75
|
180
185
|
end
|
181
186
|
end
|
182
187
|
|
183
188
|
describe "#list" do
|
184
189
|
it "creates a default list order" do
|
185
190
|
Ayadn::SetFormats.new.send(:list, ['reverse', 'false'])
|
186
|
-
expect(Ayadn::Settings.options
|
191
|
+
expect(Ayadn::Settings.options.formats.list.reverse).to eq false
|
187
192
|
end
|
188
193
|
it "raises an error" do
|
189
194
|
printed = capture_stdout do
|
@@ -197,48 +202,6 @@ describe Ayadn::SetFormats do
|
|
197
202
|
end
|
198
203
|
end
|
199
204
|
|
200
|
-
describe Ayadn::SetTimeline do
|
201
|
-
before do
|
202
|
-
init_stubs
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "#" do
|
206
|
-
it "creates a default value" do
|
207
|
-
%w{directed source symbols name date debug compact}.each do |meth|
|
208
|
-
command = meth.to_sym
|
209
|
-
Ayadn::SetTimeline.new.send(command, 'true')
|
210
|
-
expect(Ayadn::Settings.options[:timeline][command]).to eq true
|
211
|
-
printed = capture_stdout do
|
212
|
-
expect(lambda {Ayadn::SetTimeline.new.send(command, 'yolo')}).to raise_error(SystemExit)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
after do
|
219
|
-
File.delete('spec/mock/ayadn.log')
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
describe Ayadn::SetCounts do
|
224
|
-
before do
|
225
|
-
init_stubs
|
226
|
-
end
|
227
|
-
|
228
|
-
describe "#" do
|
229
|
-
it "creates a default value" do
|
230
|
-
%w{default unified global checkins conversations photos trending mentions convo posts messages search whoreposted whostarred whatstarred files}.each do |meth|
|
231
|
-
command = meth.to_sym
|
232
|
-
Ayadn::SetCounts.new.send(command, '199')
|
233
|
-
expect(Ayadn::Settings.options[:counts][command]).to eq 199
|
234
|
-
printed = capture_stdout do
|
235
|
-
Ayadn::SetCounts.new.send(command, '333')
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
205
|
describe Ayadn::SetMarker do
|
243
206
|
before do
|
244
207
|
init_stubs
|
@@ -246,9 +209,9 @@ describe Ayadn::SetMarker do
|
|
246
209
|
|
247
210
|
describe "#messages" do
|
248
211
|
it "creates a default value" do
|
249
|
-
expect(Ayadn::Settings.options
|
212
|
+
expect(Ayadn::Settings.options.marker.messages).to eq true
|
250
213
|
Ayadn::SetMarker.new.messages('0')
|
251
|
-
expect(Ayadn::Settings.options
|
214
|
+
expect(Ayadn::Settings.options.marker.messages).to eq false
|
252
215
|
end
|
253
216
|
end
|
254
217
|
|
@@ -264,23 +227,23 @@ describe Ayadn::SetBackup do
|
|
264
227
|
|
265
228
|
describe "#posts" do
|
266
229
|
it "creates a default value" do
|
267
|
-
expect(Ayadn::Settings.options
|
230
|
+
expect(Ayadn::Settings.options.backup.posts).to eq false
|
268
231
|
Ayadn::SetBackup.new.posts('1')
|
269
|
-
expect(Ayadn::Settings.options
|
232
|
+
expect(Ayadn::Settings.options.backup.posts).to eq true
|
270
233
|
end
|
271
234
|
end
|
272
235
|
describe "#messages" do
|
273
236
|
it "creates a default value" do
|
274
|
-
expect(Ayadn::Settings.options
|
237
|
+
expect(Ayadn::Settings.options.backup.messages).to eq false
|
275
238
|
Ayadn::SetBackup.new.messages('True')
|
276
|
-
expect(Ayadn::Settings.options
|
239
|
+
expect(Ayadn::Settings.options.backup.messages).to eq true
|
277
240
|
end
|
278
241
|
end
|
279
242
|
describe "#lists" do
|
280
243
|
it "creates a default value" do
|
281
|
-
expect(Ayadn::Settings.options
|
244
|
+
expect(Ayadn::Settings.options.backup.lists).to eq false
|
282
245
|
Ayadn::SetBackup.new.lists('YES')
|
283
|
-
expect(Ayadn::Settings.options
|
246
|
+
expect(Ayadn::Settings.options.backup.lists).to eq true
|
284
247
|
end
|
285
248
|
end
|
286
249
|
|
@@ -300,58 +263,26 @@ describe Ayadn::SetBackup do
|
|
300
263
|
end
|
301
264
|
end
|
302
265
|
|
303
|
-
describe Ayadn::SetMovie do
|
304
|
-
before do
|
305
|
-
init_stubs
|
306
|
-
end
|
307
|
-
describe "#hashtag" do
|
308
|
-
it "creates a new hashtag default" do
|
309
|
-
expect(Ayadn::Settings.options[:movie][:hashtag]).to eq 'nowwatching'
|
310
|
-
Ayadn::SetMovie.new.hashtag('yolo')
|
311
|
-
expect(Ayadn::Settings.options[:movie][:hashtag]).to eq 'yolo'
|
312
|
-
end
|
313
|
-
end
|
314
|
-
after do
|
315
|
-
File.delete('spec/mock/ayadn.log')
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe Ayadn::SetTVShow do
|
320
|
-
before do
|
321
|
-
init_stubs
|
322
|
-
end
|
323
|
-
describe "#hashtag" do
|
324
|
-
it "creates a new hashtag default" do
|
325
|
-
expect(Ayadn::Settings.options[:tvshow][:hashtag]).to eq 'nowwatching'
|
326
|
-
Ayadn::SetTVShow.new.hashtag('yolo')
|
327
|
-
expect(Ayadn::Settings.options[:tvshow][:hashtag]).to eq 'yolo'
|
328
|
-
end
|
329
|
-
end
|
330
|
-
after do
|
331
|
-
File.delete('spec/mock/ayadn.log')
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
266
|
describe Ayadn::SetNiceRank do
|
336
267
|
before do
|
337
268
|
init_stubs
|
338
269
|
end
|
339
270
|
describe "#threshold" do
|
340
271
|
it "creates a new threshold default" do
|
341
|
-
expect(Ayadn::Settings.options
|
272
|
+
expect(Ayadn::Settings.options.nicerank.threshold).to eq 2.1
|
342
273
|
Ayadn::SetNiceRank.new.threshold('3')
|
343
|
-
expect(Ayadn::Settings.options
|
274
|
+
expect(Ayadn::Settings.options.nicerank.threshold).to eq 3
|
344
275
|
Ayadn::SetNiceRank.new.threshold('3.2')
|
345
|
-
expect(Ayadn::Settings.options
|
276
|
+
expect(Ayadn::Settings.options.nicerank.threshold).to eq 3.2
|
346
277
|
end
|
347
278
|
end
|
348
279
|
describe "#filter" do
|
349
280
|
it "creates a new filter default" do
|
350
|
-
expect(Ayadn::Settings.options
|
281
|
+
expect(Ayadn::Settings.options.nicerank.filter).to eq true
|
351
282
|
Ayadn::SetNiceRank.new.filter('false')
|
352
|
-
expect(Ayadn::Settings.options
|
283
|
+
expect(Ayadn::Settings.options.nicerank.filter).to eq false
|
353
284
|
Ayadn::SetNiceRank.new.filter('1')
|
354
|
-
expect(Ayadn::Settings.options
|
285
|
+
expect(Ayadn::Settings.options.nicerank.filter).to eq true
|
355
286
|
printed = capture_stdout do
|
356
287
|
expect(lambda {Ayadn::SetNiceRank.new.filter('6')}).to raise_error(SystemExit)
|
357
288
|
end
|
@@ -359,11 +290,11 @@ describe Ayadn::SetNiceRank do
|
|
359
290
|
end
|
360
291
|
describe "#unranked" do
|
361
292
|
it "creates a new unranked default" do
|
362
|
-
expect(Ayadn::Settings.options
|
293
|
+
expect(Ayadn::Settings.options.nicerank.unranked).to eq false
|
363
294
|
Ayadn::SetNiceRank.new.unranked('true')
|
364
|
-
expect(Ayadn::Settings.options
|
295
|
+
expect(Ayadn::Settings.options.nicerank.unranked).to eq true
|
365
296
|
Ayadn::SetNiceRank.new.unranked('0')
|
366
|
-
expect(Ayadn::Settings.options
|
297
|
+
expect(Ayadn::Settings.options.nicerank.unranked).to eq false
|
367
298
|
printed = capture_stdout do
|
368
299
|
expect(lambda {Ayadn::SetNiceRank.new.unranked('yolo')}).to raise_error(SystemExit)
|
369
300
|
end
|