ayadn 1.7.7 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ayadn/set.rb CHANGED
@@ -37,6 +37,18 @@ module Ayadn
37
37
  tvshow_config.save
38
38
  end
39
39
 
40
+ desc "marker ITEM TRUE/FALSE", "Set values for stream markers"
41
+ map "markers" => :marker
42
+ def marker(*args)
43
+ marker_config = SetMarker.new
44
+ unless args.length != 2
45
+ marker_config.send(args[0], args[1])
46
+ else
47
+ abort(Status.error_missing_parameters)
48
+ end
49
+ marker_config.save
50
+ end
51
+
40
52
  desc "nicerank ITEM VALUE", "Set NiceRank filter values"
41
53
  long_desc Descriptions.set_nicerank
42
54
  def nicerank *args
@@ -392,6 +404,30 @@ module Ayadn
392
404
 
393
405
  end
394
406
 
407
+ class SetMarker < SetBase
408
+
409
+ def initialize
410
+ super
411
+ @category = 'marker'
412
+ end
413
+
414
+ def validate(value)
415
+ Validators.boolean(value)
416
+ end
417
+
418
+ def method_missing(meth, options)
419
+ @input = meth.to_s
420
+ @output = validate(options)
421
+ case @input
422
+ when 'update_messages'
423
+ Settings.options[:marker][meth.to_sym] = @output
424
+ else
425
+ super
426
+ end
427
+ end
428
+
429
+ end
430
+
395
431
  class SetCounts < SetBase
396
432
 
397
433
  def initialize
@@ -457,7 +493,7 @@ module Ayadn
457
493
  @input = meth.to_s.capitalize
458
494
  @output = validate(options)
459
495
  case meth.to_s
460
- when 'id', 'index', 'username', 'name', 'date', 'link', 'dots', 'hashtags', 'mentions', 'source', 'symbols', 'debug'
496
+ when 'id', 'index', 'username', 'name', 'date', 'link', 'dots', 'hashtags', 'mentions', 'source', 'symbols', 'unread', 'debug'
461
497
  Settings.options[:colors][meth.to_sym] = @output
462
498
  when 'hashtag', 'mention', 'symbol'
463
499
  Settings.options[:colors]["#{meth}s".to_sym] = @output
@@ -64,6 +64,8 @@ module Ayadn
64
64
  def self.init_config
65
65
  @config[:version] = VERSION
66
66
  @config[:platform] = RbConfig::CONFIG['host_os']
67
+ @config[:ruby] = RUBY_VERSION
68
+ @config[:locale] = ENV["LANG"]
67
69
  self.config_file
68
70
  self.create_api_file
69
71
  self.create_version_file
@@ -95,12 +97,14 @@ module Ayadn
95
97
  conf[:timeline][:show_debug] = false if conf[:timeline][:show_debug].nil?
96
98
  conf[:timeline][:show_spinner] = true if conf[:timeline][:show_spinner].nil?
97
99
  conf[:colors][:debug] = :red if conf[:colors][:debug].nil?
100
+ conf[:colors][:unread] = :cyan if conf[:colors][:unread].nil?
98
101
  conf[:nowplaying] = {} if conf[:nowplaying].nil?
99
102
  conf[:movie] = {hashtag: 'nowwatching'} if conf[:movie].nil?
100
103
  conf[:tvshow] = {hashtag: 'nowwatching'} if conf[:tvshow].nil?
101
104
  conf[:formats][:list] = {reverse: true} if conf[:formats][:list].nil?
102
105
  conf[:timeline][:compact] = false if conf[:timeline][:compact].nil?
103
106
  conf[:timeline][:show_channel_oembed] = true if conf[:timeline][:show_channel_oembed].nil?
107
+ conf[:marker] = {update_messages: true} if conf[:marker].nil?
104
108
 
105
109
  @options = conf
106
110
  self.write_config_file(config_file, @options)
