dragonfly_audio 0.0.2 → 0.0.3

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
2
  SHA1:
3
- metadata.gz: ea5b12c33329b64884570596ad8e06ffd530f830
4
- data.tar.gz: a13834b59b263db518b796b8b7765fac83201883
3
+ metadata.gz: d080095980104ba97c2ebe424891df08198092ff
4
+ data.tar.gz: 71a21130019f82955d4034d05b454eb3605b55e2
5
5
  SHA512:
6
- metadata.gz: 4febcf182f5c3874e6010d52c3a7ec686f30f33a51b1a1469e02a7133ece2ff6766e800755e37fb3f8136b259546353861dd695f056ba04753a802b1fdd9a688
7
- data.tar.gz: 3c79cf398b489981b612a87282b1554e5aa24897096d5db35aadd02ef8c93451b50ba1a925cbb556c8e03223c0e211faee0fec301827d8c427789c56680fbf48
6
+ metadata.gz: 150152ae15c6466071cb724b548827076d6af6c7b23b949feb35b80d1556973e1ba279a79079a62591218560d3cd04a8d094114a4eb4ed2b5c155e98e9f5d72c
7
+ data.tar.gz: 7821e3dbaa412fb908fdbbeafe25cfb6c11d6ef2de927a86b19045c5d69c1e81f1db46d3608258a9f0620ab3499b406d67ec1b52f9bc51f672282683ddae53f8
@@ -0,0 +1,5 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.0.3
4
+
5
+ * `AlbumArt` processor (courtesy of @asgerb)
@@ -1,19 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dragonfly_audio (0.0.2)
4
+ dragonfly_audio (0.0.3)
5
5
  dragonfly (~> 1.0)
6
6
  taglib-ruby
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.4.0)
11
+ addressable (2.5.1)
12
+ public_suffix (~> 2.0, >= 2.0.2)
12
13
  coderay (1.1.0)
13
- dragonfly (1.0.12)
14
+ dragonfly (1.1.3)
14
15
  addressable (~> 2.3)
15
16
  multi_json (~> 1.0)
16
- rack (>= 1.3.0)
17
+ rack (>= 1.3)
17
18
  ffi (1.9.10)
18
19
  formatador (0.2.5)
19
20
  guard (2.13.0)
@@ -44,7 +45,8 @@ GEM
44
45
  coderay (~> 1.1.0)
45
46
  method_source (~> 0.8.1)
46
47
  slop (~> 3.4)
47
- rack (2.0.1)
48
+ public_suffix (2.0.5)
49
+ rack (2.0.3)
48
50
  rake (10.4.2)
49
51
  rb-fsevent (0.9.6)
50
52
  rb-inotify (0.9.5)
@@ -66,4 +68,4 @@ DEPENDENCIES
66
68
  rake
67
69
 
68
70
  BUNDLED WITH
69
- 1.12.5
71
+ 1.14.6
data/README.md CHANGED
@@ -76,6 +76,16 @@ Permissible properties:
76
76
  * track
77
77
  * year
78
78
 
79
+ ### album_art
80
+
81
+ Sets the file's album art:
82
+
83
+ ```ruby
84
+ audio.album_art('path_to_file')
85
+ ```
86
+
87
+ Note thate this oly works for mp3 files.
88
+
79
89
  ## Contributing
80
90
 
