headless 2.0.0 → 2.1.0

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: 36a92b0fed73ea273bf7cc4201b545be19d539e2
4
- data.tar.gz: 29feae5dcdb2be2fa1d5147e009910d4c7f7c044
3
+ metadata.gz: 8dc1c06f85049924c12fc40b4558040fd514c01a
4
+ data.tar.gz: a5e904086bdccf72798574e2450ce76b64fda0a7
5
5
  SHA512:
6
- metadata.gz: 0a2c40f5cad61642e952565e3ab9666f00a4fe40eaee09ec99eb2facfff76bc4a87976cd2ca42dea02cf5b185d7d4f4d2a812ec44eb9c5a43ed016f9cbef12f6
7
- data.tar.gz: ce8ea2ace8823b3507bcef65da7194f57b0fbce038f2fe0eef4f7a7dfbb69e7de678e4172c4761736297eb4b7d05f1e3128c93c6ee95cd6d42e81a18050fe773
6
+ metadata.gz: d6ad825721817e789fde8d9786bac8fec26ef097e5fb4af74f8c685a9895dfa3b5850161f3bf8f809b5024a7827c08f35dfd131d843e2f0cc71b274b4197ddea
7
+ data.tar.gz: af0c4aea4a57b14f56868315a1874bf28a09e7ab8a4a91355d0b864e09e939794aa9eedcf9ced54692c79dc428ae5a30003ea43afaa097edaaf75b06ee85fd5f
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.1.0 (2015-05-10)
2
+
3
+ * Allow path to video recorder binary to be customized (from @briandamaged)
4
+
1
5
  ## 2.0.0 (2015-04-23)
2
6
 
3
7
  * Rewritten Xvfb launch using Process.spawn and avoiding a shell
data/README.md CHANGED
@@ -131,12 +131,13 @@ headless = Headless.new(:video => { :frame_rate => 12, :codec => 'libx264' })
131
131
  Available options:
132
132
 
133
133
  * :codec - codec to be used by ffmpeg
134
- * :frame_rate - frame rate of video capture
135
- * :provider - ffmpeg provider - either :libav (default) or :ffmpeg
136
- * :pid_file_path - path to ffmpeg pid file, default: "/tmp/.headless_ffmpeg_#{@display}.pid"
137
- * :tmp_file_path - path to tmp video file, default: "/tmp/.headless_ffmpeg_#{@display}.mov"
138
- * :log_file_path - ffmpeg log file, default: "/dev/null"
139
- * :extra - array of extra ffmpeg options, default: []
134
+ * :frame_rate - frame rate of video capture
135
+ * :provider - ffmpeg provider - either :libav (default) or :ffmpeg
136
+ * :provider_binary_path - Explicit path to avconv or ffmpeg. Only required when the binary cannot be discovered on the system $PATH.
137
+ * :pid_file_path - path to ffmpeg pid file, default: "/tmp/.headless_ffmpeg_#{@display}.pid"
138
+ * :tmp_file_path - path to tmp video file, default: "/tmp/.headless_ffmpeg_#{@display}.mov"
139
+ * :log_file_path - ffmpeg log file, default: "/dev/null"
140
+ * :extra - array of extra ffmpeg options, default: []
140
141
 
141
142
  ## Taking screenshots
142
143
 
@@ -3,7 +3,7 @@ spec = Gem::Specification.new do |s|
3
3
  s.email = 'leonid@shevtsov.me'
4
4
 
5
5
  s.name = 'headless'
6
- s.version = '2.0.0'
6
+ s.version = '2.1.0'
7
7
  s.summary = 'Ruby headless display interface'
8
8
 
9
9
  s.description = <<-EOF
@@ -4,6 +4,9 @@ class Headless
4
4
  class VideoRecorder
5
5
  attr_accessor :pid_file_path, :tmp_file_path, :log_file_path
6
6
 
7
+ # Allow end-users to override the path to the binary
8
+ attr_accessor :provider_binary_path
9
+
7
10
  def initialize(display, dimensions, options = {})
8
11
  @display = display