@@ -167,10 +171,10 @@ module Ayadn
167
171
  def self.defaults
168
172
  {
169
173
  timeline: {
170
- directed: 1,
171
- deleted: 0,
172
- html: 0,
173
- annotations: 1,
174
+ directed: true,
175
+ deleted: false,
176
+ html: false,
177
+ annotations: true,
174
178
  show_source: true,
175
179
  show_symbols: true,
176
180
  show_real_name: true,
@@ -180,23 +184,26 @@ module Ayadn
180
184
  show_channel_oembed: true,
181
185
  compact: false
182
186
  },
187
+ marker: {
188
+ update_messages: true
189
+ },
183
190
  counts: {
184
191
  default: 50,
185
- unified: 100,
186
- global: 100,
187
- checkins: 100,
192
+ unified: 50,
193
+ global: 50,
194
+ checkins: 50,
188
195
  conversations: 50,
189
196
  photos: 50,
190
- trending: 100,
191
- mentions: 100,
192
- convo: 100,
197
+ trending: 50,
198
+ mentions: 50,
199
+ convo: 50,
193
200
  posts: 100,
194
201
  messages: 50,
195
202
  search: 200,
196
- whoreposted: 50,
197
- whostarred: 50,
203
+ whoreposted: 20,
204
+ whostarred: 20,
198
205
  whatstarred: 100,
199
- files: 100
206
+ files: 50
200
207
  },
201
208
  formats: {
202
209
  table: {
@@ -218,6 +225,7 @@ module Ayadn
218
225
  mentions: :red,
219
226
  source: :cyan,
220
227
  symbols: :green,
228
+ unread: :cyan,
221
229
  debug: :red
222
230
  },
223
231
  backup: {
data/lib/ayadn/status.rb CHANGED
@@ -204,6 +204,9 @@ module Ayadn
204
204
  def self.no_new_posts
205
205
  "\nNo new posts since your last visit.\n\n".color(:cyan)
206
206
  end
207
+ def self.no_new_messages
208
+ "\n No new messages since your last visit.\n".color(:cyan)
209
+ end
207
210
  def self.type_and_target_missing
208
211
  "\nYou have to submit a TYPE (mention, hashtag, client name) and a TARGET (a @username, a hashtag, a client name)\n\n".color(:red)
209
212
  end
data/lib/ayadn/stream.rb CHANGED
@@ -21,10 +21,10 @@ module Ayadn
21
21
  Databases.save_max_id(stream, 'global') unless stream['meta']['max_id'].nil?
22
22
  @view.render(stream, options, niceranks)
23
23
  end
24
- if Settings.options[:timeline][:compact] == true && options[:scroll] == true
24
+ if options[:scroll]
25
25
  @view.clear_screen()
26
+ Scroll.new(@api, @view).global(options)
26
27
  end
27
- Scroll.new(@api, @view).global(options) if options[:scroll]
28
28
  puts "\n" if Settings.options[:timeline][:compact] && options[:raw].nil?
29
29
  end
30
30
 
@@ -51,10 +51,10 @@ module Ayadn
51
51
  Databases.save_max_id(stream)
52
52
  @view.render(stream, options)
53
53
  end
54
- if Settings.options[:timeline][:compact] == true && options[:scroll] == true
54
+ if options[:scroll]
55
55
  @view.clear_screen()
56
+ Scroll.new(@api, @view).send(meth, options)
56
57
  end
57
- Scroll.new(@api, @view).send(meth, options) if options[:scroll]
58
58
  puts "\n" if Settings.options[:timeline][:compact] && options[:raw].nil?
59
59
  end
60
60
 
@@ -73,10 +73,10 @@ module Ayadn
73
73
  options[:in_mentions] = true
74
74
  @view.render(stream, options)
75
75
  end
76
- if Settings.options[:timeline][:compact] == true && options[:scroll] == true
76
+ if options[:scroll]
77
77
  @view.clear_screen()
78
+ Scroll.new(@api, @view).mentions(username, options)
78
79
  end
79
- Scroll.new(@api, @view).mentions(username, options) if options[:scroll]
80
80
  puts "\n" if Settings.options[:timeline][:compact] && options[:raw].nil?
81
81
  end
82
82
 
@@ -201,13 +201,26 @@ module Ayadn
201
201
  end
202
202
 
203
203
  def messages(channel_id, options)
204
+ if options[:silent]
205
+ Settings.options[:marker][:update_messages] = false
206
+ end
204
207
  channel_id = @workers.get_channel_id_from_alias(channel_id)
205
208
  @view.downloading(options)
206
209
  resp = @api.get_messages(channel_id, options)
207
- Check.no_new_posts(resp, options, "channel:#{channel_id}")
210
+ name = "channel:#{channel_id}"
211
+ Check.no_new_posts(resp, options, name)
212
+ if Settings.options[:marker][:update_messages] == true
213
+ unless resp['meta']['max_id'].nil?
214
+ marked = @api.update_marker(name, resp['meta']['max_id'])
215
+ updated = JSON.parse(marked)
216
+ if updated['meta']['code'] != 200
217
+ raise "couldn't update channel #{channel_id} as read"
218
+ end
219
+ end
220
+ end
208
221
  Databases.save_max_id(resp)
209
222
  @view.if_raw(resp, options)
210
- Check.no_data(resp, 'messages')
223
+ Check.no_data(resp, 'messages') unless options[:scroll]
211
224
  @view.render(resp, options)
212
225
  Scroll.new(@api, @view).messages(channel_id, options) if options[:scroll]
213
226
  puts "\n" if Settings.options[:timeline][:compact] && options[:raw].nil?
data/lib/ayadn/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Ayadn
3
- VERSION = "1.7.7"
3
+ VERSION = "1.8.0"
4
4
  end
data/lib/ayadn/workers.rb CHANGED
@@ -236,14 +236,18 @@ module Ayadn
236
236
  values[:num_stars] = 0
237
237
  end
238
238
 
239
+ if post['num_replies']
240
+ values[:num_replies] = post['num_replies']
241
+ else
242
+ values[:num_replies] = 0
243
+ end
244
+
239
245
  if post['reply_to']
240
246
  values[:is_reply] = true
241
247
  values[:reply_to] = post['reply_to']
242
- values[:num_replies] = post['num_replies']
243
248
  else
244
249
  values[:is_reply] = false
245
250
  values[:reply_to] = nil
246
- values[:num_replies] = 0
247
251
  end
248
252
  if post['num_reposts']
249
253
  values[:num_reposts] = post['num_reposts']
@@ -343,6 +347,8 @@ module Ayadn
343
347
  else
344
348
  unread = "No unread messages"
345
349
  end
350
+ @shell.say_status :recording, "channel #{ch['id']}", :green
351
+ Databases.add_channel_object(ch)
346
352
  bucket << chan.new(ch['id'], ch['counts']['messages'], ch['counts']['subscribers'], ch['type'], ch['owner'], ch['annotations'], ch['readers'], ch['editors'], writers, ch['you_subscribed'], unread, ch['recent_message_id'], ch['recent_message'])
347
353
  end
348
354
  puts "\e[H\e[2J"
Binary file
@@ -86,7 +86,10 @@ describe Ayadn::Annotations do
86
86
  },
87
87
  post_max_length: 256,
88
88
  message_max_length: 2048,
89
- version: 'wee'
89
+ version: 'wee',
90
+ ruby: '0',
91
+ locale: 'gibberish',
92
+ platform: 'shoes'
90
93
  })
