flacinfo-rb 0.4 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/README +8 -4
  3. data/lib/flacinfo.rb +13 -21
  4. data/test/test-flacinfo.rb +0 -0
  5. metadata +44 -39
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d9267dacbedb7bac4eb13df1bb8c119bbbac61e2
4
+ data.tar.gz: e1c40dd876b865c06c454b3d0ce686072128a255
5
+ SHA512:
6
+ metadata.gz: e264c66fd251c141c1acd991aee4c397708356147839e62c71cb02d3cab16dc5e91d5c0b425ea15cee7ace367069fc224f4c914209dadabff9759df30f1a5844
7
+ data.tar.gz: 4653e488863c184a0117f8bb6b90cbf2e5571ecc96a3ba3ee10c37ce85e0a30fce1ca0b333f6325f5faca86a9ab273ba10e472bdfccce3e44d4d3ff4f25dbbc0
data/README CHANGED
@@ -1,7 +1,7 @@
1
- :: FlacInfo-rb ::
1
+ :: flacinfo-rb ::
2
2
  Author: Darren Kirby
3
- mailto:bulliver@badcomputer.org
4
- License: Ruby
3
+ mailto:bulliver@gmail.com
4
+ License: GPL3
5
5
 
6
6
  = Quick API docs =
7
7
 
@@ -39,5 +39,9 @@ raw_data_dump(?) :: if passed a filename it will dump flac_file['raw_data'] to
39
39
  update! :: writes comment changes to disk
40
40
  write_picture(?) :: write image from PICTURE block(s) to optional file
41
41
 
42
- For more/different documentation see http://badcomputer.org/unix/code/flacinfo/
42
+ The public methods and attributes are very well documented in the source itself. Please read
43
+ there if you don't understand any of this. You can also use Rdoc to generate HTML documentation.
43
44
 
45
+ HELP: flacinfo-rb still does not parse cuesheets, as I have never encountered a flac file
46
+ that contains one. If you have a flac file with a cuesheet please consider emailing it to
47
+ me so I can add this remaining bit of code.
@@ -11,24 +11,22 @@
11
11
  # * It parses zero or more picture blocks (METADATA_BLOCK_PICTURE)
12
12
  # * It allows you to write the embedded images to a file.
13
13
  #
14
- # My goals are to create a nice native Ruby library interface which will allow
14
+ # My goal is to create a nice native Ruby library interface which will allow
15
15
  # the user to mimic most functionality of the 'metaflac' binary programmatically.
16
16
  #
17
17
  # = Copyright and Disclaimer
18
18
  #
19
- # Copyright:: (c) 2006, 2007 Darren Kirby
19
+ # Copyright:: (C) 2006 - 2014 Darren Kirby
20
20
  #
21
21
  # FlacInfo is free software. No warranty is provided and the author
22
22
  # cannot accept responsibility for lost or damaged files.
23
23
  #
24
- # License:: Ruby
25
- # Author:: Darren Kirby (mailto:bulliver@badcomputer.org)
26
- # Website:: http://badcomputer.org/unix/code/flacinfo/index.bot
24
+ # License:: GPL3
25
+ # Author:: Darren Kirby (mailto:bulliver@gmail.com)
26
+ # Website:: https://github.com/DarrenKirby/flacinfo-rb
27
27
  #
28
28
  # = More information
29
29
  #
30
- # * There is an example irb session that shows typical usage at
31
- # http://badcomputer.org/unix/code/flacinfo/index.bot
32
30
  # * The Flac spec is at:
33
31
  # http://flac.sourceforge.net/format.html
34
32
  # * The Vorbis Comment spec is at:
@@ -37,18 +35,15 @@
37
35
 
38
36
  # FlacInfoError is raised for general user errors.
39
37
  # It will print a string that describes the problem.
40
- class FlacInfoError < StandardError
41
- end
38
+ FlacInfoError = Class.new(StandardError)
42
39
 
43
40
  # FlacInfoReadError is raised when an error occurs parsing the Flac file.
44
41
  # It will print a string that describes in which block the error occured.
45
- class FlacInfoReadError < StandardError
46
- end
42
+ FlacInfoReadError = Class.new(StandardError)
47
43
 
48
44
  # FlacInfoWriteError is raised when an error occurs writing the Flac file.
49
45
  # It will print a string that describes where the error occured.
50
- class FlacInfoWriteError < StandardError
51
- end
46
+ FlacInfoWriteError = Class.new(StandardError)
52
47
 
53
48
  # Note: STREAMINFO is the only block guaranteed to be present in the Flac file.
54
49
  # All attributes will be present but empty if the associated block is not present in the Flac file,
@@ -347,7 +342,7 @@ class FlacInfo
347
342
  raise FlacInfoError, "comments must be in the form 'name=value'"
348
343
  end
349
344
  begin
350
- @comment[@comment.length] = name
345
+ @comment << name
351
346
  @comments_changed = 1
352
347
  rescue
