ayadn 1.8.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 +4 -4
- data/.gitignore +4 -0
- data/CHANGELOG.md +73 -52
- data/README.md +17 -3
- data/ayadn.gemspec +3 -4
- data/doc/01-index.md +6 -5
- data/doc/02-install.md +23 -1
- data/doc/03-first-steps.md +22 -28
- data/doc/04-options.md +1 -1
- data/doc/05-streams.md +29 -9
- data/doc/06-post.md +13 -5
- data/doc/07-actions.md +63 -1
- data/doc/08-listings.md +112 -4
- data/doc/09-accounts.md +17 -3
- data/doc/10-nicerank.md +5 -5
- data/doc/11-blacklist.md +8 -14
- data/doc/12-alias.md +1 -13
- data/doc/14-set.md +8 -110
- data/doc/15-nowplaying.md +16 -4
- data/doc/18-contact.md +14 -13
- data/doc/19-examples.md +2 -0
- data/lib/ayadn/action.rb +322 -183
- data/lib/ayadn/alias.rb +17 -45
- data/lib/ayadn/annotations.rb +1 -1
- data/lib/ayadn/api.rb +7 -8
- data/lib/ayadn/app.rb +99 -12
- data/lib/ayadn/authorize.rb +92 -57
- data/lib/ayadn/blacklist.rb +52 -62
- data/lib/ayadn/check.rb +81 -74
- data/lib/ayadn/cnx.rb +77 -26
- data/lib/ayadn/databases.rb +890 -105
- data/lib/ayadn/debug.rb +30 -89
- data/lib/ayadn/descriptions.rb +876 -329
- data/lib/ayadn/endpoints.rb +2 -2
- data/lib/ayadn/errors.rb +9 -9
- data/lib/ayadn/extend.rb +8 -1
- data/lib/ayadn/fileops.rb +10 -8
- data/lib/ayadn/mark.rb +79 -56
- data/lib/ayadn/migration.rb +427 -0
- data/lib/ayadn/nicerank.rb +74 -72
- data/lib/ayadn/nowplaying.rb +123 -60
- data/lib/ayadn/nowwatching.rb +26 -10
- data/lib/ayadn/pinboard.rb +12 -7
- data/lib/ayadn/post.rb +40 -37
- data/lib/ayadn/profile.rb +5 -2
- data/lib/ayadn/scroll.rb +20 -5
- data/lib/ayadn/search.rb +30 -22
- data/lib/ayadn/set.rb +146 -50
- data/lib/ayadn/settings.rb +66 -67
- data/lib/ayadn/status.rb +459 -234
- data/lib/ayadn/stream.rb +80 -46
- data/lib/ayadn/switch.rb +51 -47
- data/lib/ayadn/tvshow.rb +47 -15
- data/lib/ayadn/version.rb +1 -1
- data/lib/ayadn/view.rb +119 -60
- data/lib/ayadn/workers.rb +144 -92
- data/lib/ayadn.rb +7 -8
- data/spec/mock/ayadn/accounts.sqlite +0 -0
- data/spec/mock/ayadn.sqlite +0 -0
- data/spec/unit/annotations_spec.rb +12 -13
- data/spec/unit/api_spec.rb +3 -4
- data/spec/unit/blacklistworkers_spec.rb +18 -23
- data/spec/unit/databases_spec.rb +51 -36
- data/spec/unit/endpoints_spec.rb +5 -2
- data/spec/unit/extend_spec.rb +24 -0
- data/spec/unit/nicerank_spec.rb +13 -13
- data/spec/unit/post_spec.rb +47 -36
- data/spec/unit/set_spec.rb +67 -96
- data/spec/unit/view_spec.rb +12 -6
- data/spec/unit/workers_spec.rb +38 -12
- data/tags +1285 -0
- metadata +29 -39
- data/spec/mock/aliases.db +0 -0
- data/spec/mock/blacklist.db +0 -0
- data/spec/mock/bookmarks.db +0 -0
- data/spec/mock/channels.db +0 -0
- data/spec/mock/index.db +0 -0
- data/spec/mock/nicerank.db +0 -0
- data/spec/mock/pagination.db +0 -0
- data/spec/mock/users.db +0 -0
- data/spec/unit/status_spec.rb +0 -9
data/lib/ayadn/settings.rb
CHANGED
@@ -5,58 +5,63 @@ module Ayadn
|
|
5
5
|
AYADN_CLIENT_ID = "hFsCGArAjgJkYBHTHbZnUvzTmL4vaLHL"
|
6
6
|
|
7
7
|
class << self
|
8
|
-
attr_accessor :options, :config
|
9
|
-
attr_reader :user_token
|
8
|
+
attr_accessor :options, :config, :global
|
9
|
+
attr_reader :user_token
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.load_config
|
13
|
-
|
14
|
-
|
15
|
-
db = Databases.init acc_db
|
16
|
-
active = db['ACTIVE']
|
17
|
-
home = db[active][:path]
|
13
|
+
active = self.check_for_accounts
|
14
|
+
home = active[3]
|
18
15
|
@config = {
|
19
16
|
paths: {
|
20
17
|
home: home,
|
21
18
|
log: "#{home}/log",
|
22
19
|
db: "#{home}/db",
|
23
|
-
pagination: "#{home}/pagination",
|
24
20
|
config: "#{home}/config",
|
25
21
|
auth: "#{home}/auth",
|
26
22
|
downloads: "#{home}/downloads",
|
27
|
-
backup: "#{home}/backup",
|
28
23
|
posts: "#{home}/posts",
|
29
24
|
messages: "#{home}/messages",
|
30
25
|
lists: "#{home}/lists"
|
31
26
|
},
|
32
27
|
identity: {
|
33
|
-
id:
|
34
|
-
username:
|
35
|
-
handle:
|
28
|
+
id: active[1],
|
29
|
+
username: active[0],
|
30
|
+
handle: active[2]
|
36
31
|
}
|
37
32
|
}
|
38
|
-
@default_nr = {
|
39
|
-
threshold: 2.1,
|
40
|
-
cache: 48,
|
41
|
-
filter: true,
|
42
|
-
filter_unranked: false
|
43
|
-
}
|
44
|
-
db.close
|
45
33
|
@options = self.defaults
|
34
|
+
@global = {scrolling: false, force: false}
|
46
35
|
end
|
47
36
|
|
48
|
-
def self.check_for_accounts
|
49
|
-
|
50
|
-
|
51
|
-
|
37
|
+
def self.check_for_accounts
|
38
|
+
sqlaccounts = Dir.home + "/ayadn/accounts.sqlite"
|
39
|
+
status = Status.new
|
40
|
+
if File.exist?(sqlaccounts)
|
41
|
+
# Ayadn 2.x with already authorized account(s)
|
42
|
+
return self.init_sqlite(sqlaccounts)
|
43
|
+
else
|
44
|
+
if File.exist?(Dir.home + "/ayadn/accounts.db")
|
45
|
+
# Ayadn 1.x with already authorized account(s)
|
46
|
+
status.has_to_migrate
|
47
|
+
exit
|
48
|
+
else
|
49
|
+
# Ayadn 1.x without any authorized account (gem installed but no ~/ayadn folder)
|
50
|
+
status.not_authorized
|
51
|
+
exit
|
52
|
+
end
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
56
|
+
def self.init_sqlite(sqlaccounts)
|
57
|
+
Databases.active_account(Amalgalite::Database.new(sqlaccounts))
|
58
|
+
end
|
59
|
+
|
55
60
|
def self.get_token
|
56
61
|
if self.has_token_file?
|
57
62
|
@user_token = self.read_token_file
|
58
63
|
else
|
59
|
-
|
64
|
+
Status.new.not_authorized
|
60
65
|
exit
|
61
66
|
end
|
62
67
|
end
|
@@ -87,27 +92,10 @@ module Ayadn
|
|
87
92
|
config_file = @config[:paths][:config] + "/config.yml"
|
88
93
|
if File.exist?(config_file)
|
89
94
|
begin
|
90
|
-
conf = YAML.load(File.read(config_file))
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
conf[:colors].delete_if {|k,_| k == :nicerank}
|
95
|
-
# force create mandatory keys (idem)
|
96
|
-
conf[:nicerank] = @default_nr if conf[:nicerank].nil? || conf[:nicerank].size != 4
|
97
|
-
conf[:timeline][:show_debug] = false if conf[:timeline][:show_debug].nil?
|
98
|
-
conf[:timeline][:show_spinner] = true if conf[:timeline][:show_spinner].nil?
|
99
|
-
conf[:colors][:debug] = :red if conf[:colors][:debug].nil?
|
100
|
-
conf[:colors][:unread] = :cyan if conf[:colors][:unread].nil?
|
101
|
-
conf[:nowplaying] = {} if conf[:nowplaying].nil?
|
102
|
-
conf[:movie] = {hashtag: 'nowwatching'} if conf[:movie].nil?
|
103
|
-
conf[:tvshow] = {hashtag: 'nowwatching'} if conf[:tvshow].nil?
|
104
|
-
conf[:formats][:list] = {reverse: true} if conf[:formats][:list].nil?
|
105
|
-
conf[:timeline][:compact] = false if conf[:timeline][:compact].nil?
|
106
|
-
conf[:timeline][:show_channel_oembed] = true if conf[:timeline][:show_channel_oembed].nil?
|
107
|
-
conf[:marker] = {update_messages: true} if conf[:marker].nil?
|
108
|
-
|
109
|
-
@options = conf
|
110
|
-
self.write_config_file(config_file, @options)
|
95
|
+
# conf = YAML.load(File.read(config_file))
|
96
|
+
# @options = conf
|
97
|
+
@options = YAML.load(File.read(config_file))
|
98
|
+
# self.write_config_file(config_file, @options)
|
111
99
|
rescue => e
|
112
100
|
Errors.global_error({error: e, caller: caller, data: []})
|
113
101
|
end
|
@@ -123,7 +111,9 @@ module Ayadn
|
|
123
111
|
def self.create_api_file
|
124
112
|
api_file = @config[:paths][:config] + "/api.json"
|
125
113
|
if File.exist?(api_file)
|
126
|
-
|
114
|
+
# should be 48h in secs (172800)
|
115
|
+
# but since ADN's API won't change any time soon...
|
116
|
+
if ( File.ctime(api_file) < (Time.now - 604800) )
|
127
117
|
self.new_api_file(api_file)
|
128
118
|
end
|
129
119
|
else
|
@@ -171,21 +161,16 @@ module Ayadn
|
|
171
161
|
def self.defaults
|
172
162
|
{
|
173
163
|
timeline: {
|
174
|
-
directed:
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
show_real_name: true,
|
181
|
-
show_date: true,
|
182
|
-
show_spinner: true,
|
183
|
-
show_debug: false,
|
184
|
-
show_channel_oembed: true,
|
164
|
+
directed: true,
|
165
|
+
source: true,
|
166
|
+
symbols: true,
|
167
|
+
name: true,
|
168
|
+
date: true,
|
169
|
+
debug: false,
|
185
170
|
compact: false
|
186
171
|
},
|
187
172
|
marker: {
|
188
|
-
|
173
|
+
messages: true
|
189
174
|
},
|
190
175
|
counts: {
|
191
176
|
default: 50,
|
@@ -197,8 +182,8 @@ module Ayadn
|
|
197
182
|
trending: 50,
|
198
183
|
mentions: 50,
|
199
184
|
convo: 50,
|
200
|
-
posts:
|
201
|
-
messages:
|
185
|
+
posts: 50,
|
186
|
+
messages: 20,
|
202
187
|
search: 200,
|
203
188
|
whoreposted: 20,
|
204
189
|
whostarred: 20,
|
@@ -207,12 +192,16 @@ module Ayadn
|
|
207
192
|
},
|
208
193
|
formats: {
|
209
194
|
table: {
|
210
|
-
width: 75
|
195
|
+
width: 75,
|
196
|
+
borders: true
|
211
197
|
},
|
212
198
|
list: {
|
213
199
|
reverse: true
|
214
200
|
}
|
215
201
|
},
|
202
|
+
channels: {
|
203
|
+
links: true
|
204
|
+
},
|
216
205
|
colors: {
|
217
206
|
id: :blue,
|
218
207
|
index: :red,
|
@@ -226,23 +215,33 @@ module Ayadn
|
|
226
215
|
source: :cyan,
|
227
216
|
symbols: :green,
|
228
217
|
unread: :cyan,
|
229
|
-
debug: :red
|
218
|
+
debug: :red,
|
219
|
+
excerpt: :green
|
230
220
|
},
|
231
221
|
backup: {
|
232
|
-
|
233
|
-
|
234
|
-
|
222
|
+
posts: false,
|
223
|
+
messages: false,
|
224
|
+
lists: false
|
235
225
|
},
|
236
226
|
scroll: {
|
237
|
-
|
227
|
+
spinner: true,
|
228
|
+
timer: 3,
|
229
|
+
date: false
|
230
|
+
},
|
231
|
+
nicerank: {
|
232
|
+
threshold: 2.1,
|
233
|
+
filter: true,
|
234
|
+
unranked: false
|
238
235
|
},
|
239
|
-
nicerank: @default_nr,
|
240
236
|
nowplaying: {},
|
241
237
|
movie: {
|
242
238
|
hashtag: 'nowwatching'
|
243
239
|
},
|
244
240
|
tvshow: {
|
245
241
|
hashtag: 'nowwatching'
|
242
|
+
},
|
243
|
+
blacklist: {
|
244
|
+
active: true
|
246
245
|
}
|
247
246
|
}
|
248
247
|
end
|