5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/feed2thread/publishes_posts.rb', line 5
def publish(posts, config, options)
post_limit = options.limit || posts.size
puts "Publishing #{post_limit} posts to Threads" if options.verbose
posts.reverse.take(post_limit).map { |post|
begin
puts "Publishing thread for: #{post.url}" if options.verbose
publish_thread(post, config, options)
rescue => e
warn "Failed to post #{post.url}: #{e.message}"
e.backtrace.join("\n").each_line { |line| warn line }
Result.new(post: post, status: :failed)
end
}
end
|