ayadn 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 378ae34a1b17ea7a5b489e31a4f29900ca2e0e4d
4
- data.tar.gz: f4156ace495c8386f163ab656c177fc3db99d130
3
+ metadata.gz: 4e61b11ce1fb15597ebc3135369adfa636237eb8
4
+ data.tar.gz: 21d7212478b82061405f8d19b155337ee8608dd1
5
5
  SHA512:
6
- metadata.gz: c76c035e1c8b84d265326e39cad4e2b9519de784c68b35ad30c793d12b11b2e487eaca7347be6c3c03381817ed255d3f4a692bbc5f67d65a6212558a257ef4c1
7
- data.tar.gz: aafcac122e8d86609a94bf8be2f6b8783224798254d20841192d6d060b6caa1c5138fa2b83c024475de043ced1ae6e31db54664695adee0ad255a0814f181e1d
6
+ metadata.gz: 24a08e36d52210deb4f86929d01c4b1b649cb9689244a7e19a9132c5ac75d9ba36ab6e86abb2a99f4f1f074dcdb1b8d455b9444e047aad31649c63b4d251d198
7
+ data.tar.gz: 86a3471b48d7cc678ffb28b871e41e65a2a32caa156244b03ce08d05dea32867039449774f456a3ee805cd5cbd02ade1d99d181093a907b58b0f690081498b6c
data/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
- # 1.7.0 - 'Private Investigations'
1
+ # 1.7.1 (2014-09-02) - 'Poltergeist'
2
+
3
+ - New: update your user profile (full name, bio (user description), avatar, cover, Twitter username, blog url, web url)
4
+ - Update profile: option to delete the field instead of updating
5
+ - New: option to retrieve only specified channels in Channels
6
+ - New: option to display raw response in Channels
7
+
8
+ # 1.7.0 (2014-08-21) - 'Private Investigations'
2
9
 
3
10
  - New: embed a Youtube video in a normal post with option `-Y`
4
11
  - New: embed a Vimeo video in a normal post with option `-V`
@@ -10,7 +17,7 @@
10
17
  - Fixed: value displayed when setting NiceRank
11
18
  - Refactored a few classes and methods
12
19
 
13
- # 1.6.0 - 'Beetlejuice'
20
+ # 1.6.0 (2014-08-04) - 'Beetlejuice'
14
21
 
15
22
  - New command: 'movie'. Create a post from a movie title (with link + movie poster). Customisable hashtag (default: '#nowwatching').
16
23
  - New command: 'tvshow'. Create a post from a TV show title (with link + show poster). Customisable hashtag (default: '#nowwatching'). Option to display a banner instead of a poster.
@@ -21,11 +28,11 @@
21
28
  - Fixed: bookmark convos.
22
29
  - General code cleaning and refactoring.
23
30
 
24
- # 1.5.1 - 'Holograms'
31
+ # 1.5.1 (2014-07-27) - 'Holograms'
25
32
 
26
33
  - Improved accuracy of iTunes Store requests for NowPlaying
27
34
 
28
- # 1.5.0 - 'Nozomi'
35
+ # 1.5.0 (2014-07-25) - 'Nozomi'
29
36
 
30
37
  - In 'convo', both the post id you've requested and the post it replies to are marked with arrows
31
38
  - Same feature in the view after a reply
@@ -42,7 +49,7 @@
42
49
 
43
50
  - Temporary fix for filepaths instability when uploading pictures
44
51
 
45
- # 1.4.5 - 'Sébastien'
52
+ # 1.4.5 (2014-07-19) - 'Sébastien'
46
53
 
47
54
  - Fixed a crash when iTunes Store URL contained exotic characters
48
55
 
@@ -50,7 +57,7 @@
50
57
 
51
58
  - Fixed a database problem in PM and SEND
52
59
 
53
- # 1.4.3 - 'Sergent Stretch'
60
+ # 1.4.3 (2014-07-17) - 'Sergent Stretch'
54
61
 
55
62
  - NowPlaying is compatible with iTunes and Last.fm. Default: iTunes. Add `--last-fm` or `-l` to get Last.fm last played track instead
56
63
  - NowPlaying audio link has been replaced with an iTunes Store link