91
94
  Ayadn::Errors.stub(:warn).and_return("warned")
92
95
  Ayadn::Logs.stub(:rec).and_return("logged")
@@ -94,46 +97,69 @@ describe Ayadn::Annotations do
94
97
  Ayadn::FileOps.stub(:upload_files).and_return([{'data' => {'id' => 3312,'file_token' => '0x3312-YOLO'}},{'data' => {'id' => 5550,'file_token' => '0x5550-WOOT'}}])
95
98
  end
96
99
 
100
+ let(:rest) {Ayadn::CNX}
101
+
97
102
  describe "#base" do
98
103
  it "creates basic annotations" do
99
104
  ann = Ayadn::Annotations.new({})
100
- expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}]
105
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>'shoes', "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}]
106
+ end
107
+ end
108
+
109
+ describe "#youtube" do
110
+ before do
111
+ rest.stub(:download).and_return({'width' => 33, 'height' => 12}.to_json)
112
+ end
113
+ it "creates youtube annotations" do
114
+ ann = Ayadn::Annotations.new({title: 'WUT', source: 'tEsT', options: {youtube: ['http://yolo']}})
115
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>"shoes", "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"net.app.core.oembed", "value"=>{"version"=>"1.0", "type"=>"video", "provider_name"=>"YouTube", "provider_url"=>"http://youtube.com/", "width"=>33, "height"=>12, "title"=>nil, "author_name"=>nil, "author_url"=>nil, "embeddable_url"=>"http://yolo", "html"=>nil, "thumbnail_url"=>nil, "thumbnail_height"=>nil, "thumbnail_width"=>nil}}, {"type"=>"com.ayadn.youtube", "value"=>{"title"=>nil, "link"=>"http://yolo"}}]
116
+ end
117
+ end
118
+
119
+ describe "#vimeo" do
120
+ before do
121
+ rest.stub(:download).and_return({'title' => 'yolo'}.to_json)
122
+ end
123
+ it "creates vimeo annotations" do
124
+ ann = Ayadn::Annotations.new({title: 'WUT', source: 'tEsT', options: {vimeo: ['http://yolo'],}})
125
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>"shoes", "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"net.app.core.oembed", "value"=>{"version"=>"1.0", "type"=>"video", "provider_name"=>"Vimeo", "provider_url"=>"http://vimeo.com/", "width"=>nil, "height"=>nil, "title"=>"yolo", "author_name"=>nil, "author_url"=>nil, "embeddable_url"=>"http://yolo", "html"=>nil, "thumbnail_url"=>nil, "thumbnail_height"=>nil, "thumbnail_width"=>nil}}, {"type"=>"com.ayadn.vimeo", "value"=>{"title"=>"yolo", "link"=>"http://yolo"}}]
101
126
  end
