class Drum::StdioService
A service that reads from stdin and writes to stdout.
Public Instance Methods
download(playlist_ref)
click to toggle source
# File lib/drum/service/stdio.rb, line 31 def download(playlist_ref) if playlist_ref.resource_location.include?(:stdin) # TODO: Support multiple, --- delimited playlists? [Playlist.deserialize(YAML.load(STDIN.read))] else [] end end
name()
click to toggle source
# File lib/drum/service/stdio.rb, line 12 def name 'stdio' end
parse_ref(raw_ref)
click to toggle source
# File lib/drum/service/stdio.rb, line 16 def parse_ref(raw_ref) if raw_ref.is_token location = case raw_ref.text when 'stdout' then :stdout when 'stdin' then :stdin else return nil end Ref.new(self.name, :any, [location]) elsif raw_ref.text == '-' Ref.new(self.name, :any, [:stdin, :stdout]) else nil end end
upload(playlist_ref, playlists)
click to toggle source
# File lib/drum/service/stdio.rb, line 40 def upload(playlist_ref, playlists) if playlist_ref.resource_location.include?(:stdout) playlists.each do |playlist| log.all playlist.serialize.to_yaml end nil else raise 'Cannot upload to somewhere other than stdout!' end end