Class: UPnP::Device::MediaServer
- Inherits:
-
UPnP::Device
- Object
- UPnP::Device
- UPnP::Device::MediaServer
- Defined in:
- lib/UPnP/device/media_server.rb
Overview
A UPnP MediaServer. See upnp.org for specifications.
Constant Summary collapse
- VERSION =
'1.0.0'
Class Method Summary collapse
-
.option_parser ⇒ Object
Adds directory and name options.
-
.run(argv = ARGV) ⇒ Object
Runs a MediaServer.
Class Method Details
.option_parser ⇒ Object
Adds directory and name options.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/UPnP/device/media_server.rb', line 19 def self.option_parser super do |option_parser, | [:directories] = [] [:name] = Socket.gethostname.split('.', 2).first option_parser. = <<-EOF Usage: #{option_parser.program_name} [options] Starts a UPnP media server. If no directories are given, serves content in the current directory. EOF option_parser.separator '' option_parser.on('-d', '--directory=DIRECTORY', 'Expose a directory to the media server') do |value| [:directories] << File.(value) end option_parser.on('-n', '--name=NAME', 'Set the MediaServer\'s name') do |value| [:name] = value end end end |
.run(argv = ARGV) ⇒ Object
Runs a MediaServer. Automatically adds the current directory if no directories were specified.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/UPnP/device/media_server.rb', line 49 def self.run(argv = ARGV) super @options[:directories] << Dir.pwd if @options[:directories].empty? device = create 'MediaServer', @options[:name] do |ms| ms.manufacturer = 'Seattle Ruby Brigade' ms.manufacturer_url = 'http://seattlerb.org' ms.model_description = "Ruby Media Server version #{ms.class::VERSION}" ms.model_name = 'Ruby Media Server' ms.model_url = 'http://seattlerb.org/UPnP-MediaServer' ms.model_number = UPnP::Device::MediaServer::VERSION ms.add_service 'ContentDirectory' do |cd| @options[:directories].each do |directory| cd.add_directory directory end end ms.add_service 'ConnectionManager' end device.run end |