102
127
  end
103
128
 
104
129
  describe "#movie" do
105
130
  it "creates movie annotations" do
106
131
  ann = Ayadn::Annotations.new({title: 'WUT', source: 'tEsT', options: {movie: true}})
107
- expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.movie", "value"=>{"title"=>"WUT", "source"=>"tEsT"}}]
132
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>'shoes', "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.movie", "value"=>{"title"=>"WUT", "source"=>"tEsT"}}]
108
133
  end
109
134
  end
110
135
 
111
136
  describe "#tvshow" do
112
137
  it "creates tvshow annotations" do
113
138
  ann = Ayadn::Annotations.new({title: 'WUT', source: 'tEsT', options: {tvshow: true}})
114
- expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.tvshow", "value"=>{"title"=>"WUT", "source"=>"tEsT"}}]
139
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>'shoes', "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.tvshow", "value"=>{"title"=>"WUT", "source"=>"tEsT"}}]
115
140
  end
116
141
  end
117
142
 
118
143
  describe "#nowplaying --silent" do
119
144
  it "creates nowplaying --silent annotations" do
120
145
  ann = Ayadn::Annotations.new({source: 'wadawadawada', options: {nowplaying: true, no_url: true}})
121
- expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.nowplaying", "value"=>{"status"=>"no-url", "source"=>"wadawadawada"}}]
146
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>'shoes', "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.nowplaying", "value"=>{"status"=>"no-url", "source"=>"wadawadawada"}}]
122
147
  end
