ruby-mp3info 0.8 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 421738e99b09100f70bdf70796c8f700b8a2abfd
4
+ data.tar.gz: c3d33ce01228e74e48ceee95696f422800f40323
5
+ SHA512:
6
+ metadata.gz: 8265aa027cb141ea232c63b3209f9b3e4e42d02cae25626078d2e7eed4d7c972f14b4804195e32c58e5eb42a8ede15da3ecc638a6d1329cf5ebce0a8c172ce54
7
+ data.tar.gz: f8c3f0d2128173c554f584f0c8b636abe00ae8311b48d4b65003cddc87baf49db074b4fa04fd4f118ad42fa1d65501b95a1634b012055359b9a38a57b2ab401a
@@ -1,3 +1,8 @@
1
+ === 0.8.1 / 2013-10-280
2
+
3
+ * test fixes
4
+ * added dot to temp filename
5
+
1
6
  === 0.8 / 2013-01-28
2
7
 
3
8
  * allow higher level of reading and writing to APIC tag:
data/README.md CHANGED
@@ -18,56 +18,64 @@ ruby-mp3info read low-level informations and manipulate tags on mp3 files.
18
18
  ## Synopsis
19
19
 
20
20
  ```ruby
21
- require "mp3info"
22
-
23
- # Read and display infos & tags
24
-
25
- Mp3Info.open("myfile.mp3") do |mp3info|
26
- puts mp3info
27
- end
28
-
29
- # read/write tag1 and tag2 with Mp3Info#tag attribute
30
- # when reading tag2 have priority over tag1
31
- # when writing, each tag is written.
32
-
33
- Mp3Info.open("myfile.mp3") do |mp3|
34
- puts mp3.tag.title
35
- puts mp3.tag.artist
36
- puts mp3.tag.album
37
- puts mp3.tag.tracknum
38
- mp3.tag.title = "track title"
39
- mp3.tag.artist = "artist name"
40
- end
41
-
42
- # tags are written when calling Mp3Info#close or at the end of the #open block
43
-
44
- ### access id3v2 tags
45
-
46
- Mp3Info.open("myfile.mp3") do |mp3|
47
- # you can access four letter v2 tags like this
48
- puts mp3.tag2.TIT2
49
- mp3.tag2.TIT2 = "new TIT2"
50
- # or like that
51
- mp3.tag2["TIT2"]
52
- # at this time, only COMM tag is processed after reading and before writing
53
- # according to ID3v2#options hash
54
- mp3.tag2.options[:lang] = "FRE"
55
- mp3.tag2.COMM = "my comment in french, correctly handled when reading and writing"
56
- end
57
-
58
- ### image manipulation
59
-
60
- file = File.new('input_img','rb')
61
- Mp3Info.open '1.mp3' do |m|
62
- pictures = m.tag2.get_pictures # array of images :
63
- pictures.each do |description, data|
64
- File.open(description, "wb") { |f| f.write data }
65
- end
66
- m.tag2.remove_pictures # remove all images
67
- m.tag2.add_picture(file.read) # optionally, you may include options for the header:
68
- # options = { mime: 'gif', description: "description",
69
- # pic_type: 0 }
70
- end
21
+ require "mp3info"
22
+
23
+ # Read and display infos & tags
24
+
25
+ Mp3Info.open("myfile.mp3") do |mp3info|
26
+ puts mp3info
27
+ end
28
+
29
+ # read/write tag1 and tag2 with Mp3Info#tag attribute
30
+ # when reading tag2 have priority over tag1
31
+ # when writing, each tag is written.
32
+
33
+ Mp3Info.open("myfile.mp3") do |mp3|
34
+ puts mp3.tag.title
35
+ puts mp3.tag.artist
36
+ puts mp3.tag.album
37
+ puts mp3.tag.tracknum
38
+ mp3.tag.title = "track title"
39
+ mp3.tag.artist = "artist name"
40
+ end
41
+
42
+ # tags are written when calling Mp3Info#close or at the end of the #open block
43
+
44
+ ### access id3v2 tags
45
+
46
+ Mp3Info.open("myfile.mp3") do |mp3|
47
+ # you can access four letter v2 tags like this
48
+ puts mp3.tag2.TIT2
49
+ mp3.tag2.TIT2 = "new TIT2"
50
+ # or like that
51
+ mp3.tag2["TIT2"]
52
+ # at this time, only COMM tag is processed after reading and before writing
53
+ # according to ID3v2#options hash
54
+ mp3.tag2.options[:lang] = "FRE"
55
+ mp3.tag2.COMM = "my comment in french, correctly handled when reading and writing"
56
+ end
57
+
58
+ ### image manipulation
59
+
60
+ file = File.new('input_img','rb')
61
+ Mp3Info.open '1.mp3' do |m|
62
+ pictures = m.tag2.pictures # array of images :
63
+ pictures.each do |description, data|
64
+ # description ends with (.jpg / .png) for easy writing to file
65
+ File.binwrite(description, data)
66
+ end
67
+ m.tag2.remove_pictures # remove all images
68
+
69
+ m.tag2.add_picture(file.read) # add a single image to APIC tag
70
+ # **optionally**, you may include options for the image tag to add_picture():
71
+ # options = { mime: 'jpeg|gif|png', description: "description",
72
+ # pic_type: 0 }
73
+ # There is no need to specify mime or options because the mime is guessed based on the input image
74
+ # Only one image is permitted in the mp3 for compatibility. add_picture() overwrites all previous images.
75
+ # Please note:
76
+ # If supplying :mime option just supply the mime 'jpeg', 'gif' or 'png', the code adds the "image/.." for you!
77
+ # e.g. m.tag2.add_picture(file.read, mime: 'jpeg', pic_type: 3) gets a mime "image/jpeg"
78
+ end
71
79
  ```
