kelredd-pruview 0.1.11 → 0.2.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.

Potentially problematic release.


This version of kelredd-pruview might be problematic. Click here for more details.

data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake/gempackagetask'
3
- require 'rake/testtask'
3
+ require 'simple_gem/testtasks'
4
4
 
5
5
  require 'lib/pruview/version'
6
6
 
@@ -18,8 +18,13 @@ spec = Gem::Specification.new do |s|
18
18
  s.homepage = 'http://github.com/kelredd/pruview'
19
19
  s.files = %w(README.rdoc Rakefile) + Dir.glob("{bin,features,lib,test}/**/*")
20
20
  # s.executables = ['pruview']
21
-
22
- s.add_dependency('mini_magick')
21
+
22
+ s.add_development_dependency("shoulda", [">= 2.10.0"])
23
+ s.add_development_dependency("leftright", [">= 0.0.6"])
24
+ s.add_development_dependency("kelredd-useful", [">= 0.4.0"])
25
+ s.add_development_dependency("kelredd-simple-gem", [">= 0.7.0"])
26
+
27
+ s.add_dependency('mini_magick', "~>2.1")
23
28
  s.add_dependency('flvtool2')
24
29
  end
25
30
 
@@ -27,15 +32,14 @@ Rake::GemPackageTask.new(spec) do |pkg|
27
32
  pkg.gem_spec = spec
28
33
  end
29
34
 
30
- Rake::TestTask.new do |t|
31
- t.libs << 'test'
32
- t.test_files = FileList["test/**/*_test.rb"]
33
- t.verbose = true
34
- end
35
+ SimpleGem::TestTasks.new
35
36
 
36
- desc 'Generate the gemspec to serve this Gem from Github'
37
+ desc 'Generate the gemspec for this gem'
37
38
  task :gemspec do
38
39
  file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
39
40
  File.open(file, 'w') {|f| f << spec.to_ruby }
40
41
  puts "Created gemspec: #{file}"
41
- end
42
+ end
43
+
44
+ task :default => :gem
45
+
@@ -1,9 +1,9 @@
1
1
  module Pruview
2
2
 
3
3
  class Document
4
-
4
+
5
5
  TMP_DIR = '/tmp'
6
-
6
+
7
7
  def initialize(source, target_dir, target_permission=0666)
8
8
  raise Pruview::Exceptions::InvalidError, "Invalid source file: #{source.to_s}" if !File.file?(source)
9
9
  raise Pruview::Exceptions::InvalidError, "Invalid target directory: #{target_dir.to_s}" if !File.directory?(target_dir)
@@ -14,11 +14,11 @@ module Pruview
14
14
  @image = process_image(get_image(source))
15
15
  @tempfile = nil
16
16
  end
17
-
17
+
18
18
  def to_jpg(name, width, height, crop = false)
19
19
  scale_img = scale_image(width, height, crop)
20
+ scale_img.format 'jpg'
20
21
  scale_img.combine_options do |img|
21
- img.format 'jpg'
22
22
  img.quality '90'
23
23
  img.interlace 'plane'
24
24
  end
@@ -29,9 +29,9 @@ module Pruview
29
29
  FileUtils.mv(tmp_target, target, :force => true)
30
30
  return target
31
31
  end
32
-
32
+
33
33
  protected
34
-
34
+
35
35
  def format_supported?(source)
36
36
  file_ext = file_extension(source)
37
37
  #return true if file_ext == PSD_EXT # don't support photoshop for now
@@ -39,17 +39,17 @@ module Pruview
39
39
  IMAGE_EXT.each { |extension| return true if file_ext == extension }
40
40
  return false
41
41
  end
42
-
42
+
43
43
  def format_postscript?(source)
44
44
  file_ext = file_extension(source)
45
45
  POSTSCRIPT_EXT.each { |extension| return true if file_ext == extension }
46
46
  return false
47
47
  end
48
-
48
+
49
49
  def file_extension(source_file)