123
148
  end
124
149
 
125
150
  describe "#nowplaying" do
126
151
  it "creates nowplaying annotations" do
127
152
  ann = Ayadn::Annotations.new({source: 'rspec', title: 'ibelieveicanfly', artist: 'big jim', artwork: 'http://ahah', link: 'http://ohoh', source: 'fake', width: 9000, height: 30000, artwork_thumb: 'http://hihi', width_thumb: 9, height_thumb: 3, options: {nowplaying: true}})
128
- expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.nowplaying", "value"=>{"title"=>"ibelieveicanfly", "artist"=>'big jim', "artwork"=>"http://ahah", "link"=>"http://ohoh", "source"=>"fake"}}, {"type"=>"net.app.core.oembed", "value"=>{"version"=>"1.0", "type"=>"photo", "width"=>9000, "height"=>30000, "title"=>"ibelieveicanfly", "url"=>"http://ahah", "embeddable_url"=>"http://ahah", "provider_url"=>"https://itunes.apple.com", "provider_name"=>"iTunes", "thumbnail_url"=>"http://hihi", "thumbnail_width"=>9, "thumbnail_height"=>3}}]
153
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>'shoes', "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"com.ayadn.nowplaying", "value"=>{"title"=>"ibelieveicanfly", "artist"=>"big jim", "artwork"=>"http://ahah", "link"=>"http://ohoh", "source"=>"fake"}}, {"type"=>"net.app.core.oembed", "value"=>{"version"=>"1.0", "type"=>"photo", "width"=>9000, "height"=>30000, "title"=>"ibelieveicanfly", "url"=>"http://ahah", "embeddable_url"=>"http://ahah", "provider_url"=>"https://itunes.apple.com", "provider_name"=>"iTunes", "thumbnail_url"=>"http://hihi", "thumbnail_width"=>9, "thumbnail_height"=>3}}]
129
154
  end
130
155
  end
131
156
 
132
157
  describe "#files" do
133
158
  it "creates files annotations" do
134
159
  ann = Ayadn::Annotations.new({options: {embed: ['whatever.jpg', 'another.png']}}) # fake array, cf STUB1
135
- expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"net.app.core.oembed", "value"=>{"+net.app.core.file"=>{"file_id"=>3312, "file_token"=>"0x3312-YOLO", "format"=>"oembed"}}}, {"type"=>"net.app.core.oembed", "value"=>{"+net.app.core.file"=>{"file_id"=>5550, "file_token"=>"0x5550-WOOT", "format"=>"oembed"}}}]
160
+ expect(ann.content).to eq [{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>'shoes', "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}, {"type"=>"net.app.core.oembed", "value"=>{"+net.app.core.file"=>{"file_id"=>3312, "file_token"=>"0x3312-YOLO", "format"=>"oembed"}}}, {"type"=>"net.app.core.oembed", "value"=>{"+net.app.core.file"=>{"file_id"=>5550, "file_token"=>"0x5550-WOOT", "format"=>"oembed"}}}]
136
161
  end
137
162
  end
138
163
 
164
+
139
165
  end
@@ -69,12 +69,12 @@ describe Ayadn::Endpoints do
69
69
  end
70
70
  describe '#channel' do
71
71
  it "returns the channel url" do
72
- expect(Ayadn::Endpoints.new.channel([56789, 12345])).to eq 'https://api.app.net/channels/?ids=56789,12345&access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1'
72
+ expect(Ayadn::Endpoints.new.channel([56789, 12345])).to eq 'https://api.app.net/channels/?ids=56789,12345&access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1&include_marker=1'
73
73
  end
74
74
  end
75
75
  describe '#messages' do
76
76
  it "returns the messages url" do
77
- expect(Ayadn::Endpoints.new.messages(56789)).to eq 'https://api.app.net/channels/56789/messages?access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1&include_machine=1'
77
+ expect(Ayadn::Endpoints.new.messages(56789)).to eq 'https://api.app.net/channels/56789/messages?access_token=XXX&count=100&include_html=0&include_directed=1&include_deleted=0&include_annotations=1&include_machine=1&include_marker=1'
78
78
  end
79
79
  end
80
80
  describe '#file' do
@@ -36,7 +36,10 @@ describe Ayadn::Post do
36
36
  },
37
37
  post_max_length: 256,
38
38
  message_max_length: 2048,
39
- version: 'wee'
39
+ version: 'wee',
40
+ ruby: '0',
41
+ locale: 'gibberish',
42
+ platform: 'shoes'
40
43
  })