9
12
  @dimensions = dimensions[/.+(?=x)/]
@@ -14,9 +17,14 @@ class Headless
14
17
  @codec = options.fetch(:codec, "qtrle")
15
18
  @frame_rate = options.fetch(:frame_rate, 30)
16
19
  @provider = options.fetch(:provider, :libav) # or :ffmpeg
20
+
21
+ # If no provider_binary_path was specified, then
22
+ # make a guess based upon the provider.
23
+ @provider_binary_path = options.fetch(:provider_binary_path, guess_the_provider_binary_path)
24
+
17
25
  @extra = Array(options.fetch(:extra, []))
18
26
 
19
- CliUtil.ensure_application_exists!(provider_binary, "#{provider_binary} not found on your system. Install it or change video recorder provider")
27
+ CliUtil.ensure_application_exists!(provider_binary_path, "#{provider_binary_path} not found on your system. Install it or change video recorder provider")
20
28
  end
21
29
 
22
30
  def capture_running?
@@ -55,8 +63,8 @@ class Headless
55
63
 
56
64
  private
57
65
 
58
- def provider_binary
59
- @provider==:libav ? 'avconv' : 'ffmpeg'
66
+ def guess_the_provider_binary_path
67
+ @provider== :libav ? 'avconv' : 'ffmpeg'
60
68
  end
61
69
 
62
70
  def command_line_for_capture
@@ -69,7 +77,7 @@ class Headless
69
77
  end
70
78
 
71
79
  ([
72
- CliUtil.path_to(provider_binary),
80
+ CliUtil.path_to(provider_binary_path),
73
81
  "-y",
74
82
  "-r #{@frame_rate}",
75
83
  "-s #{dimensions}",
@@ -1,17 +1,44 @@
1
1
  require 'headless'
2
2
 
3
+ require 'tempfile'
4
+
3
5
  describe Headless::VideoRecorder do
4
6
  before do
5
7
  stub_environment
6
8
  end
7
9
 
8
10
  describe "instantiation" do
9
- before do
11
+
12
+ it "throws an error if provider_binary_path is not installed" do
10
13
  allow(Headless::CliUtil).to receive(:application_exists?).and_return(false)
14
+ expect { Headless::VideoRecorder.new(99, "1024x768x32") }.to raise_error(Headless::Exception)
11
15
  end
12
16
 
13
- it "throws an error if ffmpeg is not installed" do
14
- expect { Headless::VideoRecorder.new(99, "1024x768x32") }.to raise_error(Headless::Exception)
17
+ it "allows provider_binary_path to be specified" do
18
+ Tempfile.open('some_provider') do |f|
19
+ v = Headless::VideoRecorder.new(99, "1024x768x32", provider: :ffmpeg, provider_binary_path: f.path)
20
+ expect(v.provider_binary_path).to eq(f.path)
21
+ end
22
+ end
23
+
24
+ it "allows provider_binary_path to be specified" do
25
+ Tempfile.open('some_provider') do |f|
26
+ v = Headless::VideoRecorder.new(99, "1024x768x32", provider: :ffmpeg, provider_binary_path: f.path)
27
+ expect(v.provider_binary_path).to eq(f.path)
28
+ end
29
+ end
30
+
31
+ context "provider_binary_path not specified" do
32
+ it "assumes the provider binary is 'ffmpeg' if the provider is :ffmpeg" do
33
+ v = Headless::VideoRecorder.new(99, "1024x768x32", provider: :ffmpeg)
34
+ expect(v.provider_binary_path).to eq("ffmpeg")
35
+ end
36
+
37
+ it "assumes the provider binary is 'avconv' if the provider is :libav" do
38
+ v = Headless::VideoRecorder.new(99, "1024x768x32", provider: :libav)
39
+ expect(v.provider_binary_path).to eq("avconv")
40
+ end
41
+
15
42
  end
16
43
  end
17
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: headless
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Shevtsov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -98,3 +98,4 @@ signing_key:
98
98
  specification_version: 4
99
99
  summary: Ruby headless display interface
100
100
  test_files: []
101
+ has_rdoc: