dragonfly_audio 0.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ea5b12c33329b64884570596ad8e06ffd530f830
4
- data.tar.gz: a13834b59b263db518b796b8b7765fac83201883
2
+ SHA256:
3
+ metadata.gz: 1eb56e753d688f9144b32a2d2d217a6c7bed3f434da06686ee5ed85d183903bc
4
+ data.tar.gz: 0323dccb3b593be0f3762d1113bbf9f882f87afa0f5f323b84b3f329a03b3f21
5
5
  SHA512:
6
- metadata.gz: 4febcf182f5c3874e6010d52c3a7ec686f30f33a51b1a1469e02a7133ece2ff6766e800755e37fb3f8136b259546353861dd695f056ba04753a802b1fdd9a688
7
- data.tar.gz: 3c79cf398b489981b612a87282b1554e5aa24897096d5db35aadd02ef8c93451b50ba1a925cbb556c8e03223c0e211faee0fec301827d8c427789c56680fbf48
6
+ metadata.gz: ba48651964dce80fe6e5b868e5595b12c02507ddef4875fff176e6691d1425241d097a4ccfebc4c8c3de5e90416a5c4bb98a5a71978072af43704bc0c86e0a9a
7
+ data.tar.gz: d8a55c4ecff008ed0c1f61cb0e43aba71fceaaa8eead90b0bb2d0542fe5adeec821da9d5b194ae198f2fc87d38bbfd9dead95672f2a84ae17e21e54939ef0c14
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # CHANGELOG
2
+
3
+ ## 1.1.0
4
+
5
+ - support `taglib-ruby` `1.0` – [@asgerb](https://github.com/asgerb).
6
+ - added `length_in_seconds` and `length_in_milliseconds` to `AudioProperties` – [@asgerb](https://github.com/asgerb).
7
+
8
+ ## 1.0.3
9
+
10
+ - locked `taglib-ruby` to `~> 0.7.1` – [@asgerb](https://github.com/asgerb).
11
+
12
+ ## 1.0.2
13
+
14
+ - improved `SUPPORTED_FORMATS` matching that ignores case
15
+
16
+ ## 1.0.0
17
+
18
+ - add `SUPPORTED_FORMATS` and and raise errors when not matching
19
+ - add more thorough tests for supported formats
20
+
21
+ ## 0.0.3
22
+
23
+ - `AlbumArt` processor (courtesy of @asgerb)
data/README.md CHANGED
@@ -32,6 +32,14 @@ Dragonfly.app.configure do
32
32
  end
33
33
  ```
34
34
 
35
+ ## Supported Formats
36
+
37
+ List of supported formats is available as:
38
+
39
+ ```ruby
40
+ DragonflyAudio::SUPPORTED_FORMATS # => ["aif", "aiff", …]
41
+ ```
42
+
35
43
  ## Analysers
36
44
 
37
45
  ### audio_properties
@@ -50,6 +58,8 @@ audio.audio_properties
50
58
  # genre: 'Ambient',
51
59
  # comment: 'This Music was originally composed for "The Memory Theatre of Gulio Camillo" by Matthew Maguire. A Creation production premiered at La Mama Spring 1985 thanks to Bonnie for not laughing to Justin for laughing to Jon Gordron for electronic bondage produced by Jonathan Mann for Pangea Productions recorded 8/85 at Chiens Interdits Studio in a big cover production by Ann Rower cover design by Paul Leone * all compositions by Vito Ricci * play it loud',
52
60
  # length: 345,
61
+ # length_in_seconds: 345,
62
+ # length_in_milliseconds: 345000,
53
63
  # bitrate: 192,
54
64
  # channels: 2,
55
65
  # sample_rate: 44_100
@@ -76,6 +86,16 @@ Permissible properties:
76
86
  * track
77
87
  * year
78
88
 
89
+ ### album_art
90
+
91
+ Sets the file's album art:
92
+
93
+ ```ruby
94
+ audio.album_art('path_to_file')
95
+ ```
96
+
97
+ Note that this only works for mp3 files.
98
+
79
99
  ## Contributing
80
100
 
81
101
  1. Fork it ( https://github.com/tomasc/dragonfly_audio/fork )
@@ -2,6 +2,8 @@ require 'dragonfly'
2
2
  require 'dragonfly_audio/plugin'
3
3
  require 'dragonfly_audio/version'
4
4
 
5
- Dragonfly.app.configure do
6
- plugin :audio
5
+ module DragonflyAudio
6
+ class UnsupportedFormat < RuntimeError; end
7
+
8
+ SUPPORTED_FORMATS = %w[aif aiff fla flac m4a mp4 mp4a mp4s mp3 mpga oga ogg ogx wav].freeze
7
9
  end
@@ -5,29 +5,23 @@ require 'taglib'
5
5
  module DragonflyAudio
6
6
  module Analysers
7
7
  class AudioProperties
8
- TAGS = %i(title artist album year track genre comment).freeze
9
- AUDIO_PROPS = %i(length bitrate channels sample_rate).freeze
8
+ TAGS = %w[title artist album year track genre comment].freeze
9
+ AUDIO_PROPS = %w[length_in_seconds length_in_milliseconds bitrate channels sample_rate].freeze
10
10
 
11
11
  def call(content)
12
- taglib_fileref(content)
13
- end
14
-
15
- private # =============================================================
12
+ return {} unless content.ext
13
+ return {} unless SUPPORTED_FORMATS.include?(content.ext.downcase)
16
14
 
17
- def taglib_fileref(content)
18
15
  res = {}
19
- TagLib::FileRef.open(content.path) do |fileref|
20
- unless fileref.null?
21
16
 
22
- TAGS.each do |tag_name|
23
- res[tag_name] = fileref.tag.send(tag_name)
24
- end
25
-
26
- AUDIO_PROPS.each do |prop_name|
27
- res[prop_name] = fileref.audio_properties.send(prop_name)
28
- end
29
- end
17
+ TagLib::FileRef.open(content.path) do |fileref|
18
+ return if fileref.null?
19
+ TAGS.each { |n| res[n] = fileref.tag.send(n) }
20
+ AUDIO_PROPS.each { |n| res[n] = fileref.audio_properties.send(n) }
30
21
  end
22
+
23
+ res["length"] = res["length_in_seconds"]
24
+
31
25
  res
32
26
  end
33
27
  end
@@ -1,21 +1,23 @@
1
1
  require 'dragonfly_audio/analysers/audio_properties'
2
+
2
3
  require 'dragonfly_audio/processors/tag'
4
+ require 'dragonfly_audio/processors/album_art'
3
5
 
4
6
  module DragonflyAudio
5
7
  class Plugin
6
- def call(app, _opts = {})
7
- app.add_analyser :audio_properties, DragonflyAudio::Analysers::AudioProperties.new
8
+ def call(app, options = {})
9
+ app.add_analyser :audio_properties, Analysers::AudioProperties.new
10
+
11
+ Analysers::AudioProperties::TAGS.each do |name|
12
+ app.add_analyser(name) { |c| c.analyse(:audio_properties)[name] }
13
+ end
8
14
 
9
- [
10
- DragonflyAudio::Analysers::AudioProperties::TAGS,
11
- DragonflyAudio::Analysers::AudioProperties::AUDIO_PROPS
12
- ].flatten.each do |analyser|
13
- app.add_analyser analyser do |content|
14
- content.analyse(:audio_properties)[analyser]
15
- end
15
+ Analysers::AudioProperties::AUDIO_PROPS.each do |name|
16
+ app.add_analyser(name) { |c| c.analyse(:audio_properties)[name] }
16
17
  end
17
18
 
18
- app.add_processor :tag, DragonflyAudio::Processors::Tag.new
19
+ app.add_processor :tag, Processors::Tag.new
20
+ app.add_processor :album_art, Processors::AlbumArt.new
19
21
  end
20
22
  end
21
23
  end
@@ -0,0 +1,31 @@
1
+ require 'taglib'
2
+ require 'rack'
3
+
4
+ # IMPORTANT: See http://robinst.github.io/taglib-ruby/
5
+
6
+ module DragonflyAudio
7
+ module Processors
8
+ class AlbumArt
9
+ def call(content, album_art_file)
10
+ raise UnsupportedFormat unless content.ext
11
+ raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext.downcase)
12
+ # raise UnsupportedFormat unless content.mime_type == 'audio/mpeg'
13
+
14
+ tempfile = content.temp_object
15
+
16
+ TagLib::MPEG::File.open(tempfile.path) do |file|
17
+ tag = file.id3v2_tag
18
+ album_art = TagLib::ID3v2::AttachedPictureFrame.new
19
+ album_art.mime_type = Rack::Mime.mime_type(File.extname(album_art_file))
20
+ album_art.description = "Cover"
21
+ album_art.type = TagLib::ID3v2::AttachedPictureFrame::FrontCover
22
+ album_art.picture = File.open(album_art_file, 'rb') { |f| f.read }
23
+ tag.add_frame(album_art)
24
+ file.save
25
+ end
26
+
27
+ content.update(tempfile)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -5,21 +5,22 @@ require 'taglib'
5
5
  module DragonflyAudio
6
6
  module Processors
7
7
  class Tag
8
- PERMISSIBLE_PROPERTIES = DragonflyAudio::Analysers::AudioProperties::TAGS
8
+ PERMISSIBLE_PROPERTIES = Analysers::AudioProperties::TAGS
9
9
 
10
10
  def call(content, properties)
11
- clean_properties = properties.delete_if { |key, _| !PERMISSIBLE_PROPERTIES.include?(key) }
11
+ raise UnsupportedFormat unless content.ext
12
+ raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext.downcase)
13
+
14
+ # stringify keys
15
+ properties = properties.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v }
16
+ properties = properties.select { |key, _| PERMISSIBLE_PROPERTIES.include?(key) }
12
17
 
13
18
  tempfile = Dragonfly::TempObject.new(content.tempfile)
14
19
 
15
20
  TagLib::FileRef.open(tempfile.path) do |file|
16
- unless file.null?
17
- tag = file.tag
18
- clean_properties.each do |key, value|
19
- tag.send("#{key}=", value)
20
- end
21
- file.save
22
- end
21
+ return if file.null?
22
+ properties.each { |k, v| file.tag.send("#{k}=", v) }
23
+ file.save
23
24
  end
24
25
 
25
26
  content.update(tempfile)
@@ -1,3 +1,3 @@
1
1
  module DragonflyAudio
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly_audio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-14 00:00:00.000000000 Z
12
+ date: 2021-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dragonfly
@@ -29,32 +29,46 @@ dependencies:
29
29
  name: taglib-ruby
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '1.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: '1.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.6'
48
+ version: '2.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '1.6'
55
+ version: '2.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.4'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '10.4'
70
+ - !ruby/object:Gem::Dependency
71
+ name: guard
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
74
  - - ">="
@@ -68,7 +82,7 @@ dependencies:
68
82
  - !ruby/object:Gem::Version
69
83
  version: '0'
70
84
  - !ruby/object:Gem::Dependency
71
- name: guard
85
+ name: guard-minitest
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
88
  - - ">="
@@ -82,7 +96,7 @@ dependencies:
82
96
  - !ruby/object:Gem::Version
83
97
  version: '0'
84
98
  - !ruby/object:Gem::Dependency
85
- name: guard-minitest
99
+ name: minitest
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - ">="
@@ -96,7 +110,7 @@ dependencies:
96
110
  - !ruby/object:Gem::Version
97
111
  version: '0'
98
112
  - !ruby/object:Gem::Dependency
99
- name: minitest
113
+ name: minitest-reporters
100
114
  requirement: !ruby/object:Gem::Requirement
101
115
  requirements:
102
116
  - - ">="
@@ -117,25 +131,14 @@ executables: []
117
131
  extensions: []
118
132
  extra_rdoc_files: []
119
133
  files:
120
- - ".gitignore"
121
- - ".travis.yml"
122
- - Gemfile
123
- - Gemfile.lock
124
- - Guardfile
125
- - LICENSE.txt
134
+ - CHANGELOG.md
126
135
  - README.md
127
- - Rakefile
128
- - dragonfly_audio.gemspec
129
136
  - lib/dragonfly_audio.rb
130
137
  - lib/dragonfly_audio/analysers/audio_properties.rb
131
138
  - lib/dragonfly_audio/plugin.rb
139
+ - lib/dragonfly_audio/processors/album_art.rb
132
140
  - lib/dragonfly_audio/processors/tag.rb
133
141
  - lib/dragonfly_audio/version.rb
134
- - samples/BroadmoorSirenTest.mp3
135
- - test/dragonfly_audio/analysers/audio_properties_test.rb
136
- - test/dragonfly_audio/plugin_test.rb
137
- - test/dragonfly_audio/processors/tag_test.rb
138
- - test/test_helper.rb
139
142
  homepage: https://github.com/tomasc/dragonfly_audio
140
143
  licenses:
141
144
  - MIT
@@ -155,13 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
158
  - !ruby/object:Gem::Version
156
159
  version: '0'
157
160
  requirements: []
158
- rubyforge_project:
159
- rubygems_version: 2.4.5.1
161
+ rubygems_version: 3.1.2
160
162
  signing_key:
161
163
  specification_version: 4
162
164
  summary: Wraps common audio-related tasks into Dragonfly analysers and processors.
163
- test_files:
164
- - test/dragonfly_audio/analysers/audio_properties_test.rb
165
- - test/dragonfly_audio/plugin_test.rb
166
- - test/dragonfly_audio/processors/tag_test.rb
167
- - test/test_helper.rb
165
+ test_files: []
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- .DS_Store
2
- pkg
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- script: 'bundle exec rake'
4
- rvm:
5
- - 2.2.5
6
- before_install:
7
- - sudo apt-get update
8
- - sudo apt-get install -y libtag1-dev
9
-
10
- notifications:
11
- email:
12
- recipients:
13
- - tomas.celizna@gmail.com
14
- on_failure: change
15
- on_success: never
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in dragonfly_audio.gemspec
4
- gemspec
data/Gemfile.lock DELETED
@@ -1,69 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- dragonfly_audio (0.0.2)
5
- dragonfly (~> 1.0)
6
- taglib-ruby
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.4.0)
12
- coderay (1.1.0)
13
- dragonfly (1.0.12)
14
- addressable (~> 2.3)
15
- multi_json (~> 1.0)
16
- rack (>= 1.3.0)
17
- ffi (1.9.10)
18
- formatador (0.2.5)
19
- guard (2.13.0)
20
- formatador (>= 0.2.4)
21
- listen (>= 2.7, <= 4.0)
22
- lumberjack (~> 1.0)
23
- nenv (~> 0.1)
24
- notiffany (~> 0.0)
25
- pry (>= 0.9.12)
26
- shellany (~> 0.0)
27
- thor (>= 0.18.1)
28
- guard-compat (1.2.1)
29
- guard-minitest (2.4.4)
30
- guard-compat (~> 1.2)
31
- minitest (>= 3.0)
32
- listen (3.0.3)
33
- rb-fsevent (>= 0.9.3)
34
- rb-inotify (>= 0.9)
35
- lumberjack (1.0.9)
36
- method_source (0.8.2)
37
- minitest (5.8.1)
38
- multi_json (1.12.1)
39
- nenv (0.2.0)
40
- notiffany (0.0.8)
41
- nenv (~> 0.1)
42
- shellany (~> 0.0)
43
- pry (0.10.2)
44
- coderay (~> 1.1.0)
45
- method_source (~> 0.8.1)
46
- slop (~> 3.4)
47
- rack (2.0.1)
48
- rake (10.4.2)
49
- rb-fsevent (0.9.6)
50
- rb-inotify (0.9.5)
51
- ffi (>= 0.5.0)
52
- shellany (0.0.1)
53
- slop (3.6.0)
54
- taglib-ruby (0.7.1)
55
- thor (0.19.1)
56
-
57
- PLATFORMS
58
- ruby
59
-
60
- DEPENDENCIES
61
- bundler (~> 1.6)
62
- dragonfly_audio!
63
- guard
64
- guard-minitest
65
- minitest
66
- rake
67
-
68
- BUNDLED WITH
69
- 1.12.5
data/Guardfile DELETED
@@ -1,8 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard :minitest do
5
- watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
6
- watch(%r{^test/.+_test\.rb$})
7
- watch(%r{^test/test_helper\.rb$}) { 'test' }
8
- end
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 Tomas Celizna
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,9 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new do |t|
5
- t.libs << 'test'
6
- t.pattern = 'test/**/*_test.rb'
7
- end
8
-
9
- task :default => :test
@@ -1,28 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'dragonfly_audio/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'dragonfly_audio'
8
- spec.version = DragonflyAudio::VERSION
9
- spec.authors = ['Tomas Celizna', 'Asger Behncke Jacobsen']
10
- spec.email = ['tomas.celizna@gmail.com', 'asger@8kilo.com']
11
- spec.summary = 'Wraps common audio-related tasks into Dragonfly analysers and processors.'
12
- spec.homepage = 'https://github.com/tomasc/dragonfly_audio'
13
- spec.license = 'MIT'
14
-
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ['lib']
19
-
20
- spec.add_dependency 'dragonfly', '~> 1.0'
21
- spec.add_dependency 'taglib-ruby'
22
-
23
- spec.add_development_dependency 'bundler', '~> 1.6'
24
- spec.add_development_dependency 'rake'
25
- spec.add_development_dependency 'guard'
26
- spec.add_development_dependency 'guard-minitest'
27
- spec.add_development_dependency 'minitest'
28
- end
Binary file
@@ -1,50 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyAudio::Analysers::AudioProperties do
4
- let(:app) { test_app.configure_with(:audio) }
5
- let(:audio) { app.fetch_file(SAMPLES_DIR.join('BroadmoorSirenTest.mp3')) }
6
-
7
- it 'analyses "album" property' do
8
- audio.audio_properties[:album].must_equal 'Album XYZ'
9
- end
10
-
11
- it 'analyses "artist" property' do
12
- audio.audio_properties[:artist].must_equal 'Artist'
13
- end
14
-
15
- it 'analyses "bitrate" property' do
16
- audio.audio_properties[:bitrate].must_equal 192
17
- end
18
-
19
- it 'analyses "channels" property' do
20
- audio.audio_properties[:channels].must_equal 2
21
- end
22
-
23
- it 'analyses "comment" property' do
24
- audio.audio_properties[:comment].must_equal ' Comment '
25
- end
26
-
27
- it 'analyses "genre" property' do
28
- audio.audio_properties[:genre].must_equal 'Dance'
29
- end
30
-
31
- it 'analyses "length" property' do
32
- audio.audio_properties[:length].must_equal 156
33
- end
34
-
35
- it 'analyses "sample_rate" property' do
36
- audio.audio_properties[:sample_rate].must_equal 44_100
37
- end
38
-
39
- it 'analyses "title" property' do
40
- audio.audio_properties[:title].must_equal 'SongTitle'
41
- end
42
-
43
- it 'analyses "track" property' do
44
- audio.audio_properties[:track].must_equal 0
45
- end
46
-
47
- it 'analyses "year" property' do
48
- audio.audio_properties[:year].must_equal 0
49
- end
50
- end
@@ -1,29 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyAudio
4
- describe Plugin do
5
- let(:app) { test_app.configure_with(:audio) }
6
- let(:audio) { app.fetch_file(SAMPLES_DIR.join('BroadmoorSirenTest.mp3')) }
7
-
8
- describe 'analysers' do
9
- it 'adds #audio_properties' do
10
- audio.must_respond_to :audio_properties
11
- end
12
-
13
- [
14
- DragonflyAudio::Analysers::AudioProperties::TAGS,
15
- DragonflyAudio::Analysers::AudioProperties::AUDIO_PROPS
16
- ].flatten.each do |analyser|
17
- it "adds ##{analyser}" do
18
- audio.must_respond_to analyser
19
- end
20
- end
21
- end
22
-
23
- describe 'processors' do
24
- it 'adds #tag' do
25
- audio.must_respond_to :tag
26
- end
27
- end
28
- end
29
- end
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyAudio::Processors::Tag do
4
- let(:app) { test_app.configure_with(:audio) }
5
- let(:processor) { DragonflyAudio::Processors::Tag.new }
6
- let(:analyser) { DragonflyAudio::Analysers::AudioProperties.new }
7
- let(:audio) { Dragonfly::Content.new(app, SAMPLES_DIR.join('BroadmoorSirenTest.mp3')) }
8
-
9
- let(:artist) { 'Elvis Presley' }
10
- let(:title) { 'Hound Dawg' }
11
-
12
- before { processor.call(audio, artist: artist, title: title) }
13
-
14
- describe 'properties' do
15
- it 'sets the artist tag property' do
16
- analyser.call(audio)[:artist].must_equal artist
17
- end
18
-
19
- it 'sets the title tag property' do
20
- analyser.call(audio)[:title].must_equal title
21
- end
22
- end
23
- end
data/test/test_helper.rb DELETED
@@ -1,17 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- require 'minitest'
4
- require 'minitest/autorun'
5
- require 'minitest/spec'
6
-
7
- require 'dragonfly'
8
- require 'dragonfly_audio'
9
-
10
- SAMPLES_DIR = Pathname.new(File.expand_path('../../samples', __FILE__))
11
-
12
- def test_app(name = nil)
13
- app = Dragonfly::App.instance(name)
14
- app.datastore = Dragonfly::MemoryDataStore.new
15
- app.secret = 'test secret'
16
- app
17
- end