ayadn 0.6.4 → 1.0.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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +20 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +17 -0
  5. data/Gemfile +14 -0
  6. data/Guardfile +26 -0
  7. data/LICENSE.txt +22 -0
  8. data/MANUAL.md +946 -0
  9. data/README.md +26 -411
  10. data/Rakefile +6 -0
  11. data/ayadn.gemspec +39 -0
  12. data/bin/ayadn +3 -3
  13. data/lib/ayadn.rb +12 -25
  14. data/lib/ayadn/action.rb +1121 -0
  15. data/lib/ayadn/alias.rb +106 -0
  16. data/lib/ayadn/api.rb +312 -301
  17. data/lib/ayadn/app.rb +429 -365
  18. data/lib/ayadn/authorize.rb +127 -28
  19. data/lib/ayadn/blacklist.rb +116 -0
  20. data/lib/ayadn/cnx.rb +105 -0
  21. data/lib/ayadn/databases.rb +110 -0
  22. data/lib/ayadn/descriptions.rb +1043 -0
  23. data/lib/ayadn/endpoints.rb +220 -153
  24. data/lib/ayadn/errors.rb +37 -0
  25. data/lib/ayadn/extend.rb +4 -10
  26. data/lib/ayadn/fileops.rb +48 -0
  27. data/lib/ayadn/logs.rb +32 -0
  28. data/lib/ayadn/pinboard.rb +46 -35
  29. data/lib/ayadn/post.rb +229 -212
  30. data/lib/ayadn/scroll.rb +251 -0
  31. data/lib/ayadn/set.rb +377 -0
  32. data/lib/ayadn/settings.rb +195 -0
  33. data/lib/ayadn/status.rb +226 -165
  34. data/lib/ayadn/switch.rb +72 -0
  35. data/lib/ayadn/version.rb +4 -0
  36. data/lib/ayadn/view.rb +506 -269
  37. data/lib/ayadn/workers.rb +362 -0
  38. data/spec/helpers.rb +19 -0
  39. data/spec/mock/@ericd.json +160 -0
  40. data/spec/mock/@m.json +45 -0
  41. data/spec/mock/checkins.json +1856 -0
  42. data/spec/mock/fwr_@ayadn.json +1077 -0
  43. data/spec/mock/posted.json +1 -0
  44. data/spec/mock/stream.json +1 -0
  45. data/spec/spec_helper.rb +14 -0
  46. data/spec/unit/api_spec.rb +61 -0
  47. data/spec/unit/databases_spec.rb +5 -0
  48. data/spec/unit/descriptions_spec.rb +9 -0
  49. data/spec/unit/endpoints_spec.rb +35 -0
  50. data/spec/unit/post_spec.rb +136 -0
  51. data/spec/unit/status_spec.rb +9 -0
  52. data/spec/unit/view_spec.rb +119 -0
  53. data/spec/unit/workers_spec.rb +147 -0
  54. metadata +216 -40
  55. data/CHANGELOG.md +0 -250
  56. data/CONTRIBUTORS.md +0 -5
  57. data/LICENSE.md +0 -14
  58. data/lib/ayadn/adn_files.rb +0 -84
  59. data/lib/ayadn/client-http.rb +0 -226
  60. data/lib/ayadn/colors.rb +0 -62
  61. data/lib/ayadn/config.yml +0 -35
  62. data/lib/ayadn/debug.rb +0 -36
  63. data/lib/ayadn/files.rb +0 -184
  64. data/lib/ayadn/get-api.rb +0 -43
  65. data/lib/ayadn/help.rb +0 -152
  66. data/lib/ayadn/list.rb +0 -89
  67. data/lib/ayadn/main.rb +0 -542
  68. data/lib/ayadn/requires.rb +0 -12
  69. data/lib/ayadn/skip.rb +0 -27
  70. data/lib/ayadn/tools.rb +0 -208
  71. data/lib/ayadn/user-stream.rb +0 -91
  72. data/lib/ayadn/view-channels.rb +0 -120
  73. data/lib/ayadn/view-interactions.rb +0 -57
  74. data/lib/ayadn/view-object.rb +0 -195
  75. data/lib/experiments.rb +0 -109
