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.
- checksums.yaml +4 -4
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.travis.yml +17 -0
- data/Gemfile +14 -0
- data/Guardfile +26 -0
- data/LICENSE.txt +22 -0
- data/MANUAL.md +946 -0
- data/README.md +26 -411
- data/Rakefile +6 -0
- data/ayadn.gemspec +39 -0
- data/bin/ayadn +3 -3
- data/lib/ayadn.rb +12 -25
- data/lib/ayadn/action.rb +1121 -0
- data/lib/ayadn/alias.rb +106 -0
- data/lib/ayadn/api.rb +312 -301
- data/lib/ayadn/app.rb +429 -365
- data/lib/ayadn/authorize.rb +127 -28
- data/lib/ayadn/blacklist.rb +116 -0
- data/lib/ayadn/cnx.rb +105 -0
- data/lib/ayadn/databases.rb +110 -0
- data/lib/ayadn/descriptions.rb +1043 -0
- data/lib/ayadn/endpoints.rb +220 -153
- data/lib/ayadn/errors.rb +37 -0
- data/lib/ayadn/extend.rb +4 -10
- data/lib/ayadn/fileops.rb +48 -0
- data/lib/ayadn/logs.rb +32 -0
- data/lib/ayadn/pinboard.rb +46 -35
- data/lib/ayadn/post.rb +229 -212
- data/lib/ayadn/scroll.rb +251 -0
- data/lib/ayadn/set.rb +377 -0
- data/lib/ayadn/settings.rb +195 -0
- data/lib/ayadn/status.rb +226 -165
- data/lib/ayadn/switch.rb +72 -0
- data/lib/ayadn/version.rb +4 -0
- data/lib/ayadn/view.rb +506 -269
- data/lib/ayadn/workers.rb +362 -0
- data/spec/helpers.rb +19 -0
- data/spec/mock/@ericd.json +160 -0
- data/spec/mock/@m.json +45 -0
- data/spec/mock/checkins.json +1856 -0
- data/spec/mock/fwr_@ayadn.json +1077 -0
- data/spec/mock/posted.json +1 -0
- data/spec/mock/stream.json +1 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/unit/api_spec.rb +61 -0
- data/spec/unit/databases_spec.rb +5 -0
- data/spec/unit/descriptions_spec.rb +9 -0
- data/spec/unit/endpoints_spec.rb +35 -0
- data/spec/unit/post_spec.rb +136 -0
- data/spec/unit/status_spec.rb +9 -0
- data/spec/unit/view_spec.rb +119 -0
- data/spec/unit/workers_spec.rb +147 -0
- metadata +216 -40
- data/CHANGELOG.md +0 -250
- data/CONTRIBUTORS.md +0 -5
- data/LICENSE.md +0 -14
- data/lib/ayadn/adn_files.rb +0 -84
- data/lib/ayadn/client-http.rb +0 -226
- data/lib/ayadn/colors.rb +0 -62
- data/lib/ayadn/config.yml +0 -35
- data/lib/ayadn/debug.rb +0 -36
- data/lib/ayadn/files.rb +0 -184
- data/lib/ayadn/get-api.rb +0 -43
- data/lib/ayadn/help.rb +0 -152
- data/lib/ayadn/list.rb +0 -89
- data/lib/ayadn/main.rb +0 -542
- data/lib/ayadn/requires.rb +0 -12
- data/lib/ayadn/skip.rb +0 -27
- data/lib/ayadn/tools.rb +0 -208
- data/lib/ayadn/user-stream.rb +0 -91
- data/lib/ayadn/view-channels.rb +0 -120
- data/lib/ayadn/view-interactions.rb +0 -57
- data/lib/ayadn/view-object.rb +0 -195
- data/lib/experiments.rb +0 -109
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
class AyaDN
|
4
|
-
class View
|
5
|
-
def buildInteractions(hash)
|
6
|
-
inter_string = ""
|
7
|
-
hash.each do |item|
|
8
|
-
action = item['action']
|
9
|
-
created_day = item['event_date'][0...10]
|
10
|
-
created_hour = item['event_date'][11...19]
|
11
|
-
objects_names, users_list, post_ids, post_text = [], [], [], [] # not the same as var1 = var2 = []
|
12
|
-
item['objects'].each do |o|
|
13
|
-
case action
|
14
|
-
when "follow", "unfollow", "mute", "unmute"
|
15
|
-
objects_names.push("@" + o['username'])
|
16
|
-
when "star", "unstar", "repost", "unrepost", "reply"
|
17
|
-
post_ids.push(o['id'])
|
18
|
-
#text = o['text']
|
19
|
-
post_info = buildPostInfo(o, false)
|
20
|
-
post_text.push(post_info.chomp("\n\n"))
|
21
|
-
#post_text << text
|
22
|
-
end
|
23
|
-
end
|
24
|
-
item['users'].each do |u|
|
25
|
-
if u != nil
|
26
|
-
users_list.push("@" + u['username'])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
joined_users_list = users_list.join(", ")
|
30
|
-
joined_post_text = post_text.join(" ")
|
31
|
-
inter_string << "-----\n\n".blue
|
32
|
-
inter_string << "Date: ".green + "#{created_day} #{created_hour}\n".cyan
|
33
|
-
case action
|
34
|
-
when "follow", "unfollow"
|
35
|
-
inter_string << "#{joined_users_list} ".green + "#{action}ed ".magenta + "you\n".brown
|
36
|
-
when "mute", "unmute"
|
37
|
-
inter_string << "#{joined_users_list} ".green + "#{action}d ".magenta + "#{objects_names.join(", ")}\n".brown
|
38
|
-
when "repost", "unrepost"
|
39
|
-
inter_string << "#{joined_users_list} ".green + "#{action}ed:\n".magenta
|
40
|
-
inter_string << joined_post_text
|
41
|
-
when "star", "unstar"
|
42
|
-
inter_string << "#{joined_users_list} ".green + "#{action}red:\n".magenta
|
43
|
-
inter_string << joined_post_text
|
44
|
-
when "reply"
|
45
|
-
inter_string << "#{joined_users_list} ".green + "#{action}ed to:\n".magenta
|
46
|
-
inter_string << joined_post_text
|
47
|
-
when "welcome"
|
48
|
-
inter_string << "App.net ".green + "welcomed ".magenta + "you.\n".green
|
49
|
-
else
|
50
|
-
inter_string << "Unknown data.\n".red
|
51
|
-
end
|
52
|
-
inter_string << "\n"
|
53
|
-
end
|
54
|
-
return inter_string
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
data/lib/ayadn/view-object.rb
DELETED
@@ -1,195 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
class AyaDN
|
4
|
-
class View
|
5
|
-
def create_content_string(item, annotations, me_mentioned)
|
6
|
-
if item['user']
|
7
|
-
user_name, user_real_name, user_handle = objectNames(item['user']).values_at(:user_name, :user_real_name, :user_handle)
|
8
|
-
else
|
9
|
-
user_name, user_real_name, user_handle = ""
|
10
|
-
end
|
11
|
-
created_day, created_hour = objectDate(item)
|
12
|
-
view_params = {
|
13
|
-
id: item['id'],
|
14
|
-
created_day: created_day,
|
15
|
-
created_hour: created_hour,
|
16
|
-
user_name: user_name,
|
17
|
-
user_handle: user_handle,
|
18
|
-
user_real_name: user_real_name,
|
19
|
-
text: coloredText(item),
|
20
|
-
source: item['source']['name'],
|
21
|
-
links: objectLinks(item),
|
22
|
-
annotations: annotations,
|
23
|
-
me_mentioned: me_mentioned,
|
24
|
-
num_replies: item['num_replies'],
|
25
|
-
reply_to: item['reply_to']
|
26
|
-
}
|
27
|
-
if item['repost_of'] != nil
|
28
|
-
view_params.merge!({repost_of: item['repost_of'], num_reposts: item['repost_of']['num_reposts']})
|
29
|
-
end
|
30
|
-
object_view(view_params)
|
31
|
-
end
|
32
|
-
def skip_hashtags(item, saved_tags)
|
33
|
-
skipped_hashtags_encountered = false
|
34
|
-
for post_tag in item['entities']['hashtags'] do
|
35
|
-
case post_tag['name']
|
36
|
-
when *saved_tags
|
37
|
-
skipped_hashtags_encountered = true
|
38
|
-
next
|
39
|
-
end
|
40
|
-
end
|
41
|
-
return skipped_hashtags_encountered
|
42
|
-
end
|
43
|
-
def coloredText(item)
|
44
|
-
obj_text = item['text']
|
45
|
-
obj_text != nil ? (colored_post = $tools.colorize(obj_text)) : (colored_post = "\n--Post deleted--".red)
|
46
|
-
end
|
47
|
-
def objectDate(item)
|
48
|
-
created_at = item['created_at']
|
49
|
-
return created_at[0...10], created_at[11...19]
|
50
|
-
end
|
51
|
-
def objectLinks(item)
|
52
|
-
links = item['entities']['links']
|
53
|
-
links_string = ""
|
54
|
-
if !links.empty?
|
55
|
-
links_string << "\n" if item['annotations'] == nil
|
56
|
-
for link in links do
|
57
|
-
links_string << "Link: ".cyan + link['url'].brown + "\n"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
return links_string
|
61
|
-
end
|
62
|
-
def objectSource(item)
|
63
|
-
{name: item['source']['name'], link: item['source']['link']}
|
64
|
-
end
|
65
|
-
def objectNames(item)
|
66
|
-
user_id = item['id']
|
67
|
-
user_name = item['username']
|
68
|
-
$files.users_write(user_id, user_name) if $files.users_read(user_id) == nil
|
69
|
-
user_handle = "@" + user_name
|
70
|
-
{user_name: user_name, user_real_name: item['name'], user_handle: user_handle}
|
71
|
-
end
|
72
|
-
def checkins_annotations(item)
|
73
|
-
anno_string = ""
|
74
|
-
annotations_list = item['annotations']
|
75
|
-
xxx = 0
|
76
|
-
if annotations_list != nil
|
77
|
-
annotations_list.each do
|
78
|
-
annotation_type = annotations_list[xxx]['type']
|
79
|
-
annotation_value = annotations_list[xxx]['value']
|
80
|
-
if annotation_type == "net.app.core.checkin" or annotation_type == "net.app.ohai.location"
|
81
|
-
checkins_name = annotation_value['name']
|
82
|
-
if checkins_name.nil?
|
83
|
-
checkins_name = ""
|
84
|
-
end
|
85
|
-
checkins_address = annotation_value['address']
|
86
|
-
checkins_locality = annotation_value['locality']
|
87
|
-
checkins_region = annotation_value['region']
|
88
|
-
checkins_postcode = annotation_value['postcode']
|
89
|
-
checkins_country_code = annotation_value['country_code']
|
90
|
-
anno_string << "\n" + ("." * (checkins_name.length + 6))
|
91
|
-
anno_string << ("\nName: ".cyan + checkins_name.upcase.reddish)
|
92
|
-
anno_string << ("\nAddress: ".cyan + checkins_address.green) unless checkins_address.nil?
|
93
|
-
anno_string << ("\nLocality: ".cyan + checkins_locality.green) unless checkins_locality.nil?
|
94
|
-
anno_string << (" (#{checkins_postcode})".green) unless checkins_postcode.nil?
|
95
|
-
anno_string << ("\nState/Region: ".cyan + checkins_region.green) unless checkins_region.nil?
|
96
|
-
anno_string << (" (#{checkins_country_code})".upcase.green) unless checkins_country_code.nil?
|
97
|
-
unless @source_name_and_link[:name].nil? or $tools.config['timeline']['show_client']
|
98
|
-
anno_string << "\nPosted with: ".cyan + "#{@source_name_and_link[:name]} [#{@source_name_and_link[:link]}]".green + " "
|
99
|
-
end
|
100
|
-
#anno_string += "\n"
|
101
|
-
end
|
102
|
-
if annotation_type == "net.app.core.oembed"
|
103
|
-
@same_link = false
|
104
|
-
photo_link = annotation_value['embeddable_url']
|
105
|
-
if photo_link != nil
|
106
|
-
photo_link_parsed = URI.parse(photo_link)
|
107
|
-
photo_link_to_compare = photo_link_parsed.host + photo_link_parsed.path
|
108
|
-
item['entities']['links'].each do |link|
|
109
|
-
in_entities_parsed = URI.parse(link['url'])
|
110
|
-
in_entities_to_compare = in_entities_parsed.host + in_entities_parsed.path
|
111
|
-
@same_link = true if in_entities_to_compare == photo_link_to_compare
|
112
|
-
end
|
113
|
-
anno_string << ("\nLink: ".cyan + photo_link.brown) if @same_link == false
|
114
|
-
end
|
115
|
-
end
|
116
|
-
xxx += 1
|
117
|
-
end
|
118
|
-
return anno_string
|
119
|
-
end
|
120
|
-
end
|
121
|
-
def object_view(params)
|
122
|
-
if params[:me_mentioned]
|
123
|
-
obj_view = "\n" + params[:id].to_s.red.reverse_color.ljust(14)
|
124
|
-
else
|
125
|
-
if params[:user_name] == $tools.config['identity']['prefix']
|
126
|
-
obj_view = "\n" + params[:id].to_s.green.reverse_color.ljust(14)
|
127
|
-
else
|
128
|
-
obj_view = "\n" + params[:id].to_s.cyan.ljust(14)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
obj_view << ' '
|
132
|
-
obj_view << params[:user_handle].green if params[:user_handle]
|
133
|
-
obj_view << ' '
|
134
|
-
obj_view << "[#{params[:user_real_name]}]".magenta if params[:user_real_name]
|
135
|
-
obj_view << ' '
|
136
|
-
obj_view << params[:created_day].cyan + ' ' + params[:created_hour].cyan
|
137
|
-
obj_view << ' '
|
138
|
-
obj_view << "[#{params[:source]}]".cyan if $tools.config['timeline']['show_client']
|
139
|
-
if params[:repost_of] && $tools.config['timeline']['show_reposters']
|
140
|
-
obj_view << " [x#{params[:num_reposts]}]".blue
|
141
|
-
end
|
142
|
-
if $tools.config['timeline']['show_symbols']
|
143
|
-
obj_view << " <".blue if params[:reply_to] != nil
|
144
|
-
obj_view << " >".blue if params[:num_replies] > 0
|
145
|
-
end
|
146
|
-
obj_view << "\n"
|
147
|
-
obj_view << params[:text]
|
148
|
-
obj_view << "\n" if params[:links]
|
149
|
-
obj_view << (params[:annotations] + "\n") if params[:annotations] != nil
|
150
|
-
obj_view << params[:links] + "\n"
|
151
|
-
obj_view
|
152
|
-
end
|
153
|
-
def file_view(params)
|
154
|
-
file_elements = "\nName: ".cyan + params[:name].green
|
155
|
-
file_elements << "\nKind: ".cyan + params[:kind].pink
|
156
|
-
file_elements << "\nSize: ".cyan + params[:file_size_converted].reddish unless params[:file_size] == nil
|
157
|
-
file_elements << "\nDate: ".cyan + params[:created_day].green + " " + params[:created_hour].green
|
158
|
-
file_elements << "\nSource: ".cyan + params[:source_name].brown + " - #{params[:source_link]}".brown
|
159
|
-
end
|
160
|
-
def filesDetails(item)
|
161
|
-
created_day, created_hour = objectDate(item)
|
162
|
-
file_size = item['size']
|
163
|
-
file_size_converted = file_size.to_filesize unless file_size == nil
|
164
|
-
{
|
165
|
-
name: item['name'],
|
166
|
-
file_token: item['file_token'],
|
167
|
-
source_name: item['source']['name'],
|
168
|
-
source_link: item['source']['link'],
|
169
|
-
kind: item['kind'],
|
170
|
-
id: item['id'],
|
171
|
-
file_size: file_size,
|
172
|
-
file_size_converted: file_size_converted,
|
173
|
-
file_is_public: item['public'],
|
174
|
-
file_url: item['url_permanent'],
|
175
|
-
created_day: created_day,
|
176
|
-
created_hour: created_hour
|
177
|
-
}
|
178
|
-
end
|
179
|
-
def derivedFilesDetails(derived_files)
|
180
|
-
if derived_files != nil
|
181
|
-
if derived_files['image_thumb_960r'] != nil
|
182
|
-
#file_derived_bigthumb_name = derived_files['image_thumb_960r']['name']
|
183
|
-
file_derived_bigthumb_url = derived_files['image_thumb_960r']['url']
|
184
|
-
end
|
185
|
-
if derived_files['image_thumb_200s'] != nil
|
186
|
-
#file_derived_smallthumb_name = derived_files['image_thumb_200s']['name']
|
187
|
-
file_derived_smallthumb_url = derived_files['image_thumb_200s']['url']
|
188
|
-
end
|
189
|
-
list_string += "\nBig thumbnail: ".cyan + file_derived_bigthumb_url unless file_derived_bigthumb_url == nil
|
190
|
-
list_string += "\nSmall thumbnail: ".cyan + file_derived_smallthumb_url unless file_derived_smallthumb_url == nil
|
191
|
-
end
|
192
|
-
return list_string
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
data/lib/experiments.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
class AyaDN
|
4
|
-
# experimenting without curl
|
5
|
-
# def ayadnFileUpload(file_name)
|
6
|
-
# # puts "\nUploading ".green + file_name.brown + "\n"
|
7
|
-
# # response = @api.createIncompleteFileUpload(file_name)
|
8
|
-
# # puts response.inspect #SUCCESS
|
9
|
-
# # THEN multipart => #FAIL
|
10
|
-
# end
|
11
|
-
|
12
|
-
|
13
|
-
# def ayadnDeactivateChannel(channel_id)
|
14
|
-
# resp = @api.deactivateChannel(channel_id)
|
15
|
-
# puts resp
|
16
|
-
# end
|
17
|
-
|
18
|
-
|
19
|
-
### experiment
|
20
|
-
### not DRY at all, this is ok, chill out
|
21
|
-
# def ayadnRecord(item)
|
22
|
-
# # first create with curl -i -H 'Authorization: BEARER xxx' "https://stream-channel.app.net/stream/user?auto_delete=1&include_annotations=1"
|
23
|
-
# # it stays open and returns a stream_id in the headers
|
24
|
-
# # TODO: replace curl with a good connection system with HTTP or Rest-Client
|
25
|
-
|
26
|
-
# command = "sleep 1; curl -i -H 'Authorization: BEARER #{@token}' 'https://stream-channel.app.net/stream/user?auto_delete=1&include_annotations=1'"
|
27
|
-
# pid = Process.spawn(command)
|
28
|
-
# Process.detach(pid)
|
29
|
-
|
30
|
-
# puts "Enter stream id: "
|
31
|
-
# stream_id = STDIN.gets.chomp
|
32
|
-
# last_page_id = nil
|
33
|
-
# start = Time.now
|
34
|
-
# case item
|
35
|
-
# when "global" # works :)
|
36
|
-
# @url = "https://alpha-api.app.net/stream/0/posts/stream/global?connection_id=#{stream_id}&since_id=#{last_page_id}"
|
37
|
-
# when "unified" # doesn't work, have to implement some sort of real keep-alive connection
|
38
|
-
# @url = "https://alpha-api.app.net/stream/0/posts/stream/unified?connection_id=#{stream_id}&since_id=#{last_page_id}&include_directed_posts=1"
|
39
|
-
# end
|
40
|
-
# puts "\nRecording stream in #{$tools.ayadn_configuration[:files_path]}/rec-#{item}.json\n\n"
|
41
|
-
# uri = URI.parse(@url)
|
42
|
-
# https = Net::HTTP.new(uri.host,uri.port)
|
43
|
-
# https.use_ssl = true
|
44
|
-
# https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
45
|
-
# request = Net::HTTP::Get.new(uri.request_uri)
|
46
|
-
# request["Authorization"] = "Bearer #{@token}"
|
47
|
-
# request["Content-Type"] = "application/json"
|
48
|
-
# response = https.request(request)
|
49
|
-
# @hash = JSON.parse(response.body)
|
50
|
-
# big_stream = @hash['data']
|
51
|
-
# f = File.new($tools.ayadn_configuration[:files_path] + "/rec-#{item}.json", 'w')
|
52
|
-
# f.puts(big_stream.to_json)
|
53
|
-
# f.close
|
54
|
-
# stream, last_page_id = completeStream
|
55
|
-
# displayScrollStream(stream)
|
56
|
-
# number_of_connections = 1
|
57
|
-
# file_operations_timer = 0
|
58
|
-
# loop do
|
59
|
-
# begin
|
60
|
-
# case item
|
61
|
-
# when "global"
|
62
|
-
# @url = "https://alpha-api.app.net/stream/0/posts/stream/global?connection_id=#{stream_id}&since_id=#{last_page_id}"
|
63
|
-
# when "unified"
|
64
|
-
# @url = "https://alpha-api.app.net/stream/0/posts/stream/unified?connection_id=#{stream_id}&since_id=#{last_page_id}&include_directed_posts=1"
|
65
|
-
# end
|
66
|
-
# uri = URI.parse(@url)
|
67
|
-
# request = Net::HTTP::Get.new(uri.request_uri)
|
68
|
-
# request["Authorization"] = "Bearer #{@token}"
|
69
|
-
# request["Content-Type"] = "application/json"
|
70
|
-
# before_request_id = last_page_id
|
71
|
-
# response = https.request(request)
|
72
|
-
# @hash = JSON.parse(response.body)
|
73
|
-
# stream, last_page_id = completeStream
|
74
|
-
# displayScrollStream(stream)
|
75
|
-
# if last_page_id == nil
|
76
|
-
# last_page_id = before_request_id
|
77
|
-
# sleep 0.5 # trying to play nice with the API limits
|
78
|
-
# number_of_connections += 1
|
79
|
-
# next
|
80
|
-
# end
|
81
|
-
# # don't let it run for days, it will eat your RAM
|
82
|
-
# # + the simple file dump isn't ok in the long run
|
83
|
-
# big_stream << @hash['data']
|
84
|
-
# number_of_connections += 1
|
85
|
-
# file_operations_timer += 1
|
86
|
-
# sleep 0.2 # trying to play nice with the API limits
|
87
|
-
# if file_operations_timer == 10
|
88
|
-
# puts "\nRecording stream in #{$tools.ayadn_configuration[:files_path]}/rec-#{item}.json\n\n".green
|
89
|
-
# #big_json = JSON.parse(IO.read($tools.ayadn_configuration[:files_path] + "/rec-#{item}.json"))
|
90
|
-
# f = File.new($tools.ayadn_configuration[:files_path] + "/rec-#{item}.json", 'w')
|
91
|
-
# f.puts(big_stream.to_json)
|
92
|
-
# f.close
|
93
|
-
# file_operations_timer = 0
|
94
|
-
# end
|
95
|
-
# rescue Exception => e
|
96
|
-
# puts e.inspect
|
97
|
-
# puts e.to_s
|
98
|
-
# finish = Time.now
|
99
|
-
# elapsed = finish.to_f - start.to_f
|
100
|
-
# mins, secs = elapsed.divmod 60.0
|
101
|
-
# puts "\nRequests: #{number_of_connections}\n"
|
102
|
-
# puts "Elapsed time (min:secs.msecs): "
|
103
|
-
# puts("%3d:%04.2f"%[mins.to_i, secs])
|
104
|
-
# puts "\nStream recorded in #{$tools.ayadn_configuration[:files_path]}/rec-#{item}.json"
|
105
|
-
# exit
|
106
|
-
# end
|
107
|
-
# end
|
108
|
-
# end
|
109
|
-
end
|