50
- File.extname(source_file).downcase.chomp
50
+ File.extname(source_file).downcase.chomp
51
51
  end
52
-
52
+
53
53
  def get_image(source)
54
54
  source = get_postscript_source(source) if format_postscript?(source)
55
55
  begin
@@ -58,7 +58,7 @@ module Pruview
58
58
  raise "Error reading source image: #{err.message}"
59
59
  end
60
60
  end
61
-
61
+
62
62
  def get_postscript_source(source)
63
63
  begin
64
64
  @tempfile = MiniMagick::ImageTempFile.new("pruview.jpg")
@@ -69,14 +69,14 @@ module Pruview
69
69
  run_system_command("convert -format jpg \"#{source}[0]\" \"#{@tempfile.path}\"", "Error processing postscript document")
70
70
  return @tempfile.path
71
71
  end
72
-
72
+
73
73
  def process_image(image)
74
74
  image.format PROCESS_FORMAT
75
75
  set_RGB_colorspace(image)
76
76
  image.strip
77
77
  return image
78
78
  end
79
-
79
+
80
80
  def set_RGB_colorspace(image)
81
81
  colorspace = run_system_command("identify -format \"%r\" #{image.path}", "Error reading document colorspace")
82
82
  puts "Colorspace: #{colorspace}"
@@ -93,13 +93,13 @@ module Pruview
93
93
  begin
94
94
  image = MiniMagick::Image.from_file(@image.path)
95
95
  crop_image(image, crop)
96
- image.resize "#{width}x#{height}" if crop || @image[:width].to_i > width || @image[:height] > height
96
+ image.resize "#{width}x#{height}" if crop || @image[:width].to_i > width || @image[:height] > height
97
97
  return image
98
98
  rescue Exception => err
99
99
  raise "Error scaling image: #{err.message}"
100
100
  end
101
101
  end
102
-
102
+
103
103
  def crop_image(image, ratio)
104
104
  if ratio.kind_of?(Array) && ratio.length == 2
105
105
  ratio_width, ratio_height = ratio
@@ -124,18 +124,18 @@ module Pruview
124
124
  end
125
125
  return image
126
126
  end
127
-
127
+
128
128
  def run_system_command(command, error_message)
129
129
  output = `#{command}`
130
130
  raise "#{error_message}: error given #{$?}\n#{output}" if $? != 0
131
131
  return output
132
132
  end
133
-
133
+
134
134
  end
135
-
135
+
136
136
  # Configurations
137
137
  Document::PROCESS_FORMAT = 'jpg'
138
-
138
+
139
139
  Document::PSD_EXT = '.psd'
140
140
  Document::POSTSCRIPT_EXT = ['.pdf', '.eps', '.ai']
141
141
  Document::IMAGE_EXT = ['.bmp', '.gif', '.jpg', '.jpeg', '.png', '.tga']
@@ -1,13 +1,13 @@
1
1
  module Pruview
2
2
  module Version
3
-
3
+
4
4
  MAJOR = 0
5
- MINOR = 1
6
- TINY = 11
7
-
5
+ MINOR = 2
6
+ TINY = 0
7
+
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
10
10
  end
11
-
11
+
12
12
  end
13
13
  end
data/lib/pruview/video.rb CHANGED
@@ -1,6 +1,15 @@
1
1
  module Pruview
2
2
 
3
3
  class Video
4
+ # Configurations
5
+ Video::FFYML = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'ffyml'))
6
+ Video::FFMPEG = 'ffmpeg'
7
+ Video::FLVTOOL = 'flvtool2'
8
+ Video::PAD_COLOR = "000000"
9
+ Video::AUDIO_BITRATE = 128 # kbps
10
+ Video::AUDIO_SAMPLING = 44100
11
+
12
+ Video::EXT = ['.avi', '.flv', '.mov', '.mpg', '.mp4']
4
13
 
5
14
  # this class assumes you have 'ffmpeg' and 'flvtool2' installed and in your path
6
15
 