353
348
  return false
@@ -363,7 +358,7 @@ class FlacInfo
363
358
  # If 'str' is in the form 'name=value' only exact matches
364
359
  # will be deleted. If 'str' is in the form 'name' any and all
365
360
  # comments named 'name' will be deleted. Returns 'true' if a
366
- # comment was deleted, false otherwise. Remember to call
361
+ # comment was deleted, false otherwise. Remember to call
367
362
  # 'update!' to write changes to the file.
368
363
  #
369
364
  def comment_del(name)
@@ -542,13 +537,11 @@ class FlacInfo
542
537
 
543
538
  @metadata_blocks = []
544
539
  lastheader = 0
545
- pos = 1
546
540
 
547
541
  until lastheader == 1
548
542
  # first bit = Last-metadata-block flag
549
543
  # bits 2-8 = BLOCK_TYPE. See typetable above
550
544
  block_header = @fp.read(1).unpack("B*")[0]
551
- #puts block_header
552
545
  lastheader = block_header[0].to_i & 1
553
546
  type = sprintf("%u", "0b#{block_header[1..7]}").to_i
554
547
  @metadata_blocks << [typetable[type], type, lastheader]
@@ -557,7 +550,6 @@ class FlacInfo
557
550
  raise FlacInfoReadError, "Invalid block header type"
558
551
  end
559
552
 
560
- pos += 1
561
553
  self.send "parse_#{typetable[type]}"
562
554
  end
563
555
 
@@ -613,7 +605,7 @@ class FlacInfo
613
605
  picture_type = ["Other", "32x32 pixels file icon", "Other file icon", "Cover (front)", "Cover (back)",
614
606
  "Leaflet page", "Media", "Lead artist/lead performer/soloist", "Artist/performer",
615
607
  "Conductor", "Band/Orchestra", "Composer", "Lyricist/text writer", "Recording Location",
616
- "During recording", "During performance", "Movie/video screen capture", "A bright
608
+ "During recording", "During performance", "Movie/video screen capture", "A bright
617
609
  coloured fish", "Illustration", "Band/artist logotype", "Publisher/Studio logotype"]
618
610
 
619
611
  begin
@@ -668,7 +660,7 @@ class FlacInfo
668
660
  @application['raw_data'] = @fp.read(@application['block_size'] - 4)
669
661
  end
670
662
  rescue
671
- raise FlacInfoReadError, "Could not parse METADATA_BLOCK_APPLICATION"
663
+ raise FlacInfoReadError, "Could not parse METADATA_BLOCK_APPLICATION"
672
664
  end
673
665
  end
674
666
 
@@ -798,7 +790,7 @@ class FlacInfo
798
790
  vorbis_comm_s += [@tags["vendor_tag"]].pack("A*")
799
791
  vorbis_comm_s += [@comment.length].pack("V")
800
792
  @comment.each do |c|
801
- vorbis_comm_s += [c.length].pack("V")
793
+ vorbis_comm_s += [c.bytesize].pack("V")
802
794
  vorbis_comm_s += [c].pack("A*")
803
795
  end
804
796
  vorbis_comm_s
File without changes
metadata CHANGED
@@ -1,48 +1,53 @@
1
- --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
1
+ --- !ruby/object:Gem::Specification
4
2
  name: flacinfo-rb
5
- version: !ruby/object:Gem::Version
6
- version: "0.4"
7
- date: 2007-09-08 00:00:00 -06:00
8
- summary: Pure Ruby library for accessing metadata from Flac files
9
- require_paths:
10
- - lib
11
- email: bulliver@badcomputer.org
12
- homepage: http://badcomputer.org/unix/code/flacinfo/
13
- rubyforge_project: flacinfo-rb
14
- description:
15
- autorequire: flacinfo
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
- authors:
6
+ authors:
30
7
  - Darren Kirby
31
- files:
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ flacinfo-rb is a pure Ruby library for low-level access to Flac files.
15
+ You can use it to read, set, or delete 'id3' like data (Vorbis comments),
16
+ delete, add, or resize padding blocks, and so on.
17
+ email: bulliver@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files:
21
+ - README
22
+ files:
32
23
  - README
33
24
  - lib/flacinfo.rb
34
- test_files:
35
25
  - test/test-flacinfo.rb
36
26
  - test/test.flac
27
+ homepage: https://github.com/DarrenKirby/flacinfo-rb
28
+ licenses:
29
+ - GPL-3.0
30
+ metadata: {}
31
+ post_install_message:
37
32
  rdoc_options: []
38
-
39
- extra_rdoc_files:
40
- - README
41
- executables: []
42
-
43
- extensions: []
44
-
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
45
  requirements: []
46
-
47
- dependencies: []
48
-
46
+ rubyforge_project:
47
+ rubygems_version: 2.0.14
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Pure Ruby library for accessing metadata from Flac files
51
+ test_files:
52
+ - test/test-flacinfo.rb
53
+ - test/test.flac