81
91
  1. Fork it ( https://github.com/tomasc/dragonfly_audio/fork )
@@ -1,5 +1,6 @@
1
1
  require 'dragonfly_audio/analysers/audio_properties'
2
2
  require 'dragonfly_audio/processors/tag'
3
+ require 'dragonfly_audio/processors/album_art'
3
4
 
4
5
  module DragonflyAudio
5
6
  class Plugin
@@ -16,6 +17,7 @@ module DragonflyAudio
16
17
  end
17
18
 
18
19
  app.add_processor :tag, DragonflyAudio::Processors::Tag.new
20
+ app.add_processor :album_art, DragonflyAudio::Processors::AlbumArt.new
19
21
  end
20
22
  end
21
23
  end
@@ -0,0 +1,30 @@
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, properties)
10
+ return unless content.mime_type == 'audio/mpeg'
11
+ return unless album_art_file = properties
12
+
13
+ tempfile = content.temp_object
14
+
15
+ TagLib::MPEG::File.open(tempfile.path) do |file|
16
+ tag = file.id3v2_tag
17
+ album_art = TagLib::ID3v2::AttachedPictureFrame.new
18
+ album_art.mime_type = Rack::Mime.mime_type(File.extname(album_art_file))
19
+ album_art.description = "Cover"
20
+ album_art.type = TagLib::ID3v2::AttachedPictureFrame::FrontCover
21
+ album_art.picture = File.open(album_art_file, 'rb') { |f| f.read }
22
+ tag.add_frame(album_art)
23
+ file.save
24
+ end
25
+
26
+ content.update(tempfile)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module DragonflyAudio
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
Binary file
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ describe DragonflyAudio::Processors::AlbumArt do
4
+ let(:app) { test_app.configure_with(:audio) }
5
+ let(:processor) { DragonflyAudio::Processors::AlbumArt.new }
6
+ let(:audio) { Dragonfly::Content.new(app, SAMPLES_DIR.join('BroadmoorSirenTest.mp3')) }
7
+ let(:image) { Dragonfly::Content.new(app, SAMPLES_DIR.join('album.jpg')) }
8
+
9
+ let(:artist) { 'Elvis Presley' }
10
+ let(:title) { 'Hound Dawg' }
11
+
12
+ before { processor.call(audio, image.file.path) }
13
+
14
+ describe 'properties' do
15
+ it 'sets the album art' do
16
+ TagLib::MPEG::File.open(audio.file.path) do |file|
17
+ tag = file.id3v2_tag
18
+
19
+ cover = tag.frame_list('APIC').first
20
+ cover.picture.must_equal image.data
21
+ end
22
+ end
23
+ end
24
+ 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: 0.0.3
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: 2017-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dragonfly
@@ -119,6 +119,7 @@ extra_rdoc_files: []
119
119
  files:
120
120
  - ".gitignore"
121
121
  - ".travis.yml"
122
+ - CHANGELOG.md
122
123
  - Gemfile
123
124
  - Gemfile.lock
124
125
  - Guardfile
@@ -129,11 +130,14 @@ files:
129
130
  - lib/dragonfly_audio.rb
130
131
  - lib/dragonfly_audio/analysers/audio_properties.rb
131
132
  - lib/dragonfly_audio/plugin.rb
133
+ - lib/dragonfly_audio/processors/album_art.rb
132
134
  - lib/dragonfly_audio/processors/tag.rb
133
135
  - lib/dragonfly_audio/version.rb
134
136
  - samples/BroadmoorSirenTest.mp3
137
+ - samples/album.jpg
135
138
  - test/dragonfly_audio/analysers/audio_properties_test.rb
136
139
  - test/dragonfly_audio/plugin_test.rb
140
+ - test/dragonfly_audio/processors/album_art_test.rb
137
141
  - test/dragonfly_audio/processors/tag_test.rb
138
142
  - test/test_helper.rb
139
143
  homepage: https://github.com/tomasc/dragonfly_audio
@@ -156,12 +160,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
160
  version: '0'
157
161
  requirements: []
158
162
  rubyforge_project:
159
- rubygems_version: 2.4.5.1
163
+ rubygems_version: 2.5.2
160
164
  signing_key:
161
165
  specification_version: 4
162
166
  summary: Wraps common audio-related tasks into Dragonfly analysers and processors.
163
167
  test_files:
164
168
  - test/dragonfly_audio/analysers/audio_properties_test.rb
165
169
  - test/dragonfly_audio/plugin_test.rb
170
+ - test/dragonfly_audio/processors/album_art_test.rb
166
171
  - test/dragonfly_audio/processors/tag_test.rb
167
172
  - test/test_helper.rb