@@ -30,6 +39,10 @@ module Pruview
30
39
  self.get_info(yml_info_path)
31
40
  end
32
41
 
42
+ def to_jpg(name)
43
+ VideoImage.to_jpg(@source, @target_dir, name)
44
+ end
45
+
33
46
  protected
34
47
 
35
48
  def to_base(name, width, height, extension, scale_static)
@@ -58,17 +71,21 @@ module Pruview
58
71
  command = "#{FFMPEG} -i #{source}"
59
72
  command += get_scale_command(info['width'], info['height'], width, height, scale_static)
60
73
  scale_factor = get_scale_factor(info['width'], info['height'], width, height)
74
+ bitrate_factor = file_extension(target) != '.flv' ? 1000 : 1
61
75
  if file_extension(target) != '.flv' # use h264 codec with lower bitrate scaling factor
62
- command += " -vcodec libx264"
76
+ command += " -vcodec libx264 -vpre slow -threads 0"
63
77
  scale_factor /= 2.0
64
78
  end
65
79
  puts "scale factor: #{scale_factor.to_s}"
80
+ puts "info bitrate: #{info['bitrate']}"
66
81
  if !info['bitrate'].zero?
67
- command += " -b #{(info['bitrate']*@bitrate_multiplier*scale_factor).to_s}"
82
+ calc_bitrate = info['bitrate']*@bitrate_multiplier*scale_factor*bitrate_factor
83
+ puts "calc bitrate: #{calc_bitrate}"
84
+ command += " -b #{calc_bitrate}"
68
85
  else
69
86
  command += " -sameq"
70
87
  end
71
- command += " -ab #{AUDIO_BITRATE}"
88
+ command += " -ab #{AUDIO_BITRATE*bitrate_factor}"
72
89
  command += " -ar #{AUDIO_SAMPLING}"
73
90
  command += " -y #{target}"
74
91
  end
@@ -120,16 +137,5 @@ module Pruview
120
137
  raise "Ffmpeg error: " + error_message + " - command: '#{command}'" if !system(command)
121
138
  end
122
139
 
123
- # Configurations
124
- Video::FFYML = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'ffyml'))
125
- Video::FFMPEG = 'ffmpeg'
126
- Video::FLVTOOL = 'flvtool2'
127
- Video::PAD_COLOR = "000000"
128
- Video::AUDIO_BITRATE = '128' # kbps
129
- Video::AUDIO_SAMPLING = '44100'
130
-
131
- Video::EXT = ['.avi', '.flv', '.mov', '.mpg', '.mp4']
132
-
133
140
  end
134
141
  end
