rdvd-slideshow 0.0.1

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/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2009-02-11
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,14 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/rdvd-slideshow.rb
6
+ lib/rdvd-slideshow/slideshow.rb
7
+ lib/rdvd-slideshow/slideshow_task.rb
8
+ lib/rdvd-slideshow/slideshow_input.rb
9
+ test/helper.rb
10
+ test/test.jpg
11
+ test/test_slideshow.rb
12
+ test/test_slideshow_task.rb
13
+ test/test_slideshow_input.rb
14
+ test/outputs/
data/README.txt ADDED
@@ -0,0 +1,56 @@
1
+ = rdvd-slideshow
2
+
3
+ * http://rdvd-slideshow.rubyforge.org/
4
+
5
+ == DESCRIPTION:
6
+
7
+ A ruby interface for dvd-slideshow utility (http://dvd-slideshow.sourceforge.net)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ == SYNOPSIS:
12
+
13
+ Sample script to build basic slideshow:
14
+
15
+ slideshow = RDvdSlideshow::Slideshow.build do |show|
16
+ show.output_dir = "/tmp"
17
+ show.write_input do |input|
18
+ input.title "My slideshow", "2.0"
19
+ input.image "/tmp/picture1.jpg", "0.5"
20
+ input.image "/tmp/picture2.jpg", "0.5"
21
+ input.exit
22
+ end
23
+ end
24
+
25
+ == REQUIREMENTS:
26
+
27
+ * RProgram >= 0.1.3
28
+
29
+ == INSTALL:
30
+
31
+ $ sudo gem install rdvd-slideshow
32
+
33
+ == LICENSE:
34
+
35
+ (The MIT License)
36
+
37
+ Copyright (c) 2009 FIX
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining
40
+ a copy of this software and associated documentation files (the
41
+ 'Software'), to deal in the Software without restriction, including
42
+ without limitation the rights to use, copy, modify, merge, publish,
43
+ distribute, sublicense, and/or sell copies of the Software, and to
44
+ permit persons to whom the Software is furnished to do so, subject to
45
+ the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/lib')
4
+
5
+ require 'rubygems'
6
+ require 'hoe'
7
+ require './lib/rdvd-slideshow.rb'
8
+
9
+ Hoe.new('rdvd-slideshow', RDvdSlideshow::VERSION) do |p|
10
+ p.rubyforge_name = 'rdvd-slideshow'
11
+ p.developer('sdabet', 'sebastiendabet@gmail.com')
12
+ p.remote_rdoc_dir = ''
13
+ p.extra_deps = [['rprogram', '>=0.1.3']]
14
+ end
15
+
16
+ # vim: syntax=Ruby
@@ -0,0 +1,5 @@
1
+ require 'rdvd-slideshow/slideshow'
2
+
3
+ module RDvdSlideshow
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,39 @@
1
+ require 'rdvd-slideshow/slideshow_task'
2
+ require 'rprogram/program'
3
+
4
+ module RDvdSlideshow
5
+
6
+ class Slideshow < RProgram::Program
7
+ name_program "dvd-slideshow"
8
+
9
+ def initialize(path)
10
+ super(path)
11
+ end
12
+
13
+ #
14
+ # Launches the building of the slideshow.
15
+ # Options and/or block can be passed to configure the slideshow.
16
+ # Example:
17
+ # Slideshow.build(:output_dir=>"output",:input_file=>"input.txt")
18
+ #
19
+ # or with a block:
20
+ # Slideshow.build do |show|
21
+ # show.output_dir = "output"
22
+ # show.write_input do |input|
23
+ # input.image "toto.jpg", "0.5"
24
+ # end
25
+ # end
26
+ #
27
+ def self.build(options={},&block)
28
+ self.find.build(options,&block)
29
+ end
30
+
31
+ #
32
+ # Instance method for building slideshow
33
+ #
34
+ def build(options={},&block)
35
+ run_task(SlideshowTask.new(options,&block))
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,103 @@
1
+ require 'tempfile'
2
+
3
+ module RDvdSlideshow
4
+
5
+ #
6
+ # A SlideshowInput is responsible for building the input file used by dvd-slideshow.
7
+ #
8
+ class SlideshowInput
9
+
10
+ #
11
+ # Initializes the file path and write the content of the file.
12
+ # If no file path is given, a temp file is used (Tempfile).
13
+ # The provided block is used to build the content of the file.
14
+ # The file is flushed after writing.
15
+ #
16
+ def initialize(file_path=nil,&block)
17
+ @file = file_path ? File.new(file_path,'w') : Tempfile.new('slideshow_input')
18
+
19
+ block.call(self) if block
20
+ @file.flush
21
+ end
22
+
23
+ # Path to the path where slideshow input configuration is written
24
+ def file_path
25
+ @file.path
26
+ end
27
+
28
+ #
29
+ # Adds a new image
30
+ #
31
+ def image(path,duration,options={})
32
+ write_line(path,duration,options,[:subtitle,:effect,:effect_params])
33
+ end
34
+
35
+ #
36
+ # Adds a title
37
+ #
38
+ def title(duration,text)
39
+ write_line("title",duration,{:text=>text},[:text])
40
+ end
41
+
42
+ #
43
+ # Adds a title bar
44
+ # Possible options are : _upper\_title_ and _lower\_title_
45
+ #
46
+ def titlebar(duration,options={})
47
+ write_line("titlebar",duration,options,[:upper_title,:lower_title])
48
+ end
49
+
50
+ #
51
+ # Adds a music
52
+ # Possible options are : _subtitle_
53
+ #
54
+ def musictitle(duration,options={})
55
+ write_line("musictitle",duration,options,[:subtitle])
56
+ end
57
+
58
+ def fadein(duration,options={})
59
+ write_line("fadein",duration,options,[:subtitle])
60
+ end
61
+
62
+ def fadeout(duration,options={})
63
+ write_line("fadeout",duration,options,[:subtitle])
64
+ end
65
+
66
+ #
67
+ # Adds an exit command
68
+ #
69
+ def exit
70
+ @file.puts "exit"
71
+ end
72
+
73
+ protected
74
+
75
+ def separator
76
+ ':'
77
+ end
78
+
79
+ def write_line(keyword,duration,options={},sorted_keys=[])
80
+ @file.puts build_line(keyword,duration,options,sorted_keys)
81
+ end
82
+
83
+ def build_line(keyword,duration,options={},sorted_keys=[])
84
+ line = keyword + separator + format_duration(duration)
85
+ index = 0
86
+ remaining_options = options.values.length
87
+ while remaining_options > 0
88
+ line << separator
89
+ value = options[sorted_keys[index]]
90
+ line << (value || "")
91
+ index += 1
92
+ remaining_options -= 1 if value
93
+ end
94
+ return line
95
+ end
96
+
97
+ def format_duration(duration)
98
+ "%.3f" % duration.to_f
99
+ end
100
+
101
+ end
102
+
103
+ end
@@ -0,0 +1,67 @@
1
+ require 'rprogram/task'
2
+ require 'rdvd-slideshow/slideshow_input'
3
+
4
+ module RDvdSlideshow
5
+
6
+ #
7
+ # ==dvd-slideshow options:
8
+ #
9
+ # <tt>-n</tt>:: <tt>mencoder.name</tt>
10
+ # <tt>-o</tt>:: <tt>mencoder.output_dir</tt>
11
+ # <tt>-b</tt>:: <tt>mencoder.background</tt>
12
+ # <tt>-a</tt>:: <tt>mencoder.audio_file</tt>
13
+ # <tt>-p</tt>:: <tt>mencoder.pal</tt>
14
+ # <tt>-mp2</tt>:: <tt>mencoder.mp2</tt>
15
+ # <tt>-L</tt>:: <tt>mencoder.low_quality</tt>
16
+ # <tt>-H</tt>:: <tt>mencoder.high_quality</tt>
17
+ # <tt>-theme</tt>:: <tt>mencoder.theme</tt>
18
+ # <tt>-border</tt>:: <tt>mencoder.border</tt>
19
+ # <tt>-sharpen</tt>:: <tt>mencoder.sharpen</tt>
20
+ # <tt>-r</tt>:: <tt>mencoder.auto_crop</tt>
21
+ # <tt>-w</tt>:: <tt>mencoder.widescreen</tt>
22
+ # <tt>-smp</tt>:: <tt>mencoder.smp</tt>
23
+ # <tt>-mpeg2enc</tt>:: <tt>mencoder.mpeg2enc</tt>
24
+ # <tt>-vcd</tt>:: <tt>mencoder.vcd</tt>
25
+ # <tt>-flv</tt>:: <tt>mencoder.flv</tt>
26
+ # <tt>-s</tt>:: <tt>mencoder.output_size</tt>
27
+ # <tt>-f</tt>:: <tt>mencoder.input_file</tt>
28
+ #
29
+ # Instead of providing an input file it is possible to programatically define the input with the write_input method
30
+ #
31
+ class SlideshowTask < RProgram::Task
32
+
33
+ long_option :flag => '-n', :name => :name
34
+ long_option :flag => '-o', :name => :output_dir
35
+ long_option :flag => '-b', :name => :background
36
+ long_option :flag => '-a', :name => :audio_file
37
+ long_option :flag => '-p', :name => :pal
38
+ long_option :flag => '-mp2', :name => :mp2
39
+ long_option :flag => '-L', :name => :low_quality
40
+ long_option :flag => '-H', :name => :high_quality
41
+ long_option :flag => '-theme'
42
+ long_option :flag => '-border'
43
+ long_option :flag => '-sharpen'
44
+ long_option :flag => '-r', :name => :auto_crop
45
+ long_option :flag => '-w', :name => :widescreen
46
+ long_option :flag => '-smp'
47
+ long_option :flag => '-mpeg2enc'
48
+ long_option :flag => '-vcd'
49
+ long_option :flag => '-flv'
50
+ long_option :flag => '-s', :name => :output_size
51
+ long_option :flag => '-f', :name => :input_file
52
+
53
+ #
54
+ # Configures the input configuration of the slideshow
55
+ # and generates automatically the corresponding input file.
56
+ # The provided block is used to configure the SlideshowInput object
57
+ #
58
+ def write_input(&block)
59
+ @input = SlideshowInput.new do |input|
60
+ block.call(input) if block
61
+ end
62
+ @options[:input_file] = @input.file_path
63
+ end
64
+
65
+ end
66
+
67
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,45 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'fileutils'
6
+
7
+ class Test::Unit::TestCase
8
+
9
+ def input_file
10
+ File.dirname(__FILE__) + '/input_file'
11
+ end
12
+
13
+ def output_dir
14
+ File.dirname(__FILE__) + '/outputs'
15
+ end
16
+
17
+ def default_image
18
+ File.dirname(__FILE__) + '/test.jpg'
19
+ end
20
+
21
+ def setup
22
+ FileUtils.mkdir_p output_dir
23
+ end
24
+
25
+ def teardown
26
+ # Delete test input file
27
+ File.delete(input_file) if File.file?(input_file)
28
+ # Clean outputs directory
29
+ delete_content output_dir
30
+ end
31
+
32
+ protected
33
+
34
+ # Recursively delete folder content
35
+ def delete_content(dir)
36
+ Dir.foreach(dir) do |f|
37
+ path = dir + "/" + f
38
+ if f == '.' or f == '..' then next
39
+ elsif File.directory?(path) then FileUtils.rm_rf(path)
40
+ else FileUtils.rm(path)
41
+ end
42
+ end
43
+ end
44
+
45
+ end
data/test/test.jpg ADDED
Binary file
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+ require 'rdvd-slideshow/slideshow'
3
+
4
+ class TestSlideshow < Test::Unit::TestCase
5
+
6
+ def test_slideshow
7
+ result = RDvdSlideshow::Slideshow.build(:name=>"test slideshow",:output_dir=>output_dir,:mp2=>true) do |show|
8
+ show.write_input do |input|
9
+ input.image default_image, 2
10
+ end
11
+ end
12
+
13
+ assert result
14
+ assert File.exists?(output_dir + "/test_slideshow.vob")
15
+ end
16
+
17
+ end
@@ -0,0 +1,98 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+ require 'rdvd-slideshow/slideshow_input'
3
+
4
+ class TestSlideshowInput < Test::Unit::TestCase
5
+
6
+ def test_empty_input
7
+ input = RDvdSlideshow::SlideshowInput.new(nil)
8
+
9
+ assert File.exists?(input.file_path), "Input file was not created"
10
+
11
+ lines = File.readlines(input.file_path)
12
+ assert lines.empty?, "Input file should be empty"
13
+ end
14
+
15
+ def test_image
16
+ input = RDvdSlideshow::SlideshowInput.new(input_file) do |input|
17
+ input.image(default_image,0.5)
18
+ input.image(default_image,0.5, :effect=>"special_effect")
19
+ end
20
+
21
+ lines = File.readlines(input.file_path)
22
+ assert_equal 2, lines.length
23
+ assert_equal "#{default_image}:0.500\n", lines[0]
24
+ assert_equal "#{default_image}:0.500::special_effect\n", lines[1]
25
+ end
26
+
27
+ def test_image_with_no_input_file_path
28
+ input = RDvdSlideshow::SlideshowInput.new do |input|
29
+ input.image(default_image,0.5)
30
+ input.image(default_image,0.5, :effect=>"special_effect")
31
+ end
32
+
33
+ lines = File.readlines(input.file_path)
34
+ assert_equal 2, lines.length
35
+ assert_equal "#{default_image}:0.500\n", lines[0]
36
+ assert_equal "#{default_image}:0.500::special_effect\n", lines[1]
37
+ end
38
+
39
+ def test_title
40
+ input = RDvdSlideshow::SlideshowInput.new(input_file) do |input|
41
+ input.title 0.5,"test_title"
42
+ end
43
+
44
+ lines = File.readlines(input.file_path)
45
+ assert_equal 1, lines.length
46
+ assert_equal "title:0.500:test_title\n", lines[0]
47
+ end
48
+
49
+ def test_titlebar
50
+ input = RDvdSlideshow::SlideshowInput.new(input_file) do |input|
51
+ input.titlebar 0.5
52
+ input.titlebar 0.5,{:upper_title=>"my upper text"}
53
+ input.titlebar 0.5,{:lower_title=>"my lower text"}
54
+ input.titlebar 0.5,{:upper_title=>"my upper text",:lower_title=>"my lower text"}
55
+ end
56
+
57
+ lines = File.readlines(input.file_path)
58
+ assert_equal 4, lines.length
59
+ assert_equal "titlebar:0.500\n", lines[0]
60
+ assert_equal "titlebar:0.500:my upper text\n", lines[1]
61
+ assert_equal "titlebar:0.500::my lower text\n", lines[2]
62
+ assert_equal "titlebar:0.500:my upper text:my lower text\n", lines[3]
63
+ end
64
+
65
+ def test_musictitle
66
+ input = RDvdSlideshow::SlideshowInput.new(input_file) do |input|
67
+ input.musictitle(0.5)
68
+ input.musictitle(0.5,{:subtitle=>"my subtitle"})
69
+ end
70
+
71
+ lines = File.readlines(input.file_path)
72
+ assert_equal 2, lines.length
73
+ assert_equal "musictitle:0.500\n", lines[0]
74
+ assert_equal "musictitle:0.500:my subtitle\n", lines[1]
75
+ end
76
+
77
+ def test_exit
78
+ input = RDvdSlideshow::SlideshowInput.new(input_file) do |input|
79
+ input.exit
80
+ end
81
+
82
+ lines = File.readlines(input.file_path)
83
+ assert_equal 1, lines.length
84
+ assert_equal "exit\n", lines[0]
85
+ end
86
+
87
+ def test_duration_conversion
88
+ input = RDvdSlideshow::SlideshowInput.new(input_file) do |input|
89
+ input.image(default_image, 2)
90
+ input.image(default_image, 1.23456789)
91
+ end
92
+
93
+ lines = File.readlines(input.file_path)
94
+ assert_equal "#{default_image}:2.000\n", lines[0]
95
+ assert_equal "#{default_image}:1.235\n", lines[1]
96
+ end
97
+
98
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+ require 'rdvd-slideshow/slideshow_task'
3
+
4
+ class TestSlideshowTask < Test::Unit::TestCase
5
+
6
+ def test_slideshow_task
7
+ task = RDvdSlideshow::SlideshowTask.new(:output_dir => output_dir)
8
+ task.write_input do |input|
9
+ input.image default_image, 0.5
10
+ end
11
+
12
+ input_file = task.input_file
13
+ assert !input_file.nil?
14
+
15
+ lines = File.readlines(input_file)
16
+ assert 1, lines.length
17
+ assert_equal "#{default_image}:0.500\n",lines[0]
18
+ end
19
+
20
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rdvd-slideshow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - sdabet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-13 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rprogram
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.1.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.2
34
+ version:
35
+ description: A ruby interface for dvd-slideshow utility (http://dvd-slideshow.sourceforge.net)
36
+ email:
37
+ - sebastiendabet@gmail.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - History.txt
44
+ - Manifest.txt
45
+ - README.txt
46
+ files:
47
+ - History.txt
48
+ - Manifest.txt
49
+ - README.txt
50
+ - Rakefile
51
+ - lib/rdvd-slideshow.rb
52
+ - lib/rdvd-slideshow/slideshow.rb
53
+ - lib/rdvd-slideshow/slideshow_task.rb
54
+ - lib/rdvd-slideshow/slideshow_input.rb
55
+ - test/helper.rb
56
+ - test/test.jpg
57
+ - test/test_slideshow.rb
58
+ - test/test_slideshow_task.rb
59
+ - test/test_slideshow_input.rb
60
+ - test/outputs/
61
+ has_rdoc: true
62
+ homepage: http://rdvd-slideshow.rubyforge.org/
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --main
66
+ - README.txt
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ requirements: []
82
+
83
+ rubyforge_project: rdvd-slideshow
84
+ rubygems_version: 1.3.1
85
+ signing_key:
86
+ specification_version: 2
87
+ summary: A ruby interface for dvd-slideshow utility (http://dvd-slideshow.sourceforge.net)
88
+ test_files:
89
+ - test/test_slideshow_input.rb
90
+ - test/test_slideshow.rb
91
+ - test/test_slideshow_task.rb