@@ -60,7 +67,7 @@
60
67
  - Automatically fixes the arguments order for 'post' if needed when uploading a picture
61
68
  - General code cleaning
62
69
 
63
- # 1.4.2 - 'Caligula'
70
+ # 1.4.2 (2014-07-15) - 'Caligula'
64
71
 
65
72
  - Ayadn is more resilient to connectivity errors
66
73
  - Better handling of filenames when uploading
@@ -69,7 +76,7 @@
69
76
 
70
77
  - A few fixes in the NowPlaying section
71
78
 
72
- # 1.4.0 - 'Florian'
79
+ # 1.4.0 (2014-07-14) - 'Florian'
73
80
 
74
81
  - New feature: embed one or several pictures within a post (in write, post, reply, and pm)
75
82
  - Nowplaying inserts preview URL and album art from iTunes Store (you can prevent this with: `--no-url`)
@@ -78,11 +85,11 @@
78
85
 
79
86
  - Fixed: Global stream crashed if NiceRank was enabled but unreachable
80
87
 
81
- # 1.3.1 - 'Nico'
88
+ # 1.3.1 (2014-06-16) - 'Nico'
82
89
 
83
90
  - NiceRank threshold is a float again. Default value is 2.1
84
91
 
85
- # 1.3.0 - 'K'
92
+ # 1.3.0 (2014-06-09) - 'K'
86
93
 
87
94
  - Updated the NiceRank API url
88
95
  - NiceRank filter is more efficient (checks is_human + real_person)
@@ -99,14 +106,14 @@ Features:
99
106
 
100
107
  - Fixed the non-installing unicode_utils Gem
101
108
 
102
- # 1.2.9 - 'Kirschen'
109
+ # 1.2.9 (2014-05-29) - 'Kirschen'
103
110
 
104
111
  - NiceRank database auto-limits to 10000 users
105
112
  - Better handling of connection errors
106
113
  - Better display of emojis
107
114
  - General code cleaning
108
115
 
109
- # 1.2.8 - 'Hans'
116
+ # 1.2.8 (2014-05-27) - 'Hans'
110
117
 
111
118
  - No more Ruby 1.9.3
112
119
  - Search for users: returns a detailed view of users containing word(s) in their bio/description
@@ -132,7 +139,7 @@ Features:
132
139
 
133
140
  - Fix the NiceRank filter staying on true
134
141
 
135
- # 1.2.4 - 'Stoopid me'
142
+ # 1.2.4 (2014-05-25) - 'Stoopid me'
136
143
 
137
144
  - Fix the copy/paste error in Settings
138
145
 
@@ -146,23 +153,23 @@ Features:
146
153
  - Option for showing debug messages
147
154
  - Show spinner = true
148
155
 
149
- # 1.2.2 - 'Chris'
156
+ # 1.2.2 (2014-05-21) - 'Chris'
150
157
 
151
158
  - No more empty lines in the scroll
152
159
  - Spinner while waiting for posts (false by default)
153
160
  - Hashtags support accented characters
154
161
 
155
- # 1.2.1 - 'Vinz'
162
+ # 1.2.1 (2014-05-20) - 'Vinz'
156
163
 
157
164
  - Fixed the exclusion bug in NiceRank filters
158
165
  - Improved the truncation in Mark list
159
166
  - Changes to match changes in NiceRank API
160
167
 
161
- # 1.2.0 - 'Jason'
168
+ # 1.2.0 (2014-05-19) - 'Jason'
162
169
 
163
170
  - @matigo's NiceRank filter for the Global stream
164
171
 
165
- # 1.1.3 - 'Kevin'
172
+ # 1.1.3 (2014-05-17) - 'Kevin'
166
173
 
167
174
  - Bookmark a conversation
168
175
  - List, delete, rename bookmarks
@@ -171,12 +178,12 @@ Features:
171
178
 
172
179
  - URL for the docs
173
180
 
174
- # 1.1.1 - 'State Of The Onion'
181
+ # 1.1.1 (2014-05-07) - 'State Of The Onion'
175
182
 
176
183
  - Star and unstar a reposted post