data/lib/ayadn/files.rb DELETED
@@ -1,184 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pstore'
3
- require 'fileutils'
4
-
5
- # encoding: utf-8
6
- class AyaDN
7
- class Files
8
- def initialize
9
- @token_path = $tools.ayadn_configuration[:authorization_path] + "/token"
10
- @channels_path = $tools.ayadn_configuration[:messages_path] + "/channels.json"
11
- end
12
- def users_write(key, value)
13
- db = PStore.new($tools.ayadn_configuration[:db_path] + "/users.db")
14
- db.transaction do
15
- db[key] = value
16
- end
17
- end
18
- def users_read(key)
19
- db = PStore.new($tools.ayadn_configuration[:db_path] + "/users.db")
20
- db.transaction do
21
- @value = db[key]
22
- end
23
- return @value
24
- end
25
- def makedir(value)
26
- unless Dir.exists? value
27
- FileUtils.mkdir_p value
28
- end
29
- end
30
- def get_last_page_id(value)
31
- if File.exists?(value)
32
- f = File.open(value, "r")
33
- last_page_id = f.gets
34
- f.close
35
- else
36
- last_page_id = nil
37
- end
38
- return last_page_id
39
- end
40
- def write_last_page_id(value, content)
41
- f = File.new(value, "w")
42
- f.puts(content)
43
- f.close
44
- end
45
- def save_channel_alias(channel_id, channel_alias)
46
- db = PStore.new($tools.ayadn_configuration[:db_path] + "/channels_alias.db")
47
- db.transaction do
48
- db[channel_alias] = channel_id
49
- end
50
- end
51
- def load_channel_id(channel_alias)
52
- db = PStore.new($tools.ayadn_configuration[:db_path] + "/channels_alias.db")
53
- db.transaction do
54
- @channel_id = db[channel_alias]
55
- end
56
- return @channel_id
57
- end
58
- def save_channel_id(value, content)
59
- newPrivateChannel = { "#{value}" => "#{content}" }
60
- if !File.exists?@channels_path
61
- f = File.new(@channels_path, "w")
62
- f.puts(newPrivateChannel.to_json)
63
- f.close
64
- else
65
- the_hash = JSON.parse(IO.read(@channels_path)).to_hash
66
- the_hash.merge!(newPrivateChannel)
67
- f = File.new(@channels_path, "w")
68
- f.puts(the_hash.to_json)
69
- f.close
70
- end
71
- end
72
- def save_channel_message(params)
73
- channel_to_save = { params[:id] => {
74
- text: params[:text],
75
- username: params[:username],
76
- message_date: params[:message_date]
77
- }
78
- }
79
- the_path = $tools.ayadn_configuration[:messages_path] + "/channels_with_recent_message.json"
80
- if !File.exists?the_path
81
- f = File.new(the_path, "w")
82
- f.puts(channel_to_save.to_json)
83
- f.close
84
- else
85
- the_hash = JSON.parse(IO.read(the_path)).to_hash
86
- the_hash.merge!(channel_to_save)
87
- f = File.new(the_path, "w")
88
- f.puts(the_hash.to_json)
89
- f.close
90
- end
91
- end
92
- def load_channels_with_messages
93
- the_path = $tools.ayadn_configuration[:messages_path] + "/channels_with_recent_message.json"
94
- JSON.load(IO.read(the_path)) if File.exists?the_path
95
- end
96
- def load_channels
97
- JSON.load(IO.read(@channels_path)) if File.exists?@channels_path
98
- end
99
- def auth_read
100
- token = IO.read(@token_path) if File.exists?@token_path
101
- return token.chomp() if token != nil
102
- end
103
- def auth_write(content)
104
- f = File.new(@token_path, "w")
105
- f.puts(content)
106
- f.close
107
- end
108
- def reset_pagination(content = nil, option = nil)
109
- if content != nil
110
- if option != nil
111
- puts "\nResetting #{content} pagination for #{option}.\n".red
112
- filePath = $tools.ayadn_configuration[:last_page_id_path] + "/last_page_id-#{content}-#{option}"
113
- if File.exists?(filePath)
114
- FileUtils.rm_rf(filePath)
115
- puts "\nDone!\n\n".green
116
- else
117
- puts "\nAlready done: no #{content} pagination value for #{option} was found.\n\n".green
118
- end
119
- else
120
- puts "\nResetting the pagination for #{content}.\n".red
121
- filePath = $tools.ayadn_configuration[:last_page_id_path] + "/last_page_id-#{content}"
122
- if File.exists?(filePath)
123
- FileUtils.rm_rf(filePath)
124
- puts "\nDone!\n\n".green
125
- else
126
- puts "\nAlready done: no #{content} pagination value was found.\n\n".green
127
- end
128
- end
129
- else
130
- puts "\nResetting all pagination data.\n".red
131
- Dir["#{$tools.ayadn_configuration[:last_page_id_path]}/*"].each do |file|
132
- FileUtils.rm_rf file
133
- end
134
- puts "\nDone!\n\n".green
135
- end
136
- end
137
- def reset_credentials
138
- FileUtils.rm_rf(@token_path) if File.exists?(@token_path)
139
- end
140
- def save_post(post_id)
141
- makedir($tools.ayadn_configuration[:posts_path])
142
- f = File.new($tools.ayadn_configuration[:posts_path] + "/#{post_id}.post", "w")
143
- f.puts(AyaDN::API.new(auth_read).getSinglePost(post_id))
144
- f.close
145
- end
146
- def download_file(file_url, new_file_name, token)
147
- download_file_path = $tools.ayadn_configuration[:files_path] + "/#{new_file_name}"
148
- if !File.exists?download_file_path
149
- resp = AyaDN::API.new(token).http_download(file_url)
150
- f = File.new(download_file_path, "wb")
151
- f.puts(resp.body)
152
- f.close
153
- puts "File downloaded in ".green + $tools.ayadn_configuration[:files_path].pink + "/#{new_file_name}".brown + "\n\n"
154
- else
155
- puts "Canceled: ".red + "#{new_file_name} ".pink + "already exists in ".red + "#{$tools.ayadn_configuration[:files_path]}".brown + "\n\n"
156
- end
157
- end
158
- def delete_file(target, token)
159
- puts AyaDN::API.new(token).deleteFile(target)
160
- end
161
- def uploadFiles(file, token)
162
- case File.extname(file).downcase
163
- when ".png"
164
- `curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=image/png" -X POST`
165
- when ".gif"
166
- `curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=image/gif" -X POST`
167
- when ".json",".txt",".md",".markdown",".mdown",".html",".css",".scss",".sass",".jade",".rb",".py",".sh",".js",".xml",".csv",".styl",".liquid",".ru","yml",".coffee",".php"
168
- `curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=text/plain" -X POST`
169
- when ".zip"
170
- `curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=application/zip" -X POST`
171
- when ".rar"
172
- `curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=application/rar" -X POST`
173
- when ".mp4"
174
- `curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=video/mp4" -X POST`
175
- when ".mov"
176
- `curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=video/quicktime" -X POST`
177
- when ".mkv",".mp3",".m4a",".m4v",".wav",".aif",".aiff",".aac",".flac"
178
- `curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=application/octet-stream" -X POST`
179
- else
180
- `curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F content=@#{file} -X POST`
181
- end
182
- end
183
- end
184
- end
data/lib/ayadn/get-api.rb DELETED
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
- class AyaDN
4
- def configAPI
5
- @time_now = DateTime.now
6
- api_config_path = $tools.ayadn_configuration[:api_config_path]
7
- $files.makedir(api_config_path)
8
- file_API = api_config_path + "/config.json"
9
- file_timer = api_config_path + "/timer.json"
10
- if !File.exists?(file_API)
11
- resp = get_api(file_API, file_timer)
12
- else
13
- f = File.open(file_timer, "r")
14
- hash_timer = JSON.parse(f.gets)
15
- f.close
16
- if DateTime.parse(hash_timer['deadline']) >= @time_now
17
- f = File.open(file_API, "r")
18
- resp = JSON.parse(f.gets)
19
- f.close
20
- else
21
- resp = get_api(file_API, file_timer)
22
- end
23
- end
24
- $tools.ayadn_configuration[:post_max_length] = resp['data']['post']['text_max_length']
25
- $tools.ayadn_configuration[:message_max_length] = resp['data']['message']['text_max_length']
26
- end
27
- def get_api(file_API, file_timer)
28
- resp = @api.getAPIConfig
29
- if resp['meta']['code'] == 200
30
- f = File.new(file_API, "w")
31
- f.puts(resp.to_json)
32
- f.close
33
- end
34
- hash_timer = {
35
- checked: @time_now,
36
- deadline: @time_now + 7
37
- }
38
- f = File.new(file_timer, "w")
39
- f.puts(hash_timer.to_json)
40
- f.close
41
- return resp
42
- end
43
- end
data/lib/ayadn/help.rb DELETED
@@ -1,152 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
- class AyaDN
4
- class Tools
5
- def helpScreen
6
- help = "USAGE: ".cyan + "ayadn ".pink + "+ " + "optional action ".green + "+ " + "optional target(s) ".green + "+ " + "optional value(s)\n\n".green
7
- help << "- " + "without options: ".cyan + "\tdisplay your unified stream\n" #.rjust(50)
8
- help << "- " + "write ".green + "+ [Enter key] ".magenta + "\tcreate a post\n" #.rjust(33)
9
- help << "- " + "write ".green + "\"your text\" ".brown + "\tcreate a post\n" #.rjust(35)
10
- help << "- " + "reply ".green + "PostID ".brown + "\t\treply to a post\n" #.rjust(42)
11
- # help << "- " + "delete postID ".green + "to delete a post\n"
12
- help << "- " + "pm ".green + "@username ".brown + "\t\tsend a private message\n"
13
- help << "- " + "channels ".green + "\t\tdisplay private channels\n"
14
- help << "- " + "messages ".green + "channelID ".brown + "\tdisplay private messages\n"
15
- help << "- " + "search ".green + "word ".brown + "\t\tsearch for word(s)\n"
16
- help << "- " + "tag ".green + "hashtag ".brown + "\t\tsearch for a hashtag\n"
17
- # help << "- " + "star/unstar postID ".green + "to star/unstar a post\n"
18
- # help << "- " + "repost/unrepost postID ".green + "to repost/unrepost a post\n"
19
- # help << "- " + "infos @username/postID ".green + "to display detailed informations on a user or a post\n"
20
- # help << "- " + "convo postID ".green + "to display the conversation around a post\n"
21
- help << "- " + "posts ".green + "@username ".brown + "\tdisplay a user's posts\n"
22
- help << "- " + "mentions ".green + "@username ".brown + "\tdisplay posts mentionning a user\n"
23
- # help << "- " + "starred @username/postID ".green + "to display a user's starred posts / who starred a post\n"
24
- # help << "- " + "reposted postID ".green + "to display who reposted a post\n"
25
- # help << "- " + "interactions ".green + "to display a stream of your interactions\n"
26
- help << "- " + "global/trending/checkins/conversations/photos ".green + "\tdisplay a stream\n"
27
- # help << "- " + "follow/unfollow @username ".green + "to follow/unfollow a user\n"
28
- # help << "- " + "mute/unmute @username ".green + "to mute/unmute a user\n"
29
- #help << "- " + "save/load postID ".green + "to save/load a post locally\n"
30
- help << "- " + "list/backup followings/followers/muted ".green + "@username/me ".brown + "\tlist/backup users\n"
31
- help << "- " + "infos, delete, star/unstar, repost/unrepost, convo, starred, reposted ".green + "PostID\n".brown
32
- help << "- " + "infos, starred, follow, unfollow, mute, unmute ".green + "@username\n".brown
33
- #help << "- " + "help ".green + "\t\t\tdisplay this screen\n"
34
- help << "- " + "help/commands/webhelp".green + "\n\n"
35
- #help << "- " + "tip: ".cyan + "some commands have a shortcut: w(rite), r(eply), s(earch), p(osts), m(entions), t(ag), c(onvo), i(nfos), h(elp)\n"
36
- help << "- " + "Tip: put 'scroll' before a stream to use the scrolling feature\n".cyan
37
- help << "- " + "Visit https://github.com/ericdke/ayadn#ayadn for help, tips, commands, etc\n\n".cyan
38
- help << "Examples:\n\n".cyan
39
- help << "ayadn \n"#.green + "(display your Unified stream)\n"
40
- help << "ayadn install config\n"#.green + "(display your Unified stream)\n"
41
- help << "ayadn write \n"#.green + "(write a post with a compose window)\n"
42
- help << "ayadn write \'@ayadn Posting with AyaDN!\' \n"#.green + "(write a post instantly between double quotes)\n"
43
- help << "ayadn reply 14805036 \n"#.green + "(reply to post n°14805036 with a compose window)\n"
44
- #help << "ayadn tag nowplaying \n"#.green + "(search for hashtag #nowplaying)\n"
45
- help << "ayadn star 14805036 \n"#.green + "(star post n°14805036)\n"
46
- help << "ayadn checkins \n"#.green + "(display the Checkins stream)\n"
47
- help << "ayadn scroll unified \n"
48
- help << "ayadn follow @ayadn \n"#.green + "(follow user @ericd)\n"
49
- help << "ayadn search ruby,json \n"#.green + "(search for posts with these words)\n"
50
- #help << "ayadn list files \n"
51
- #help << "ayadn backup followings me \n"
52
- help << "\n"
53
- return help
54
- end
55
- def list_of_commands
56
- commands = "\nList of commands: \n\n".cyan
57
- commands << "ayadn\n"
58
- commands << "ayadn scroll\n"
59
- commands << "ayadn write\n"
60
- commands << "ayadn write '@ericd Good morning Eric!'\n"
61
- commands << "ayadn reply 18527205\n"
62
- commands << "ayadn pm @ericd\n"
63
- commands << "ayadn global\n"
64
- commands << "ayadn scroll global\n"
65
- commands << "ayadn checkins\n"
66
- commands << "ayadn scroll checkins\n"
67
- commands << "ayadn trending\n"
68
- commands << "ayadn scroll trending\n"
69
- commands << "ayadn photos\n"
70
- commands << "ayadn scroll photos\n"
71
- commands << "ayadn conversations\n"
72
- commands << "ayadn scroll conversations\n"
73
- commands << "ayadn mentions @ericd\n"
74
- commands << "ayadn scroll mentions @ericd\n"
75
- commands << "ayadn posts @ericd\n"
76
- commands << "ayadn scroll posts @ericd\n"
77
- commands << "ayadn starred @ericd\n"
78
- commands << "ayadn starred 18527205\n"
79
- commands << "ayadn reposted 18527205\n"
80
- commands << "ayadn infos @ericd\n"
81
- commands << "ayadn infos 18527205\n"
82
- commands << "ayadn convo 15726105\n"
83
- commands << "ayadn tag nowplaying\n"
84
- commands << "ayadn follow @ericd\n"
85
- commands << "ayadn unfollow @ericd\n"
86
- commands << "ayadn mute @ayaio\n"
87
- commands << "ayadn unmute @ayaio\n"
88
- commands << "ayadn block @spammer\n"
89
- commands << "ayadn unblock @spammer\n"
90
- commands << "ayadn interactions\n"
91
- commands << "ayadn list files\n"
92
- commands << "ayadn list files all\n"
93
- commands << "ayadn download 286458\n"
94
- commands << "ayadn download 286458,286797\n"
95
- commands << "ayadn upload /path/to/kitten.jpg\n"
96
- commands << "ayadn private 286458\n"
97
- commands << "ayadn public 286458\n"
98
- commands << "ayadn delete-file 286458\n"
99
- commands << "ayadn search ruby\n"
100
- commands << "ayadn search ruby,json\n"
101
- commands << "ayadn channels\n"
102
- commands << "ayadn send 12345\n"
103
- commands << "ayadn messages 12345\n"
104
- commands << "ayadn messages 12345 all\n"
105
- commands << "ayadn alias-channel 12345 channel_name\n"
106
- commands << "ayadn messages channel_name\n"
107
- commands << "ayadn star 18527205\n"
108
- commands << "ayadn unstar 18527205\n"
109
- commands << "ayadn repost 18527205\n"
110
- commands << "ayadn unrepost 18527205\n"
111
- commands << "ayadn quote 18527205\n"
112
- commands << "ayadn delete 12345678\n"
113
- commands << "ayadn delete-message 12345 23456789\n"
114
- commands << "ayadn list muted\n"
115
- commands << "ayadn list followings @ericd\n"
116
- commands << "ayadn list followers @ericd\n"
117
- commands << "ayadn backup muted\n"
118
- commands << "ayadn backup followings @ericd\n"
119
- commands << "ayadn backup followers @ericd\n"
120
- commands << "ayadn save 18527205\n"
121
- commands << "ayadn load 18527205\n"
122
- commands << "ayadn skip-source add IFTTT\n"
123
- commands << "ayadn skip-source remove IFTTT\n"
124
- commands << "ayadn skip-source show\n"
125
- commands << "ayadn skip-tag add sports\n"
126
- commands << "ayadn skip-tag remove sports\n"
127
- commands << "ayadn skip-tag show\n"
128
- commands << "ayadn skip-mention add username\n"
129
- commands << "ayadn skip-mention remove username\n"
130
- commands << "ayadn skip-mention show\n"
131
- commands << "ayadn pin 16864003 ruby,json\n"
132
- commands << "ayadn unified 10\n"
133
- commands << "ayadn global 10\n"
134
- commands << "ayadn checkins 10\n"
135
- commands << "ayadn photos 10\n"
136
- commands << "ayadn trending 10\n"
137
- commands << "ayadn conversations 10\n"
138
- commands << "ayadn mentions @ericd 10\n"
139
- commands << "ayadn posts @ericd 10\n"
140
- commands << "ayadn starred @ericd 10\n"
141
- commands << "ayadn does @ericd follow @ayadn\n"
142
- commands << "ayadn reset pagination\n"
143
- commands << "ayadn help\n"
144
- commands << "ayadn commands\n"
145
- commands << "ayadn webhelp\n"
146
- commands << "ayadn random\n"
147
- commands << "ayadn install config\n"
148
- commands << "\n"
149
- return commands
150
- end
151
- end
152
- end
data/lib/ayadn/list.rb DELETED
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
- class AyaDN
4
- def ayadn_list_files(value)
5
- with_url = false
6
- if value == "all"
7
- puts "\nGetting the list of all your files...\n".green
8
- beforeID = nil
9
- i = 1
10
- loop do
11
- params = @view.new(@api.getFilesList(beforeID)).showFilesList(with_url, true)
12
- beforeID = params[2].last
13
- break if beforeID == nil
14
- puts params[0]
15
- i += 1
16
- if params[2].first != nil
17
- $tools.countdown(5) unless i == 2
18
- print "\r" + (" " * 40) unless i == 2
19
- print "\n\nPlease wait, fetching page (".cyan + "#{beforeID}".pink + ")...\n".cyan unless i == 2
20
- end
21
- end
22
- puts "\n"
23
- else
24
- puts "\nGetting the list of your recent files...\n".green
25
- params = @view.new(@api.getFilesList(nil)).showFilesList(with_url, false)
26
- puts params[0]
27
- end
28
- end
29
- def fetch_list(list, name, beforeID)
30
- case list
31
- when "followers"
32
- @api.getFollowers(name, beforeID)
33
- when "followings"
34
- @api.getFollowings(name, beforeID)
35
- when "muted"
36
- @api.getMuted(name, beforeID)
37
- when "blocked"
38
- @api.getBlocked(name, beforeID)
39
- end
40
- end
41
- def getList(list, name)
42
- beforeID = nil
43
- big_hash = {}
44
- @progress_indicator = false
45
- loop do
46
- @hash = fetch_list(list, name, beforeID)
47
- users_hash, min_id = @view.new(@hash).buildFollowList
48
- big_hash.merge!(users_hash)
49
- break if min_id == nil
50
- beforeID = min_id
51
- end
52
- big_hash
53
- end
54
-
55
- def ayadnShowList(list, name)
56
- puts $status.fetchingList(list)
57
- puts $status.showList(list, name)
58
- users, number = @view.new(getList(list, name)).showUsers
59
- puts "\n"
60
- if number == 0
61
- puts $status.errorEmptyList
62
- exit
63
- end
64
- puts users
65
- puts "Number of users: ".green + " #{number}\n\n".brown
66
- end
67
-
68
- def ayadnSaveList(list, name) # to be called with: var = ayadnSaveList("followers", "@ericd")
69
- @progress_indicator = false
70
- fileURL = $tools.ayadn_configuration[:lists_path] + "/#{name}-#{list}.json"
71
- unless Dir.exists?$tools.ayadn_configuration[:lists_path]
72
- puts "Creating lists directory in ".green + "#{$tools.ayadn_configuration[:data_path]}".brown + "\n"
73
- FileUtils.mkdir_p $tools.ayadn_configuration[:lists_path]
74
- end
75
- if File.exists?(fileURL)
76
- puts "\nYou already saved this list.\n".red
77
- puts "Delete the old one and replace with this one? (n/y)\n".red
78
- abort("\nCanceled.\n\n".red) unless STDIN.getch == ("y" || "Y")
79
- end
80
- puts $status.showList(list, name)
81
- puts "Please wait...\n".green
82
- puts "Saving the list...\n".green
83
- f = File.new(fileURL, "w")
84
- f.puts(getList(list, name).to_json)
85
- f.close
86
- puts "\nSuccessfully saved the list.\n\n".green
87
- exit
88
- end
89
- end