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 +5 -5
- data/CHANGELOG.md +23 -0
- data/README.md +20 -0
- data/lib/dragonfly_audio.rb +4 -2
- data/lib/dragonfly_audio/analysers/audio_properties.rb +11 -17
- data/lib/dragonfly_audio/plugin.rb +12 -10
- data/lib/dragonfly_audio/processors/album_art.rb +31 -0
- data/lib/dragonfly_audio/processors/tag.rb +10 -9
- data/lib/dragonfly_audio/version.rb +1 -1
- metadata +29 -31
- data/.gitignore +0 -2
- data/.travis.yml +0 -15
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -69
- data/Guardfile +0 -8
- data/LICENSE.txt +0 -22
- data/Rakefile +0 -9
- data/dragonfly_audio.gemspec +0 -28
- data/samples/BroadmoorSirenTest.mp3 +0 -0
- data/test/dragonfly_audio/analysers/audio_properties_test.rb +0 -50
- data/test/dragonfly_audio/plugin_test.rb +0 -29
- data/test/dragonfly_audio/processors/tag_test.rb +0 -23
- data/test/test_helper.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1eb56e753d688f9144b32a2d2d217a6c7bed3f434da06686ee5ed85d183903bc
|
4
|
+
data.tar.gz: 0323dccb3b593be0f3762d1113bbf9f882f87afa0f5f323b84b3f329a03b3f21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 )
|
data/lib/dragonfly_audio.rb
CHANGED
@@ -2,6 +2,8 @@ require 'dragonfly'
|
|
2
2
|
require 'dragonfly_audio/plugin'
|
3
3
|
require 'dragonfly_audio/version'
|
4
4
|
|
5
|
-
|
6
|
-
|
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 = %
|
9
|
-
AUDIO_PROPS = %
|
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
|
-
|
13
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
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,
|
7
|
-
app.add_analyser :audio_properties,
|
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
|
-
|
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,
|
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 =
|
8
|
+
PERMISSIBLE_PROPERTIES = Analysers::AudioProperties::TAGS
|
9
9
|
|
10
10
|
def call(content, properties)
|
11
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
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)
|
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:
|
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:
|
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: '
|
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: '
|
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:
|
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
|
-
-
|
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
|
-
|
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
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
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
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
data/dragonfly_audio.gemspec
DELETED
@@ -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
|