popcap 0.9.4 → 0.9.5

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
  SHA1:
3
- metadata.gz: fea0c001050c49c768666996a3335dfeea602e23
4
- data.tar.gz: 801e023c5a89d89175f937e1dc6a8c286755d5af
3
+ metadata.gz: 19c8a2f61072567a49cd9cfb4dad74e9bb766741
4
+ data.tar.gz: e694ba3707d3d62326c089804c0eeea990bc531c
5
5
  SHA512:
6
- metadata.gz: 8b139abe4a75f5e28465ee7e3fd2460f4771ef82ecc167ffe24de16581845aca690b1970f0d3dd89d55546a4d577dc50605333eac4d8fc7b7f8e9f6382ead4a5
7
- data.tar.gz: 06991cac3f333aca610873228efbcae2564b798a9af10770fa126615ba24ce80cd8856f32de8aeec7be8230ced270733582939662e7a844c24e11a4307b03119
6
+ metadata.gz: 2f06b264c3438911551fee0766ce57312a23d703e86e7b1673025d0ffcf73d8cc3d5dbefe26d7c5aa64a91fb064dbe825c17180ef2e8d8c9d4df4e3a81f5995b
7
+ data.tar.gz: 949a6fab5d0f834592a37e40f1cf4456fbe42fbf2bea3fe5376e8006ca161e881d3311225031402fd5cb066caa2cf56f9fa0eac2561a5cc798afe02a32c729ee
@@ -7,7 +7,10 @@ require 'pop_cap/tag_struct'
7
7
  require 'pop_cap/fileable'
8
8
 
9
9
  module PopCap
10
+ VALID_AUDIO_FORMATS = %q(.flac .m4a .mp3 .mp4 .ogg .wav .wma)
11
+
10
12
  FileNotFound = Class.new(StandardError)
13
+ InvalidAudioFormat = Class.new(StandardError)
11
14
  # Public: This is a class for managing audio files on the filesystem.
12
15
  # It is used to read & write metadata tags, convert between audio formats,
13
16
  # and manage a file on the filesystem using standard UNIX file commands.
@@ -30,6 +33,7 @@ module PopCap
30
33
  #
31
34
  def initialize(filepath)
32
35
  raise(FileNotFound, filepath) unless File.exists?(filepath)
36
+ raise(InvalidAudioFormat, filepath) unless valid_audio_format?(filepath)
33
37
  @filepath = File.realpath(filepath)
34
38
  end
35
39
 
@@ -171,5 +175,14 @@ module PopCap
171
175
  self.reload!
172
176
  self.tags
173
177
  end
178
+
179
+ private
180
+ def valid_audio_format?(filepath)
181
+ VALID_AUDIO_FORMATS.include?(file_format(filepath))
182
+ end
183
+
184
+ def file_format(filepath)
185
+ File.extname(filepath).downcase
186
+ end
174
187
  end
175
188
  end
@@ -1,3 +1,3 @@
1
1
  module PopCap
2
- VERSION = '0.9.4'
2
+ VERSION = '0.9.5'
3
3
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'pop_cap/ffmpeg/analyze_file'
2
+ require 'pop_cap/analyze_file'
3
3
  require 'fileutils'
4
4
 
5
5
  module PopCap
@@ -117,5 +117,18 @@ module PopCap
117
117
  expect(File.exists?('spec/fixtures/sample.mp3')).to be_true
118
118
  end
119
119
  end
120
+
121
+ context "errors" do
122
+ let(:bad_file_format) { "spec/fixtures/not_audio_file.jpg" }
123
+
124
+ before { FileUtils.touch bad_file_format }
125
+ after { FileUtils.rm_f bad_file_format }
126
+
127
+ it "raises an error if invalid audio format" do
128
+ expect do
129
+ AudioFile.new(bad_file_format)
130
+ end.to raise_error
131
+ end
132
+ end
120
133
  end
121
134
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popcap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Culley Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-12 00:00:00.000000000 Z
11
+ date: 2013-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reek