135
-
data/test/helper.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'useful/shoulda_macros/test_unit'
5
+ require 'leftright'
6
+
7
+ # Add test and lib paths to the $LOAD_PATH
8
+ [ File.dirname(__FILE__),
9
+ File.join(File.dirname(__FILE__), '..', 'lib')
10
+ ].each do |path|
11
+ full_path = File.expand_path(path)
12
+ $LOAD_PATH.unshift(full_path) unless $LOAD_PATH.include?(full_path)
13
+ end
14
+
15
+ require 'pruview'
16
+
17
+ FILES_PATH = "./test/files"
18
+ OUTPUT_PATH = "./test_output"
19
+ INVALID_OUTPUT_PATH = "./test_output/invalid"
20
+ FILES = {
21
+ 'basic image' => "./test/files/basic.jpg",
22
+ 'invalid image' => "./test/files/invalid.jpg",
23
+ 'error image' => "./test/files/error.jpg",
24
+ 'basic video' => "./test/files/basic.mpg",
25
+ 'invalid video' => "./test/files/invalid.mov",
26
+ 'error video' => "./test/files/error.mov",
27
+ 'invalid format' => "./test/files/invalid_format.poop"
28
+ }
29
+
30
+ FileUtils.mkdir_p File.expand_path(FILES_PATH) unless File.exists? File.expand_path(FILES_PATH)
31
+ FileUtils.mkdir_p File.expand_path(OUTPUT_PATH) unless File.exists? File.expand_path(OUTPUT_PATH)
32
+
33
+ def should_complain_about(should_statement, message_match, &block)
34
+ should "complain about #{should_statement}" do
35
+ assert_raises Pruview::Exceptions::InvalidError do
36
+ block.call
37
+ end
38
+ begin
39
+ block.call
40
+ rescue Exception => err
41
+ assert_match message_match, err.message
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,31 @@
1
+ require 'test/helper'
2
+
3
+ module Pruview
4
+ class DocumentTest < Test::Unit::TestCase
5
+
6
+ context "A Pruview::Document" do
7
+ setup { @file = Pruview::Document.new(FILES['basic image'], OUTPUT_PATH) }
8
+ subject { @file }
9
+
10
+ should_have_instance_methods :to_jpg
11
+
12
+ should_complain_about("converting invalid images", /^Invalid source file/) do
13
+ Pruview::Document.new(FILES['invalid image'], OUTPUT_PATH)
14
+ end
15
+ should_complain_about("converting invalid image formats", /not supported - file extension: .poop/) do
16
+ Pruview::Document.new(FILES['invalid format'], OUTPUT_PATH)
17
+ end
18
+ should_complain_about("converting with invalid output paths", /^Invalid target directory/) do
19
+ Pruview::Document.new(FILES['basic image'], INVALID_OUTPUT_PATH)
20
+ end
21
+
22
+ should "create a jpg version of itself" do
23
+ @output = @file.to_jpg('file', 50, 50)
24
+ assert File.exists?(@output)
25
+ assert_equal '.jpg', File.extname(@output)
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ require 'test/helper'
2
+
3
+ module Pruview
4
+ class VideoImageTest < Test::Unit::TestCase
5
+
6
+ context "A Pruview::VideoImage" do
7
+
8
+ should_have_class_methods :to_jpg
9
+
10
+ should_complain_about("converting invalid video", /^Invalid source file/) do
11
+ Pruview::VideoImage.to_jpg(FILES['invalid video'], OUTPUT_PATH, 'file')
12
+ end
13
+ should_complain_about("converting invalid video formats", /not supported - file extension: .poop/) do
14
+ Pruview::VideoImage.to_jpg(FILES['invalid format'], OUTPUT_PATH, 'file')
15
+ end
16
+ should_complain_about("converting with invalid output paths", /^Invalid target directory/) do
17
+ Pruview::VideoImage.to_jpg(FILES['basic video'], INVALID_OUTPUT_PATH, 'file')
18
+ end
19
+
20
+ should "create a jpg version of itself" do
21
+ @output = Pruview::VideoImage.to_jpg(FILES['basic video'], OUTPUT_PATH, 'file')
22
+ assert File.exists?(@output)
23
+ assert_equal '.jpg', File.extname(@output)
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,45 @@
1
+ require 'test/helper'
2
+
3
+ module Pruview
4
+ class VideoTest < Test::Unit::TestCase
5
+
6
+ context "A Pruview::Video" do
7
+ setup { @file = Pruview::Video.new(FILES['basic video'], OUTPUT_PATH) }
8
+ subject { @file }
9
+
10
+ should_have_instance_methods :to_flv, :to_mov, :to_jpg, :info
11
+
12
+ should_complain_about("converting invalid video", /^Invalid source file/) do
13
+ Pruview::Video.new(FILES['invalid video'], OUTPUT_PATH)
14
+ end
15
+ should_complain_about("converting invalid video formats", /not supported - file extension: .poop/) do
16
+ Pruview::Video.new(FILES['invalid format'], OUTPUT_PATH)
17
+ end
18
+ should_complain_about("converting with invalid output paths", /^Invalid target directory/) do
19
+ Pruview::Video.new(FILES['basic video'], INVALID_OUTPUT_PATH)
20
+ end
21
+
22
+ should "create a mov version of itself" do
23
+ @output = @file.to_mov('file', 50, 50)
24
+ assert File.exists?(@output)
25
+ assert_equal '.mov', File.extname(@output)
26
+ end
27
+
28
+ # too unstable to test right now
29
+ # the above test validates the plumbing and command building
30
+ #should "create an flv version of itself" do
31
+ # @output = @file.to_flv('file', 50, 50)
32
+ # assert File.exists?(@output)
33
+ # assert_equal '.flv', File.extname(@output)
34
+ #end
35
+
36
+ should "create a jpg version of itself" do
37
+ @output = @file.to_jpg('file')
38
+ assert File.exists?(@output)
39
+ assert_equal '.jpg', File.extname(@output)
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-pruview
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 1
8
- - 11
9
- version: 0.1.11
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Kelly Redding
@@ -14,33 +15,102 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-06-11 00:00:00 -05:00
18
+ date: 2010-09-11 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: mini_magick
22
+ name: shoulda
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 39
27
30
  segments:
31
+ - 2
32
+ - 10
28
33
  - 0
29
- version: "0"
30
- type: :runtime
34
+ version: 2.10.0
35
+ type: :development
31
36
  version_requirements: *id001
32
37
  - !ruby/object:Gem::Dependency
33
- name: flvtool2
38
+ name: leftright
34
39
  prerelease: false
35
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 0
48
+ - 0
49
+ - 6
50
+ version: 0.0.6
51
+ type: :development
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: kelredd-useful
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
36
58
  requirements:
37
59
  - - ">="
38
60
  - !ruby/object:Gem::Version
61
+ hash: 15
62
+ segments:
63
+ - 0
64
+ - 4
65
+ - 0
66
+ version: 0.4.0
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: kelredd-simple-gem
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ - 7
81
+ - 0
82
+ version: 0.7.0
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: mini_magick
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 1
94
+ segments:
95
+ - 2
96
+ - 1
97
+ version: "2.1"
98
+ type: :runtime
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ name: flvtool2
102
+ prerelease: false
103
+ requirement: &id006 !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
39
109
  segments:
40
110
  - 0
41
111
  version: "0"
42
112
  type: :runtime
43
- version_requirements: *id002
113
+ version_requirements: *id006
44
114
  description:
45
115
  email: kelly@kelredd.com
46
116
  executables: []
@@ -53,15 +123,6 @@ files:
53
123
  - README.rdoc
54
124
  - Rakefile
55
125
  - bin/ffyml
56
- - features/document.feature
57
- - features/step_definitions/common_steps.rb
58
- - features/step_definitions/document_steps.rb
59
- - features/step_definitions/support/env.rb
60
- - features/step_definitions/support/helpers.rb
61
- - features/step_definitions/video_image_steps.rb
62
- - features/step_definitions/video_steps.rb
63
- - features/video.feature
64
- - features/video_image.feature
65
126
  - lib/pruview/document.rb
66
127
  - lib/pruview/exceptions.rb
67
128
  - lib/pruview/sRGB.icm
@@ -75,8 +136,10 @@ files:
75
136
  - test/files/error.jpg
76
137
  - test/files/error.mov
77
138
  - test/files/invalid_format.poop
78
- - test/test_helper.rb
79
- - test/unit/pruview_test.rb
139
+ - test/helper.rb
140
+ - test/unit/document_test.rb
141
+ - test/unit/video_image_test.rb
142
+ - test/unit/video_test.rb
80
143
  has_rdoc: true
81
144
  homepage: http://github.com/kelredd/pruview
82
145
  licenses: []
@@ -88,23 +151,27 @@ rdoc_options:
88
151
  require_paths:
89
152
  - lib
90
153
  required_ruby_version: !ruby/object:Gem::Requirement
154
+ none: false
91
155
  requirements:
92
156
  - - ">="
93
157
  - !ruby/object:Gem::Version
158
+ hash: 3
94
159
  segments:
95
160
  - 0
96
161
  version: "0"
97
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
+ none: false
98
164
  requirements:
99
165
  - - ">="