41
44
  Ayadn::Settings.stub(:user_token).and_return('XYZ')
42
45
  Ayadn::Settings.stub(:check_for_accounts)
@@ -46,14 +49,17 @@ describe Ayadn::Post do
46
49
 
47
50
  let(:post) { Ayadn::Post.new }
48
51
  #let(:rest) {Ayadn::CNX = double} #verbose in RSpec output, but useful
49
- let(:rest) {Ayadn::CNX}
52
+ let(:rest) {Ayadn::CNX}
50
53
 
51
54
  describe "#post" do
52
55
  before do
53
56
  rest.stub(:post).and_return(File.read("spec/mock/posted.json"))
54
57
  end
55
58
  it "posts a post" do
56
- expect(rest).to receive(:post).with("https://api.app.net/posts/?include_annotations=1&access_token=XYZ", {"text"=>"YOLO", "entities"=>{"parse_markdown_links"=>true, "parse_links"=>true}, "annotations"=>[{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}]})
59
+ expect(rest).to receive(:post).with("https://api.app.net/posts/?include_annotations=1&access_token=XYZ", {"text"=>"YOLO", "entities"=>{"parse_markdown_links"=>true, "parse_links"=>true}, "annotations"=>[{"type"=>"com.ayadn.user", "value"=>{"+net.app.core.user"=>{"user_id"=>"@test", "format"=>"basic"}, "env"=>{"platform"=>"shoes", "ruby"=>"0", "locale"=>"gibberish"}}}, {"type"=>"com.ayadn.client", "value"=>{"url"=>"http://ayadn-app.net", "author"=>{"name"=>"Eric Dejonckheere", "username"=>"ericd", "id"=>"69904", "email"=>"eric@aya.io"}, "version"=>"wee"}}]})
60
+ x = post.post({text: 'YOLO'})
61
+ end
62
+ it "posts a post" do
57
63
  x = post.post({text: 'YOLO'})
58
64
  end
59
65
  it "returns the posted post" do
@@ -68,6 +68,9 @@ def init_stubs
68
68
  auto_save_sent_posts: false,
69
69
  auto_save_sent_messages: false,
70
70
  auto_save_lists: false
71
+ },
72
+ marker: {
73
+ update_messages: true
71
74
  }
72
75
  })