177
184
  - Nowplaying shows an error message if iTunes is closed or not currently playing any track
178
185
 
179
- # 1.1.0 - 'Leviathan'
186
+ # 1.1.0 (2014-04-28) - 'Leviathan'
180
187
 
181
188
  - Show who's writing, and who's the recipient
182
189
  - Less help text when writing, more concise
@@ -188,7 +195,7 @@ Features:
188
195
  - New command: photos stream
189
196
  - New command: delete message (private or in a channel)
190
197
 
191
- # 1.0.13 - 'Charlotte'
198
+ # 1.0.13 (2014-04-25) - 'Charlotte'
192
199
 
193
200
  - New layout for '#nowplaying'
194
201
  - Compact index.db and pagination.db if necessary
@@ -212,14 +219,14 @@ Features:
212
219
 
213
220
  - Fixes the stubborn 'nowplaying' database bug
214
221
 
215
- # 1.0.8 - 'Laurent'
222
+ # 1.0.8 (2014-04-16) - 'Laurent'
216
223
 
217
224
  - Better error messages/logs (specifically when HTTP errors)
218
225
  - Token is anonymized if in error logs
219
226
  - No more database error when canceling a 'nowplaying' post
220
227
  - Better mentions colorization
221
228
 
222
- # 1.0.7 - 'Hugo'
229
+ # 1.0.7 (2014-04-13) - 'Hugo'
223
230
 
224
231
  - Machine-only messages in channels are now viewable
225
232
  - Don't output "Downloading" if options = raw in messages view
@@ -227,7 +234,7 @@ Features:
227
234
  - Removed username in front of ">>" in Auto (in case the authd user changed)
228
235
  - Compatibility with Windows is broken
229
236
 
230
- # 1.0.6 - 'Matthew'
237
+ # 1.0.6 (2014-04-12) - 'Matthew'
231
238
 
232
239
  - Fixed a bug where post_max_chars was displayed instead of message_max_chars
233
240
  - Show raw JSON in messages even if no data
@@ -237,7 +244,7 @@ Features:
237
244
  - Fixed the colorization for mentions
238
245
  - Added tests for colorization
239
246
 
240
- # 1.0.4 - 'Jeremy'
247
+ # 1.0.4 (2014-04-06) - 'Jeremy'
241
248
 
242
249
  - Fixed 'reply to an indexed stream' for Ruby < 2.1
243
250
  - More tests for Databases
@@ -256,7 +263,7 @@ Features:
256
263
  - Better layout for checkins
257
264
  - Better alert message if error 429
258
265
 
259
- # 1.0.1 - 'Phoenix'
266
+ # 1.0.1 (2014-04-04) - 'Phoenix'
260
267
 
261
268
  Release!
262
269
 
data/README.md CHANGED
@@ -14,22 +14,25 @@ The purpose of Ayadn is to let you use all the features of App.net from the cons
14
14
  - reply to users
15
15
  - write fast single-line or complex multi-line posts
16
16
  - embed pictures in posts
17
+ - embed online video in posts
18
+ - embed movie poster in posts
17
19
  - view/scroll the Global stream with spammers filtered out
18
20
  - view/scroll posts from specific users or posts mentioning a user
19
21
  - follow/unfollow users, star/repost/mute/block/unstar/etc
20
- - create/manage silent bookmarks for conversations
22
+ - create local bookmarks for conversations
21
23
  - get information about users and their followers/followings
22
24
  - search for words, hashtags, post annotations, channels, etc
23
25
  - extract links from conversations, streams, posts, etc
24
26
  - list and download your files
25
27
  - view (and write to) all your channels including Broadcasts, Patter, Ohai, etc
26
28
  - 'nowplaying' from iTunes or Last.fm, with album art and store link
27
- - 'movie' creates a post from a movie title with poster, etc
28
- - 'tvshow' creates a post from a TV show title with poster, etc
29
+ - 'movie' creates a post from a movie title with poster, plot, and link
30
+ - 'tvshow' creates a post from a TV show title with poster, plot, and link
29
31
  - view/send private messages
30
32
  - view geolocation data in streams
