Я знаю, что это не так элегантно, но я решил немного похожую проблему, используя capture.output
; к сожалению, sink
не допускает одновременного захвата сообщения с и вывода . Вы не получите их в исходном порядке, но вы можете извлечь по крайней мере оба потока (здесь мы обратились к HTML):
runApp(shinyApp(
ui = fluidPage(
uiOutput("test")
),
server = function(input,output, session) {
output$test <- renderUI({
HTML(
paste(capture.output(type = "message", expr = {
message(capture.output(type = "output", expr = {
cat("test cat<br>")
message("test message")
cat("test cat2<br>")
message("test message2")
}))
}), collapse="<br>")
)})
})
)
Вывод:
test message
test message2
test cat
test cat2
Возможно, в случае если пользователь хочет захватить оба, но также разделить их, это обеспечит удобный обходной путь. (Ваша shinyjs
посылка кажется аккуратной, нужно взглянуть на нее!)
http://www.hakubi.us/ruby-taglib/
Я использовал это для проекта, и он работал довольно хорошо. Обертка вокруг taglib, очень портативная.
I've used this:
http://ruby-mp3info.rubyforge.org/
or
gem install ruby-mp3info
(add the regulation sudo
for Mac or *nix)
There's some rdoc documentation, which is nice. On the downside, I don't much like the use of upper-case field names, which seems too concerned to preserve the names from the spec. Maybe I should hack in some aliases. Anyway, this sample script scans my music library and counts words in titles:
require 'mp3info'
count = 0
words = Hash.new { |h, k| h[k] = 0 }
Dir.glob("E:/MUSIC/**/*.mp3") do |f|
count += 1
Mp3Info.open(f) do |mp3info|
title = mp3info.tag2.TIT2
next unless title
title.split(/\s/).each { |w| words[w.downcase] += 1 }
end
end
puts "Examined #{count} files"
words.to_a.sort{ |a, b| b[1] <=> a[1] }[0,100].each { |w| puts "#{w[0]}: #{w[1]}" }
http://id3lib-ruby.rubyforge.org/
Мне особенно понравился этот, вы также можете записывать теги в файл.