72
80
 
73
81
  ## Requirements
data/Rakefile CHANGED
@@ -7,8 +7,6 @@ Hoe.plugin :gemspec
7
7
 
8
8
  Hoe.spec('ruby-mp3info') do
9
9
  developer "Guillaume Pierronnet", "guillaume.pierronnet@gmail.com"
10
- remote_rdoc_dir = ''
11
- rdoc_locations << "rubyforge.org:/var/www/gforge-projects/ruby-mp3info/"
12
10
  end
13
11
 
14
12
  # vim: syntax=Ruby
@@ -1,7 +1,6 @@
1
1
  # coding:utf-8
2
2
  # License:: Ruby
3
3
  # Author:: Guillaume Pierronnet (mailto:guillaume.pierronnet@gmail.com)
4
- # Website:: http://ruby-mp3info.rubyforge.org/
5
4
 
6
5
  require "fileutils"
7
6
  require "stringio"
@@ -18,7 +17,7 @@ end
18
17
 
19
18
  class Mp3Info
20
19
 
21
- VERSION = "0.8"
20
+ VERSION = "0.8.1"
22
21
 
23
22
  LAYER = [ nil, 3, 2, 1]
24
23
  BITRATE = {
@@ -443,7 +442,9 @@ class Mp3Info
443
442
  # @io.seek(@io.get_syncsafe - 4, IO::SEEK_CUR) if ext_header
444
443
  # @io.seek(tag2_len, IO::SEEK_CUR)
445
444
  # end
446
- tempfile_name = @filename_or_io + ".tmp"
445
+ filename_splitted = File.split(@filename_or_io)
446
+ filename_splitted[-1] = ".#{filename_splitted[-1]}.tmp"
447
+ tempfile_name = File.join(filename_splitted)
447
448
  File.open(tempfile_name, "wb") do |tempfile|
448
449
  unless @tag2.empty?
449
450
  tempfile.write(@tag2.to_bin)
@@ -1,7 +1,6 @@
1
1
  # coding:utf-8
2
2
  # License:: Ruby
3
3
  # Author:: Guillaume Pierronnet (mailto:guillaume.pierronnet@gmail.com)
4
- # Website:: http://ruby-mp3info.rubyforge.org/
5
4
 
6
5
  class Mp3Info
7
6
  module HashKeys #:nodoc:
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
  # License:: Ruby
3
3
  # Author:: Guillaume Pierronnet (mailto:guillaume.pierronnet@gmail.com)
4
- # Website:: http://ruby-mp3info.rubyforge.org/
5
4
 
6
5
  require "delegate"
7
6
 
@@ -305,7 +304,7 @@ class ID3v2 < DelegateClass(Hash)
305
304
  end
306
305
 
307
306
  puts "analysing image: #{header.inspect}..." if $DEBUG
308
- mim, pic_type, desc, data = pic[mime_pos, pic.length].unpack('Z*hZ*a*')
307
+ _, _, desc, data = pic[mime_pos, pic.length].unpack('Z*hZ*a*')
309
308
 
310
309
  if mime != "dat" and (!data.match(start) or data.nil?)
311
310
  real_start = pic =~ start
@@ -594,9 +593,8 @@ class ID3v2 < DelegateClass(Hash)
594
593
 
595
594
  ### this is especially useful for printing out APIC data because
596
595
  ### only the header of the APIC tag is of interest
597
- ### The result also shows some bytes escaped for cleaner display
598
596
  def pretty_header(str, chars=128)
599
- "#{str.unpack("a#{chars}").first}<<<...snip...>>>".force_encoding('BINARY').inspect[1..-2]
597
+ "#{str.unpack("a#{chars}").first}<<<...snip...>>>".inspect[1..-2]
600
598
  end
601
599
 
602
600
 
@@ -64,7 +64,7 @@ class Mp3InfoTest < Test::Unit::TestCase
64
64
  f.write(str)
65
65
  end
66
66
  assert_raises(Mp3InfoError) do
67
- mp3 = Mp3Info.new(TEMP_FILE)
67
+ Mp3Info.new(TEMP_FILE)
68
68
  end
69
69
  end
70
70
 
@@ -142,7 +142,7 @@ class Mp3InfoTest < Test::Unit::TestCase
142
142
  end
143
143
 
144
144
  def test_removetag2
145
- w = write_tag2_to_temp_file("TIT2" => "sdfqdsf")
145
+ write_tag2_to_temp_file("TIT2" => "sdfqdsf")
146
146
 
147
147
  assert( Mp3Info.hastag2?(TEMP_FILE) )
148
148
  Mp3Info.removetag2(TEMP_FILE)
@@ -155,7 +155,7 @@ class Mp3InfoTest < Test::Unit::TestCase
155
155
  end
156
156
  assert(Mp3Info.hastag1?(TEMP_FILE))
157
157
 
158
- written_tag = write_tag2_to_temp_file(DUMMY_TAG2)
158
+ write_tag2_to_temp_file(DUMMY_TAG2)
159
159
  assert(Mp3Info.hastag2?(TEMP_FILE))
160
160
  end
161
161
 
@@ -189,13 +189,21 @@ class Mp3InfoTest < Test::Unit::TestCase
189
189
  assert_equal( "2.3.0", written_tag.version )
190
190
  end
191
191
 
192
+ =begin
193
+ # test for good output of APIC tag inspect (escaped and snipped)
194
+ def test_id3v2_to_inspect_hash
195
+ Mp3Info.open(TEMP_FILE) do |mp3|
196
+ mp3.tag2.APIC = "\0testing.jpg\0" * 20
197
+ assert_match(/\\0testing\.jpg\\0.*<<<\.\.\.snip\.\.\.>>>$/, mp3.tag2.to_inspect_hash["APIC"])
198
+ end
199
+ end
200
+ =end
201
+
192
202
  # test for good output of APIC tag inspect (escaped and snipped)
193
203
  def test_id3v2_to_inspect_hash
194
204
  Mp3Info.open(TEMP_FILE) do |mp3|
195
205
  mp3.tag2.APIC = "\x00testing.jpg\x00" * 20
196
- escaped_str = "\\x00testing.jpg\\x00" * 20
197
- snipped_str = escaped_str.unpack('a185').first + "<<<...snip...>>>"
198
- assert_equal(snipped_str, mp3.tag2.to_inspect_hash["APIC"])
206
+ assert_match(/^(\\x00testing.jpg\\x00)+.*<<<\.\.\.snip\.\.\.>>>$/, mp3.tag2.to_inspect_hash["APIC"])
199
207
  end
200
208
  end
201
209
 
@@ -469,7 +477,7 @@ class Mp3InfoTest < Test::Unit::TestCase
469
477
  io = load_string_io
470
478
  assert(Mp3Info.hastag1?(io))
471
479
 
472
- written_tag = write_tag2_to_temp_file(DUMMY_TAG2)
480
+ write_tag2_to_temp_file(DUMMY_TAG2)
473
481
  io = load_string_io
474
482
  assert(Mp3Info.hastag2?(io))
475
483
  end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-mp3info
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.8'
5
- prerelease:
4
+ version: 0.8.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Guillaume Pierronnet
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-29 00:00:00.000000000 Z
11
+ date: 2013-10-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: hoe-yard
14
+ name: rdoc
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 0.1.2
19
+ version: '3.10'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 0.1.2
26
+ version: '3.10'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: hoe
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -63,30 +58,28 @@ files:
63
58
  - .gemtest
64
59
  homepage: http://github.com/moumar/ruby-mp3info
65
60
  licenses: []
61
+ metadata: {}
66
62
  post_install_message:
67
63
  rdoc_options:
68
- - --title
69
- - TestRuby::TestMp3info Documentation
70
- - --quiet
64
+ - --main
65
+ - README.md
71
66
  require_paths:
72
67
  - lib
73
68
  required_ruby_version: !ruby/object:Gem::Requirement
74
- none: false
75
69
  requirements:
76
- - - ! '>='
70
+ - - '>='
77
71
  - !ruby/object:Gem::Version
78
72
  version: '0'
79
73
  required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
74
  requirements:
82
- - - ! '>='
75
+ - - '>='
83
76
  - !ruby/object:Gem::Version
84
77
  version: '0'
85
78
  requirements: []
86
79
  rubyforge_project: ruby-mp3info
87
- rubygems_version: 1.8.24
80
+ rubygems_version: 2.1.5
88
81
  signing_key:
89
- specification_version: 3
82
+ specification_version: 4
90
83
  summary: ruby-mp3info read low-level informations and manipulate tags on mp3 files.
91
84
  test_files:
92
85
  - test/test_ruby-mp3info.rb