31
- - create/manage silent black lists of users, mentions or hashtags
32
- - create/manage aliases for easier use of channels ids
33
+ - create silent black lists of users, mentions or hashtags
34
+ - create aliases for easier use of channels ids
35
+ - update your user profile
33
36
  - export links and text from a post to Pinboard
34
37
  - option to export almost any stream or object in JSON
35
38
  - options: set the number of posts by request, show only new posts, etc
@@ -61,7 +64,7 @@ Uninstall:
61
64
 
62
65
  # DOCUMENTATION
63
66
 
64
- [Read the docs at ayadn-app.net/doc](http://ayadn-app.net/doc/)
67
+ [In the /doc folder of the repo](https://github.com/ericdke/na/tree/master/doc)
65
68
 
66
69
  # CONTACT
67
70
 
data/doc/07-actions.md CHANGED
@@ -113,3 +113,39 @@ Export a post's link and text, with tags, to your Pinboard account.
113
113
  `ayadn pin 22790201 Ayadn gem update`
114
114
 
115
115
  `ayadn pin 26874913 duel swords france`
116
+
117
+ # UPDATE
118
+
119
+ Update your user profile.
120
+
121
+ Use option `--delete` or `-D` to delete the field.
122
+
123
+ `ayadn --update --bio`
124
+
125
+ `ayadn -U --bio`
126
+
127
+ `ayadn --update --bio --delete`
128
+
129
+ `ayadn -U --bio -D`
130
+
131
+ `ayadn -U --name`
132
+
133
+ `ayadn -U --twitter`
134
+
135
+ `ayadn -U --twitter -D`
136
+
137
+ `ayadn -U --blog`
138
+
139
+ `ayadn -U --blog -D`
140
+
141
+ `ayadn -U --web`
142
+
143
+ `ayadn -U --web -D`
144
+
145
+ `ayadn -U --avatar ~/Pics/myface.jpg`
146
+
147
+ Avatar: the uploaded image will be cropped to square and must be smaller than 1 MB. The optimal size is 200×200 pixels.
148
+
149
+ `ayadn -U --cover ~/Pics/mycats.jpg`
150
+
151
+ Cover: the uploaded image must be at least 960 pixels wide and less than 4 MB in size.
data/doc/08-listings.md CHANGED
@@ -30,6 +30,18 @@ List your active App.net channels.
30
30
 
31
31
  `ayadn -ch`
32
32
 
33
+ Retrieve only specified channel(s) with option `--id`:
34
+
35
+ `ayadn -ch --id 55123`
36
+
37
+ `ayadn -ch --id 55123 34678 988776`
38
+
39
+ Display raw response with option `-x`:
40
+
41
+ `ayadn -ch -x`
42
+
43
+ `ayadn -ch -x --id 55123`
44
+
33
45
  # INTERACTIONS
34
46
 
35
47
  Shows a short reminder of your recent App.net activity.
data/lib/ayadn/action.rb CHANGED
@@ -311,26 +311,46 @@ module Ayadn
311
311
 
312
312
  def view_settings(options)
313
313
  begin
314
- options[:raw] ? (puts Settings.options.to_json) : @view.show_settings
314
+ if options[:raw]
315
+ jj JSON.parse(Settings.config.to_json)
316
+ jj JSON.parse(Settings.options.to_json)
317
+ else
318
+ @view.show_settings
319
+ end
320
+ rescue => e
321
+ Errors.global_error({error: e, caller: caller, data: [options]})
322
+ end
323
+ end
324
+
325
+ def userupdate options
326
+ begin
327
+ profile = Profile.new(options)
328
+ profile.get_text_from_user
329
+ profile.prepare_payload
330
+ puts "\n\nUpdating profile...\n".color(:green)
331
+ profile.update
332
+ puts Status.done
333
+ userinfo('me')
315
334
  rescue => e
316
335
  Errors.global_error({error: e, caller: caller, data: [options]})
317
336
  end
318
337
  end
319
338
 
320
- def userinfo(username, options)
339
+ def userinfo(username, options = {})
321
340
  begin
341
+ username = [username] unless username.is_a?(Array)
322
342
  Check.no_username(username)
323
343
  username = @workers.add_arobase(username)
324
- @view.downloading(options)
325
344
  if options[:raw]
326
- resp = @api.get_user(username)
327
- @view.show_raw(resp, options)
328
- exit
345
+ @view.show_raw(@api.get_user(username), options)
346
+ else
347
+ @view.downloading
348
+ stream = @api.get_user(username)
349
+ Check.no_user(stream, username)
350
+ Check.same_username(stream) ? token = @api.get_token_info['data'] : token = nil
351
+ @view.clear_screen
352
+ @view.infos(stream['data'], token)
329
353
  end
330
- stream = @api.get_user(username)
331
- Check.no_user(stream, username)
332
- Check.same_username(stream) ? token = @api.get_token_info['data'] : token = nil
333
- @view.infos(stream['data'], token)
334
354
  rescue => e
335
355
  Errors.global_error({error: e, caller: caller, data: [username, options]})
336
356
  end
@@ -340,14 +360,13 @@ module Ayadn
340
360
  begin
341
361
  Settings.options[:force] = true if options[:force]
342
362
  Check.bad_post_id(post_id)
343
- @view.downloading(options)
363
+ details = lambda { @api.get_details(post_id, options) }
344
364
  if options[:raw]
345
- details = @api.get_details(post_id, options)
346
- @view.show_raw(details, options)
365
+ @view.show_raw(details.call, options)
347
366
  exit
348
367
  end
349
368
  @view.clear_screen
350
- response = @api.get_details(post_id, options)
369
+ response = details.call
351
370
  Check.no_post(response, post_id)
352
371
  resp = response['data']
353
372
  response = @api.get_user("@#{resp['user']['username']}")
@@ -373,14 +392,16 @@ module Ayadn
373
392
 
374
393
  def files(options)
375
394
  begin
376
- @view.downloading(options)
395
+ get_files = lambda { @api.get_files_list(options) }
377
396
  if options[:raw]
378
- @view.show_raw(@api.get_files_list(options), options)
379
- exit
397
+ @view.show_raw(get_files.call)
398
+ else
399
+ @view.downloading
400
+ list = get_files.call
401
+ Errors.no_data('files') if list.empty?
402
+ @view.clear_screen
403
+ @view.show_files_list(list)
380
404
  end
381
- list = @api.get_files_list(options)
382
- @view.clear_screen
383
- list.empty? ? Errors.no_data('files') : @view.show_files_list(list)
384
405
  rescue => e
385
406
  Errors.global_error({error: e, caller: caller, data: [options]})
386
407
  end
@@ -396,14 +417,25 @@ module Ayadn
396
417
  end
397
418
  end
398
419
 
399
- def channels
420
+ def channels options
400
421
  begin
401
- @view.downloading
402
- resp = @api.get_channels
403
- @view.clear_screen
404
- @view.show_channels(resp)
422
+ channels = if options[:id]
423
+ channel_id = options[:id].map {|id| @workers.get_channel_id_from_alias(id)}
424
+ lambda { @api.get_channel(channel_id, options) }
425
+ else
426
+ lambda { @api.get_channels }
427
+ end
428
+ if options[:raw]
429
+ @view.show_raw(channels.call)
430
+ exit
431
+ else
432
+ @view.downloading
433
+ resp = channels.call
434
+ @view.clear_screen
435
+ @view.show_channels(resp)
436
+ end
405
437
  rescue => e
406
- Errors.global_error({error: e, caller: caller, data: [resp['meta']]})
438
+ Errors.global_error({error: e, caller: caller, data: [options]})
407
439
  end
408
440
  end
409
441
 
@@ -576,7 +608,7 @@ module Ayadn
576
608
 
577
609
  def nowplaying(options = {})
578
610
  np = NowPlaying.new(@api, @view, @workers)
579
- options['lastfm'] ? np.lastfm(options) : np.itunes(options)
611
+ options[:lastfm] ? np.lastfm(options) : np.itunes(options)
580
612
  end
581
613
 
582
614
  def nowwatching(args, options = {})
@@ -596,10 +628,10 @@ module Ayadn
596
628
  begin
597
629
  abort(Status.error_missing_title) if args.empty?
598
630
  client = TvShow.new
599
- if options['alt']
600
- show_obj = client.find_alt(args.join(' '))
631
+ show_obj = if options[:alt]
632
+ client.find_alt(args.join(' '))
601
633
  else
602
- show_obj = client.find(args.join(' '))
634
+ client.find(args.join(' '))
603
635
  end
604
636
  candidate = client.create_details(show_obj)
605
637
  candidate.ok ? candidate.post(options) : candidate.cancel
data/lib/ayadn/api.rb CHANGED
@@ -225,6 +225,11 @@ module Ayadn
225
225
  # big
226
226
  end
227
227
 
228
+ def get_channel channel_id, options
229
+ options = {:recent_message => 1, :annotations => 1, :before_id => nil}
230
+ get_parsed_response(Endpoints.new.channel(channel_id, options))
231
+ end
232
+
228
233
  def get_messages(channel_id, options)
229
234
  options = paginate options, "channel:#{channel_id}"
230
235
  get_parsed_response(Endpoints.new.messages(channel_id, options))
data/lib/ayadn/app.rb CHANGED
@@ -3,7 +3,7 @@ module Ayadn
3
3
  class App < Thor
4
4
  package_name "Ayadn"
5
5
 
6
- %w{action stream api search descriptions endpoints cnx view workers settings post status extend databases fileops logs pinboard set alias errors blacklist scroll authorize switch mark nicerank debug check nowplaying nowwatching tvshow annotations}.each { |r| require_relative "#{r}" }
6
+ %w{action stream api search descriptions endpoints cnx view workers settings post status extend databases fileops logs pinboard set alias errors blacklist scroll authorize switch mark nicerank debug check nowplaying nowwatching tvshow annotations profile}.each { |r| require_relative "#{r}" }
7
7
 
8
8
  ##
9
9
  # These methods are intended to be called from the CLI.
@@ -232,6 +232,21 @@ module Ayadn
232
232
  Action.new.userinfo(username, options)
233
233
  end
234
234
 
235
+ desc "userupdate", "Update your user profile informations (-U)"
236
+ map "-U" => :userupdate
237
+ long_desc Descriptions.userupdate
238
+ option :delete, aliases: "-D", type: :boolean, desc: "Delete this content from your profile"
239
+ option :bio, type: :boolean, desc: "Update your user bio"
240
+ option :name, type: :boolean, desc: "Update your user full name"
241
+ option :twitter, type: :boolean, desc: "Update your Twitter username"
242
+ option :blog, type: :boolean, desc: "Update your blog url"
243
+ option :web, type: :boolean, desc: "Update your web url"
244
+ option :avatar, type: :array, desc: "Update your avatar picture"
245
+ option :cover, type: :array, desc: "Update your cover picture"
246
+ def userupdate
247
+ Action.new.userupdate(options)
248
+ end
249
+
235
250
  desc "postinfo POST", "Show detailed informations about a post (-pi)"
236
251
  map "-pi" => :postinfo
237
252
  long_desc Descriptions.postinfo
@@ -338,8 +353,10 @@ module Ayadn
338
353
  desc "channels", "List your active channels (-ch)"
339
354
  map "-ch" => :channels
340
355
  long_desc Descriptions.channels
356
+ option :id, aliases: "-i", type: :array, desc: "Retrieve only the specified channel(s)"
357
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
341
358
  def channels
342
- Action.new.channels
359
+ Action.new.channels(options)
343
360
  end
344
361
 
345
362
  desc "messages CHANNEL", "Show messages in a CHANNEL (-ms)"
data/lib/ayadn/cnx.rb CHANGED
@@ -157,5 +157,19 @@ module Ayadn
157
157
  end
158
158
  end
159
159
 
160
+ def self.patch(url, payload)
161
+ begin
162
+ RestClient.patch(url, payload.to_json, :content_type => :json, :accept => :json) do |response, request, result|
163
+ Debug.http response, url
164
+ check response
165
+ end
166
+ rescue SocketError, SystemCallError => e
167
+ puts "\nConnection error.".color(:red)
168
+ Errors.global_error({error: e, caller: caller, data: [url, payload]})
169
+ rescue => e
170
+ Errors.global_error({error: e, caller: caller, data: [url, payload]})
171
+ end
172
+ end
173
+
160
174
  end
161
175
  end
@@ -495,6 +495,30 @@ module Ayadn
495
495
  \n\n
496
496
  USAGE
497
497
  end
498
+ def self.userupdate
499
+ <<-USAGE
500
+ Update your user profile.
501
+
502
+ Usage:
503
+
504
+ ayadn userupdate --bio
505
+
506
+ ayadn -U --bio
507
+
508
+ ayadn -U --name
509
+
510
+ ayadn -U --birthday
511
+
512
+ ayadn -U --twitter
513
+
514
+ ayadn -U --blog
515
+
516
+ ayadn -U --avatar ~/Pics/myface.jpg
517
+
518
+ ayadn -U --cover ~/Pics/mycats.jpg
519
+ \n\n
520
+ USAGE
521
+ end
498
522
  def self.postinfo
499
523
  <<-USAGE
500
524
  Show detailed informations about post n°POST.
@@ -256,12 +256,20 @@ module Ayadn
256
256
  "#{@channels_url}?access_token=#{Settings.user_token}#{API.build_query(options)}"
257
257
  end
258
258
 
259
+ def channel(channel_id, options = {})
260
+ "#{@channels_url}#{channel_id.join(',')}?access_token=#{Settings.user_token}#{API.build_query(options)}"
261
+ end
262
+
259
263
  def messages(channel_id, options = {})
260
264
  "#{@channels_url}#{channel_id}/messages?access_token=#{Settings.user_token}#{API.build_query(options)}&include_machine=1"
261
265
  end
262
266
 
263
- def ayadnlog
264
- "#{@channels_url}47348/messages?access_token=#{Settings.user_token}"
267
+ def avatar
268
+ "#{@users_url}me/avatar"
269
+ end
270
+
271
+ def cover
272
+ "#{@users_url}me/cover"
265
273
  end
266
274
 
267
275
  end
data/lib/ayadn/fileops.rb CHANGED
@@ -63,6 +63,22 @@ module Ayadn
63
63
  end
64
64
  end
65
65
 
66
+ def self.upload_avatar file
67
+ begin
68
+ `curl -X POST -H "Authorization: Bearer #{Settings.user_token}" -F "avatar=@#{file}" #{Endpoints.new.avatar}`
69
+ rescue Errno::ENOENT
70
+ abort(Status.no_curl)
71
+ end
72
+ end
73
+
74
+ def self.upload_cover file
75
+ begin
76
+ `curl -X POST -H "Authorization: Bearer #{Settings.user_token}" -F "cover=@#{file}" #{Endpoints.new.cover}`
77
+ rescue Errno::ENOENT
78
+ abort(Status.no_curl)
79
+ end
80
+ end
81
+
66
82
  private
67
83
 
68
84
  def get_users(list)
data/lib/ayadn/post.rb CHANGED
@@ -16,6 +16,7 @@ module Ayadn
16
16
  next if m == Settings.config[:identity][:username]
17
17
  reply << " @#{m}"
18
18
  end
19
+ post_size(reply)
19
20
  dic[:text] = reply
20
21
  dic[:reply_to] = dic[:id]
21
22
  send_content(Endpoints.new.posts_url, payload_reply(dic))
@@ -104,11 +105,22 @@ module Ayadn
104
105
  post
105
106
  end
106
107
 
107
- def check_post_length(lines_array)
108
+ def post_size(post) # works on a string
109
+ size, max_size = post.length, Settings.config[:post_max_length]
110
+ if size < 1
111
+ abort(error_text_empty)
112
+ elsif size > max_size
113
+ Errors.warn "Canceled: too long (#{size - max_size}chars)"
114
+ puts "\nYour text was: \n\n#{post}\n\n".color(:yellow)
115
+ abort(Status.too_long(size, max_size))
116
+ end
117
+ end
118
+
119
+ def check_post_length(lines_array) # works on an array
108
120
  check_length(lines_array, Settings.config[:post_max_length])
109
121
  end
110
122
 
111
- def check_message_length(lines_array)
123
+ def check_message_length(lines_array) # works on an array
112
124
  check_length(lines_array, Settings.config[:message_max_length])
113
125
  end
114
126
 
@@ -0,0 +1,73 @@
1
+ # encoding: utf-8
2
+ module Ayadn
3
+ class Profile
4
+
5
+ attr_reader :options, :text, :payload
6
+
7
+ def initialize options
8
+ abort(Status.profile_options) if options.empty?
9
+ @options = options
10
+ end
11
+
12
+ def update
13
+ if @options[:avatar]
14
+ FileOps.upload_avatar(@options[:avatar].join)
15
+ elsif @options[:cover]
16
+ FileOps.upload_cover(@options[:cover].join)
17
+ else
18
+ CNX.patch(Endpoints.new.user('me'), @payload)
19
+ end
20
+ end
21
+
22
+ def get_text_from_user
23
+ unless @options[:delete] || @options[:avatar] || @options[:cover]
24
+ writer = Post.new
25
+ input = writer.compose()
26
+ writer.check_post_length(input)
27
+ @text = input.join("\n")
28
+ end
29
+ end
30
+
31
+ def prepare_payload
32
+ @payload = \
33
+ if @options[:bio]
34
+ if @options[:delete]
35
+ {'description' => {'text' => ''}}
36
+ else
37
+ {'description' => {'text' => @text}}
38
+ end
39
+ elsif @options[:name]
40
+ if @options[:delete]
41
+ abort("'Delete' isn't available for 'name'.\n".color(:red))
42
+ else
43
+ {'name' => @text}
44
+ end
45
+ elsif @options[:twitter]
46
+ if @options[:delete]
47
+ {'annotations' => [{'type' => 'net.app.core.directory.twitter'}]}
48
+ else
49
+ {'annotations' => [{
50
+ 'type' => 'net.app.core.directory.twitter',
51
+ 'value' => {'username' => @text}}]}
52
+ end
53
+ elsif @options[:blog]
54
+ if @options[:delete]
55
+ {'annotations' => [{'type' => 'net.app.core.directory.blog'}]}
56
+ else
57
+ {'annotations' => [{
58
+ 'type' => 'net.app.core.directory.blog',
59
+ 'value' => {'url' => @text}}]}
60
+ end
61
+ elsif @options[:web]
62
+ if @options[:delete]
63
+ {'annotations' => [{'type' => 'net.app.core.directory.homepage'}]}
64
+ else
65
+ {'annotations' => [{
66
+ 'type' => 'net.app.core.directory.homepage',
67
+ 'value' => {'url' => @text}}]}
68
+ end
69
+ end
70
+ end
71
+
72
+ end
73
+ end
data/lib/ayadn/status.rb CHANGED
@@ -312,5 +312,8 @@ module Ayadn
312
312
  def self.no_force target
313
313
  "\n'#{target}' can't be displayed (could be muted, blocked, in the Blacklist, etc). Use option '--force' ('-f') to try and display this content anyway.\n\n".color(:blue)
314
314
  end
315
+ def self.profile_options
316
+ "\n\nYou have to specify what to update or delete: --bio, --name, --blog, --twitter or --web.\n\n".color(:red)
317
+ end
315
318
  end
316
319
  end
data/lib/ayadn/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Ayadn
3
- VERSION = "1.7.0"
3
+ VERSION = "1.7.1"
4
4
  end
data/lib/ayadn/workers.rb CHANGED
@@ -269,6 +269,7 @@ module Ayadn
269
269
 
270
270
  def build_channels(data, options = {})
271
271
  bucket = []
272
+ data = [data] unless data.is_a?(Array)
272
273
  if options[:channels]
273
274
  puts "Downloading list of channels and their users credentials.\n\nPlease wait, it could take a while if there are many results and users...".color(:cyan)
274
275
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ayadn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-23 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -285,6 +285,7 @@ files:
285
285
  - lib/ayadn/nowwatching.rb
286
286
  - lib/ayadn/pinboard.rb
287
287
  - lib/ayadn/post.rb
288
+ - lib/ayadn/profile.rb
288
289
  - lib/ayadn/scroll.rb
289
290
  - lib/ayadn/search.rb
290
291
  - lib/ayadn/set.rb