100
166
  - !ruby/object:Gem::Version
167
+ hash: 3
101
168
  segments:
102
169
  - 0
103
170
  version: "0"
104
171
  requirements: []
105
172
 
106
173
  rubyforge_project:
107
- rubygems_version: 1.3.6
174
+ rubygems_version: 1.3.7
108
175
  signing_key:
109
176
  specification_version: 3
110
177
  summary: A gem to ease generating image previews (thumbnails) of various files
@@ -1,21 +0,0 @@
1
- Feature: Document
2
- In order have file thumbnails programmatically
3
- As a user
4
- I want create document file thumbnails
5
-
6
- Scenario: Basic Image thumbnail
7
- Given I have a basic image document
8
- When I create a jpg version
9
- Then I should have a jpg file
10
-
11
- Scenario: Invalid source image
12
- Given I have an invalid image document
13
- Then Pruview should complain about an invalid source file
14
-
15
- Scenario: Invalid output path
16
- Given I have an invalid output path for documents
17
- Then Pruview should complain about an invalid output path
18
-
19
- Scenario: Invalid source format
20
- Given I have an invalid format document
21
- Then Pruview should complain about an invalid source file format
@@ -1,32 +0,0 @@
1
- When /^I create a[n]* (.+) version$/ do |format|
2
- @output = @file.send("to_#{format}", 'file', 50, 50)
3
- end
4
-
5
- Then /^I should have a[n]* (.+) file$/ do |format|
6
- assert File.exists?(@output)
7
- assert File.extname(@output), format
8
- end
9
-
10
- Then /^Pruview should complain about an invalid source file$/ do
11
- assert @complaint
12
- assert_kind_of Pruview::Exceptions::InvalidError, @complaint
13
- assert_match /^Invalid source file/, @complaint.message
14
- end
15
-
16
- Then /^Pruview should complain about an invalid output path$/ do
17
- assert @complaint
18
- assert_kind_of Pruview::Exceptions::InvalidError, @complaint
19
- assert_match /^Invalid target directory/, @complaint.message
20
- end
21
-
22
- Then /^Pruview should complain about an invalid source file format$/ do
23
- assert @complaint
24
- assert_kind_of Pruview::Exceptions::InvalidError, @complaint
25
- assert_match /not supported - file extension: .poop/, @complaint.message
26
- end
27
-
28
- Then /^Pruview should complain about an error$/ do
29
- assert @complaint
30
- assert_kind_of Pruview::Exceptions::InvalidError, @complaint
31
- assert_match /not supported - file extension: .poop/, @complaint.message
32
- end
@@ -1,16 +0,0 @@
1
- Given /^I have a[n]* (.+) document$/ do |file_type|
2
- begin
3
- @file = Pruview::Document.new(FILES[file_type], OUTPUT_PATH)
4
- rescue Exception => err
5
- @complaint = err
6
- end
7
- end
8
-
9
- Given /^I have an invalid output path for documents$/ do
10
- begin
11
- @file = Pruview::Document.new(FILES['basic image'], INVALID_OUTPUT_PATH)
12
- rescue Exception => err
13
- @complaint = err
14
- end
15
- end
16
-
@@ -1,20 +0,0 @@
1
- require 'test/unit/assertions'
2
- World(Test::Unit::Assertions)
3
-
4
- require File.dirname(__FILE__) + '/../../../lib/pruview'
5
-
6
- FILES_PATH = "./test/files"
7
- OUTPUT_PATH = "./test_output"
8
- INVALID_OUTPUT_PATH = "./test_output/invalid"
9
- FILES = {
10
- 'basic image' => "./test/files/basic.jpg",
11
- 'invalid image' => "./test/files/invalid.jpg",
12
- 'error image' => "./test/files/error.jpg",
13
- 'basic video' => "./test/files/basic.mpg",
14
- 'invalid video' => "./test/files/invalid.mov",
15
- 'error video' => "./test/files/error.mov",
16
- 'invalid format' => "./test/files/invalid_format.poop"
17
- }
18
-
19
- FileUtils.mkdir_p File.expand_path(FILES_PATH) unless File.exists? File.expand_path(FILES_PATH)
20
- FileUtils.mkdir_p File.expand_path(OUTPUT_PATH) unless File.exists? File.expand_path(OUTPUT_PATH)
@@ -1,5 +0,0 @@
1
- module PruviewFeature
2
- module Helpers
3
-
4
- end
5
- end
@@ -1,16 +0,0 @@
1
- Given /^I have a[n]* (.+) video image (.+)$/ do |file_type, format|
2
- begin
3
- @output = Pruview::VideoImage.send("to_#{format}", FILES[file_type], OUTPUT_PATH, 'file')
4
- rescue Exception => err
5
- @complaint = err
6
- end
7
- end
8
-
9
- Given /^I have an invalid output path for video images$/ do
10
- begin
11
- @output = Pruview::VideoImage.to_jpg(FILES['basic video'], INVALID_OUTPUT_PATH, 'file')
12
- rescue Exception => err
13
- @complaint = err
14
- end
15
- end
16
-
@@ -1,16 +0,0 @@
1
- Given /^I have a[n]* (.+) file$/ do |file_type|
2
- begin
3
- @file = Pruview::Video.new(FILES[file_type], OUTPUT_PATH)
4
- rescue Exception => err
5
- @complaint = err
6
- end
7
- end
8
-
9
- Given /^I have an invalid output path for videos$/ do
10
- begin
11
- @file = Pruview::Video.new(FILES['basic video'], INVALID_OUTPUT_PATH)
12
- rescue Exception => err
13
- @complaint = err
14
- end
15
- end
16
-
@@ -1,26 +0,0 @@
1
- Feature: Video
2
- In order to use video in more universal ways
3
- As a user
4
- I want convert video to other formats for viewing
5
-
6
- Scenario: Basic video to FLV
7
- Given I have a basic video file
8
- When I create an flv version
9
- Then I should have an flv file
10
-
11
- Scenario: Basic video to MOV
12
- Given I have a basic video file
13
- When I create an mov version
14
- Then I should have an mov file
15
-
16
- Scenario: Invalid source video
17
- Given I have an invalid video file
18
- Then Pruview should complain about an invalid source file
19
-
20
- Scenario: Invalid output path
21
- Given I have an invalid output path for videos
22
- Then Pruview should complain about an invalid output path
23
-
24
- Scenario: Invalid source format
25
- Given I have an invalid format file
26
- Then Pruview should complain about an invalid source file format
@@ -1,20 +0,0 @@
1
- Feature: Video Image
2
- In order have video image thumbnails programmatically
3
- As a user
4
- I want create video image file thumbnails
5
-
6
- Scenario: Basic Image thumbnail
7
- Given I have a basic video video image jpg
8
- Then I should have a jpg file
9
-
10
- Scenario: Invalid source image
11
- Given I have an invalid video video image jpg
12
- Then Pruview should complain about an invalid source file
13
-
14
- Scenario: Invalid output path
15
- Given I have an invalid output path for video images
16
- Then Pruview should complain about an invalid output path
17
-
18
- Scenario: Invalid source format
19
- Given I have an invalid format video image jpg
20
- Then Pruview should complain about an invalid source file format
data/test/test_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- # http://sneaq.net/textmate-wtf
2
- $:.reject! { |e| e.include? 'TextMate' }
3
-
4
- require 'rubygems'
5
- require 'test/unit'
6
- require 'matchy'
7
- require 'context'
8
- require 'mocha'
9
-
10
- require File.dirname(__FILE__) + '/../lib/pruview'
@@ -1,13 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
2
-
3
- class PruviewTest < Test::Unit::TestCase
4
-
5
- describe "An instance of the Pruview class" do
6
-
7
- it "should flunk" do
8
- flunk "Please provide some tests"
9
- end
10
-
11
- end
12
-
13
- end