73
76
  Ayadn::Settings.stub(:config).and_return({
@@ -182,7 +185,7 @@ describe Ayadn::SetTimeline do
182
185
 
183
186
  describe "#" do
184
187
  it "creates a default value" do
185
- %w{directed html show_source show_symbols show_real_name show_date show_spinner show_debug}.each do |meth|
188
+ %w{directed html show_source show_symbols show_real_name show_date show_spinner show_debug compact}.each do |meth|
186
189
  command = meth.to_sym
187
190
  Ayadn::SetTimeline.new.send(command, 'true')
188
191
  expect(Ayadn::Settings.options[:timeline][command]).to eq true
@@ -244,6 +247,24 @@ describe Ayadn::SetCounts do
244
247
  end
245
248
  end
246
249
 
250
+ describe Ayadn::SetMarker do
251
+ before do
252
+ init_stubs
253
+ end
254
+
255
+ describe "#update_messages" do
256
+ it "creates a default value" do
257
+ expect(Ayadn::Settings.options[:marker][:update_messages]).to eq true
258
+ Ayadn::SetMarker.new.update_messages('0')
259
+ expect(Ayadn::Settings.options[:marker][:update_messages]).to eq false
260
+ end
261
+ end
262
+
263
+ after do
264
+ File.delete('spec/mock/ayadn.log')
265
+ end
266
+ end
267
+
247
268
  describe Ayadn::SetBackup do
248
269
  before do
249
270
  init_stubs
@@ -25,7 +25,10 @@ describe Ayadn::View do
25
25
  show_symbols: true,
26
26
  show_source: true
27
27
  },
28
- formats: {table: {width: 75}},
28
+ formats: {
29
+ table: {width: 75},
30
+ list: {reverse: true}
31
+ },
29
32
  counts: {
30
33
  default: 33
31
34
  }
@@ -55,79 +58,86 @@ describe Ayadn::View do
55
58
  let(:int) { JSON.parse(File.read("spec/mock/int.json")) }
56
59
  let(:files) { JSON.parse(File.read("spec/mock/files.json")) }
57
60
  let(:user_e) { JSON.parse(File.read("spec/mock/@ericd.json")) }
61
+ let(:rest) {Ayadn::CNX}
58
62
  let(:users) { {"007"=>["bond", "James Bond", true, true], "666"=>["mrtest", "Mr Test", false, false]} }
59
63
 
60
- # describe "#show_list_reposted" do
61
- # before do
62
- # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
63
- # end
64
- # it "outputs the reposters list" do
65
- # printed = capture_stdout do
66
- # Ayadn::View.new.show_list_reposted(list[0]['data'], 123456)
67
- # end
68
- # expect(printed).to include *['Joel Timmins', 'Donny Davis', 'Nicolas Maumont', '95.41', 'reposted post']
69
- # end
70
- # end
71
-
72
- # describe "#show_list_starred" do
73
- # before do
74
- # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
75
- # end
76
- # it "outputs the starred list" do
77
- # printed = capture_stdout do
78
- # Ayadn::View.new.show_list_starred(list[0]['data'], 123456)
79
- # end
80
- # expect(printed).to include *['Joel Timmins', 'Donny Davis', 'Nicolas Maumont', '95.41', 'starred post']
81
- # end
82
- # end
83
-
84
- # describe "#show_list_followings" do
85
- # before do
86
- # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
87
- # end
88
- # it "outputs the followings list" do
89
- # printed = capture_stdout do
90
- # Ayadn::View.new.show_list_followings(users, '@bond')
91
- # end
92
- # expect(printed).to include *['List of users', 'is following', '0.83']
93
- # end
94
- # end
95
-
96
- # describe "#show_list_followers" do
97
- # before do
98
- # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
99
- # end
100
- # it "outputs the followers list" do
101
- # printed = capture_stdout do
102
- # Ayadn::View.new.show_list_followers(users, '@bond')
103
- # end
104
- # expect(printed).to include *['List of users following', '0.83']
105
- # end
106
- # end
107
-
108
- # describe "#show_list_muted" do
109
- # before do
110
- # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
111
- # end
112
- # it "outputs the muted list" do
113
- # printed = capture_stdout do
114
- # Ayadn::View.new.show_list_muted(users)
115
- # end
116
- # expect(printed).to include *['List of users you muted', '0.83']
117
- # end
118
- # end
119
-
120
- # describe "#show_list_blocked" do
121
- # before do
122
- # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
123
- # end
124
- # it "outputs the blocked list" do
125
- # printed = capture_stdout do
126
- # Ayadn::View.new.show_list_blocked(users)
127
- # end
128
- # expect(printed).to include *['List of users you blocked', '0.83']
129
- # end
130
- # end
64
+ describe "#show_list_reposted" do
65
+ before do
66
+ Ayadn::NiceRank.stub(:from_ids).and_return([{}])
67
+ rest.stub(:get)
68
+ end
69
+ it "outputs the reposters list" do
70
+ printed = capture_stdout do
71
+ Ayadn::View.new.show_list_reposted(list[0]['data'], 123456)
72
+ end
73
+ expect(printed).to include *['Joel Timmins', 'Donny Davis', 'Nicolas Maumont', 'reposted post', '123456']
74
+ end
75
+ end
76
+
77
+ describe "#show_list_starred" do
78
+ before do
79
+ Ayadn::NiceRank.stub(:from_ids).and_return([{}])
80
+ rest.stub(:get)
81
+ end
82
+ it "outputs the starred list" do
83
+ printed = capture_stdout do
84
+ Ayadn::View.new.show_list_starred(list[0]['data'], 123456)
85
+ end
86
+ expect(printed).to include *['Joel Timmins', 'Donny Davis', 'Nicolas Maumont', 'starred post', '123456']
87
+ end
88
+ end
89
+
90
+ describe "#show_list_followings" do
91
+ before do
92
+ Ayadn::NiceRank.stub(:from_ids).and_return([{}])
93
+ rest.stub(:get)
94
+ end
95
+ it "outputs the followings list" do
96
+ printed = capture_stdout do
97
+ Ayadn::View.new.show_list_followings(users, '@bond')
98
+ end
99
+ expect(printed).to include *['List of users', 'is following', '@bond']
100
+ end
101
+ end
102
+
103
+ describe "#show_list_followers" do
104
+ before do
105
+ Ayadn::NiceRank.stub(:from_ids).and_return([{}])
106
+ rest.stub(:get)
107
+ end
108
+ it "outputs the followers list" do
109
+ printed = capture_stdout do
110
+ Ayadn::View.new.show_list_followers(users, '@bond')
111
+ end
112
+ expect(printed).to include *['List of users following', '@bond']
113
+ end
114
+ end
115
+
116
+ describe "#show_list_muted" do
117
+ before do
118
+ Ayadn::NiceRank.stub(:from_ids).and_return([{}])
119
+ rest.stub(:get)
120
+ end
121
+ it "outputs the muted list" do
122
+ printed = capture_stdout do
123
+ Ayadn::View.new.show_list_muted(users)
124
+ end
125
+ expect(printed).to include *['List of users you muted', '@mrtest', '@bond', 'Mr Test']
126
+ end
127
+ end
128
+
129
+ describe "#show_list_blocked" do
130
+ before do
131
+ Ayadn::NiceRank.stub(:from_ids).and_return([{}])
132
+ rest.stub(:get)
133
+ end
134
+ it "outputs the blocked list" do
135
+ printed = capture_stdout do
136
+ Ayadn::View.new.show_list_blocked(users)
137
+ end
138
+ expect(printed).to include *['List of users you blocked', '@mrtest', '@bond', 'Mr Test']
139
+ end
140
+ end
131
141
 
132
142
  describe "#show_interactions" do
133
143
  it "outputs the interactions list" do
@@ -154,6 +164,10 @@ describe Ayadn::View do
154
164
  end
155
165
  expect(printed).to include "23184500"
156
166
  expect(printed).to include "Backer of the Day"
167
+ expect(printed).to include '23184932'
168
+ expect(printed).to include '20:11:14'
169
+ expect(printed).to include 'too big for humans to check'
170
+ expect(printed).to include 'https://app.net/b/m6bk3'
157
171
  end
158
172
  end
159
173
 
@@ -187,6 +201,9 @@ describe Ayadn::View do
187
201
  end
188
202
 
189
203
  describe "#show_userinfos" do
204
+ before do
205
+ rest.stub(:get_response_from)
206
+ end
190
207
  it "outputs user info" do
191
208
  printed = capture_stdout do
192
209
  Ayadn::View.new.show_userinfos(user_e['data'], "")