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 +4 -4
- data/lib/pop_cap/audio_file.rb +13 -0
- data/lib/pop_cap/version.rb +1 -1
- data/spec/lib/pop_cap/analyze_file_spec.rb +1 -1
- data/spec/lib/pop_cap/audio_file_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19c8a2f61072567a49cd9cfb4dad74e9bb766741
|
4
|
+
data.tar.gz: e694ba3707d3d62326c089804c0eeea990bc531c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f06b264c3438911551fee0766ce57312a23d703e86e7b1673025d0ffcf73d8cc3d5dbefe26d7c5aa64a91fb064dbe825c17180ef2e8d8c9d4df4e3a81f5995b
|
7
|
+
data.tar.gz: 949a6fab5d0f834592a37e40f1cf4456fbe42fbf2bea3fe5376e8006ca161e881d3311225031402fd5cb066caa2cf56f9fa0eac2561a5cc798afe02a32c729ee
|
data/lib/pop_cap/audio_file.rb
CHANGED
@@ -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
|
data/lib/pop_cap/version.rb
CHANGED
@@ -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
|
+
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-
|
11
|
+
date: 2013-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reek
|