tubemp 0.5.0 → 0.6.0
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.
- data/lib/thumbnail.rb +6 -2
- data/lib/tubemp.rb +3 -1
- data/lib/youtube.rb +2 -2
- data/spec/thumbnail_spec.rb +19 -4
- data/spec/youtube_spec.rb +3 -1
- metadata +2 -2
data/lib/thumbnail.rb
CHANGED
@@ -31,9 +31,13 @@ class Thumbnail
|
|
31
31
|
self
|
32
32
|
end
|
33
33
|
|
34
|
-
def add_overlay
|
34
|
+
def add_overlay
|
35
|
+
@filename_parts << "overlay"
|
36
|
+
|
37
|
+
filename = File.join(Dir.pwd, "assets","overlay.png")
|
38
|
+
# Fallback to asset packaged with gem
|
39
|
+
filename = GEMDIR.join("assets", "overlay.png") unless File.exists? filename
|
35
40
|
@images << Magick::ImageList.new(filename)[0]
|
36
|
-
@filename_parts << File.basename(filename, ".*")
|
37
41
|
|
38
42
|
self
|
39
43
|
end
|
data/lib/tubemp.rb
CHANGED
@@ -7,8 +7,10 @@ require 'thumbnail.rb'
|
|
7
7
|
|
8
8
|
include ERB::Util
|
9
9
|
|
10
|
+
GEMDIR = Pathname.new(File.expand_path(File.join(File.dirname(__FILE__), '..')))
|
11
|
+
|
10
12
|
class Tubemp < Sinatra::Application
|
11
|
-
this_dir =
|
13
|
+
this_dir = GEMDIR.join("lib")
|
12
14
|
set :views, this_dir.join("views")
|
13
15
|
set :public_folder, this_dir.join("public")
|
14
16
|
|
data/lib/youtube.rb
CHANGED
@@ -30,7 +30,7 @@ class YouTube
|
|
30
30
|
|
31
31
|
def valid?
|
32
32
|
parse
|
33
|
-
not @meta.nil?
|
33
|
+
not @meta.title.nil?
|
34
34
|
end
|
35
35
|
|
36
36
|
def id
|
@@ -68,7 +68,7 @@ class YouTube
|
|
68
68
|
tmpfile.close
|
69
69
|
|
70
70
|
thumbs["basic"] = Thumbnail.new(id, tmpfile).write
|
71
|
-
thumbs["overlay"] = Thumbnail.new(id, tmpfile).add_overlay
|
71
|
+
thumbs["overlay"] = Thumbnail.new(id, tmpfile).add_overlay.write(@uri)
|
72
72
|
ensure
|
73
73
|
images = nil
|
74
74
|
tmpfile.unlink
|
data/spec/thumbnail_spec.rb
CHANGED
@@ -19,9 +19,9 @@ describe Thumbnail do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should include overlay filenames in filename' do
|
22
|
-
@thumbnail.add_overlay
|
22
|
+
@thumbnail.add_overlay
|
23
23
|
@thumbnail.write
|
24
|
-
File.should exist(File.join(@container, "#{@id}
|
24
|
+
File.should exist(File.join(@container, "#{@id}_overlay.png"))
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should be chainable' do
|
@@ -67,7 +67,7 @@ describe Thumbnail do
|
|
67
67
|
before do
|
68
68
|
@overlay_name = File.join("assets", "overlay.png")
|
69
69
|
@expected = Magick::ImageList.new(@overlay_name)[0]
|
70
|
-
@thumbnail.add_overlay
|
70
|
+
@thumbnail.add_overlay
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should add files to ImageList stack' do
|
@@ -80,8 +80,23 @@ describe Thumbnail do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should be chainable' do
|
83
|
-
@thumbnail.add_overlay
|
83
|
+
@thumbnail.add_overlay.should be_kind_of(Thumbnail)
|
84
84
|
end
|
85
|
+
|
86
|
+
it 'should prefer an overlay-image from current dir' do
|
87
|
+
assets_dir = File.join("/", "tmp", "assets")
|
88
|
+
FileUtils.mkdir_p(assets_dir)
|
89
|
+
FileUtils.cp(File.join("assets", "overlay.png"), File.join(assets_dir, "overlay.png"))
|
90
|
+
Dir.stub(:pwd).and_return("/tmp")
|
91
|
+
|
92
|
+
@thumbnail.add_overlay
|
93
|
+
# Don't know how to fetch the current_filename or Filename from Magick::Image
|
94
|
+
# so using #inspect and regexing that.
|
95
|
+
@thumbnail.images.last.inspect.should match %r{/tmp/assets/overlay\.png .*}
|
96
|
+
|
97
|
+
FileUtils.rm_r(assets_dir)
|
98
|
+
end
|
99
|
+
|
85
100
|
end
|
86
101
|
|
87
102
|
describe "uri_path" do
|
data/spec/youtube_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tubemp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|