dmap 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +34 -1
  2. data/Rakefile +1 -1
  3. data/lib/dmap.rb +11 -2
  4. metadata +1 -1
data/README.rdoc CHANGED
@@ -1,9 +1,42 @@
1
1
  = dmap
2
2
 
3
+ WHOA THERE!
4
+
5
+ This is very unfinished work. Feel free to use or expand, but expect some changes.
6
+
3
7
  I'm planning on building a Ruby library to parse and create DMAP bytestrings. Primarily in order to create a DAAP server in ruby, though if anyone has other interesting uses that would require changes to this code please don't hesitate to get in touch!
4
8
 
5
9
  == What is dmap?
6
10
 
7
11
  DMAP are a method of storing a variety of objects in a bytestring, its used all over the shot by Apple in iTunes, iPhoto and probably many other places. You can read up a little on the wikipedia (http://en.wikipedia.org/wiki/Digital_Audio_Access_Protocol) or read about the daap protocol (http://tapjam.net/daap/) to get the gist of it.
8
12
 
9
- There's a big ol' list of the tags that are known on the deleet.de website (http://www.deleet.de/projekte/daap/?ContentCodes) but there are undoubtedly many more (I remember from an old project that similar file structure is used for QuickTime's mov containers and even for the mp4 container, so there may well be more there too). If you find any useful resources please get in touch!
13
+ There's a big ol' list of the tags that are known on the deleet.de website (http://www.deleet.de/projekte/daap/?ContentCodes) but there are undoubtedly many more (I remember from an old project that similar file structure is used for QuickTime's mov containers and even for the mp4 container, so there may well be more there too). If you find any useful resources please get in touch!
14
+
15
+ == Examples!
16
+
17
+ We all love examples, so here's an example of how to use this module:
18
+
19
+ require 'dmap'
20
+
21
+ # You can load from any IO source:
22
+ d = DMAP::Element(open("your_dmap"))
23
+ p d
24
+ # => <MSRV: [<MINM: "I'm a string!">]>
25
+
26
+ # Or write out what you want in code:
27
+ d = DMAP::Element.new("msrv",[DMAP::Element.new('minm',"I'm a string!")])
28
+ p d
29
+ # => <MSRV: [<MINM: "I'm a string!">]>
30
+
31
+ # All DMAP elements act like their Ruby counterparts:
32
+ d.push(DMAP::Element.new('asdm'))
33
+
34
+ # They can also be pre-populated with data of an appropriate type
35
+ d.push(DMAP::Element.new('astm',123))
36
+
37
+ p d
38
+ # => <MSRV: [<MINM: "I'm a string!">, <ASDM: Fri Nov 06 11:18:29 +0000 2009>, <ASTM: 123>]>
39
+
40
+ If you want to allow parsing of more tags, you're probably not going to want to go there right now (I'm likely to change the way this works) but if you just specify a new constant in the DMAP module, who's name is the 4-byte code, set it to an array like [:string, 'domain.app.name'].
41
+
42
+ The first item there specifies what datatype it is, but you will need to have a function called DMAP::Element#parse_your_datatype - you'll get the idea if you look into the code. You will also need to extend the real class used to store your value so that it has a #to_dmap function. Again, go poke around the code.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "dmap"
8
- gem.version = "0.1.2"
8
+ gem.version = "0.1.3"
9
9
  gem.summary = %Q{Parses Apple's DMAP strings (4-byte serialization method)}
10
10
  gem.description = %Q{Apple uses a system of serialization (I think its called dmap…) where a 4-byte string tells of the information following, both its type and what it represents. Its used in the DAAP (Protocol), QuickTime mov structure and doubtless many other places.}
11
11
  gem.email = "jphastings@gmail.com"
data/lib/dmap.rb CHANGED
@@ -4,7 +4,7 @@ require 'delegate'
4
4
 
5
5
  # If you plan on extending this module (like you'll need to if you want extra tags available)
6
6
  # make sure you don't use any class names with four letters in. It saves a bit of processor time
7
- # if I don't have to remove
7
+ # if I don't have to remove them.
8
8
  module DMAP
9
9
  # Represents any DMAP tag and its content.
10
10
  # Will have methods appropriate to the dmap specified
@@ -426,4 +426,13 @@ module DMAP
426
426
  CEJS = [:signed, 'com.apple.itunes.jukebox-score']
427
427
  ASDM = [:time, 'daap.songdatemodified']
428
428
  AESF = [:number, 'com.apple.itunes.itms-storefrontid']
429
- end
429
+ end
430
+
431
+ d = DMAP::Element.new("msrv",[DMAP::Element.new('minm',"I'm a string!")])
432
+ p d
433
+ # All DMAP elements act like their Ruby counterparts:
434
+ d.push(DMAP::Element.new('asdm'))
435
+ # They can also be pre-populated with data of an appropriate type
436
+ d.push(DMAP::Element.new('astm',123))
437
+ p d
438
+ # => <MSRV: [<MINM: "I'm a string!">, <ASDM: Fri Nov 06 11:18:29 +0000 2009>, <ASTM: 123>]>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Hastings-Spital