wahwah 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e742f50b1a22c7cbbe63ba26506803720bbc44dbfe9943ac07a32e7efe048cbe
4
- data.tar.gz: 47e1352b98217e34eb3e3fb3c258695a8f7cf2a4d579ce6baaeda1216703f4e8
3
+ metadata.gz: 7e3b8992dca29fbbe7a537a7d2ad23ca0fe33e9596dfbabb5131e615461d22b1
4
+ data.tar.gz: 58809228e4e9b7f2e40c48136f68cdd2f29939b8628e6690efd75e95cf7c0e88
5
5
  SHA512:
6
- metadata.gz: f5450f35d5478a3a434ac0e366589edb3999b40eb1f321e53086ccd1d3d20c5542ce63ac9d8d7b380379cafd719bbc97c33d2768d585c9a2b1d71218950f1b36
7
- data.tar.gz: 86a134f7ac39a2430fcc2a62756a23354aa42825bf1a97ad4b7ba6b71f42bb72c20f3dda4a884db06e77faa84517c7fe5f4004e317939bd36d4c60369067c93e
6
+ metadata.gz: 501f86ff6b621bfb302b7503e05ef45a472c8faa8c128fc8cb15cf92cb35deca4e828d416bfb0e3bc750f63fb2b299cccabee9d9718729372225edb3e4618f9f
7
+ data.tar.gz: f1d7c0a92c982180f7041883137b6909c11a761d2da17564aaa4a758297d56db197ae1a1698d3028b8397864ab0673c1f7300acb4bcd6fcfda3d82a6dce1832e
@@ -12,15 +12,28 @@ module WahWah
12
12
  @file_io = file_io
13
13
  super(*arg)
14
14
  @position = @file_io.pos
15
+ @data = get_data if @file_io.is_a?(StringIO)
15
16
  end
16
17
 
17
18
  def data
18
- @file_io.seek(@position)
19
- @file_io.read(size)
19
+ if @file_io.closed? && @file_io.is_a?(File)
20
+ @file_io = File.open(@file_io.path)
21
+ @data = get_data
22
+ @file_io.close
23
+ end
24
+
25
+ @data ||= get_data
20
26
  end
21
27
 
22
28
  def skip
29
+ @file_io.seek(@position)
23
30
  @file_io.seek(size, IO::SEEK_CUR)
24
31
  end
32
+
33
+ private
34
+ def get_data
35
+ @file_io.seek(@position)
36
+ @file_io.read(size)
37
+ end
25
38
  end
26
39
  end
@@ -38,7 +38,7 @@ module WahWah
38
38
  end
39
39
 
40
40
  def is_vbr?
41
- xing_header.valid? || vbri_header.valid?
41
+ mpeg_frame_header.valid? && (xing_header.valid? || vbri_header.valid?)
42
42
  end
43
43
 
44
44
  private
@@ -48,8 +48,8 @@ module WahWah
48
48
  end
49
49
 
50
50
  def parse_id3_tag
51
- id3_v1_tag = ID3::V1.new(@file_io)
52
- id3_v2_tag = ID3::V2.new(@file_io)
51
+ id3_v1_tag = ID3::V1.new(@file_io.dup)
52
+ id3_v2_tag = ID3::V2.new(@file_io.dup)
53
53
 
54
54
  return id3_v2_tag if id3_v2_tag.valid?
55
55
  id3_v1_tag if id3_v1_tag.valid?
@@ -90,7 +90,7 @@ module WahWah
90
90
  atom = self.class.new(atoms_data_io)
91
91
  children_atoms.push(atom)
92
92
 
93
- atoms_data_io.seek(atom.size, IO::SEEK_CUR)
93
+ atom.skip
94
94
  end
95
95
 
96
96
  children_atoms
@@ -16,18 +16,6 @@ module WahWah
16
16
  :composer,
17
17
  :sample_rate
18
18
 
19
- def duration
20
- @duration ||= parse_duration
21
- end
22
-
23
- def bitrate
24
- @bitrate ||= parse_bitrate
25
- end
26
-
27
- def bit_depth
28
- @bit_depth ||= parse_bit_depth
29
- end
30
-
31
19
  private
32
20
  def packets
33
21
  @packets ||= Ogg::Packets.new(@file_io)
@@ -51,6 +39,10 @@ module WahWah
51
39
  when identification_packet.start_with?("\x7FFLAC")
52
40
  Ogg::FlacTag.new(identification_packet, comment_packet)
53
41
  end
42
+
43
+ @duration = parse_duration
44
+ @bitrate = parse_bitrate
45
+ @bit_depth = parse_bit_depth
54
46
  end
55
47
 
56
48
  def parse_duration
@@ -43,6 +43,8 @@ module WahWah
43
43
  value = instance_variable_get("@#{attr_name}")&.to_i
44
44
  instance_variable_set("@#{attr_name}", value)
45
45
  end
46
+ ensure
47
+ @file_io.close
46
48
  end
47
49
 
48
50
  def inspect
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WahWah
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wahwah
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - aidewoode
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-11 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler