updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / ruby-taglib / ruby-1.9.patch
blob4f5a3bd99f4c8963b1fee22933c40ed1661694b4
1 diff -aur ruby-taglib-1.1/.config ruby-taglib-1.1+patch2_ruby1.9//.config
2 --- ruby-taglib-1.1/lib/taglib.rb 2006-05-09 16:39:37.000000000 +0200
3 +++ ruby-taglib-1.1+patch2_ruby1.9//lib/taglib.rb 2010-07-26 18:03:14.000000000 +0200
4 @@ -1,4 +1,5 @@
5 # Copyright (C) 2004 Neil Stevens <neil@hakubi.us>
6 +# Copyright (C) 2010 Vincent Carmona <vinc4mai@gmail.com>
8 # Permission is hereby granted, free of charge, to any person obtaining a copy
9 # of this software and associated documentation files (the "Software"), to deal
10 @@ -37,10 +38,15 @@
12 module TagLib
14 -extend DL::Importable
15 +begin
16 + extend DL::Importer#Since ruby 1.9
17 +rescue NameError
18 + extend DL::Importable#Old ruby versions
19 +end
21 begin
22 dlload 'libtag_c.so'
23 + #dlload 'libtag_c.so.0'# for debian-like or use a link.
24 rescue
25 begin
26 dlload 'libtag_c.dylib'
27 @@ -69,15 +75,15 @@
28 extern 'char* taglib_tag_album(void*)'
29 extern 'char* taglib_tag_comment(void*)'
30 extern 'char* taglib_tag_genre(void*)'
31 -extern 'uint taglib_tag_year(void*)'
32 -extern 'uint taglib_tag_track(void*)'
33 +extern 'unsigned int taglib_tag_year(void*)'
34 +extern 'unsigned int taglib_tag_track(void*)'
35 extern 'void taglib_tag_set_title(void*, char*)'
36 extern 'void taglib_tag_set_artist(void*, char*)'
37 extern 'void taglib_tag_set_album(void*, char*)'
38 extern 'void taglib_tag_set_comment(void*, char*)'
39 extern 'void taglib_tag_set_genre(void*, char*)'
40 -extern 'void taglib_tag_set_year(void*, uint)'
41 -extern 'void taglib_tag_set_track(void*, uint)'
42 +extern 'void taglib_tag_set_year(void*, unsigned int)'
43 +extern 'void taglib_tag_set_track(void*, unsigned int)'
45 extern 'int taglib_audioproperties_length(void*)'
46 extern 'int taglib_audioproperties_bitrate(void*)'
47 @@ -100,9 +106,7 @@
49 def initialize(p)
50 @path = p
51 - if not @path
52 - raise BadPath.new
53 - end
54 + raise BadPath.new unless @path
56 if MAHORO_PRESENT
57 mahoro = Mahoro.new
58 @@ -119,7 +123,7 @@
59 @file = TagLib.taglib_file_new(@path)
60 end
62 - if not @file
63 + unless @file
64 @path = nil
65 raise BadFile.new
66 end
67 @@ -139,8 +143,13 @@
68 @audio = nil
69 end
71 +#I have had to_s method to be sure that methods return a string and not a char*.
72 +#The behaviour is inconsistent depending on ruby version.
73 +#I hope that is not too ugly.
74 +#Vincent
76 def title
77 - return TagLib.taglib_tag_title(tag)
78 + TagLib.taglib_tag_title(tag).to_s
79 end
81 def title=(string)
82 @@ -148,7 +157,7 @@
83 end
85 def artist
86 - return TagLib.taglib_tag_artist(tag)
87 + TagLib.taglib_tag_artist(tag).to_s
88 end
90 def artist=(string)
91 @@ -156,7 +165,7 @@
92 end
94 def album
95 - return TagLib.taglib_tag_album(tag)
96 + TagLib.taglib_tag_album(tag).to_s
97 end
99 def album=(string)
100 @@ -164,7 +173,7 @@
103 def comment
104 - return TagLib.taglib_tag_comment(tag)
105 + TagLib.taglib_tag_comment(tag).to_s
108 def comment=(string)
109 @@ -172,7 +181,7 @@
112 def genre
113 - return TagLib.taglib_tag_genre(tag)
114 + TagLib.taglib_tag_genre(tag).to_s
117 def genre=(string)
118 @@ -180,7 +189,7 @@
121 def year
122 - return TagLib.taglib_tag_year(tag)
123 + TagLib.taglib_tag_year(tag)
126 def year=(uint)
127 @@ -188,7 +197,7 @@
130 def track
131 - return TagLib.taglib_tag_track(tag)
132 + TagLib.taglib_tag_track(tag)
135 def track=(uint)
136 @@ -196,46 +205,36 @@
139 def length
140 - return TagLib.taglib_audioproperties_length(audio)
141 + TagLib.taglib_audioproperties_length(audio)
144 def bitrate
145 - return TagLib.taglib_audioproperties_bitrate(audio)
146 + TagLib.taglib_audioproperties_bitrate(audio)
149 def samplerate
150 - return TagLib.taglib_audioproperties_samplerate(audio)
151 + TagLib.taglib_audioproperties_samplerate(audio)
154 def channels
155 - return TagLib.taglib_audioproperties_channels(audio)
156 + TagLib.taglib_audioproperties_channels(audio)
159 private
160 def tag
161 - if not @tag
162 - @tag = TagLib.taglib_file_tag(@file)
163 - if not @tag
164 - raise BadTag.new
165 - end
166 - end
167 - return @tag
168 + @tag ||= TagLib.taglib_file_tag(@file)
169 + raise BadTag.new unless @tag
170 + @tag
173 def audio
174 - if not @audio
175 - @audio = TagLib.taglib_file_audioproperties(@file)
176 - if not @audio
177 - raise BadAudioProperties.new
178 - end
179 - end
180 - return @audio
181 + @audio ||= TagLib.taglib_file_audioproperties(@file)
182 + raise BadAudioProperties.new unless @audio
183 + @audio
186 def taglibForMime(mime)
187 - if mime.include?('MP3')
188 - return TagLib::MPEG
189 - end
190 + return TagLib::MPEG if mime.include?('MP3')
192 if mime.include?('Ogg') or mime.include?('ogg')
193 if mime.include?('Vorbis') or mime.include?('vorbis')